Jump to content
  • Advertisement
Sign in to follow this  
treeway

Scene Graph

This topic is 4335 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi all my meshes, sounds, sprites and stuff derive from a common Entity class which contains the methods to postion something in 3d space. In my Node class, i want to store a list of these things to show that they are attaced to the node. As they all derive from entity it is possible to store them as an array or linked list of Entities but this "chopps" them to the entity level which only gives me access to the positional methods. When i come to access things from nodes, I have to re-cast them every time into what they originally were. Is there a better way of doing this? thanks

Share this post


Link to post
Share on other sites
Advertisement
Hello,

The first question you should consider is: why do you need to cast back? Once your objects are in the scene graph, they should just be Entities!

If you need to change the properties of a particular object, your best bet is probably to keep a reference to the object (for example, Car) outside your graph (where it is upcasted as an entity). When moving your car, you call the method "move" on your Car reference. Note that you could use some messaging system to arrive to the same result. Using the Visitor pattern is another solution.

Have a try with these different techniques, and get an idea of which one is the most maintainable in regards to the rest of your design.

Happy Coding!

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Depending upon which information you want access too, making your functions virtual would allow specific information too be looked up at runtime. This of course is a limited approach as you obviously don't want to make all of the functionality virtual. Other suggestions?

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!