question on best way to store keyframe models

Started by
0 comments, last by Arcibald Wearlot 19 years, 7 months ago
I just started using direct3D (used to openGL) and am now implementing a model loader into my code. While I usually highly optimized code for my terrain, sky, static models, and other geometry, I usually defaulted to immediate mode for animated models so that I wouldn't have to store each frame in memory. However, in direct3D there doesn't seem to be an immediate mode (I guess the closest analogy would be to create a new vertex buffer each frame, render from it, and then release it). I am wondering if when I load in my models, if I should create a separate vertex buffer for each frame, or simply load up the current frame during a game loop into a vertex buffer and then release it afterwards.
Advertisement
I think you need a dynamic vertex buffer, that is, a vertex buffer optimized to be locked/changed/unlocked every frame.
To create it, use CreateVertexBuffer() passing D3DUSAGE_DYNAMIC to the second parameter.
Now every frame you Lock() the vertex buffer getting a pointer to the memory, modify the vertices (for example you can do time-based interpolation between two key-frames), Unlock() it and finally draw.
You can keep the key-frame information in your own structures, they don't need to be in a vertex buffer as they are not directly drawn, they are just used to create the real vertex buffer.

This topic is closed to new replies.

Advertisement