Home Game Development c# – How to use bindpose for vertex skinning?

c# – How to use bindpose for vertex skinning?

0
c# – How to use bindpose for vertex skinning?

[ad_1]

I’m making a mannequin/animation viewer in C# utilizing OpenTK for a recreation’s fashions. Before stating my downside I need to describe a bit what I’ve completed up to now in case I’m basically lacking one thing.

First of all I parsed the mannequin skeleton. Like described just about in every single place on the net, what I do is to traverse all of the hierarchy ranging from the foundation bone and begin increase the joint matrices. The recreation file gives individually translation,rotation and scale vectors. In order to create all of the joint matrices I’m utilizing solely the rotation values, which I’m changing right into a rotation matrix and I’m saving it because the nativeMatrix. I’m saving the translations as joint place (nativePosition) and I’m utilizing them in a while to calculate the worldPosition of my joints by remodeling that utilizing the father or mother’s worldMatrix.

The following strategies are answerable for getting the joint world Matrix and its world Position

public Vector3 worldPosition {
        get
        {
            if (father or mother != null)
                return father or mother.worldPosition + Vector3.Transform(this.nativePosition, father or mother.worldMat);
                this.worldMat);
            else
                return this.nativePosition;
        }
}
public Matrix4 worldMat
    {
        get
        {
            if (father or mother != null)
                return Matrix4.Mult(this.localMat, father or mother.worldMat);
            else
                return this.localMat;
        }
}

Using that piece of code I can preview the skeleton completely. I additionally managed to parse the animations. I used the rotation data on every body in an effort to replace every joints native matrix and due to this fact I used to be capable of efficiently preview the animation on the joint skeleton.

Now the one factor I’m lacking is to bind the mesh on the skeleton (I’m making an attempt to do this utilizing a vertex shader). Wherever I search on the net, i discover that i would like to use the next equation:

eq

I obtained the mixIndices and the blendWeights in order that’s not an issue as effectively.
I’m fully confused with the bone matrices although. If I perceive appropriately matrix[i] is the joint’s world transformation matrix. The different inverse matrix is meant to remodel my vertex again to the bindpose? Since my mannequin is already within the bindpose what do I would like this matrix for?

I attempted making use of simply the joint worldmatrices that I’ve precalculated, however the mesh was fully corrupted. So I’m undoubtedly lacking one thing.

I’ve additionally discovered some matrices within the mannequin file which seem to be they’re most likely prebaked joint world matrices. In reality I in contrast their values and they’re EXACTLY the identical with those I’m calculating by means of traversing the bone hierarchy. Their solely distinction although is that in addition they include translation data. So my query is: Do bone matrices include translation data as effectively? If so, then which means my method of parsing the skeleton is unsuitable? I simply cannot factor of one other method to make use of the complete matrices (rotation + translation) in an effort to appropriately place the joints.

[ad_2]

LEAVE A REPLY

Please enter your comment!
Please enter your name here