Class Camera


  • public class Camera
    extends Object
    Represent a moveable camera in the 3d world
    Author:
    Darius Dinger
    • Constructor Summary

      Constructors 
      Constructor Description
      Camera()
      Creating new camera at (0, 0, 0) with no rotation Reclaculate all matrices
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      javax.vecmath.Matrix4f getFacingMatrix()
      Getting cameras facing matrix, where the object every time facing the camera
      javax.vecmath.Matrix4f getFacingMVPMatrix​(float x, float y, float z)
      Getting cameras current view projection matrix, where the object every time facing the camera
      float getFarPlane()
      Gets cameras far plane distance
      float getFov()
      Gets cameras field of view
      float getNearPlane()
      Gets cameras near plane distance
      float getPitch()
      Gets cameras pitch (rotation around the x axis) in degrees
      javax.vecmath.Vector3f getPosition()
      Gets cameras current position in world space as 3d vector
      javax.vecmath.Matrix4f getProjectionMatrix()  
      CameraRay getRay()  
      float getRoll()
      Gets cameras roll (rotation around the z axis) in degrees
      javax.vecmath.Matrix4f getRotX()
      Gets the current rotation matrix around the x axis
      javax.vecmath.Matrix4f getRotY()
      Gets the current rotation matrix around the y axis
      javax.vecmath.Matrix4f getRotZ()
      Gets the current rotation matrix around the z axis
      javax.vecmath.Matrix4f getViewMatrix()  
      javax.vecmath.Matrix4f getViewProjectionMatrix()
      Getting cameras current view projection matrix
      float getYaw()
      Gets cameras yaw (rotation around the y axis) in degrees
      void recalcViewMatrix()
      Recalculate view matrix from position and rotation from this camera
      void recalcViewProjectionMatrix()
      Recalculate view projection matrix from view andprojection matrix from this camera
      void setFarPlane​(float farPlane)
      Setting new camera far plane
      void setFov​(float fov)
      Setting new camera field of view
      void setNearPlane​(float nearPlane)
      Setting new camera near plane
      void setPitch​(float pitch)
      Setting new camera pitch and sets camera rotated to true if it has changed
      void setRoll​(float roll)
      Setting new camera roll and sets camera rotated to true if it has changed
      void setX​(float x)
      Setting new camera x position and sets moved to true if it has changed
      void setY​(float y)
      Setting new camera y position and sets moved to true if it has changed
      void setYaw​(float yaw)
      Setting new camera yaw and sets camera rotated to true if it has changed
      void setZ​(float z)
      Setting new camera z position and sets moved to true if it has changed
      void updateViewMatrix()
      Check if camera was moved.
    • Constructor Detail

      • Camera

        public Camera()
        Creating new camera at (0, 0, 0) with no rotation Reclaculate all matrices
    • Method Detail

      • updateViewMatrix

        public void updateViewMatrix()
        Check if camera was moved. if then and update matrices setting moved and rotated variables to false
      • recalcViewProjectionMatrix

        public final void recalcViewProjectionMatrix()
        Recalculate view projection matrix from view andprojection matrix from this camera
      • recalcViewMatrix

        public final void recalcViewMatrix()
        Recalculate view matrix from position and rotation from this camera
      • setPitch

        public void setPitch​(float pitch)
        Setting new camera pitch and sets camera rotated to true if it has changed
        Parameters:
        pitch - New camera pitch
      • setYaw

        public void setYaw​(float yaw)
        Setting new camera yaw and sets camera rotated to true if it has changed
        Parameters:
        yaw - New camera yaw
      • setRoll

        public void setRoll​(float roll)
        Setting new camera roll and sets camera rotated to true if it has changed
        Parameters:
        roll - New camera roll
      • setX

        public void setX​(float x)
        Setting new camera x position and sets moved to true if it has changed
        Parameters:
        x - New camera x position
      • setY

        public void setY​(float y)
        Setting new camera y position and sets moved to true if it has changed
        Parameters:
        y - New camera y position
      • setZ

        public void setZ​(float z)
        Setting new camera z position and sets moved to true if it has changed
        Parameters:
        z - New camera z position
      • setFarPlane

        public void setFarPlane​(float farPlane)
        Setting new camera far plane
        Parameters:
        farPlane - New camera far plane
      • setNearPlane

        public void setNearPlane​(float nearPlane)
        Setting new camera near plane
        Parameters:
        nearPlane - New camera near plane
      • setFov

        public void setFov​(float fov)
        Setting new camera field of view
        Parameters:
        fov - New camera fov
      • getProjectionMatrix

        public javax.vecmath.Matrix4f getProjectionMatrix()
      • getViewMatrix

        public javax.vecmath.Matrix4f getViewMatrix()
      • getFov

        public float getFov()
        Gets cameras field of view
        Returns:
        New cameras fov
      • getNearPlane

        public float getNearPlane()
        Gets cameras near plane distance
        Returns:
        Cameras near plane distance
      • getFarPlane

        public float getFarPlane()
        Gets cameras far plane distance
        Returns:
        Cameras far plane distance
      • getPosition

        public javax.vecmath.Vector3f getPosition()
        Gets cameras current position in world space as 3d vector
        Returns:
        Current position as 3d vector
      • getPitch

        public float getPitch()
        Gets cameras pitch (rotation around the x axis) in degrees
        Returns:
        Cameras pitch in degrees
      • getYaw

        public float getYaw()
        Gets cameras yaw (rotation around the y axis) in degrees
        Returns:
        Cameras yaw in degrees
      • getRoll

        public float getRoll()
        Gets cameras roll (rotation around the z axis) in degrees
        Returns:
        Cameras roll in degrees
      • getViewProjectionMatrix

        public javax.vecmath.Matrix4f getViewProjectionMatrix()
        Getting cameras current view projection matrix
        Returns:
        View proejction matrix of the camera
      • getFacingMVPMatrix

        public javax.vecmath.Matrix4f getFacingMVPMatrix​(float x,
                                                         float y,
                                                         float z)
        Getting cameras current view projection matrix, where the object every time facing the camera
        Parameters:
        x - X offset of the matrix
        y - Y offset of the matrix
        z - Z offset of the matrix
        Returns:
        View projection matrix of the camera
      • getRotX

        public javax.vecmath.Matrix4f getRotX()
        Gets the current rotation matrix around the x axis
        Returns:
        X axis rotation matrix
      • getRotY

        public javax.vecmath.Matrix4f getRotY()
        Gets the current rotation matrix around the y axis
        Returns:
        Y axis rotation matrix
      • getRotZ

        public javax.vecmath.Matrix4f getRotZ()
        Gets the current rotation matrix around the z axis
        Returns:
        Z axis rotation matrix
      • getFacingMatrix

        public javax.vecmath.Matrix4f getFacingMatrix()
        Getting cameras facing matrix, where the object every time facing the camera
        Returns:
        Facing matrix of the camera
      • getRay

        public CameraRay getRay()
        Returns:
        Current ray the camera is looking to