Saturday, December 12, 2009

Side Dish For Venison



I've been reading some articles on game programming using components and go that I was excited.

game engines such as Unity, TorqueX, Nebula 3 or CryEngine, can create objects from the GUI combining components, which greatly reduces the dependence on the programming and also better suited to the iterative design of the games.

This is achieved, instead of using class hierarchy, using composition.

This video elaborates:



There is good explanation in this article.
http://cowboyprogramming.com/2007/01/05/evolve-your-heirachy/

this type of development is known as data driven, as all game objects can be created by reading information from files.

For example, to create the player:
 
\u0026lt;Entity name="Player">
\u0026lt;component name="Mesh" file="player.md5"/>
\u0026lt;component name = "Position "x =" 0 "y =" 0 "z =" 0 "/>
\u0026lt;component name="Renderer"/>
\u0026lt;component name = "PhysicBody" />
\u0026lt;component name="PlayerController" camera="follow"/>
\u0026lt;/ Entity>


After seeing this and analyze the code push button engine is I got the idea to create a simple library for the language C + + (believe me I've searched but can not find any out there) to handle Entities. The idea is:



As you see in the image above, we would have the following lessons: (pseudocode)

 CEntityManager 

class List {
\u0026lt;CEntity> EntityList; Bool
createEntity (char * name);
CEntity getEntityByName (char * name);}


CEntity
class List {
\u0026lt;CComponent> ComponentList;
bool addComponent (CComponent);}


CComponent class: public
IUpdate
{/ / occurs when the component is added to the entity
OnAdd void () {

UpdateManager.add (this);}

onUpdate void () {}}


CUpdateManager
class List {
\u0026lt;IUpdate> componentList ;
onUpdate void () {

componentList.getFirst component = ();
while (component ! = Null) {

obj.onUpdate ();
componentList.next component = ();

}}}



We are saying that this would free you can create components in any of the libraries used today.

Render3D: Ogre3D / Irrlicht / DirectX / OpenGL
Physic: Physx / Newton GD / Havok / Bullet / etc ...
Sound: IrrKlang / FMOD / OpenAL
Number: OpenSTA / FSM
...


If anyone is interested in this would deliver or if you want help, you can contact me at marco_tmp.nospam @ hotmail.com. Sure, you take it. Nospam. ;) Peter Molyneaux

0 comments:

Post a Comment