# What's a good way to render animated models?

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

## Recommended Posts

I'll be using 3ds max models in my project and will be using keyframe animation. I'm piecing together what all this entails in my mind before I sit down to code. I'm wondering what a good way to draw the objects is. Display lists are obviously out, as the shape's triangular vertices must constantly be translated independently. I'm thinking vertex arrays are as well, unless I were to attempt to load in each vertex for each key frame and just using glDrawArray, but I'm thinking that's going to be inefficient. I don't know much about VBO's, could they be of some use here? I'd appreciate any suggestions and am happy to comment more on how I plan on implementing things. Thanks in advance!

##### Share on other sites
VBOs are just a system to allow you to put VAs into video ram.

Personally, the way i'd do it would be to supply the 2 frames either side of the current time in two streams and a time metric (between 0 and 1) and use a vertex program to interpolate between the two frames.

If you added VBOs into the mix then you'd have to copy each frame as needed to the gfx card and then render it (which could infact use a clever caching scheme if you have more than one type of each model in view at once and try to reuse frames if you can to save the upload time) (note, this is not really any different than streaming it from system ram as a VA at draw time, infact it could work out to be better).

##### Share on other sites
Here's a question. Let's say I set up a vertex array and pass glVertexPointer the pointer to an array of vertices (standard VA setup). If I later modify those vertices, will the modified values be drawn when I call glDrawArray/elements?

Doing it that way allows me to just keep pointers to the vertex data and manipulate what they point to as I wish. It also allows me to use VBOs (as you said).

So can it be done that way? Or would I have to call glVertexPointer each time I modified the data? If that is the case (which I would not think it is), is that feasible to do each frame?

Thanks!

##### Share on other sites
Quote:
 Original post by CyberSlag5kHere's a question. Let's say I set up a vertex array and pass glVertexPointer the pointer to an array of vertices (standard VA setup). If I later modify those vertices, will the modified values be drawn when I call glDrawArray/elements?Doing it that way allows me to just keep pointers to the vertex data and manipulate what they point to as I wish. It also allows me to use VBOs (as you said).So can it be done that way? Or would I have to call glVertexPointer each time I modified the data? If that is the case (which I would not think it is), is that feasible to do each frame?Thanks!

gl*Pointer() functions just tell OpenGL where to get the data. It isn't sent until you call a glDraw*() function. So yes, you can call glVertexPointer(), modify the array, and then call glDrawElements() and render the modified vertices. With that said, the gl*Pointer functions usually aren't called until right before you call glDraw*() anyway, since most programs will be using more than one vertex array. It usually goes something like...
Enable all needed vertex array states (vertex, normal, texcoord, etc)For all vertex arrays     Tell where to get the data (gl*Pointer)     Send data to card and render (glDraw*)Disable all vertex array states

Just make sure that if you need different states enabled for different vertex arrays that only the ones needed for the current vertex array are enabled and the rest are disabled, otherwise the drivers may complain and crash your program. So you would add enabling and disabling inside the for loop.

##### Share on other sites
Thanks a lot. I thought that was the case.

It's all coming together *evil cackle*

1. 1
Rutin
32
2. 2
3. 3
4. 4
5. 5

• 11
• 13
• 86
• 11
• 10
• ### Forum Statistics

• Total Topics
632972
• Total Posts
3009611
• ### Who's Online (See full list)

There are no registered users currently online

×