Class Simple1DOFCamera


  • public class Simple1DOFCamera
    extends java.lang.Object
    Class for a simple camera. Restricted: always looks at 0,0,0 from a position defined by rotationX, distance and height.

    For rotationX = 0, the camera will be at y=distance, x=0, so that the default view will have the usual X/Y plane on the ground.

    Since:
    0.6.0
    Author:
    Erich Schubert
    • Field Detail

      • rotationZ

        private double rotationZ
        Rotation on X axis.
      • distance

        private double distance
        Distance
      • height

        private double height
        Height
      • ratio

        private double ratio
        Screen ratio
      • viewp

        private int[] viewp
        GLU viewport storage
      • modelview

        private double[] modelview
        GLU model view matrix
      • projection

        private double[] projection
        GLU projection matrix
      • glu

        private javax.media.opengl.glu.GLU glu
        GLU utility
      • cosZ

        private double cosZ
        Cache the Z rotation cosine
      • sinZ

        private double sinZ
        Cache the Z rotation sine
    • Constructor Detail

      • Simple1DOFCamera

        public Simple1DOFCamera​(javax.media.opengl.glu.GLU glu)
        Constructor.
        Parameters:
        glu - GLU utility class
      • Simple1DOFCamera

        public Simple1DOFCamera​(Simple1DOFCamera other)
        Copy constructor, for freezing a camera position. Note: listeners will not be copied.
        Parameters:
        other - Existing camera
    • Method Detail

      • getDistance

        public double getDistance()
        Get the distance
        Returns:
        Distance
      • setDistance

        public void setDistance​(double distance)
        Set camera distance
        Parameters:
        distance - Distance
      • getHeight

        public double getHeight()
        Get camera height
        Returns:
        Camera height
      • setHeight

        public void setHeight​(double height)
        Set camera height
        Parameters:
        height - Camera height
      • getRatio

        public double getRatio()
        Get screen ratio.
        Returns:
        Screen ratio
      • setRatio

        public void setRatio​(double ratio)
        Set screen ratio.
        Parameters:
        ratio - Screen ratio
      • getRotationZ

        public double getRotationZ()
        Get the Z rotation in radians.
        Returns:
        Z rotation angle (radians)
      • setRotationZ

        public void setRotationZ​(double rotationZ)
        Set the z rotation angle in radians.
        Parameters:
        rotationZ - Z rotation angle.
      • apply

        public void apply​(javax.media.opengl.GL2 gl)
        Apply the camera to a GL context.
        Parameters:
        gl - GL context.
      • unproject

        public double[] unproject​(double x,
                                  double y,
                                  double z)
        Unproject a screen coordinate (at depth 0) to 3D model coordinates.
        Parameters:
        x - X
        y - Y
        z - Z
        Returns:
        model coordinates
      • unproject

        public void unproject​(double x,
                              double y,
                              double z,
                              double[] out)
        Unproject a screen coordinate (at depth 0) to 3D model coordinates.
        Parameters:
        x - X
        y - Y
        z - Z
        out - output buffer
      • project

        public void project​(double x,
                            double y,
                            double z,
                            double[] out)
        Project a coordinate
        Parameters:
        x - X
        y - Y
        z - Z
        out - output buffer
      • squaredDistanceFromCamera

        public double squaredDistanceFromCamera​(double x,
                                                double y)
        Distance from camera
        Parameters:
        x - X position
        y - Y position
        Returns:
        Squared distance
      • squaredDistanceFromCamera

        public double squaredDistanceFromCamera​(double x,
                                                double y,
                                                double z)
        Distance from camera
        Parameters:
        x - X position
        y - Y position
        z - Z position
        Returns:
        Squared distance
      • fireCameraChangedEvent

        protected void fireCameraChangedEvent()
        Fire the camera changed event.