This project is read-only.

Model Animation Issue

Nov 20, 2008 at 11:27 PM
Hello,

First of all, thank you for the great work you are doing on your Xen Graphics API. I've been fooling around with it a bit and it proves to be a great learning experience!

Second, i'm having some issues with animating a model. I've used the code from the examples and the included "tiny" model.
When I first draw the model with its position set at 0,0,0 the center of the model is drawn at 0,0,0. However, when I play an animation (for example Walk) the bottom of the model is drawn at position 0,0,0 thus moving the model up. When the animation is done playing the model's center returns to position 0,0,0, moving the model down again.

I've included a screenshot of the problem and a code snippet:
Screenshot
Code


Can you tell me what I'm missing here?

Also a bit unrelated, but how can I change the intensity of the ambient light?

Thank you for taking the time to read this!

Cheers,

JJ
Nov 21, 2008 at 12:45 AM

Hi. This is actually a limitation of the model. All the animations it uses translate the model so the feet sit at 0 height.

What you can do is have the idle animation playing as a loop. Then, as you want to play the walk animation, increase the weighting of the walk animation (towards 1.0) while reducing the weighting of the idle animation back to zero (ideally, you want to have all animation weightings add up to 1.0).

The geometry used in ModelData includes a MaterialShader to describe the look of the material (texture, normal map, etc). The ModelInstance class lets you set a MaterialLightCollection that it will use for the geometry, this class is used with a MaterialShader and contains an ambient light term.

Hope that helps

Nov 21, 2008 at 11:32 AM

Hi. This is actually a limitation of the model. All the animations it uses translate the model so the feet sit at 0 height.

What you can do is have the idle animation playing as a loop. Then, as you want to play the walk animation, increase the weighting of the walk animation (towards 1.0) while reducing the weighting of the idle animation back to zero (ideally, you want to have all animation weightings add up to 1.0).


Thank you for your explanation it makes complete sense for me now! Also playing the idle animation is an excellent idea. The model should probably never not play an animation.


The geometry used in ModelData includes a MaterialShader to describe the look of the material (texture, normal map, etc). The ModelInstance class lets you set a MaterialLightCollection that it will use for the geometry, this class is used with a MaterialShader and contains an ambient light term.

I am looking at tutorial 14, i've seen the MaterialLightCollection and the AmbientLightColour property, however, I do not see a property to set the ambient intensity (ambient power?).
Or am I misunderstanding an article about lights and should the power of the ambient light always be 1?

Thanks again for your time!

Cheers,

JJ
Nov 22, 2008 at 11:47 AM
Edited Nov 22, 2008 at 11:48 AM
Hi JJ.

I'm not an official developer, but maybe my answer will be useful^^
Ambient color is a constant lighting color for your scene, it doesn't depend on some kind of ambient power, ambient direction, ambient attenuation and other such things. It lights all object vertices in the same cheapest way possible, so you may have some basic lightning without creating point/directional lights.
The only other factor which affects it is the MaterialShader.DiffuseColor property, so the resulting color for vertices is a combination of those two. So if you won't specify LightCollection to pass into MaterialShader, Ambient color for the object will be the same as it's DiffuseColor.
Nov 22, 2008 at 3:10 PM
Thank you for your reply.
I couldn't figure out how to make my scene darker, turning the DiffuseColor property down solved this issue! I never realised the diffuse color also affected the ambient.
Guess I got to do some more lighting research!

Cheers,

JJ