Jump to content
  • Advertisement
Sign in to follow this  
CyberSlag5k

What's a good way to render animated models?

This topic is 4834 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'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 this post


Link to post
Share on other sites
Advertisement
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 this post


Link to post
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 this post


Link to post
Share on other sites
Quote:
Original post by CyberSlag5k
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!


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 this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

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

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!