Friday, February 19, 2010

Command Structure

in Framework for Game Engine Tools

I’m done with the command handlers on both sides, and though their functionality is similar the command function structure still differs a bit.
Note: I’ll refer the command handler class as the Handler and the command class (containing the functions) as the Container for simplicity - and by “commands” or “functions” I mean the method with their respective implementation.

Both the C++ and C# Containers are singletons because commands must be called through an instance.
On the C++ side all Container functions are private and must be registered together with a text string in a map - in order to be retrieved through the GetCommandFunction method. Each command may require a different number of parameters, but for a function to be accepted in the map they all must only accept the same input. Therefore I’ve designed commands to accept two items: a string array containing parameters and their attributes (more of that below), and a single text string for content. Because of this each function will have to first parse its input before its execution (for example retreiving matrix data to a variable). The Handler can accept and parse a message in order to execute commands along with their input.

The C# side is a bit different as .NET got more functionality. The command functions are easily accessed but can only be executed, or “invoked”, with an array of type “object” as input. This brings problems as each command might need different input, therefore I’ve designed commands to either accept a single “object”, or no input. This single object consists of a string array with content and the parameters with their attributes that need to be extracted at first in each function. This Container need all the command functions to be public in order to be retrieved and called from other classes. This Handler may also execute commands through a message.

Commands on either side got input values and content as strings and arrays. The arrays contain a number of elements that is double compared to parameters (“numParams”), where the first half are the input names and the second half include their respective values. For example, the value of the input at index T is at index T + numParams. If param “A” got attribute “1”, “B” got null and “C” got “foobar” then array would look like [A, B, C, 1, null, foobar] as if it were a two-dimensional array.
In the C++ side, each command accept one such array and one string with content. Though in the C# side, functions only accept one object, so the content is added as last element. This will result in the array having size numParams * 2 + 1.

New commands are created in C# just by implementing a public function in the Container with either no or one “object” input. In C++ they’re created by first implementing a function in the Container (preferably private), and secondly mapping it through AddCommand with a key string (will be the name of which the function is called, can differ from function name) and reference to the function. Currently the function mapping is done in the Container constructor.
Then they can be accessed and executed from their respective Handler, note that the command access names/keys are case sensitive.

With this done, I’ll finish implementing the connection between the two sides next.

Posted by Joel Marklund on 02/19 at 06:40 PM
Framework for Game Engine Tools • Add comments (0)
Page 1 of 1 pages

Projects

  • Realistic 50's diner for film production
  • Animation friendly character rig with lip-sync
  • 3D Portal Rendering
  • Beyond the Frame
  • Creature Modeling for Film Production
  • Framework for Game Engine Tools
  • Game Character Creation
  • Character Creation for Game / Cinematic
  • Game Demo
    • AI Programming
    • Animation
    • Character Modeling
    • Environment Design
  • Modeling for game engine
  • Character modeling and texturing
  • OpenCL Particle System
  • Peasant Village, Visual effects in live action
  • General
  • 3D Environment Design
  • Realistic tiger animation for film
  • Shading for Real-time Applications
  • Shortfilm, helicopter explosion VFX

Search


Monthly Archives

  • April 2010
  • March 2010
  • February 2010
  • January 2010
  • Complete Archives
  • Category Archives

Most recent entries

  • Final Lipsync
  • Project Concluded
  • Peasant Village
  • FINAL RESULT!
  • Goal driven behavior
  • At Last Everything Is Done!
  • Final Result
  • Finished!
  • Path smoothing
  • Helicopter Vfx, Final Result!
  • 50’s Diner - Finished!
  • Update
  • Finally Done Almost XP
  • Shortfilm, HVFX - The film
  • Deadline!