• 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

Assimp and COLLADA bind shape matrix

4 posts in this topic

I've been using Assimp to convert models into a nice runtime format. However Assimp does not seem to load/store the bind shape matrix of a given mesh.

This is not to be confused with a bind matrix for skinning. The bind shape matrix is a transformation matrix in which every vertex of a mesh must be transformed by to be in its proper location and orientation in the model.

For example, lets say my COLLADA model is composed of two equal sized cubes, one centred on the origin and one stacked on top of it. In this case, the vertices of both cube meshes will be identical, but one of them will have a translation component in it's bind shape matrix to move it into its proper location.

At first I thought Assimp would simply bake the vertices since thats what I was going to do anyway but it doesn't do that. I checked the *aiNode for the mesh in the scene graph thinking maybe it will store it in its mTransformation field but those only have an identity matrix.

Does anyone know what happens to these matrices and/or where I could find it in the scene graph? Edited by pondwater

Share this post

Link to post
Share on other sites
Odd ... can you verify that the collada file you're using has those transformations in it? If you aren't using the aiProcess_PreTransformVertices flag when reading the file, the transformations for your aiMesh instances should be in the aiNodes that they're attached to. Are you using the aiProcess_OptimizeGraph flag?

Share this post

Link to post
Share on other sites
I can verify that the transformations are present in the .dae file. Neither the aiProcess_OptimizeGraph or aiProcess_PreTransformVertices flags are set, im using aiProcessPreset_TargetRealtime_Quality which contains:

[CODE]aiProcess_CalcTangentSpace | \
aiProcess_GenSmoothNormals | \
aiProcess_JoinIdenticalVertices | \
aiProcess_ImproveCacheLocality | \
aiProcess_LimitBoneWeights | \
aiProcess_RemoveRedundantMaterials | \
aiProcess_SplitLargeMeshes | \
aiProcess_Triangulate | \
aiProcess_GenUVCoords | \
aiProcess_SortByPType | \
aiProcess_FindDegenerates | \
aiProcess_FindInvalidData [/CODE]

Yeah all the mTransformation aiNodes for meshes are the identity matrix.


Share this post

Link to post
Share on other sites
Is this something that could be solved by freezing/baking/applying the transforms before you export to .dae? I have to do that with Blender if I want verts to apply correctly to the model-space origin on export. I'm not sure which 3d package you're working with, or if you're getting the .dae files secondhand, but is there a reason to keep 2 cubes and 2 transformation matrices as opposed to 2 cubes with different vertex position values?

Share this post

Link to post
Share on other sites
I probably could bake them, but its a standard element of the COLLADA structure, Assimp should be able to handle this. Here's a peek at the source code for the ColladaHelper.h [url="http://projects.developer.nokia.com/spaceblokqt/browser/trunk/src/qt3d/3rdparty/assimp/code/ColladaHelper.h?rev=145#L567"]http://projects.deve....h?rev=145#L567[/url]

/** A skeleton controller to deform a mesh with the use of joints */
struct Controller
// the URL of the mesh deformed by the controller.
std::string mMeshId;
// accessor URL of the joint names
std::string mJointNameSource;
///< The bind shape matrix, as array of floats. I'm not sure what this matrix actually describes, but it can't be ignored in all cases
float mBindShapeMatrix[16];
// accessor URL of the joint inverse bind matrices
std::string mJointOffsetMatrixSource;
// input channel: joint names.
InputChannel mWeightInputJoints;
// input channel: joint weights
InputChannel mWeightInputWeights;
// Number of weights per vertex.
std::vector<size_t> mWeightCounts;
// JointIndex-WeightIndex pairs for all vertices
std::vector< std::pair<size_t, size_t> > mWeights;

So it is at least acknowledged.

Here's from ColladaLoader.cpp [url="http://projects.developer.nokia.com/spaceblokqt/browser/trunk/src/qt3d/3rdparty/assimp/code/ColladaLoader.cpp?rev=145&desc=1"]http://projects.deve...?rev=145&desc=1[/url]

// apply bind shape matrix to offset matrix
aiMatrix4x4 bindShapeMatrix;
bindShapeMatrix.a1 = pSrcController->mBindShapeMatrix[0];
bindShapeMatrix.a2 = pSrcController->mBindShapeMatrix[1];
bindShapeMatrix.a3 = pSrcController->mBindShapeMatrix[2];
bindShapeMatrix.a4 = pSrcController->mBindShapeMatrix[3];
bindShapeMatrix.b1 = pSrcController->mBindShapeMatrix[4];
bindShapeMatrix.b2 = pSrcController->mBindShapeMatrix[5];
bindShapeMatrix.b3 = pSrcController->mBindShapeMatrix[6];
bindShapeMatrix.b4 = pSrcController->mBindShapeMatrix[7];
bindShapeMatrix.c1 = pSrcController->mBindShapeMatrix[8];
bindShapeMatrix.c2 = pSrcController->mBindShapeMatrix[9];
bindShapeMatrix.c3 = pSrcController->mBindShapeMatrix[10];
bindShapeMatrix.c4 = pSrcController->mBindShapeMatrix[11];
bindShapeMatrix.d1 = pSrcController->mBindShapeMatrix[12];
bindShapeMatrix.d2 = pSrcController->mBindShapeMatrix[13];
bindShapeMatrix.d3 = pSrcController->mBindShapeMatrix[14];
bindShapeMatrix.d4 = pSrcController->mBindShapeMatrix[15];
bone->mOffsetMatrix *= bindShapeMatrix;

From this it would seem like the transform gets baked into the inverse bind matrix... and checking now... it seems that this is the case because the mOffsetMatrix is different for the same joint when comparing two sepearte meshes with unique bind shape matrices.

Hmm that would explain why the bone influences are defined seperately for each mesh, instead of one global skeleton.

This seems really inefficient, because now I need to store a seperate version of each bone for each mesh because of these unique inverse bind transforms...

Should I just store the inverse binds along with the mesh objects instead of inside the bones? Then for a given model, iterate over the skeleton, update the global transforms, then update the unique skinning matrices using the inverse binds stored in the mesh? Edited by pondwater

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