Weighted animation
If I have a character's vertices in world coordinates as the default
pose, and these vertices have weights, what do I need to do to transform
them back, before I begin animating?
I have this simple equation to deform them forward:
V' = (v,B1)*w1 + (v,B2)*w2 ... etc
where B are the bone matrices, (v,B) represents a vertex-Matrix multiplication.
To deform the vertices back, is it just as simple as using the same
equation, except using the inverse of B?
V' = (v,B1-1)*w1 + (v,B2-1)*w2 ... etc
where B-1 is the inverse matrix.
[edited by - jtech on November 19, 2002 5:01:10 PM]
I''m not sure exactly what you''re trying to do, but I believe that the equation would work. Why do you want to deform them back? Why not just do all animation from the initial pose, and never worry about transforming back?
Again, I''m not entirely sure how you''re going about animating, maybe some more info would help.
________________________
Grab your sword, and get prepared for the SolidSteel RPG engine, coming soon...(i.e. when it''s done)
Again, I''m not entirely sure how you''re going about animating, maybe some more info would help.
________________________
Grab your sword, and get prepared for the SolidSteel RPG engine, coming soon...(i.e. when it''s done)
The initial pose is in world coordinates, so they must be transformed
back, at least in the beginning of the animation.
I''ve been through a dozen skeleton animation tutorials on the net, and
not a single one explains how to do this. Seems like an important
step to ignore.
back, at least in the beginning of the animation.
I''ve been through a dozen skeleton animation tutorials on the net, and
not a single one explains how to do this. Seems like an important
step to ignore.
Okay, why are you storing the initial pose in world coordinates? This seems like it would be confusing.
I''ve implemented skeletal animation, so I''ll give you a basic idea of the ay I did it (This probably isn''t the best way, but it works)
I''ve got a model, and the entire model mesh is defined in local model coords. The trick is that the main mesh is broken into smaller meshes that are attached to the bones. They are not defined relative to the bone pivot, they are still relative to the model origin.
Now, this is the mesh I load. It is all specified in local coordinates. This is what I use for the initial pose, ie no transformations applied to any of the bones.
All of my animation is done relative to this local coordinate system. The rotations are ultimately specified relative to the initial position. Once I do all the transformations in local space, I then transform from the local coordinates to the world coordinates. I never need to go back to local coordinates from the world coordinates. The weighted transformations are applied in the transformation of each vertex relative to each bone matrix in local space. The weights really have nothing to do with the world transformation.
The world transformation is basically to place the model in the world after all other transformations have been applied. You animate your model, and once you have the pose done, then you move it into the world properly. Maybe you could explain how you have the model pose stored in world space. You may want to redesign, as having it in world space could be awkward.
________________________
Grab your sword, and get prepared for the SolidSteel RPG engine, coming soon...(i.e. when it''s done)
I''ve implemented skeletal animation, so I''ll give you a basic idea of the ay I did it (This probably isn''t the best way, but it works)
I''ve got a model, and the entire model mesh is defined in local model coords. The trick is that the main mesh is broken into smaller meshes that are attached to the bones. They are not defined relative to the bone pivot, they are still relative to the model origin.
Now, this is the mesh I load. It is all specified in local coordinates. This is what I use for the initial pose, ie no transformations applied to any of the bones.
All of my animation is done relative to this local coordinate system. The rotations are ultimately specified relative to the initial position. Once I do all the transformations in local space, I then transform from the local coordinates to the world coordinates. I never need to go back to local coordinates from the world coordinates. The weighted transformations are applied in the transformation of each vertex relative to each bone matrix in local space. The weights really have nothing to do with the world transformation.
The world transformation is basically to place the model in the world after all other transformations have been applied. You animate your model, and once you have the pose done, then you move it into the world properly. Maybe you could explain how you have the model pose stored in world space. You may want to redesign, as having it in world space could be awkward.
________________________
Grab your sword, and get prepared for the SolidSteel RPG engine, coming soon...(i.e. when it''s done)
>>Okay, why are you storing the initial pose in world coordinates? This seems like it would be confusing.
I''m not doing it intentionally, that''s just how it is.
Imagine that my model is a character model with no animation, no bones,
and is standing tall with its arms out. That is it''s initial pose,
completely transformed in world coordinates.
I mean, that''s how models start out when you first create them, then
you bone them and add animation, so I''m not sure why you find this
confusing?
Are you telling me you have never had to transform your model back
from world coordinates? That I find confusing.
I''m not doing it intentionally, that''s just how it is.
Imagine that my model is a character model with no animation, no bones,
and is standing tall with its arms out. That is it''s initial pose,
completely transformed in world coordinates.
I mean, that''s how models start out when you first create them, then
you bone them and add animation, so I''m not sure why you find this
confusing?
Are you telling me you have never had to transform your model back
from world coordinates? That I find confusing.
the confusion of "world coordinates" methinks is just a semantic issue.
the cooddinates that the model''s vertices get from the modelling program are the "model coordinates" the coordinates that a model gets in your game are the "world coordinates"
i.e. you have 3 models each created in 3ds-max or wahtever. each of those models has their vertices calculated from wahtever was the origin in the modelling program.
now to display in your game usually you just give the object''s a position and display them as such(openGL code):
make sense?
typically you''re dynamic object''s are done that way so you can let the accelerated hardware recalculate the vertex positions so you only have to worry about moving around one coordinate (the position coordinate) for each model.
static objects you typically transform into world coordinates so that placing them into spatial partitioning structures (BSP, OctTree) is easier.
-me
the cooddinates that the model''s vertices get from the modelling program are the "model coordinates" the coordinates that a model gets in your game are the "world coordinates"
i.e. you have 3 models each created in 3ds-max or wahtever. each of those models has their vertices calculated from wahtever was the origin in the modelling program.
now to display in your game usually you just give the object''s a position and display them as such(openGL code):
for (int i = 0; i < numModels; i++) { glPushMatrix() glTranslatef(model.pos.x, model.pos.y, model.pos.z); drawModel(model); glPopMatrix();}
make sense?
typically you''re dynamic object''s are done that way so you can let the accelerated hardware recalculate the vertex positions so you only have to worry about moving around one coordinate (the position coordinate) for each model.
static objects you typically transform into world coordinates so that placing them into spatial partitioning structures (BSP, OctTree) is easier.
-me
Yes, I hope everyone understands what I mean by world coordinates.
The way I''m doing animation works, but when I started using vertex
weights, some parts of the model didn''t deform the way they should.
I don''t know exactly where the problem is coming from. If I am
using vertex weights the right way, then the problem is somewhere else.
The way I''m doing animation works, but when I started using vertex
weights, some parts of the model didn''t deform the way they should.
I don''t know exactly where the problem is coming from. If I am
using vertex weights the right way, then the problem is somewhere else.
Ohh, I see we were using different definitions of world coordinates. Now it makes more sense. I'm still confused about what exaclty you are going for?
You have an initial pose right? Where are you trying to go from there exactly. I don't understand what you are trying to go 'back' to.
Your equation for calculating transformations looks fine, perhaps calculating the bone weights is a problem? How did you model your models?
________________________
Grab your sword, and get prepared for the SolidSteel RPG engine, coming soon...(i.e. when it's done)
[edited by - Cold_Steel on November 21, 2002 7:39:27 PM]
You have an initial pose right? Where are you trying to go from there exactly. I don't understand what you are trying to go 'back' to.
Your equation for calculating transformations looks fine, perhaps calculating the bone weights is a problem? How did you model your models?
________________________
Grab your sword, and get prepared for the SolidSteel RPG engine, coming soon...(i.e. when it's done)
[edited by - Cold_Steel on November 21, 2002 7:39:27 PM]
If you want to see the source code am I using (at least where
I started from), here it is:
http://www.swissquake.ch/chumbalum-soft/files/MsViewer.zip
I basically took this, and converted it to use vertex weights.
In the file model.cpp, under the function SetupBones(), the mesh,
which is initially posed in world coordinates is transformed back:
pVertex->Vertex[0] -= m_pBones[pVertex->nBoneIndex].mAbsolute[0][3];
pVertex->Vertex[1] -= m_pBones[pVertex->nBoneIndex].mAbsolute[1][3];
pVertex->Vertex[2] -= m_pBones[pVertex->nBoneIndex].mAbsolute[2][3];
msVec3 vTmp;
VectorIRotate (pVertex->Vertex, m_pBones[pVertex->nBoneIndex].mAbsolute, vTmp);
These lines are basically just an inverse VertexMatrix multiplication.
For vertex weights, I just do what I posted above.
What I''m thinking is, if this is correct, then maybe the problem is
with the animation keys?
I started from), here it is:
http://www.swissquake.ch/chumbalum-soft/files/MsViewer.zip
I basically took this, and converted it to use vertex weights.
In the file model.cpp, under the function SetupBones(), the mesh,
which is initially posed in world coordinates is transformed back:
pVertex->Vertex[0] -= m_pBones[pVertex->nBoneIndex].mAbsolute[0][3];
pVertex->Vertex[1] -= m_pBones[pVertex->nBoneIndex].mAbsolute[1][3];
pVertex->Vertex[2] -= m_pBones[pVertex->nBoneIndex].mAbsolute[2][3];
msVec3 vTmp;
VectorIRotate (pVertex->Vertex, m_pBones[pVertex->nBoneIndex].mAbsolute, vTmp);
These lines are basically just an inverse VertexMatrix multiplication.
For vertex weights, I just do what I posted above.
What I''m thinking is, if this is correct, then maybe the problem is
with the animation keys?
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement