tags:

views:

64

answers:

1

Hi all.

I recently started to to learn Irricht 3D Engine, I already went through all the tutorials and I'm feeling ready to build a simple game upon it. So here is some background:

I have irricht , a 3D engine that is based upon the scene graph model . It knows how to load meshes & textures and show them , It provides me structured classes to handle input from the user , It provide me easy way to build a GUI. It provide me easy ways to define camers , lights , fogs , etc and provide me more convenient ways to do more things....

BUT , naturally , What the engine doesn't provide is a way to define the entities in the game and the logic relations between them. (For example , If a ball hit the wall , I want the wall to be broken into several pieces).

So ok , This is my job to lay down an infrastructure that will represent the game logic. so lets say I already did it , and I have some Data model that abstract objects and how they relate to each other (I am talking about Logic relations and not Spatial relations) that handle all the logic and represents all entities in the game.

Now Here is my question. What is the Best way to connect my data model to the engine? This is not a techincal question but rather a design question.

Some points to keep in mind:

  • My data model isn't built upon the engine. It doesn't aware of anything. It is accessible through interfaces though.
  • When something in the data model changes , I don't want to build my whole scene graph again but rather only the appropriate parts.
  • My Data model Is mainly a class hierarchy of of entities that can communicate with each other in some way.

I am thinking about the MVC pattern , but I would like to hear more opinions from anyone who has some experience with making games.

+1  A: 

The objects (entities) in the scene graph can have both local and world transformation applied to them (translation, scaling, etc...). The local transformation is the transformation of the child object relative to the coordinate system of the parent object.

For example, if we have a room and a desk in the room. The desk's local transformations are relative to the room's coordinate system. An a pen in the desk can have local transformations in the desk's coordinate system. So translating a desk will cause to rebuild the scene graph from the desk (this will result in the desk and the pen's world transformation).

So if yo have a scene graph like:

Room -> Desk -> Pen

This is how you calculate the transformations (W-world, L-local transformation):

Wroom = Lroom

Wdesk = Wroom Ldesk = Lroom Ldesk

Wpen = Wdesk Lpen = Lroom Ldesk Lpen

And about the MVC pattern you are ok to go with it, you already have your model and the view. Although it could prove to be a little bit of overkill to go pure MVC. In game development the controller usually ends up in the view.

Bojan Milenkoski