Assimp bone structure

Started by
13 comments, last by _Flame_ 5 years ago

Hello.

Basically i want to draw a skeleton of a model in initial position.

Assimp has aiBone type and it has mOffsetMatrix which is "Matrix that transforms from mesh space to bone space in bind pose".

So i assumed that what i need is just use position component of that matrix and it's done. But no, skeleton is not correct.

Does anyone know how to get correct bone matrices in initial position?

Advertisement

Turns out that first we need to calculate global transforms of all nodes by doing this.

global_transform = global_parent_transform * node_transform.

Then we can apply offset.

mesh_transform = global_transform * offset_matrix.

The only problem is that we also need to apply global inverse matrix of root.

final_transform = global_inverse * mesh_transform

But skeleton in not correct even after these operations.

Also I don't understand the point of global_inverse transformation.

Can anyone shed light on global_inverse transformation from here - http://ogldev.atspace.co.uk/www/tutorial38/tutorial38.html?

Comments in that linked tutorial indicate the purpose of global_inverse transformation is to flip the handedness of the author’s content by changing its orientation.

1 hour ago, Steve_Segreto said:

Comments in that linked tutorial indicate the purpose of global_inverse transformation is to flip the handedness of the author’s content by changing its orientation.

Thanks. Does it mean we shouldn't apply this weird transform in general?

That I don't know … I don't have familiarity with ASSIMP myself. It seems like the commenter on the article said if the model content is designed for left-hand coordinate system but is to be displayed in GL's traditional right-hand coordinate system then you would need the weird transform.

well wait...we need the inverse op to put rotation at the origin otherwise we'd have orbit behavior. Order of operation in play here?

27 minutes ago, GoliathForge said:

well wait...we need the inverse op to put rotation at the origin otherwise we'd have orbit behavior. Order of operation in play here?

Could you elaborate please?

For now i update skeleton structure by multiplying parent and node matrices: world_transform = parent->world_transform * transform;

But skeleton looks broken.

Oh I really wish I could. Is it possible to see a video of the result. I tried looking through one of my projects that use assimp (ogl3/glfw thing) all I've seen that was relative is this function call. I put it for reference or compare maybe. its the recursive one at startup.


void cJoint::calcInverseBindTransform(glm::mat4 parentBindTransform)
{
	glm::mat4 bindTransform = parentBindTransform * _localBindTransform;
	_inverseBindTransform = glm::inverse(bindTransform);

	for (cJoint* child : children)
	{
		child->calcInverseBindTransform(bindTransform);
	}
}

I'm a little short on animation structure in this code base I'm looking at. Worst case, it would be good to walk through your entire process making sure every step is logical. I always want the quick fix too. 

 

edit: we appear to do it the same here.

It looks like you are calculation inverse matrices in order to use them to transform vertices to bone space(or local space). These matrices should be same as the offset matrices of assimp.

I don't think it's same as global_inverse transformation of first node in the article.

For now i want to draw only a skeleton and i don't think we need inverse matrices for it at all.

This might be helpful … didn't realize it was using ASSIMP

 

This topic is closed to new replies.

Advertisement