Jump to content
  • Advertisement
Sign in to follow this  
MohammadAhmed

Scene graph

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

Hello game developers , I have in my game every thing , but all what I need right now is a fast way to create 100 model for example ( zombie )   can you post some code showing the data structures ... etc , say what you know about this smile.png , I have for each model modelAnimatorManager and physicsManager  , so if I want to create 100 zombie model I must create 100 modelAnimaorManager and 100 physicsManager !!!! that's too much right ?!?! 

I used List<model> zombie = new list<model>(); 

and iterate over the model 100 times !!!!!!!!!!!!!! bla bla bla the same goes for physicsManager and modelAnimatorMnager , I know this is not good strategy !!

Sorry game developers if my topic was not related , I have not enough information about these issues , but I think my problem is about mange the scene or whatever is the definition .

Edited by mrmohadnan

Share this post


Link to post
Share on other sites
Advertisement

That entirly depends ...

 

What does modelAnimatorManager and physicsManager do? do you NEED 1 for each zombie?

 

if you have 100 items in the list, and you need to iterate over it, there is no way to get around doing it 100 times. you could look into Multi-threading, but that could cause more problems than it solves.

 

without any details, i would say Do each of the items NEED a physics manager? Why not 1 physics manager that can handle the updating of everything?

 

I currently use a physics engine and have over 1000 objects updating each frame, and the framework does this for me in ~20ms.

Share this post


Link to post
Share on other sites

thanks Andy474 , modelAnimator just load the animation for the model and set the world matrix which will be drawn later on the screen , not physics manager but it's like the controller for the model , i.e updating the bounding box for the model ......etc .

 I was talking with my friend belfegor , he advice me to create one class that contain the model and the modelAnimator and the chrachter controller and just make list of it instead of making 100 list from each one of model , modelAnimator , chrachter controller for each class !!!

for you Andy , what is your advice , tell me about the data structure you used and tell me your opinion in general smile.png and how did you manage all your stuff 1000 model or whatever 

Edited by mrmohadnan

Share this post


Link to post
Share on other sites

Well I use an engine called Farseer Physics to manage my games physics. you could look at the source code, But 1000 objects are not going to take anytime to process at all.

 

I have ~1346 and my update frame time is about 15ms.

Share this post


Link to post
Share on other sites

Ok , Andy do you face problem like this :

you have 10 models using the same effect , if you use XNA or Directx (the same applied ) I got this error :

Code used to make 10 copies of ModelManagerSupprt which will contain the model and the effect and will holds chrachter controller (BEPU Phsics Engine) :
 

            
            foreach (ModelManagerSupport dwarfModel in dwarfModels)
            {
                //dwarfModel.model = Content.Load<Model>("Models//dwarf//dwarfmodel");
                //dwarfModel.effect = Content.Load<Effect>("Models//dwarf//skinFX");
                //dwarfModel.setEffect(camera , game);
                //dwarfModel.setModelAnimationStatus(game);
                //dwarfModel.intializeChrachterController(new Vector3(0, 0, 0), 20, 10, 2000, 2000, 80, 40);

                //space.Add(dwarfModel.chrachterController);

                //dwarfModels.Add(dwarfModel);
            }

 

 


iatq84t8ca58z3x6g.jpg

Edited by mrmohadnan

Share this post


Link to post
Share on other sites
Asking for code is typically a bad approach. People don't want to write your software for you, and besides that ruins all the fun of it :). What you want to do is "instanced drawing". You load the model once into a Vertex Buffer, and then draw the same object over and over using different shader parameters. Edited by metsfan

Share this post


Link to post
Share on other sites

metsfan , thanks but why I can't simply load effect and 10 models which use the same effect ? , besides that is Instancing works for animated models  (.x ) format ?

Edited by mrmohadnan

Share this post


Link to post
Share on other sites

metsfan , my problem is not with instancing , my problem is that I can't create 2 effects and 2 models which used the same effect as shown above in the code 

Share this post


Link to post
Share on other sites

If your models have a lot of detail and your game starts to stall, you can try to implement Instancing, so instead of having separate draw call for identical zombies (for instance say 100 draw calls). You have one shader, which can draw desired number of models at once.

You can read about animated model instancing here:

 

http://developer.download.nvidia.com/SDK/10/direct3d/Source/SkinnedInstancing/doc/SkinnedInstancingWhitePaper.pdf

 

It might get tricky so first thing is to ask yourself if you really need such optimisation.

Edited by Tasaq

Share this post


Link to post
Share on other sites

OK , Thaaaaaanks so much , but for now I will not do Instancing , all I need is to figure out the bug in my game .

If I load 2 models ( the same model zombie ) and give them the same effect I got the following errore :

 

   for(int i =0 ; i<2 ; i++)
        {
            dwarfModel.model = Content.Load<Model>("Models//dwarf//dwarfmodel");
            dwarfModel.effect = Content.Load<Effect>("Models//dwarf//skinFX");
            dwarfModel.setEffect(camera , game);
            dwarfModel.setModelAnimationStatus(game);
            dwarfModel.intializeChrachterController(new Vector3(0, 0, 0), 20, 10, 2000, 2000, 80, 40);

            space.Add(dwarfModel.chrachterController);

            dwarfModels.Add(dwarfModel);
        }

 

 


iatq84t8ca58z3x6g.jpg

Edited by mrmohadnan

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!