12 Replies - 362 Views - Last Post: 06 August 2013 - 02:08 PM Rate Topic: -----

#1 Nano511  Icon User is offline

  • D.I.C Head

Reputation: 3
  • View blog
  • Posts: 145
  • Joined: 07-October 12

How to handle 3d animation efficiently?

Posted 05 August 2013 - 07:06 AM

The only method i know of and have been using is: create an animation in blender and save each frame as an obj, then load and flip through each frame. But this takes a long time to load even for just 1 player model and 1 run animation. Is there a better way?
Is This A Good Question/Topic? 0
  • +

Replies To: How to handle 3d animation efficiently?

#2 modi123_1  Icon User is offline

  • Suitor #2
  • member icon



Reputation: 8374
  • View blog
  • Posts: 31,122
  • Joined: 12-June 08

Re: How to handle 3d animation efficiently?

Posted 05 August 2013 - 07:15 AM

Have you've flipped through:
http://www.blender.o...ials/animation/
.. or this?
http://cg.tutsplus.c...r-using-rigify/
Was This Post Helpful? 1
  • +
  • -

#3 Nano511  Icon User is offline

  • D.I.C Head

Reputation: 3
  • View blog
  • Posts: 145
  • Joined: 07-October 12

Re: How to handle 3d animation efficiently?

Posted 05 August 2013 - 08:26 AM

Yeah i can make animations fine, i need help with the programming side of it. Like right now my code flips through 50 frames, each frame being a complete wavefront, each containing idk about 2000 vertices? Anyway its a lot of data even for just one animation, is there a better way to handle animation? Im using OpenGL and Assimp by the way.
Was This Post Helpful? 0
  • +
  • -

#4 BBeck  Icon User is online

  • Here to help.
  • member icon


Reputation: 535
  • View blog
  • Posts: 1,189
  • Joined: 24-April 12

Re: How to handle 3d animation efficiently?

Posted 05 August 2013 - 08:33 AM

I'm guessing you didn't read the post before yours.
Was This Post Helpful? 0
  • +
  • -

#5 Nano511  Icon User is offline

  • D.I.C Head

Reputation: 3
  • View blog
  • Posts: 145
  • Joined: 07-October 12

Re: How to handle 3d animation efficiently?

Posted 05 August 2013 - 09:59 AM

What? Those links just show how to make an animation in blender. I know how to do that, that isnt my problem. Im making a game in c++ and i wanted to know the most efficient way to handle animation. My current approach is to have a frame for each object, and switch between them to make it look like an animation. However, with one 55 frame walk animation it takes a while to load. I expect ill have at least 8-10 animations for 1 character model which is about 500 .obj files. That will probably take like 3 minutes to load which is unacceptable for just 1 character. My question is, is there a more efficient way to handle animation in game programming? I dont need help creating animations in blender.
Was This Post Helpful? 0
  • +
  • -

#6 modi123_1  Icon User is offline

  • Suitor #2
  • member icon



Reputation: 8374
  • View blog
  • Posts: 31,122
  • Joined: 12-June 08

Re: How to handle 3d animation efficiently?

Posted 05 August 2013 - 10:02 AM

Really? It didn't sound like you were running the blender model through a game, but were still _in_ blender.


so.. what's the 411 on this c++ game? Is there an API? SDK? What are you using?
Was This Post Helpful? 0
  • +
  • -

#7 BBeck  Icon User is online

  • Here to help.
  • member icon


Reputation: 535
  • View blog
  • Posts: 1,189
  • Joined: 24-April 12

Re: How to handle 3d animation efficiently?

Posted 05 August 2013 - 10:05 AM

@Modi, Thanks for the links. I already had the walking animation one, but I'll take a look at the other when I get a chance; I'm hoping to get a better handle on skinned animation in the next few weeks.


@Nano, I spent half the morning answering this question this morning. So I don't want to repeat what I said. (Funny how two people can independently come to the same question at the same time.)


http://www.dreaminco...ound-to-meshes/
Was This Post Helpful? 0
  • +
  • -

#8 Nano511  Icon User is offline

  • D.I.C Head

Reputation: 3
  • View blog
  • Posts: 145
  • Joined: 07-October 12

Re: How to handle 3d animation efficiently?

Posted 05 August 2013 - 10:24 AM

@Modi: The game im making is inspired by Ocarina of Time and I'm making it for the sole purpose of acquiring experience in 3D game programming. Im using c++(MSVC++) with OpenGL, and Assimp for object loading. It's still in very early stages. All it is right now is a skybox, a basic level(a floor with a wall), simple collision(SpherePlane), and a player that can move around. You can toggle first person or 3rd person camera.

@BBeck The last line of your post pretty much summed up where i am, "It's really how the code plays back the animation where I'm really unsure of how it works for skinned animation." I didn't know about the interpolation bit, ill have to look into that because i could cut down each animation from ~50 frames to just potentially 10-15 key frames.

