• 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
uglybdavis

MD5 Skinned Mesh

6 posts in this topic

I'm following this tutorial: http://3dgep.com/?p=1053

So far everything works, things render as expected. But i'm having a hard time understanding the PrepareMesh method:

void MD5Model::PrepareMesh(MD5Mesh& mesh) {
    mesh.m_vPositionBuffer.clear();
    mesh.m_vTexCoordBuffer.clear();
    
    for (unsigned int i = 0; i < mesh.m_vVerts.size(); ++i) {
        MD5Vertex& vert = mesh.m_vVerts[i];
        
        vert.position = Vector();
        vert.normal = Vector();
        vert.position.w = 1.0f;
        vert.normal.w = 0.0f;
        
        for (int j = 0; j < vert.weightCount; ++j) {
            MD5Weight& weight = mesh.m_vWeights[vert.startWeight + j];
            MD5Joint& joint = m_vJoints[weight.jointId];
            
            Vector rotPos = joint.orientation.Inverse() * weight.position;
            vert.position += (joint.position + rotPos) * weight.bias;
        }
        
        mesh.m_vPositionBuffer.push_back(vert.position);
        mesh.m_vTexCoordBuffer.push_back(vert.uv);
    }
}

 

The vertex has no position before this method. From what i gather, weight.position is the position of the vertex in bone space local to the bone we're looking at. This leads me to my question, do we have one unique weight for every vertex per bone it attaches to? Or can vertices share weights?

 

Also, is this standard? Is there perhaps another file format that does vertex with a different approach? This seems so wasteful for some reason, but if it can't be worked around, oh well.

0

Share this post


Link to post
Share on other sites

What you have there is cpu skinning.

The vertex positions are calculated by the joint data and the weight, usually a vertex can be affected by multiple joints

the weight is giving information about how much a given joint affects a vertex.

If you do not need to access the transformed vertex data you can use GPU skinning,

there is a good article about gpu skinning in this gpu gems article, right after the morph targets.

 

Also in the comments of the tutorial you mentioned is a link to a gpu skinned version of it, which may be more helpful to you:

http://3dgep.com/?p=1053#comment-1465

Edited by LJ_1102
1

Share this post


Link to post
Share on other sites

this is actually a pretty typical approach.

 

one optimization strategy (if not done already) is basically to cache all the vertex positions for a given frame (since a model generally wont move within a frame). this way, if the model is being drawn multiple times, this avoids recalculating it.

 

similarly, if the model is not moving or is far away, then generally this can be skipped for many frames (say, we only use keyframes rather than interpolated frames, and skip updating positions for if using the same keyframe). likewise, updates can be skipped for models which aren't currently visible, ...

 

also, when modeling, general things like being conservative with triangle counts and numbers of weights and similar may apply, ...

1

Share this post


Link to post
Share on other sites

Thanks guys that answered most of my questions, but there is still one glaring thing i don't get.

 

Why do the weights have a position? And why is the vertex position derived from that?

 

Wouldn't it make more sense (and take up less data) if a weight was just a float and a joint id?

Then instead of deriving the vertex position from all these offsets, transform the vertex into each joints space, and add up all the transforms (multiplied by the bias) to get a final position?

 

The format just seems backwards....

0

Share this post


Link to post
Share on other sites

hy do the weights have a position? And why is the vertex position derived from that?

 

This is md5 specific, md5 does not store the vertex positions themselfs.

The vertex positions need to be calculated from the weights.

I've never parsed MD5 meshes myself, maybe this link is helpful to you:

http://tfc.duke.free.fr/coding/md5-specs-en.html

 

Wouldn't it make more sense (and take up less data) if a weight was just a float and a joint id?

Since a vertex can have multiple joints affecting it you'll have multiple weights for each _vertex_.

Checkout the sturcture in the linked gpu gems article, not about morph target but about gpu vertex skinning.

 

The format just seems backwards....

It is :)

Edited by LJ_1102
1

Share this post


Link to post
Share on other sites

Thanks LJ, it's the MD5 specific part i was missing.

 

Are there any formats that are widely used but laid out differently?

 

I have the MD5 animation working, but i don't like the format very much...

0

Share this post


Link to post
Share on other sites

You could use collada, but parsing it can become pretty much a pain because its so flexible the different

exporters from tools like 3DS Max, Lightwave, Blender and everything are very inconsistent.

 

The 3ds fileformat is also widely used for assets and very well documented.

 

 

Depending on the language you use you could implement Assimp and let it do the parsing for you.

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