View Full Version : weighted vertices

08-22-2000, 06:16 AM
Hello. I'm want to put a mesh over a skeleton, and the position of all the vertices in the mesh will depend on it's closeness to certain bones.
For example, a vertex in the middle of the fore-arm will be slightly affected by the position of the upper-arm, but mostly affected by the position of the fore-arm. This is accomplished by calculating at load time, weights for all bones around a given vertex. Then these weights must be applied during run time of the animated character.
Will this be efficient, say for 1-2 8000 poly characters? If not, is there a better way?
Thanks. Hope you understand what I'm trying to do...

08-22-2000, 06:57 AM
I think what you want to do.. and is what many people do (including those at both game companies I have worked for in the past) it store for each joint, an offset from the parent joint and a rotation value, then all vertices of that peice are relative to that joint. There might be better ways, but this is the way I know http://www.opengl.org/discussion_boards/ubb/smile.gif

Anways, just to dig a little bit deeper..
To draw the object, simple step through it's heirarchy like such: (in almost-code.. a bit more advanced than psuedo-code)

class Mesh{
Mesh *child;
Mesh *next; // sibling
Face *faces;
Vector3 offset;
EulerAngle orientation; //or whatever

void Draw();

void Mesh: http://www.opengl.org/discussion_boards/ubb/biggrin.gifraw()
// save matrix stack
// add this joint's translation and orientation
glTranslatef( offset.x, offset.y, offset.z );
glRotate( orientation ); //--however I use quaternions actually

// draw all the faces of this peice
faces->DrawFaces(); // again however...

// if a child exists, draw it
if( child )

// restore stack

// if a sibling exists, draw it
if( next )

Now, to animate, simply go through the list updating the orientation of each joint that moves each time it moves.

If you need furthur explaination, please feel free to email me: kyberteknik@geocities.com

08-22-2000, 07:21 AM
I don't think this is getting the effect I was talking about. This will animate the mesh in chunks based on the position of the skeleton, which is basically what I wanted to do. However, my main problem was coming up with a good way to fill in the spaces that may appear at joints. I was using two or three bones to affect the position of one vertex. I'm thinking that if the fore-arm rotates, an ugly crack will appear at the elbow, and at the inner elbow, textures will slide under one-another. Am I right in my thinking? I don't have much experience in this stuff, so I'm just trying to picture it in my head...

08-22-2000, 09:24 AM
Have you seen GL_EXT_vertex_weighting ?

It's designed to solve exactly this problem, and is supported by current high-end consumer hardware. There's a description in nVIDIA's extensions doc, at http://www.nvidia.com/Marketing/Developer/DevRel.nsf/pages/A86B9D846E815D628825681E007AA680

08-22-2000, 10:05 AM
I didn't think that openGL would implement something like that....

08-23-2000, 02:34 AM
The problem with this extension is that it doesn't appear on all drivers.

I have a graphics blaster 3d TNT2 and my driver doesn't support it. How do I acheive the same results, with and without the extension?


08-24-2000, 06:22 AM
You should check the DirectX Bend sample (a bending banana ) from the DirectX SDK (immediate mode samples). It does vertex blending using 2 matrices.

Also, there is a document in the MSDN library that gives all the formulas you need. Just do a topic search on "blending weights" and you will find it.

Good luck !

08-24-2000, 09:32 AM
Thanks. I started looking at the banana example. Just one thing. I searched for "blending weights" in "MSDN Library
Visual Studio 6.0 release", with no luck. Is this the right place? Thanks for the help.

08-24-2000, 09:49 AM
Actually, you can get the same thing on Microsoft's web site. Go to this address :

08-24-2000, 10:21 AM
Thanks for the help.

08-24-2000, 11:29 AM
Glad I could help ! http://www.opengl.org/discussion_boards/ubb/smile.gif