Observer registration in Smoke demo framework

Observer registration in Smoke demo framework

Hi,

I'm currently taking a look at the smoke framework and having some trouble understanding the way objects from differents systems are linked together.

If you take a look at this object for example:

[xhtml]








[/xhtml]

How are those objects from different scenes linked, so that a position change in the physics system will result in a position change in the graphics system? I can understand the idea of using the observer pattern and one system posting changes so that another system can update its internal copy of the variable thus making sure all system will always get their "fresh" data, but I'm having a hard time following this idea in terms of execution, e.g. how those links are established.

Thanks for any hints or advice!
S_W

4 posts / 0 nouveau(x)
Dernière contribution
Reportez-vous à notre Notice d'optimisation pour plus d'informations sur les choix et l'optimisation des performances dans les produits logiciels Intel.

I'm sorry the code seems to be hard to read, so here it goes again:

That's a good question. The XML files are parsed at start up and this is when the observer/subject relationships are created. In the example you provided, the XML file is defining an object called "Ball." This object has properties in the Graphics and PhysicsCollision system. When the XML file is parsed, an object will be created in SystemGraphics (ObjectMesh.cpp) and an object will be created in SystemPhysicsCollisionHavok (ObjectPhysics.cpp). If you look at these cpp files you will see two methods called GetPotentialSystemChanges and GetDesiredSystemChanges. GetPotentialSystemChanges lists all the changes this object will make and GetDesiredSystemChanges lists all the changes this object wants to know about. So, when these objects are created, the Change Control Manager calls these functions to determine which data might be propagated. For example, the ObjectPhysics says it will change position and ObjectMesh says it wants to know about position changes. When ObjectPhysics posts a position change, the Change Control Manager knows to tell the ObjectMesh about it.

I hope this helps.
Let me know if you have any further questions.
Thanks,
Orion

Thanks for the quick answer! This is exactly what I was looking for.

Laisser un commentaire

Veuillez ouvrir une session pour ajouter un commentaire. Pas encore membre ? Rejoignez-nous dès aujourd’hui