# OpenGL Include a animated model in an OpenGL scene

## Recommended Posts

Hi all,

I am currently starting to use OpenGL to write a game of Android. At this time, my scene contained just cube and basic figures so I never try to look at how to render complex things in my world. But now, I have to animate a full person in my world and make it running ! So, for that purpose, I would need to know how to render a model. Because the game is targetted for a mobile platform and I think this might consume a lot of resources, I am looking for efficient solution that might not consume too much resources.

So, I would like to know how to load and animate such a model, do we need to load something from an external program or is it better to do everything programmaticaly ? If we need to build and load a model, is there some tutorial and/or libraries to see how to do/proceed and what are the most efficient way to proceed ? And if I need to build my own animated model, do you have a suggestion about the tool to use ? (possibly for Linux since I am using this platform as my development platform).

Best,

##### Share on other sites
[quote]I am currently starting to use OpenGL to write a game of Android. At this time, my scene contained just cube and basic figures[/quote]
That is a gigantic step to understanding and using animation. I don't know of any 3rd party tools that will take care of this. I guess it would be best to just use unity or some other big name engine for phones because if all you know is how to move a cube around, then doing an animation system on your own is going to be hard and take a lot of hours.

##### Share on other sites
Ok, thanks for your reply ! Also, as I would like to really understand the internals of OpenGL and how it works, I am ready to spend some time on that topic. So, this is not really a big issue, as long as I have enough book materials that could help me. So, if anybody has some inputs that would help me, I would really appreciate :-)

Greetings,

##### Share on other sites
Like dpadam450 said, going from basic meshes to fully animated models is a big step! But it's not impossible of course. There are several options out there that can help you achieve what you want:

1. Write your own model loader. There are quite a few examples out there for various formats that support. Just dig in what kind of model formats suit your needs best and loop up on how you can load an animate it, you're probably not the only one that asked this question

2. Do you really need animation? Well you probably do, but in some cases you can get away with just simple translation/rotation. This all depends on what you want to achieve probably.

3. Use an external library! There are plenty of frameworks/engine out there that have done all the hard work for you, so you can focus on things that are really important, like making the actual game! I see [url="http://libgdx.badlogicgames.com/"]Libgdx [/url]popping up on a regular basis and there will most likely be plenty of others.

I would say to not try and re-invent the wheel, but it might be a good practice if you want to learn to load the model in yourself. Should you really want to load an animated model yourself, I found that the MD5 model format is the easiest to get in to.

Good luck!

##### Share on other sites
I agree defiantly use MD5, it was used in popular games such as Doom 3, Quake, Prey, etc and I was able to find good examples online how to load them and skin them using Blender to rig, animate, etc for my old game engine. Though they are in C++, doesn't mean you can't convert it to Java for Android. Both have very close syntax anyways, and of course to be a good programmer, you kinda have to maybe spend more time on things you really don't want to. lol I don't have any links... But a Google search wouldn't hurt.

Good luck!

##### Share on other sites
Considering your response to dpadam, i'm going to simply dive straight into what you need, and what your options are.

Their are several ways to animate an model, but in general, you will first need to write a timer, and frame controller class, so this way you can animate at a specific time step, and determine what frame your animations are on, all animations are going to require being played at some speed, and need to be updated, so a good animation controller class is much needed for w/e way you decide to do animation.

In general, their are two solid approaches to animation that are most usable in games:

A. save the model in a series of frames, and load them. this can be very memory intensive, but gives perfectly free rain to your artists. it's not a method i like due to the high memory requirement's, but it's one of the easiest methods(just check what frame you are on, and draw the appropriate model.)

B. skinning and skeletons, this is the method i personally use to do animations, while it doesn't fit all situations, i've found it to be the least memory intensive, while providing the best results. however, it can be very cpu intensive, directly related to the number of vertice's a model has. This can be offloaded to the gpu later on, when you understand skeletal animation further.

In effect, rotating one bone, will rotate all the vertice's attached to that bone by an influenced weight.

you have alot to learn mate, but at the end of the journey, you'll probably be much better off in what you know.

##### Share on other sites
Hi guys,

Thanks for your contributions and instructing me the different solutions. I will look a little bit the different possibilities and will see. Also, the goal is to learn the roots of OpenGL before using a framework/engine : as for C and assembly language, this is always a good thing to first learn the lower-level aspects before using high-level APIs. And from what I have read and seen, it seems that libgdx would be a good thing for later projects ...

Thanks again,

## Create an account

Register a new account

• ## Partner Spotlight

• ### Forum Statistics

• Total Topics
627674
• Total Posts
2978558
• ### Similar Content

• Both functions are available since 3.0, and I'm currently using glMapBuffer(), which works fine.
But, I was wondering if anyone has experienced advantage in using glMapBufferRange(), which allows to specify the range of the mapped buffer. Could this be only a safety measure or does it improve performance?
Note: I'm not asking about glBufferSubData()/glBufferData. Those two are irrelevant in this case.
• By xhcao
Before using void glBindImageTexture(    GLuint unit, GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum access, GLenum format), does need to make sure that texture is completeness.
• By cebugdev
hi guys,
are there any books, link online or any other resources that discusses on how to build special effects such as magic, lightning, etc. in OpenGL? i mean, yeah most of them are using particles but im looking for resources specifically on how to manipulate the particles to look like an effect that can be use for games,. i did fire particle before, and I want to learn how to do the other 'magic' as well.
Like are there one book or link(cant find in google) that atleast featured how to make different particle effects in OpenGL (or DirectX)? If there is no one stop shop for it, maybe ill just look for some tips on how to make a particle engine that is flexible enough to enable me to design different effects/magic
let me know if you guys have recommendations.
• By dud3
How do we rotate the camera around x axis 360 degrees, without having the strange effect as in my video below?
Mine behaves exactly the same way spherical coordinates would, I'm using euler angles.
Tried googling, but couldn't find a proper answer, guessing I don't know what exactly to google for, googled 'rotate 360 around x axis', got no proper answers.

References:
Code: https://pastebin.com/Hcshj3FQ
The video shows the difference between blender and my rotation:

• By Defend
I've had a Google around for this but haven't yet found some solid advice. There is a lot of "it depends", but I'm not sure on what.
My question is what's a good rule of thumb to follow when it comes to creating/using VBOs & VAOs? As in, when should I use multiple or when should I not? My understanding so far is that if I need a new VBO, then I need a new VAO. So when it comes to rendering multiple objects I can either:
* make lots of VAO/VBO pairs and flip through them to render different objects, or
* make one big VBO and jump around its memory to render different objects.
I also understand that if I need to render objects with different vertex attributes, then a new VAO is necessary in this case.
If that "it depends" really is quite variable, what's best for a beginner with OpenGL, assuming that better approaches can be learnt later with better understanding?

• 11
• 11
• 10
• 12
• 22