Free .ms3d animated loader - need help with getting joint position/rotation

Started by
-1 comments, last by CyanPrime 11 years, 9 months ago
I got a really cool gift for you! It's a simple to use animated model loader!
Here is the entire package you'll need to start your 3d animated modeled games today!
https://dl.dropbox.c...ointConnect.zip

Here is how to use it:
[source lang="java"]AnimatedModel model = new AnimatedModel([filename], [scale vector]); [/source]

Where [filename] is something like "C:\models\model.ms3d" and [scale vector] is a LWJGL Vector3f that re-sizes the model based on it's content.
For example to make a half width double height model you'd say[background=white] [/background]
[source lang="java"][background=white]new Vector3f(0.5f, 2.0f, 1.0f)[/background][/source][background=white]
[/background]
So that's that, and now you may all be wondering why I'm posting this in a help section? Well, you see. It's because I need a bit of help on a thing I'm trying to implement, where you can attach other models to joints of a master model (like master warrior is holding a sword in his left hand) what it boils down to is that I can't figure out how to get the accessory model to stay , or even get to the right place.

This is the code the accessory model uses to get it's position and rotation. It's in AnimatedModel.java
[source lang="java"]

[background=white]public Vector3f[] getJointInfo(float frame, int jointID, float myYaw){
Vector3f[] jointInfo = new Vector3f[2];
jointInfo[0] = new Vector3f(0,0,0);
jointInfo[1] = new Vector3f(0,0,0);

advanceAnimation(frame, true);

Matrix4f worldMatrix = new Matrix4f();
worldMatrix.load(fjm[jointID]);
worldMatrix.invert();

worldMatrix.rotate((float) Math.toRadians(myYaw), new Vector3f(0,1,0));
VectorRotate(joints.get(jointID).pos, worldMatrix, jointInfo[0]);
/*roll*/jointInfo[1].z = (float) Math.toDegrees(Math.atan2(worldMatrix.m10, worldMatrix.m00));
/*pitch*/jointInfo[1].x = (float) - Math.toDegrees(Math.asin(worldMatrix.m20));
/*yaw*/jointInfo[1].y = (float) Math.toDegrees(Math.atan2(worldMatrix.m01, worldMatrix.m22));
return jointInfo;
} [/background]

[/source][background=white]
[/background]So, if anyone wants to download the .ms3d model loader package and take a look at that method and help me figure out why it's not working it'd help out not only me, but everyone who decides to use this model loader.

This topic is closed to new replies.

Advertisement