• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
big_dilliams

Teach me how to parse .md5mesh and .md5anim, OpenGL

5 posts in this topic

[b]Hello developers,[/b]
since a while I started to programm C++ with OpenGL.
I made the basics, draw a triangle, rotate, scale one, import .obj and so on.
But now I'm stuck in parsing and rendering .md5 models in OpenGL. I also tried to parse Collada or IQM, but all of them were to complicated for me especially the quaternions.

Now I hoping that someone could help me and teach me how to parse such files, cuz all the tutorials I read couldn't help me so good as a human individual could.

I would appreciate any kind of help [img]http://public.gamedev.net//public/style_emoticons/default/smile.png[/img]

Best regards
bigdilliams


[size=2][i]Sry for my creepy english but its not my main language. [img]http://public.gamedev.net//public/style_emoticons/default/rolleyes.gif[/img] [/i][/size]
0

Share this post


Link to post
Share on other sites
It's hard to give a lecture on skeletal animation through a forum. But I'll try and explain how it works.


Skeletal animation works by getting a bunch of bone transforms, where the transform of each bone is relative to it's parent's transform. So if you have an 'absolute' transform you want to get rid of that by multiplying the absolute transform of any bone at any frame by the inverse absolute of it's parent. This gives you a local transform for a bone to start with. With this you need to have a bone-hierarchy that lists the parent-child relationships of you skeletal system. Ideally, regardless of any animation, if you twist a spine bone of any character, their 'upper body' and other connected bones that inherit the transform of that spine bone, should rotate/translate relative to that twisting. So you're animation and update step for a skeleton is to compute the 'local' transformation of each bone in the skeleton according to animation, and then to generate an absolute transform for each bone that is the transformation of that bone's parents inherit into it's transformations.

So you need the animation data for each bone for each frame to be in a local context in order to get the correct motion. Once you have that you create the 'world' or 'absolute' transforms for each bone to generate your animation matrix.

Now, before you can render the vertices, you need an inverse bind pose, which is the absolute inverse matrix of each bone at it's starting position. You transform the vertices by the inverse bind pose, then the absolute pose generated from the animation, to move each vertex of the model into the correct position.

As far as quaternions are concerned. Quaternions are just easier to interpolate smoothly compared to matrices. You still need to do the same thing in terms of multiplications by inverses and bind poses etc with quaternions that you would with matrices. The only difference being that with the quaternions a rotation animation will be spherically interpolated. And you do need that spherical interpolation to animate the skeleton correctly.

Following on from this, generally in a skeletal animation system the only actual animation data you need is rotation. Position of bone transforms and scale of bones is optional I guess, I would probably add it to the solution just in case, but I can't guarantee that data will be there in the keyframe data in the md5mesh format. But the position and scale of the bones at the bind pose should at least, because that's part of the mathematical formula to position the vertices correctly.

If you read up and study some quaternion math, you'll see that quaternions aren't that hard. They're just ways of specifying rotation that are more efficient than transform matrices and come with the benefit of interpolating between rotations smoothly. So the things I would look for and do to get a skeletal animation system working would be:

1) Bind Pose
2) Inverse Bind Pose
3) Bone Hierarchy
4) Animation in Local Bone Space
5) Interpolation of local space bone transforms to play back animation
6) Create the pose for the skeleton at the current frame from the local space transforms by transforming by parents
7) Transform the absolute transforms by the inverse bind pose to combine those transformations
8) Send vertex & matrix data to the GPU
9) On the GPU: Calculate the position of the transformed vertex by the bones it's bone indices point to, and then interpolate those results by the bone weights to get the correct vertex position. If using normals, do the same thing, but only apply the inner 3x3 component of the matrices so that you're transforming rotation only.

EDIT: It's been scotch O'clock for the last hour now, so sorry if any of this is incoherent or missing details. Edited by Kyall
0

Share this post


Link to post
Share on other sites
Thank you for you're response.
[quote name='Kyall' timestamp='1350377946' post='4990656']
1) Bind Pose
2) Inverse Bind Pose
3) Bone Hierarchy
4) Animation in Local Bone Space
5) Interpolation of local space bone transforms to play back animation
6) Create the pose for the skeleton at the current frame from the local space transforms by transforming by parents
7) Transform the absolute transforms by the inverse bind pose to combine those transformations
8) Send vertex & matrix data to the GPU
9) On the GPU: Calculate the position of the transformed vertex by the bones it's bone indices point to, ......
[/quote]
Now, at first I will take a look at those things here listed and do some maths with quaternions.
Probably there will be some more questions later [img]http://public.gamedev.net//public/style_emoticons/default/biggrin.png[/img] Edited by bigdilliams
0

Share this post


Link to post
Share on other sites
Now after some days I still don't understand the parsing of skeletal animation formats like .md5mesh, .md5anim because they have some complicated maths in it like quaternions.

Can someone help me parsing .md5 models, problably with some explanations over skype, or anything else?
0

Share this post


Link to post
Share on other sites
[quote name='bigdilliams' timestamp='1350586454' post='4991517']
Now after some days I still don't understand the parsing of skeletal animation formats like .md5mesh, .md5anim because they have some complicated maths in it like quaternions.

Can someone help me parsing .md5 models, problably with some explanations over skype, or anything else?
[/quote]

If you use a third party library like [url="http://assimp.sourceforge.net/"]assimp[/url] you can abstract yourself from all the nitty gritty file specific stuff and just use the structures exposed by assimp. It should handle md5s for you. Edited by ic0de
0

Share this post


Link to post
Share on other sites

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  
Followers 0