Sign in to follow this  

How to make 3D model move in game

This topic is 3783 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

Hello I want to manage 3D model (made in e.g. 3ds max) in game (C++,WinAPI,OpenGL) i.e. I have some monster with texture on it.. how to import it into game (I have window in WinAPI and OpenGL initialized)? Some theoretical question: If I want to make my monster run I must make animation in 3ds max and then write in e.g. C++ some code to import and start this animation? Or I import only 3D model and all animations: running, sitting etc. I must write in C++ (I think it would be very laborious but I'm not sure whether first or second or some other version of creating animations in game is true... so I ask:) How does it works? Greetings

Share this post


Link to post
Share on other sites
Why don't you use an existing engine (such as Ogre, Torque, or another one)? Because if you have to ask these questions, then implementing such an animation system will probably be a bit too much for you for now. Besides, using an engine saves you a lot of tedious work anyway.

Of course, it can be educative to write such a system, but if your goal is to write a game, then you'd better spend your time writing your game, rather than trying to reinvent the engine wheel. I once wrote a basic OpenGL driven renderer (non-optimized and all) and a half-finished model loader. Recently, I built a scriptable game using an existing 3D engine. Granted, the latter took me about twice as long, but the result was far more than twice as good.

Share this post


Link to post
Share on other sites
Quote:
Why don't you use an existing engine

right, why not!
but I still don't know how does it works.
my earlier question:
Quote:
If I want to make my monster run I must make animation in 3ds max and then write in e.g. C++ some code to import and start this animation?

Or I import only 3D model and all animations: running, sitting etc. I must write in C++ (I think it would be very laborious but I'm not sure whether first or second or some other version of creating animations in game is true... so I ask:)

So i make animations in 3ds max and then run it due to C++ code or I write animations in C++?
is very important for me;)

and tell me what does that engine (like ogre, irrlicht or sth like that) makes to help me programming?

Share this post


Link to post
Share on other sites
There multiple way of animating models; morphing, stitching, but most game use skinning. You know in Max you can add a skeleton (biped etc) and skin the bones to your mesh using a modifier so you can animate it. Once it's done you need a format to export to, most standard format don't export animation so games usually create their own (quake md2/md3, half-life mdl, etc). Then in the game engine reload it recreating a bone hierarchy and bone manipulation who modify the skin just like max. It's a complicated concept (most games company have a programmer who is specialized on animations). That's why Captain P recommended a already existing game engine with already existing model loading and animating code.

Share this post


Link to post
Share on other sites
1.
So when You make animations? In 3ds max and then You import it to game and start it in proper time? Or You animate it using code? (e.g. right arm 10px to the right?:P)

2.
Quote:
most standard format don't export animation so games usually create their own

You mean 3ds max format doesn't export animations?

Share this post


Link to post
Share on other sites
Quote:
most standard format don't export animation

That depends on what you think a standard format is.

Quote:
In 3ds max and then You import it to game and start it in proper time?

Yes. You export .3ds file. Many game engines natively import .3ds files. You can write your own importer. You can find converters into formats that game engine will accept.
For example XSI can natively export .x files, .collada files, .fbx files, all contain animation info.

Share this post


Link to post
Share on other sites
I've always found the process of getting the data into your engine to be the hardest part. Once it's there, implementing a animation system isn't so bad. You can do most of it in a vertex shader. As mentioned above, the way you usually do it is write your own intermediate file format and exporter, which takes a lot of time. As luck would have it, there is this great new technology out there called Collada (www.collada.org). Collada is an open source XML based intermediate file format which most major DCC packages (3DS Max included) can export. Collada features full surface description (geometry data, transform hierarchy, shaders, textures) as well as animation, skinning, physics, lights, and arbitrary user data. Using the Collada Document Object Model (DOM), you can extract data from a Collada file quickly and easily, then load that data into your engine's own structures.

So here's how it would work:
Export Collada from Max -> Convert Collada data to proprietary data using the DOM -> Use converted assets at runtime

Share this post


Link to post
Share on other sites
Thank You! :)

so animations are made in 3ds max and then exported with model? (in the same file or other?)

and one more question about own file formats.
As You said, some games have own file formats for models... So where do programmers make this models?
Is it made in 3ds max and exportet to model.max and then somehow converted into md2/md3 (for quake) format?

Share this post


Link to post
Share on other sites
Yep, since a convertor is a lot easier to write than a full modelling package, that's what most people do: they use an existing tool and write their own convertor. And yep, animations are created in a modelling package - hardcoding them would be extremely tedious.

Take a look at existing games if you want to get more comfortable with the process. Many games nowadays come with modding tools, like level-editors and a wide range of conversion tools for model and texture formats. I'm sure that it'll give you a better insight.

Share this post


Link to post
Share on other sites
Quote:
Original post by Ka-lolek
Yes, indeed!
Is there some tutorial/e-book/book which You recommend about it? (importing models, animating it in game and creating 3D games at all)

actually, the books from the moderators are not bad for beginner.

Share this post


Link to post
Share on other sites
Basicly you have a model that contains additional information about how much vectors are influenced by bones. That's what is known as skinning.

The actually animation will be any file format that has information about the bone transformations for each animation frame. Using ticks or similar you decide in which state your animation is in an get the corresponding bone transformations. E.g: frame 20. This information is usually pushed into the vertex shader which will calculate the actually positions of the vertex combining the weight informations created when the model was skinned and the bone transformation.

That´s how the model starts to animate, moving hands, arms, legs etc.




Share this post


Link to post
Share on other sites

This topic is 3783 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this