I have a problem with my rotation on my 3D object (it's in java, but that doesn't really matter)
Background:
I have a simple 3d model, and you are the first player on it, you move the mouse up to look up (IE turn the 3D x-axis) and move the mouse down to look down (turn the direction in the opposite direction)
But:
I also have left and right arrow keys to rotate left / right (which rotates the three-dimensional y axis)
Now the problem is that when I rotate, when I rotate along the x axis, it ceases to be as expected, i.e. if you rotate 180 degrees by moving the mouse down, you really look up, and if you move the mouse up you really look down.
What rotation can be performed on the x / y axis to fix this?
- No matter how much / little I turned, moving the mouse up will look up and moving the mouse down will look down.
Sorry, I can’t explain it better, but if you need more information, just make a comment.
Thank,
This is a simple conversion, but I can’t think: (
Some of the Java rotation codes:
Mouse up / down:
public void rotateXY(double radians, double Yradians)
{
vpTrans.getTransform(T3D);
Transform3D test = new Transform3D();
Transform3D testX = new Transform3D();
Transform3D testY = new Transform3D();
translate.set(lastXcord, lastYcord, lastZcord);
testX.rotX(radians);
testY.rotY(Yradians);
test.mul(testX, testY);
test.setTranslation(translate);
vpTrans.setTransform(test);
}
Left: (on the right it looks like, but with a minus instead of a plus when changing the angle)
public void run() {
Transform3D test = new Transform3D();
Transform3D rotX = new Transform3D();
Transform3D rotY = new Transform3D();
vpTrans.getTransform(T3D);
translate.set(lastXcord, lastYcord, lastZcord);
angle += 0.05;
trueangle += 0.05;
rotX.rotX(angle);
rotY.rotY(Yangle);
test.mul(rotX, rotY);
test.setTranslation(translate);
vpTrans.setTransform(test);
}
What transformations / rotations do I need to add, so that regardless of the y axis, the camera will search when the mouse moves up and down, when the mouse moves down?