Quantcast
Channel: Community | MonoGame - Latest topics
Viewing all articles
Browse latest Browse all 6821

Assimp Model Matrix's (The Inverse bind pose matrix and transforms ?)

$
0
0

@willmotil wrote:

Alright so i have assimp loading a fbx up out of blender but im having trouble in seeing how assimp expects this offset matrix to work in relation to the other matrices.

I was thinking that this should be a cummulative transform were the local matrix is multiplied to the parent to get a cummulative transform im reading that the offset matrix is supposed to be applied to the transform but im a little lost as to what the assimp offset matrix is really supposed to be doing here.
I mean if i didn't care about animation data later on then no problem i would just do it my own way.
but i do sooo... im having trouble seeing how this inverse bind pose is supposed to work.

In fact im not even sure if im even remotely on track.

Is it supposed to just work or am i supposed to be recalculating it and if so how ?
What is the order of application for when it is to be applied ect?

A image of what im getting.
With the the initial code to calculate the initial node matrix chain data below.
(animation isn't even added yet.)

        public static BoneNode Update(BoneNode node, ref Matrix[] globalBoneTransformMatrices, ref Matrix[] globalBoneOffsetMatrices)
        {
            if (node.isThisAhBoneInTheOffsetList)
            {
                if (node.parent != null)
                {
                    node.CummulativeTransform = node.parent.CummulativeTransform * node.LocalTransform * globalBoneOffsetMatrices[node.boneOffsetMatrixIndex]; // not to sure about how to apply the offset.
                }
                else
                {
                    node.CummulativeTransform = node.LocalTransform * globalBoneOffsetMatrices[node.boneOffsetMatrixIndex];
                }
                // set this to the global transform since it is a actuall bone named index.
                globalBoneTransformMatrices[node.boneOffsetMatrixIndex] = node.CummulativeTransform;
            }
            else
            {
                if (node.parent != null)
                {
                    node.CummulativeTransform = node.parent.CummulativeTransform * node.LocalTransform;
                }
                else
                {
                    node.CummulativeTransform = node.LocalTransform;
                }
            }


            Console.WriteLine("\n");
            Console.WriteLine("Name" + node.name);
            Console.WriteLine();
            PrintMatrix(node.LocalTransform, "node.LocalTransform");
            if(node.isThisAhBoneInTheOffsetList)
                PrintMatrix(globalBoneOffsetMatrices[node.boneOffsetMatrixIndex], "globalBoneOffsetMatrices["+node.boneOffsetMatrixIndex+"]");
            PrintMatrix(node.CummulativeTransform, "node.CummulativeTransform");

            // if its a requisite child transform in a bone chain be it a actual bone or not then iterate the child and calculate.
            for (int i =0; i < node.children.Count; i++)
            {
                if (node.children[i].isThisNodeTransformNecessary)
                    Update(node.children[i], ref globalBoneTransformMatrices, ref globalBoneOffsetMatrices);
            }
            return node;
        }

Output...

node.LocalTransform
 Right:          {X:1 Y:0 Z:0}
 Up:             {X:0 Y:1 Z:0}
 Forward:        {X:0 Y:0 Z:-1}
 Translation:    {X:0 Y:0 Z:0}
node.CummulativeTransform
 Right:          {X:1 Y:0 Z:0}
 Up:             {X:0 Y:1 Z:0}
 Forward:        {X:0 Y:0 Z:-1}
 Translation:    {X:0 Y:0 Z:0}


NameArmature

node.LocalTransform
 Right:          {X:600 Y:0 Z:0}
 Up:             {X:0 Y:-9.775241E-05 Z:600}
 Forward:        {X:0 Y:600 Z:9.775241E-05}
 Translation:    {X:0 Y:0 Z:0}
node.CummulativeTransform
 Right:          {X:600 Y:0 Z:0}
 Up:             {X:0 Y:-9.775241E-05 Z:600}
 Forward:        {X:0 Y:600 Z:9.775241E-05}
 Translation:    {X:0 Y:0 Z:0}


NamerootBone

node.LocalTransform
 Right:          {X:1 Y:0 Z:0}
 Up:             {X:0 Y:-1.629207E-07 Z:-1}
 Forward:        {X:0 Y:-1 Z:1.629207E-07}
 Translation:    {X:0 Y:0 Z:0}
globalBoneOffsetMatrices[0]
 Right:          {X:0.1666667 Y:0 Z:0}
 Up:             {X:0 Y:-2.715345E-08 Z:0.1666667}
 Forward:        {X:0 Y:0.1666667 Z:2.715345E-08}
 Translation:    {X:0 Y:0 Z:0}
node.CummulativeTransform
 Right:          {X:99.99999 Y:0 Z:0}
 Up:             {X:0 Y:-1.629207E-05 Z:99.99999}
 Forward:        {X:0 Y:99.99999 Z:1.629207E-05}
 Translation:    {X:0 Y:0 Z:0}


NametopBone

node.LocalTransform
 Right:          {X:0.005747838 Y:0.9999834 Z:1.343566E-07}
 Up:             {X:-0.9999834 Y:0.005747838 Z:-1.335865E-07}
 Forward:        {X:1.343565E-07 Y:1.335865E-07 Z:-1}
 Translation:    {X:0 Y:0 Z:0}
globalBoneOffsetMatrices[1]
 Right:          {X:0.1666667 Y:0 Z:0}
 Up:             {X:0 Y:-2.715345E-08 Z:0.1666667}
 Forward:        {X:0 Y:0.1666667 Z:2.715345E-08}
 Translation:    {X:0 Y:0 Z:0}
node.CummulativeTransform
 Right:          {X:0.09579729 Y:-4.954575E-06 Z:16.66639}
 Up:             {X:4.760242E-07 Y:-16.66666 Z:-4.957393E-06}
 Forward:        {X:-16.66639 Y:-5.045105E-07 Z:0.09579729}
 Translation:    {X:0 Y:0 Z:0}
Model Loaded

While this is what is in the actual scene nodes and mesh bones when i load the model.


Node.Name: RootNode
Children:  Armature Cube
node.Transform:
: 1 0 0 0
: 0 1 0 0
: 0 0 1 0
: 0 0 0 1
HasMeshes: No

        Node.Name: Armature
        Parent: RootNode
        Children:  rootBone
        node.Transform:
        : 600 0 0 0
        : 0 -9.775241E-05 600 -600
        : 0 -600 -9.775241E-05 0
        : 0 0 0 1
        HasMeshes: No

                Node.Name: rootBone
                Parent: Armature
                Children:  topBone
                node.Transform:
                : 1 0 0 0
                : 0 -1.629207E-07 -1 0
                : 0 1 -1.629207E-07 0
                : 0 0 0 1
                HasMeshes: No

                        Node.Name: topBone
                        Parent: rootBone
                        Children:  topBone_end
                        node.Transform:
                        : 0.005747838 0.9999834 1.343566E-07 0
                        : -0.9999834 0.005747838 -1.335865E-07 1
                        : -1.343565E-07 -1.335865E-07 1 0
                        : 0 0 0 1
                        HasMeshes: No

                                Node.Name: topBone_end
                                Parent: topBone
                                node.Transform:
                                : 1 0 0 0
                                : 0 1 0 1
                                : 0 0 1 0
                                : 0 0 0 1
                                HasMeshes: No

        Node.Name: Cube
        Parent: RootNode
        node.Transform:
        : 100 0 0 0
        : 0 -1.629207E-05 100 0
        : 0 -100 -1.629207E-05 0
        : 0 0 0 1
        HasMeshes: Yes   MeshIndexs  0


 ========= Mesh Bone Data (The offsets are this >>>> bone space to mesh space maybe ?) =========


Mesh #0 name: Cube.001
  bones: 2
   Name: rootBone
     OffsetMatrix:
     : 0.1666667 0 0 0
     : 0 -2.715345E-08 0.1666667 1
     : 0 -0.1666667 -2.715345E-08 0
     : 0 0 0 1
   Name: topBone
     OffsetMatrix:
     : 0.1666667 0 0 0
     : 0 -2.715345E-08 0.1666667 0
     : 0 -0.1666667 -2.715345E-08 0
     : 0 0 0 1

Whats really confusing me is that there is nothing in the translational component for any of these bones.
But then that just might be because of how i modeled this or how blender exported my model.

Well any hints even are appreciated.

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 6821

Trending Articles