I want to add character animation and don’t know how to do it best.
I thought of using bones and draw in a hierachical order. But how should I do:
a) Calculate Vertex changes to the model in the current phase and then draw it normal.
b) or draw in hierachical order and use:
glRotate and pop and push matrix between them?
I’d vote for b, but then I have no idea, how to handle the different materials. Now I draw the materials one after another. but if i use bones I could subdivide materials into bones or bones into materials (all seem to get slow) or reduce all chars to 1 material+ 1 texture.
method a would be a way, but calculating all the vertices in real time (quaternion translations) would be to slow I guess.
I could pre calculate the different poses and store them in vertex arrays, lists???
no idea. I hope you can help!
In general I try not to have multiple textures per mesh. Individual mesh objects/sub objects i allow to have individual textures.
As for the bones system. I recommend this. Its basically the way I have fiddled around with. Store the matrix tranformation for each level in the hierarchy. By this I mean that lower levels consist of the levels matrix transformation applied on top of the previous levels matrix. Basically premultiply the levels. This saves doing the push/pop at each level. I find that its better to store the modelview matrix in a temp variable. You probably are already storing it somewhere anyways. Then push once for each model. Load the modelview matrix you saved. And multiply the objects matrix at the appropriate level. Then just load the modelview again and multiply again for the next level. Both moving up and down/forward and back in the hierarchy. I am not sure if this is really any faster than using push/pop. The thing I don’t like about push/pop is watching the levels you are at in the stack. This eleviates this problem. Although like I said I don’t know if this is any faster.
Sorry about the unorganized nature of this post. I really haven’t done vertex animation yet. At least not a full blown system. So this is rather adhock.
Hope this helps, or at least gives you some ideas.
Check out Jeff Lander’s Game Developer Magazine articles:
Note that in the 2nd link, the PDF article ends with a discussion about the technique not being available in OpenGL- well, that’s changed since the article was published.
Note also that if you’re willing to get into vertex programs, most limitations for the number of bones per vertex can be eliminated.
(I’ve heard rumors of developers getting bone animation and shadow mapping together in the same vertex program- which is one reason that people still do vertex weighted animation on the CPU, because the deformed mesh is still needed for shadows. Then there’s the deformed mesh’s use for collision detection… that’s not going to happen on the GPU within the next year…)
Hope this info helps.