2
\$\begingroup\$

When creating meshes, I made a mesh class and then used that one as base model and redrew that same mesh for each instance of an object with that mesh. (For eaxmple, one rock mesh, many rock objects.) This is good for saving memory.

Now I'm trying to do this for dynamic models. I have implemented an MD5 animation and I can't really use the same method, because different instances of the same model may be in different stages of the animation.

Is there a similar design pattern that works for animated meshes and which will let me avoid creating a mesh per instance?

\$\endgroup\$
3
\$\begingroup\$

You can still have the same single mesh just with different bones matrices (prepared for different animation frames of meshes instances) and do the transformations in shader. For that you need to decouple mesh from animated bones.

So that you can still redraw same mesh several times, just changing the meshes position AND bones matrices between drawcalls. From shaders perspective position uniforms are the same as bones matrices uniforms - both transform vertices in some way.

Will that work for MD5anim joints?

That will work irregardless of skeleton composition because in the end skeleton bones/joints get converted into matrices that affect vertices in shader. Shader do not care how these matrices were generated.

P.S. In fact I have just converted my testbed tool from using MD5 joints into LW bones without touching vertex/matrix code. Just had to change the order of rotation/offset for matrix generation.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.