Multiple ModelAnimators using the same "Model"

Topics: Developer Forum, User Forum
Dec 31, 2009 at 4:41 PM

Hey guys,


I have been trying to figure out how to draw multiple ModelAnimators using the same model in the content menu.



If you load the same model (with the same asset name) more than once, it only draws the ModelAnimator loaded last. This is how I load:


Effect animEffects = Content.Load<Effect>("Effects/test");
Model x = loadModel("Models/Animated/test");

ModelAnimator testA = new ModelAnimator(this, x);
ModelAnimator testB = new ModelAnimator(this, x);

// Also, this is how I load a model (truncated version)
public Model loadModel(assetName, animEffects)
    Model model = Content.Load<Model>(assetName);
    foreach (ModelMesh mesh in model.Meshes)
        foreach (ModelMeshPart meshPart in mesh.MeshParts)
            meshPart.Effect = animEffects.Clone(device);


Note that I have moved these two objects slightly apart from eachother.


Now the weird thing is...:

With the above code, testB will draw, testA will not.

If I remove the line that loads testB, testA will actually draw


But: if I copy model "test", to say "test2", and then load testB as "test2"... both will display. So this only happens if you have the exact same asset name.


So it seems, if you use the same model (same asset name), then it will only draw the last one you initialized. I'm quite new to XNA, hence I'm posting here. Is there any easy way to fix this?


I'm using XNA3, and the lib someone posted on here :)

Thanks in advance!

Jan 9, 2010 at 4:14 AM

Hi Barttech,

It's been long since I coded this part in my project, so I don't have evrth clear right now & I'm not in front of the code. But I remember I had some trouble too when trying to display multiple instances of a model.

But I think that you are doing smth different here. You want many modelAnimators for the same model. I am not sure if this is possible nor correct, but I think you should try creating multiple instances of the same model instead. This will actually work. I don't remember if there is a way to clone a model once loaded from disk (to avoid multiple file access), but I believe there may be.

So maybe u can give it a try!!
Good luck!


Jan 9, 2010 at 11:21 AM

Hey Synth,


Thanks for your reply! There isn't a built in .Clone() function, but maybe I need to do something with copybones? :)

I'll give it a try soon, and once I have a proper solution I'll post back here (may be a while, busy times) :)




Jan 28, 2010 at 3:44 AM

I have the same problem, any solution ?

thank you !