So this question may be a little advanced and hard to explain, but I’ll do the best I can. Keep in mind that I’m using a modified version of com.jmex.model.ogrexml.anim.Bone.java as seen here: http://www.jmonkeyengine.com/forum/index.php?topic=12969
So I have an animated ogrexml soldier character for my FPS style game. My setup is the camera is a CameraNode attached to the head bone of the model, and both the head bone as well as the two shoulder bones are controlled by the mouse using: bone.setUserTransforms()
The character is in a gun holding pose, and my problem is my rotation code to rotate the bones up and down with the mouse/camera sorta matches up. The problem looks to be that the arms cross or spread out horizontally on the screen. The issue I think is the shoulder bones, unlike the neck, aren’t aligned to the x-axis of the entire model and are only rotated by their local x-axis. I hope this makes some sense. Anyways, the code that I using to get around this isn’t working, I believe my math is incorrect since I’m rather new to Quaternions. Much like KeyLookDownAction or KeyLookUpAction, my mouse input action has a performAction() method. It goes like this:
public void performAction(final InputActionEvent p_event) {
angle += speed * p_event.getTime();
angle = FastMath.clamp(angle, (-FastMath.DEG_TO_RAD * 45) + 0.01F, (FastMath.DEG_TO_RAD * 45) - 0.01F);
tempLeftShoulderRot.fromAngleAxis(angle, leftShoulder.getWorldRot().inverseLocal().getRotationColumn(0));
leftShoulder.setUserTransforms(Vector3f.ZERO, tempLeftShoulderRot, Vector3f.UNIT_XYZ);
tempRightShoulderRot.fromAngleAxis(angle, rightShoulder.getWorldRot().inverseLocal().getRotationColumn(0));
rightShoulder.setUserTransforms(Vector3f.ZERO, tempRightShoulderRot, Vector3f.UNIT_XYZ);
tempNeckRot.fromAngleAxis(angle, Vector3f.UNIT_X);
neck.setUserTransforms(Vector3f.ZERO, tempNeckRot, Vector3f.UNIT_XYZ);
}
Just to explain the types here are the "declarations":
private Quaternion
tempNeckRot = new Quaternion(),
tempLeftShoulderRot = new Quaternion(),
tempRightShoulderRot = new Quaternion();
private final Bone leftShoulder, rightShoulder, neck;
private float speed;
private float angle = 0.0F;
I believe this is what I need to convert from a specific shoulder bone space to overall model/node space, except it gives me the results of the arms crossing as I described earlier. You also may have to look at the Bone.java file to see what the user transform is actually getting multiplied by (esp. the modified version of Bone.java I linked to above). So what do you think? Basically, I don't want my arms on screen to move horizontally, but only vertically as like most FPS. Don't hesitate to ask me to specify something if I haven't explained it throughly enough.
Thanks a million in advance,
SomethingNew :D