Camera with Roll Pitch and Yaw

wow the net is full cameras that support yaw and pitch… but not roll.

does anyone have a good example / tutorial or sample of a full yaw/pitch/roll camera?

thx
j.

Here’s my code for the oculus rift with Z up using GL11:


            float yaw = MyOculusRift.getOR().getYawDegrees_LH();
            float pitch = MyOculusRift.getOR().getPitchDegrees_LH();
            float roll = MyOculusRift.getOR().getRollDegrees_LH();
            GL11.glRotatef(roll, 0, 0, 1);
            float originalX = POSITION.getX();
            float originalY = POSITION.getY();
            double length =
                FastMath.hypot(BufferedMathFunctions.cos(-yaw) * BufferedMathFunctions.sin(90 - pitch),
                    BufferedMathFunctions.sin(-yaw) * BufferedMathFunctions.sin(90 - pitch));
            if (leftEye) {
                POSITION.setX((float)(originalX - BufferedMathFunctions.cos(-yaw)
                    * BufferedMathFunctions.sin(90 - pitch)
                    / length
                    * MyOculusRift.getOR().getHMDInfo().InterpupillaryDistance
                    / 2));
                POSITION.setY((float)(originalY - BufferedMathFunctions.sin(-yaw)
                    * BufferedMathFunctions.sin(90 - pitch)
                    / length
                    * MyOculusRift.getOR().getHMDInfo().InterpupillaryDistance
                    / 2));
            } else {
                POSITION.setX((float)(originalX + BufferedMathFunctions.cos(-yaw)
                    * BufferedMathFunctions.sin(90 - pitch)
                    / length
                    * MyOculusRift.getOR().getHMDInfo().InterpupillaryDistance
                    / 4));
                POSITION.setY((float)(originalY + BufferedMathFunctions.sin(-yaw)
                    * BufferedMathFunctions.sin(90 - pitch)
                    / length
                    * MyOculusRift.getOR().getHMDInfo().InterpupillaryDistance
                    / 4));
            }
            GLU.gluLookAt(POSITION.getX(), POSITION.getY(), POSITION.getZ(), POSITION.getX()
                + BufferedMathFunctions.sin(-yaw)
                * BufferedMathFunctions.sin(90 - pitch), POSITION.getY()
                - BufferedMathFunctions.cos(-yaw)
                * BufferedMathFunctions.sin(90 - pitch), POSITION.getZ() - BufferedMathFunctions.cos(90 - pitch), 0, 0, 1);

Hope it helps!

Mike

thanks for the code snippet…
I’ll review it but not sure it will work for what i need.

An FPS style camera usually moves on a plane and pitch but does not adjust for a roll.

The camera im looking to make need to be more “flight sim” in style. ie… the camera can bank and pull up and the relative direction has changed.

you can take a look at the PerspectiveCamera class in the libgdx framework