View Full Version : Bones

01-24-2007, 09:10 AM

I don't know where I should put this topic, so I'm posting it here...\\

I have big troubles with understanding how mesh is animated in lightwave when artist gives me object without weight maps for each vertex. So far I know how to animate with supplied vertex weight maps and now I need version where I can compute missing maps on the fly in same way as LW is doing it...

In bone preferences there are some settings (for example: fallof, strength, etc..) but how to use them? What algorithm is used in mesh deformation with bones?

Can anyone help me? pleease!

02-01-2007, 07:38 PM
Nobody knows exact algorithm.. ;)
One vertex can be driven by the all bones, if it's close enough..
Inside of vertex loop, you should have bone loop, and getting the all bone informations and check whether bone is close enough to vertex to affect it, and then add bone deformation to vertex.. When the all bones are evaluated deformed position is final..

int vertex_count = mesh.GetVertexCount();
int bone_count = mesh.GetBoneCount();
for( int i = 0; i < vertex_count; i++ )
CVertex vertex = mesh.GetVertexByIndex( i );
CVector object_position = vertex.GetObjectPosition();
CVector world_position = vertex.GetWorldPosition();
for( int j = 0; j < bone_count; j++ )
CBone bone = mesh.GetBoneByIndex( j );
if( bone.IsVertexAffectedByBone( object_position ) )
bone.DeformVertexPosition( world_position );
vertex.SetDeformedPosition( world_position );

If you're making game engine, that's highly unoptimized bone deformation method.. Looking good, smoother than vertex map only version, but imagine having 10,000 points and 20 bones.. internal deformation routine can be even called 200,000 times.. and this has to be done each rendered frame.. FPS will drop a lot.. ;)