Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.


To copy meshes or not to copy...

This topic is 5426 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I''ve run into a problem that I''m having some slight difficulty getting my head around. At the moment my D3D Game keeps one copy of every mesh loaded on a manager, and then positions that one mesh in the position for the first object that needs it, draws it, then resets its position. After that the next object that uses the model positions it where it should be, draws it, resets position, continue until all objects are done. Works fine and dandy for static objects and static textures. Now I want to make animated textures. Textures work the same way, one copy on a manager and then given out as needed for the models. However, the mesh objects also hold pointers to the textures that they use--meaning that if I only have one copy of a mesh, every object of that mesh will be on the same animation frame. ie, if I set off one explosion it will start playing, and if another one goes off in the middle of the first the second explosion will start half way through and end at the same time as the first. Now the solution seems simple--seperate the mesh into it''s own art object and convert the current manager to dealing with straight vertex mesh''s without texture pointers, then create a seperate art object that controls which texture and mesh to point to, while being able to be unique to each object (or integrate that into the object itself, but I''d rather make a seperate class). Now the problem is I don''t know how to convert D3DXLoadMeshFromX because that loads the Mesh and the material info for textures, or how to know what textures belong to which parts of the mesh. This also leads me to think further when I might not use static meshes and might desire to change the vertices of the mesh on a per object basis--for full model animations. Should I be keeping with the one mesh loaded idea, or should I create unique meshes for objects, or is there a third option I haven''t thought of? Thanks for any input.

Share this post

Link to post
Share on other sites
The third option is skinned meshes.
See the SDK''s skinnedmesh example.
That is one mesh, and in the .x file the triangles have extra attributes indicating to which position they belong. The skeleton is made of bones, which are not visible lines but just matrices. A vertex shader takes triangles plus some constants (those matrices and the attributes) as input, and moves the triangles accordingly. This way you can fully animate a mesh while still having only one copy.

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!