Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public int ID;
- public int Parent;
- public Quaternion Direction;
- public Vector3 Translation;
- //seems to work
- public Bone(int id, int parent, Quaternion direction, Vector3 translation)
- {
- ID = id;
- Parent = parent;
- Direction = direction;
- Translation = translation;
- }
- //not so much
- public Bone(Bone[] bones, int id, int parent, Vector3 dest)
- {
- ID = id;
- Parent = parent;
- Vector3 bonepos = dest;
- Vector3 parentbonepos = bones[parent].GetBindTranslation(bones);
- //(length)
- Translation = new Vector3(0,0, (bonepos - parentbonepos).Length());
- Vector3 notneeded;
- Vector3 alsonotneeded;
- Matrix.CreateLookAt(bonepos,parentbonepos, Vector3.Up).Decompose(out notneeded, out Direction, out alsonotneeded);
- }
- public Matrix GetBindPose(Bone[] bones)
- {
- if(Parent == -1)
- return Matrix.CreateTranslation(Translation)*Matrix.CreateFromQuaternion(Direction);
- return Matrix.CreateTranslation(Translation) * Matrix.CreateFromQuaternion(Direction) * bones[Parent].GetBindPose(bones);
- }
- public Vector3 GetBindTranslation(Bone[] bones)
- {
- return Vector3.Transform(Vector3.Zero, GetBindPose(bones));
- }
Add Comment
Please, Sign In to add comment