malignate

MS had announce an animation sample some weeks before and you just told us, that i will be released soon, but the question is, what soon means...When will you release the example. All I need are some informations how to transform the bone matrices to absolute ones to transform the mesh.


Re: XNA Game Studio Express Animation sample

AlfonsAberg

If you can't wait, have a look at these sites in the mean time:
http://www.codeplex.com/animationcomponents

http://abi.exdream.com/




Re: XNA Game Studio Express Animation sample

malignate

Thanks a lot, i know both ressources and already studied them.



Re: XNA Game Studio Express Animation sample

Montana Jones

Hi,

There was a similar post regarding what reference frame the matrices specified in the keyframe animation data structures was in, don't know if this is what u r referring to in ur query, but i hope it helps:

http://forums.microsoft.com/MSDN/ShowPost.aspx PostID=1121017&SiteID=1




Re: XNA Game Studio Express Animation sample

malignate

It helps a littel bit. If I understand it, this means that the following code should give me the absolute animation matrices to transform my Model with.

public override ModelContent Process(NodeContent input, ContentProcessorContext context)
{


// node = the node with the animation data, that means a BoneContent type
foreach (AnimationContent ac in node.Animations.Values)
{
foreach (string key in ac.Channels.Keys)
{
foreach (AnimationKeyframe keyFrame in channel)
{
// IS THIS THE CORRECT TRANSFORMATION IT DOESNT WORK.
Matrix FINALMATRIX = input.Transform * keyFrame.Transform;
}
}
}




Re: XNA Game Studio Express Animation sample

leclerc9

An AnimationChannel contains a set of keyframes for a given bone. The name of the bone to which the channel corresponds is stored as the key for that channel in the AnimationContent.Channels property.  A keyframe in the channel stores the non-absolute transform for the bone at a given time.

If you want to get the absolute transform of the bone at that time, one way to do it is to set all the Transform matrices on the Model.Bones collection to your keyframe transforms, and then call the CopyAbsoluteTransformsTo method and have them copied to an array. But that just gives the absolute transforms and you still need to do more work to make your model display in a skinned aimation.

The next step is to make an effect that uses (usually) a matrix palette to display the vertices properly for a skinned model.

Then, you need to find out how the bone indices in the vertex buffer will map to the indices on the model. I'm not exactly sure how the default mapping works, but I think it is one of two possibilities (the first is that it is mapped directly to the indices in the bones of the model and the second is that it is mapped in the order that the bones containing skin weights appear in the hierarchy). I just overrode the default implementation and manually mapped them. Once you have resolved this, you can make your matrix array that will be passed to your shader as a matrix palette.

Finally, vertices in the model are stored in the bind pose. In other words, if you were to just render all the vertices of a skinned model on a screen and not transform them by any bone matrices, the model would appear as it did when it was initially rigged in the modeling program. So, because of this, just passing the absolute bone transforms to the shader will not display the model properly. For the final step, you will need the matrix that transforms the vertices from the bind pose bone space to the local space of the bone. This can be found by multiplying the absolute mesh transform by the inverse absolute transform of the bone (when the model is originally loaded). This transform has been called a large number of different names by many different people (its "official" name is perhaps the inverse bind pose transform), but I just call it the skin transform. Finally, you can get the transform that you want to pass to the shader by multiplying the "skin transform" by the absolute bone transform for that frame.

Edit:
The one thing I forgot to mention is that the keyframes are not interpolated, so if you don't keyframe your animation to 60 fps in your modeling program, you probably also want to do that in the processor.




Re: XNA Game Studio Express Animation sample

malignate

I will try it again, i hope your explanation will help me, thanks a lot.
btw: the default already keyframes the animations to 60FPS, i think.




Re: XNA Game Studio Express Animation sample

MikeStramba

leclerc9 wrote:
.

.. set all the Transform matrices on the Model.Bones collection to your keyframe transforms, ...

.... make an effect that uses (usually) a matrix palette to display the vertices properly for a skinned model.

.... find out how the bone indices in the vertex buffer will map to the indices on the model.

.... multiplying the absolute mesh transform by the inverse absolute transform of the bone (when the model is originally loaded). .


Holy animation BatMan !

I got dizzy just reading your post !

This is bizzare and frankly IMO utterly ridiculous.

What year is this 2007 .. or 1997 Why not just program everything in assembly language

I appreciate you sharing the info, though I have no idea how to implement it, any chance of posting a code example somewhere

Is this the process that professional game developers have to use to put animated characters in a game ... or is it a limitation of the XNA Game Studio express

Mike





Re: XNA Game Studio Express Animation sample

Shawn Hargreaves - MSFT

There is a sample here: https://creators.xna.com/Headlines/developmentaspx/archive/2007/02/13/Skinned-Model-Sample.aspx

Yes, this is exactly the same process professional game developers use. Except of course that they might be using a game engine that already implements this, or have some code to reuse from a previous game. You could get a similar result by reusing the animation code from our sample.






Re: XNA Game Studio Express Animation sample

MikeStramba

Shawn Hargreaves - MSFT wrote:

There is a sample here: https://creators.xna.com/Headlines/developmentaspx/archive/2007/02/13/Skinned-Model-Sample.aspx

Yes, this is exactly the same process professional game developers use. Except of course that they might be using a game engine that already implements this, or have some code to reuse from a previous game. You could get a similar result by reusing the animation code from our sample.



Shawn,

Thanks for the link.

I just bought a new video card and can finally run the examples.

Before I dig into the animation code, I am trying to figure out how to combine the Skinned Model sample with the GeneratedGeometrySample. What's the easiest / best way to do that

Mike