If anyone who has coded 3d animation could chime in that would be great.
Was This Post Helpful? 0
  • +
  • -

#9 BBeck  Icon User is online

  • Here to help.
  • member icon


Reputation: 535
  • View blog
  • Posts: 1,189
  • Joined: 24-April 12

Re: How to handle 3d animation efficiently?

Posted 05 August 2013 - 10:39 AM

Yes. I think what you're looking for is how to play back an animation stored in a file, whether that is the model's file or an animation specific file, such as a .bvh file. Of course, the first step is obtaining a model file that has such animations in it. The best file I have for that only has one animation, which leaves me with the question of how to do multiple animations.

I can point you to some XNA examples, that I think are kind of "so-so". But they're XNA specific. It will obviously be different for C++. What you really need is a couple tutorials on how to do skinned animation playback in C++. DirectX examples should work in OpenGL because reading the file, storing the animation, and playing it back are probably not included as part of DX or OpenGL. So, any tutorial on one should probably mostly help you in the other.

Anyway, I would also be interested in C++ tutorials on how to read and playback skinned animation, if anyone knows where to find them. I haven't tried just googling it yet. (Personally, I'm trying to master it in XNA before trying to really figure it out in C++. But I'll be trying to do it in C++ eventually.)
Was This Post Helpful? 0
  • +
  • -

#10 Nano511  Icon User is offline

  • D.I.C Head

Reputation: 3
  • View blog
  • Posts: 145
  • Joined: 07-October 12

Re: How to handle 3d animation efficiently?

Posted 05 August 2013 - 10:45 AM

After researching for about 2 minutes i decided keyframe interpolation is the way to go. I can load in objects fine, so im assuming i just load in the neccessary key frames and then use a timer to correctly interpolate. I found this http://www-scf.usc.e...cap/mocap4.html which i will read when i get back home.
Was This Post Helpful? 0
  • +
  • -

#11 BBeck  Icon User is online

  • Here to help.
  • member icon


Reputation: 535
  • View blog
  • Posts: 1,189
  • Joined: 24-April 12

Re: How to handle 3d animation efficiently?

Posted 05 August 2013 - 10:56 AM

Sounds like you are on the right track. I think curved interpolation, such as spline interpolation is what you want to make the animations smooth. The big question in my mind is "What is a key frame in the data file?" I'm guessing a key frame is just a hiearchy of transformation matrices that make up the skeleton. I assume these transformation matrices, when combined with the transformation matrices of the bind pose, will deform the vertices in such a way to put the model into that pose. So, you only have one model, and the transformation matrices do all the deformations to move the model. So, all animations are just matrices rather than repeating all of the data for all the vertices and such. That's worlds more efficient than storing all the data for the entire model over and over again and quicker to draw.

So, if it does actually work that way, then the big question in my mind is "How do you interpolate between matrices?" I have a starting orientation matrix and a final orientation matrix and I want to calculate a matrix at some percentage of the way in between the two. How do I do that?
Was This Post Helpful? 0
  • +
  • -

#12 BBeck  Icon User is online

  • Here to help.
  • member icon


Reputation: 535
  • View blog
  • Posts: 1,189
  • Joined: 24-April 12

Re: How to handle 3d animation efficiently?

Posted 05 August 2013 - 11:25 AM

I'm not certain, but I believe skinned and skeletal animation are basically the same thing. You might try including that in your search.

I'm doing a quick Google search. It sounds like you have to decompose your matrices in order to interpolate between them. So, if you extract all the info from the two matrices, you can interpolate those values seperately and then combine them back into a matrix. One suggestion is to convert the rotations in the matrices to quaternions and SLERP them. You could treat any scaling or position data seperately and interpolate between those values quite easily.


Here's a bunch of info on skelatal animation. I think they use vectors instead of matrices.
http://www.flipcode....ts/charfaq.html

This may be the sort of tutorial you're looking for, but I only glanced it over rather than reading it.
http://www.it.hiof.n...p-skeletal.html


http://content.gpwik...ic_Bones_System

http://www.opengl.or...letal_Animation

http://en.wikipedia....letal_animation


A DirectX example against an .MD5 file animation.
http://www.braynzars...php?p=D3D11MD52
Was This Post Helpful? 1
  • +
  • -

#13 Nano511  Icon User is offline

  • D.I.C Head

Reputation: 3
  • View blog
  • Posts: 145
  • Joined: 07-October 12

Re: How to handle 3d animation efficiently?

Posted 06 August 2013 - 02:08 PM

Hey, i dont know what kind of progress you've made, but i decided the first step was exporting the armiture data from blender. I was able to do it by exporting it to .x, but im having trouble making sense of the data. Here it is in case you can make some sense of it.

Spoiler



Edit: Actually, the more i look at it the more sense it makes.

This post has been edited by Nano511: 06 August 2013 - 02:39 PM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1