Class JavaApplication3D

  • All Implemented Interfaces:
    java.awt.event.KeyListener, java.awt.event.MouseListener, java.awt.event.MouseMotionListener, java.awt.event.MouseWheelListener, java.io.Serializable, java.util.EventListener

    public abstract class JavaApplication3D
    extends JavaApplication
    implements java.awt.event.KeyListener, java.awt.event.MouseListener, java.awt.event.MouseMotionListener, java.awt.event.MouseWheelListener, java.io.Serializable
    See Also:
    Serialized Form
    • Field Detail

      • m_spkCamera

        protected Camera m_spkCamera
        Camera object.
      • m_akWorldAxis

        protected Vector3f[] m_akWorldAxis
        camera motion parameters
      • m_fTrnSpeed

        protected float m_fTrnSpeed
        Translation speed
      • m_fRotSpeed

        protected float m_fRotSpeed
        Rotation speed
      • m_fZoomSpeed

        protected float m_fZoomSpeed
        Zoom speed
      • m_bLInsertPressed

        protected boolean m_bLInsertPressed
        flag indicating the insert key was pressed.
      • m_bRDeletePressed

        protected boolean m_bRDeletePressed
        flag indicating the delete key was pressed.
      • m_fTrnSpeedFactor

        protected float m_fTrnSpeedFactor
        Increase/Decrease translation speed factor
      • m_fRotSpeedFactor

        protected float m_fRotSpeedFactor
        Increase/Decrease rotation speed factor
      • m_bUArrowPressed

        protected boolean m_bUArrowPressed
        flag indicating the up arrow was pressed
      • m_bDArrowPressed

        protected boolean m_bDArrowPressed
        flag indicating the down arrow was pressed
      • m_bLArrowPressed

        protected boolean m_bLArrowPressed
        flag indicating the left arrow was pressed
      • m_bRArrowPressed

        protected boolean m_bRArrowPressed
        flag indicating the right arrow was pressed
      • m_bPgUpPressed

        protected boolean m_bPgUpPressed
        flag indicating page up was pressed
      • m_bPgDnPressed

        protected boolean m_bPgDnPressed
        flag indicating page down was pressed
      • m_bHomePressed

        protected boolean m_bHomePressed
        flag indicating the home key was pressed
      • m_bEndPressed

        protected boolean m_bEndPressed
        flag indicating the end key was pressed
      • m_bCameraMoveable

        protected boolean m_bCameraMoveable
        flag indicating the camera is movable
      • m_iMouseButton

        protected int m_iMouseButton
        The last button on the mouse to be pressed/released
      • zCameraMove

        protected float zCameraMove
        Move the camera forward or backward.
      • yCameraMove

        protected float yCameraMove
        Move the camera up or down.
      • xCameraMove

        protected float xCameraMove
        Move the camera right or left.
      • xCameraTurn

        protected float xCameraTurn
        Turn the camera left or right.
      • yCameraTurn

        protected float yCameraTurn
        Turn the camera to up or down.
      • cameraParams

        protected float[] cameraParams
        Camera parameters.
      • m_spkMotionObject

        protected Spatial m_spkMotionObject
        Object rotation node:
      • m_iDoRoll

        protected int m_iDoRoll
        Roll, yaw, pitch:
      • m_iDoYaw

        protected int m_iDoYaw
        Roll, yaw, pitch:
      • m_iDoPitch

        protected int m_iDoPitch
        Roll, yaw, pitch:
      • rollRotationAngle

        protected float rollRotationAngle
        Roll, yaw, pitch rotation angle
      • yawRotationAngle

        protected float yawRotationAngle
        Roll, yaw, pitch rotation angle
      • pitchRotationAngle

        protected float pitchRotationAngle
        Roll, yaw, pitch rotation angle
      • objectParams

        private float[] objectParams
        Object rotation parameters.
      • m_fXTrack0

        protected float m_fXTrack0
        Trackball start and end xy pixel coordinates:
      • m_fYTrack0

        protected float m_fYTrack0
        Trackball start and end xy pixel coordinates:
      • m_fXTrack1

        protected float m_fXTrack1
        Trackball start and end xy pixel coordinates:
      • m_fYTrack1

        protected float m_fYTrack1
        Trackball start and end xy pixel coordinates:
      • m_fXDrag0

        protected float m_fXDrag0
        Drag xy pixel coordinates:
      • m_fYDrag0

        protected float m_fYDrag0
        Drag xy pixel coordinates:
      • m_kSaveRotate

        protected Matrix3f m_kSaveRotate
        Current rotation, saved during trackball rotate:
      • m_bUseTrackBall

        protected boolean m_bUseTrackBall
        Trackball rotation flags:
      • m_bTrackBallDown

        protected boolean m_bTrackBallDown
        Trackball rotation flags:
      • m_bObjectZoomed

        protected boolean m_bObjectZoomed
        Trackball rotation flags:
      • m_dLastTime

        protected double m_dLastTime
        Frame-rate Performance parameters:
      • m_dAccumulatedTime

        protected double m_dAccumulatedTime
        Frame-rate Performance parameters:
      • m_dFrameRate

        protected double m_dFrameRate
        Frame-rate Performance parameters:
      • m_iFrameCount

        protected int m_iFrameCount
        Frame-rate Performance parameters:
      • m_iAccumulatedFrameCount

        protected int m_iAccumulatedFrameCount
        Frame-rate Performance parameters:
      • m_iTimer

        protected int m_iTimer
        Frame-rate Performance parameters:
      • m_iMaxTimer

        protected int m_iMaxTimer
        Frame-rate Performance parameters:
      • m_mouseRotSpeed

        protected float m_mouseRotSpeed
        mouse control rotation speed
    • Constructor Detail

      • JavaApplication3D

        public JavaApplication3D​(java.lang.String acWindowTitle,
                                 int iXPosition,
                                 int iYPosition,
                                 int iWidth,
                                 int iHeight,
                                 ColorRGBA rkBackgroundColor)
        Creates a new JavaApplication3.
        Parameters:
        acWindowTitle - the window title
        iXPosition - window screen x-position
        iYPosition - window screen y-position
        iWidth - window width
        iHeight - window height
        rkBackgroundColor - background color
    • Method Detail

      • getCameraLocation

        public Vector3f getCameraLocation()
        Get the camera current location
        Returns:
        camera position vector
      • getCameraParameters

        public float[] getCameraParameters()
        Get the camera parameters for move and turn.
        Returns:
        camera parameter array
      • getObjectParameters

        public float[] getObjectParameters()
        Get the object rotation parameters ( roll, pitch, yaw )
        Returns:
        Object rotation parameters array
      • getObjectRotation

        public Matrix3f getObjectRotation()
        Get the object rotation matrix.
        Returns:
        rotation matrix
      • keyPressed

        public void keyPressed​(java.awt.event.KeyEvent kKey)
        keyPressed callback.
        Specified by:
        keyPressed in interface java.awt.event.KeyListener
        Overrides:
        keyPressed in class JavaApplication
        Parameters:
        kKey - the KeyEvent triggering the callback.
      • keyReleased

        public void keyReleased​(java.awt.event.KeyEvent kKey)
        keyReleased callback.
        Specified by:
        keyReleased in interface java.awt.event.KeyListener
        Overrides:
        keyReleased in class JavaApplication
        Parameters:
        kKey - the KeyEvent triggering the callback.
      • keyTyped

        public void keyTyped​(java.awt.event.KeyEvent e)
        Specified by:
        keyTyped in interface java.awt.event.KeyListener
        Overrides:
        keyTyped in class JavaApplication
      • mouseClicked

        public void mouseClicked​(java.awt.event.MouseEvent e)
        User input: stub
        Specified by:
        mouseClicked in interface java.awt.event.MouseListener
        Parameters:
        e - the MouseEvent
      • mouseDragged

        public void mouseDragged​(java.awt.event.MouseEvent e)
        Rotates the object with a virtual trackball:
        Specified by:
        mouseDragged in interface java.awt.event.MouseMotionListener
        Parameters:
        e - the MouseEvent
      • mouseEntered

        public void mouseEntered​(java.awt.event.MouseEvent e)
        User input: stub
        Specified by:
        mouseEntered in interface java.awt.event.MouseListener
        Parameters:
        e - the MouseEvent
      • mouseExited

        public void mouseExited​(java.awt.event.MouseEvent e)
        User input: stub
        Specified by:
        mouseExited in interface java.awt.event.MouseListener
        Parameters:
        e - the MouseEvent
      • mouseMoved

        public void mouseMoved​(java.awt.event.MouseEvent e)
        User input: stub
        Specified by:
        mouseMoved in interface java.awt.event.MouseMotionListener
        Parameters:
        e - the MouseEvent
      • mousePressed

        public void mousePressed​(java.awt.event.MouseEvent e)
        Initializes trackball rotation:
        Specified by:
        mousePressed in interface java.awt.event.MouseListener
        Parameters:
        e - the MouseEvent
      • mouseReleased

        public void mouseReleased​(java.awt.event.MouseEvent e)
        Ends trackball rotation:
        Specified by:
        mouseReleased in interface java.awt.event.MouseListener
        Parameters:
        e - the MouseEvent
      • mouseWheelMoved

        public void mouseWheelMoved​(java.awt.event.MouseWheelEvent e)
        Specified by:
        mouseWheelMoved in interface java.awt.event.MouseWheelListener
      • OnDisplay

        public void OnDisplay()
        OnDisplay callback, called when the application window is displayed.
        Overrides:
        OnDisplay in class JavaApplication
      • OnInitialize

        public boolean OnInitialize()
        OnInitialize callback, called when the application is created.
        Overrides:
        OnInitialize in class JavaApplication
        Returns:
        true
      • OnTerminate

        public void OnTerminate()
        OnTerminate callback, called when the application terminates.
        Overrides:
        OnTerminate in class JavaApplication
      • setCameraLocation

        public void setCameraLocation​(Vector3f v)
        Set the camera location.
        Parameters:
        v - camera position vector
      • setCameraParameters

        public void setCameraParameters​(float[] newCameraParams)
        Get the camera parameters for move and turn.
      • setObjectRotation

        public void setObjectRotation​(Matrix3f rot)
        Set the object rotation matrix
        Parameters:
        rot - rotation matrix
      • setObjectParameters

        public void setObjectParameters​(float[] newObjectParams)
        Get the object rotation parameters ( roll, pitch, yaw )
      • DrawFrameRate

        protected void DrawFrameRate​(int iX,
                                     int iY,
                                     ColorRGBA rkColor)
        Performance measurement: Draws the frame rate on screen
        Parameters:
        iX - the x-position for drawing the frame rate
        iY - the y-position for drawing the frame rate
        rkColor - the text color
      • UpdateCameraTranslationSpeed

        protected void UpdateCameraTranslationSpeed​(float fTrnSpeed)
        update camera translation speed
        Parameters:
        fTrnSpeed - camera translation speed
      • UpdateCameraRotationSpeed

        protected void UpdateCameraRotationSpeed​(float fRotSpeed)
        update camera rotation speed
        Parameters:
        fRotSpeed - camera rotation speed
      • UpdateCameraZoomSpeed

        protected void UpdateCameraZoomSpeed​(float fZoomSpeed)
        update camera zoom speed
        Parameters:
        fRotSpeed - camera zoom speed
      • UpdateMouseRotationSpeed

        protected void UpdateMouseRotationSpeed​(float fRotSpeed)
        update camera rotation speed
        Parameters:
        fRotSpeed - mouse rotation speed
      • InitializeCameraMotion

        protected void InitializeCameraMotion​(float fTrnSpeed,
                                              float fRotSpeed)
        Initialize Camera Motion
        Parameters:
        fTrnSpeed - camera translation speed
        fRotSpeed - camera rotation speed
      • InitializeCameraMotion

        protected void InitializeCameraMotion​(float fTrnSpeed,
                                              float fRotSpeed,
                                              float fTrnSpeedFactor,
                                              float fRotSpeedFactor)
        Initialize Camera Motion
        Parameters:
        fTrnSpeed - camera translation speed
        fRotSpeed - camera rotation speed
        fTrnSpeedFactor - camera translation speed factor
        fRotSpeedFactor - camera rotation speed factor
      • InitializeObjectMotion

        protected void InitializeObjectMotion​(Spatial pkMotionObject)
        Initializes Object Motion
      • LookDown

        protected void LookDown()
        Causes the camera to look down.
      • LookUp

        protected void LookUp()
        Causes the camera to look up.
      • MeasureTime

        protected void MeasureTime()
        Performance measurement: Measure time
      • MoveBackward

        protected void MoveBackward()
        Moves the camera backward.
      • MoveCamera

        protected boolean MoveCamera()
        Camera Motion
        Returns:
        true when the camera has moved, false if the camera has not moved
      • MoveDown

        protected void MoveDown()
        Moves the camera down.
      • MoveForward

        protected void MoveForward()
        Moves the camera forward.
      • MoveLeft

        protected void MoveLeft()
        Moves the camera left.
      • MoveObject

        protected boolean MoveObject()
        Moves object.
        Returns:
        true when the object has moved, false otherwise.
      • MoveRight

        protected void MoveRight()
        Moves the camera right.
      • MoveUp

        protected void MoveUp()
        Moves the camera up.
      • ResetTime

        protected void ResetTime()
        Performance measurement: Resets time
      • RotateTrackBall

        protected void RotateTrackBall​(float fX0,
                                       float fY0,
                                       float fX1,
                                       float fY1)
        Rotate the the object with a virtual trackball
        Parameters:
        fX0 - start mouse x-position
        fY0 - start mouse y-position
        fX1 - end mouse x-position
        fY1 - end mouse y-position
      • TurnLeft

        protected void TurnLeft()
        Turns the camera left.
      • TurnRight

        protected void TurnRight()
        Turns the camera right.
      • UpdateFrameCount

        protected void UpdateFrameCount()
        Performance measurement: Update frame count