I’m working on a 3d game in LibGDX, got help on here with my model rotation. Worked great. But now I’m dealing with the model’s roll, and it’s not behaving as expected. It’s controlled by:
handPos.set(cam.position); handPos.add(forwardTemp.set(cam.direction).scl(2.5f)); handInst.transform.setToRotation(Vector3.Z, cam.direction); handInst.transform.getRotation(handRot, true); handAngle = handRot.getYaw(); camAngle = getCameraRotation(); float h = (camAngle-handAngle); handInst.transform.rotate(Vector3.Z, h); handInst.transform.setTranslation(handPos);
Moving it works great, and I’ve had no difficulty getting my camera roll – I’ve made a method to do that. I have a label onscreen that shows current camAngle, and current handAngle. CamAngle looks right, but the handAngle doesn’t match what I’m seeing, and so my math to keep hands stationary in the view isn’t working. I’ve tried getting the yaw or pitch instead, in case the axes are messed up, but it isn’t better.
I’m trying to keep the roll of the model in front of the camera to match the roll of the camera – so if you look around, your hands don’t spin. Any ideas on what’s wrong here?