Jump to content

  • Log In with Google      Sign In   
  • Create Account

We're offering banner ads on our site from just $5!

1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


Scene graph


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
12 replies to this topic

#1 mrmohadnan   Members   -  Reputation: 279

Like
0Likes
Like

Posted 26 May 2013 - 09:05 AM

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, 26 May 2013 - 09:08 AM.


Sponsor:

#2 Andy474   Members   -  Reputation: 690

Like
2Likes
Like

Posted 26 May 2013 - 01:07 PM

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.



#3 mrmohadnan   Members   -  Reputation: 279

Like
0Likes
Like

Posted 26 May 2013 - 01:24 PM

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, 26 May 2013 - 01:26 PM.


#4 Andy474   Members   -  Reputation: 690

Like
0Likes
Like

Posted 26 May 2013 - 05:03 PM

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.



#5 mrmohadnan   Members   -  Reputation: 279

Like
0Likes
Like

Posted 26 May 2013 - 05:27 PM

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, 26 May 2013 - 05:29 PM.


#6 metsfan   Members   -  Reputation: 654

Like
2Likes
Like

Posted 26 May 2013 - 05:44 PM

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, 26 May 2013 - 05:44 PM.


#7 mrmohadnan   Members   -  Reputation: 279

Like
0Likes
Like

Posted 26 May 2013 - 05:52 PM

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, 26 May 2013 - 05:54 PM.


#8 mrmohadnan   Members   -  Reputation: 279

Like
0Likes
Like

Posted 26 May 2013 - 06:04 PM

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 



#9 Tasaq   Members   -  Reputation: 1250

Like
0Likes
Like

Posted 27 May 2013 - 03:56 AM

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, 27 May 2013 - 03:58 AM.


#10 mrmohadnan   Members   -  Reputation: 279

Like
0Likes
Like

Posted 27 May 2013 - 06:18 AM

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[i].model = Content.Load<Model>("Models//dwarf//dwarfmodel");
            dwarfModel[i].effect = Content.Load<Effect>("Models//dwarf//skinFX");
            dwarfModel[i].setEffect(camera , game);
            dwarfModel[i].setModelAnimationStatus(game);
            dwarfModel[i].intializeChrachterController(new Vector3(0, 0, 0), 20, 10, 2000, 2000, 80, 40);

            space.Add(dwarfModel[i].chrachterController);

            dwarfModels.Add(dwarfModel);
        }

 

 


iatq84t8ca58z3x6g.jpg


Edited by mrmohadnan, 27 May 2013 - 08:35 AM.


#11 kunos   Crossbones+   -  Reputation: 2207

Like
1Likes
Like

Posted 27 May 2013 - 08:07 AM

that has nothing to do with loading 1, 10, 100 or 1 million objects.

That's just a problem trying to upcast and Effect into something that is not (a BasicEffect), just as the error message is complaining about.

 

The rest of the thread doesn't make a lot of sense either... unless you want to draw 1 million zombies in the same pose, you'll need to draw them separately.

Having the animation data shared for all the zombies or one for every zombie is a memory problem.. are you having problems with memory? If you have, I bet there are MANY other places eating up your memory.. but seriously, considering the fact that you can't understand a simple error message like that means you don't have problems with memory solvable by sharing animation data.. so my suggestion is.. keep coding and forget about all this.


Stefano Casillo
Lead Programmer
TWITTER: @KunosStefano
AssettoCorsa - netKar PRO - Kunos Simulazioni

#12 mrmohadnan   Members   -  Reputation: 279

Like
0Likes
Like

Posted 27 May 2013 - 08:33 AM

kunos  thanks , so I did not see your advice and answer for my problem !! I still can't figure out the problem as show in the picture above !! 


Edited by mrmohadnan, 27 May 2013 - 08:34 AM.


#13 kunos   Crossbones+   -  Reputation: 2207

Like
3Likes
Like

Posted 27 May 2013 - 08:55 AM

well.. sorry to be blunt, but if you dont understand why a cast is failing at runtime you should go back to basics and study C#, inheritance and all that before moving on.

 

Let's have a base class Effect, and then BasicEffect and CustomEffect derived from that. You cannot cast an Effect into a BasicEffect if that is pointing to a CustomEffect... .NET is gentle enough to point that out for you.


Stefano Casillo
Lead Programmer
TWITTER: @KunosStefano
AssettoCorsa - netKar PRO - Kunos Simulazioni




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS