• Advertisement
Sign in to follow this  

object oriented design

This topic is 4170 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

I'm working on a game, and I've decided to actually plan it out this time. Instead of starting with libraries and graphics, I'm starting with the organization of the game, and putting raphics and physics in later, in the places that were left for them. My question is this: should a model be stored unde rthe object it belongs to, or in a seperate place in the graphics enngine?

Share this post


Link to post
Share on other sites
Advertisement
In the engine that we use ( Crystal Space ) the models are stored as something called "Factories" ( example for Mesh Object Factory). When then use this factory to create instances of a model we are looking for. We preload all of the model factories at startup and create instances as we need them. Our game 'objects' keep a pointer to their 'instance' of that model.

Share this post


Link to post
Share on other sites
Sometimes this is called a 'mesh exemplar' method - the primary mesh(es) (factory) in Crystalspace terms is not deformed by animation, and each instance carries its own animation states. Basically you don't want to carry around a whole new model for each instance. This is especially true if you're using a vertex animation (mesh tweening) method - they get heavy.

Share this post


Link to post
Share on other sites
Quote:
Original post by NIm
I'm working on a game, and I've decided to actually plan it out this time. Instead of starting with libraries and graphics, I'm starting with the organization of the game, and putting raphics and physics in later, in the places that were left for them. My question is this: should a model be stored unde rthe object it belongs to, or in a seperate place in the graphics enngine?


Absolutely elsewhere. The reason is that you may have 100 of some object, and keeping 100 identical models around is crazy. You might want to either let your rendering code figure it out (for example, it might go "this is a fighter jet, and it's on fire, so let's use the model that came from jet_on_fire.mds"), or you could store the model as just a reference ID to a model factory or a pointer.

Share this post


Link to post
Share on other sites
Each object should store a reference to its model. There should be some kind of model repository (one model per model file? per object class?) in which the models are actually kept in memory; as others have said, if you have ten cars that use the same model, you only want one copy of that model loaded.

Share this post


Link to post
Share on other sites
Thank you very much! You've all helped me. I will keep a list of models as part of the graphics system, and each object will keep a reference for which model it needs at which animation frame.

Share this post


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

  • Advertisement