Class CameraManager

java.lang.Object
gaiasky.scene.camera.CameraManager
All Implemented Interfaces:
IObserver, ICamera

public class CameraManager extends Object implements ICamera, IObserver
  • Field Details

  • Constructor Details

  • Method Details

    • getFrustumCornersEye

      public static void getFrustumCornersEye(com.badlogic.gdx.graphics.PerspectiveCamera cam, com.badlogic.gdx.math.Matrix4 frustumCorners)
      Stores the normalized rays representing the camera frustum in eye space in a 4x4 matrix. Each row is a vector.
      Parameters:
      cam - The perspective camera
      frustumCorners - The matrix to fill
    • updateCurrentCamera

      public void updateCurrentCamera()
    • isNatural

      public boolean isNatural()
    • getCamera

      public com.badlogic.gdx.graphics.PerspectiveCamera getCamera()
      Description copied from interface: ICamera
      Returns the perspective camera.
      Specified by:
      getCamera in interface ICamera
      Returns:
      The perspective camera.
    • setCamera

      public void setCamera(com.badlogic.gdx.graphics.PerspectiveCamera perspectiveCamera)
      Description copied from interface: ICamera
      Sets the active camera
      Specified by:
      setCamera in interface ICamera
      Parameters:
      perspectiveCamera - The perspective camera.
    • getFovFactor

      public float getFovFactor()
      Specified by:
      getFovFactor in interface ICamera
    • getPos

      public Vector3b getPos()
      Specified by:
      getPos in interface ICamera
    • setPos

      public void setPos(Vector3d pos)
      Specified by:
      setPos in interface ICamera
    • setPos

      public void setPos(Vector3b pos)
      Specified by:
      setPos in interface ICamera
    • getPreviousPos

      public Vector3b getPreviousPos()
      Specified by:
      getPreviousPos in interface ICamera
    • setPreviousPos

      public void setPreviousPos(Vector3d prevpos)
      Specified by:
      setPreviousPos in interface ICamera
    • setPreviousPos

      public void setPreviousPos(Vector3b prevpos)
      Specified by:
      setPreviousPos in interface ICamera
    • getInversePos

      public Vector3b getInversePos()
      Specified by:
      getInversePos in interface ICamera
    • getVelocity

      public Vector3d getVelocity()
      Specified by:
      getVelocity in interface ICamera
    • getDirection

      public Vector3d getDirection()
      Specified by:
      getDirection in interface ICamera
    • setDirection

      public void setDirection(Vector3d dir)
      Specified by:
      setDirection in interface ICamera
    • getUp

      public Vector3d getUp()
      Specified by:
      getUp in interface ICamera
    • swapBuffers

      public void swapBuffers()
      Specified by:
      swapBuffers in interface ICamera
    • setGamepadInput

      public void setGamepadInput(boolean state)
      Description copied from interface: ICamera
      Main input mode is a gamepad.
      Specified by:
      setGamepadInput in interface ICamera
    • backupCamera

      public void backupCamera()
    • restoreCamera

      public void restoreCamera()
    • update

      public void update(double dt, ITimeFrameProvider time)
      Update method.
      Specified by:
      update in interface ICamera
      Parameters:
      dt - Delta time in seconds.
      time - The time frame provider.
    • updateMode

      public void updateMode(ICamera previousCam, CameraManager.CameraMode previousMode, CameraManager.CameraMode newMode, boolean centerFocus, boolean postEvent)
      Runs on each camera after a mode change.
      Specified by:
      updateMode in interface ICamera
    • notify

      public void notify(Event event, Object source, Object... data)
      Description copied from interface: IObserver
      Event notification call.
      Specified by:
      notify in interface IObserver
      Parameters:
      event - The event type.
      source - The source object, if any.
      data - The data associated with this event.
    • getDirections

      public Vector3d[] getDirections()
      Specified by:
      getDirections in interface ICamera
    • getNCameras

      public int getNCameras()
      Specified by:
      getNCameras in interface ICamera
    • getFrontCameras

      public com.badlogic.gdx.graphics.PerspectiveCamera[] getFrontCameras()
      Specified by:
      getFrontCameras in interface ICamera
    • getMode

      public CameraManager.CameraMode getMode()
      Specified by:
      getMode in interface ICamera
    • updateAngleEdge

      public void updateAngleEdge(int width, int height)
      Specified by:
      updateAngleEdge in interface ICamera
    • getAngleEdge

      public float getAngleEdge()
      Description copied from interface: ICamera
      Gets the angle of the edge of the screen, diagonally. It assumes the vertical angle is the field of view and corrects the horizontal using the aspect ratio. It depends on the viewport size and the field of view itself.
      Specified by:
      getAngleEdge in interface ICamera
      Returns:
      The angle in radians.
    • getManager

      public CameraManager getManager()
      Specified by:
      getManager in interface ICamera
    • render

      public void render(int rw, int rh)
      Specified by:
      render in interface ICamera
    • getCurrent

      public ICamera getCurrent()
      Specified by:
      getCurrent in interface ICamera
    • getSpeed

      public double getSpeed()
      Description copied from interface: ICamera
      Gets the current velocity of the camera in km/h.
      Specified by:
      getSpeed in interface ICamera
      Returns:
      The velocity in km/h.
    • isFocus

      public boolean isFocus(com.badlogic.ashley.core.Entity cb)
      Description copied from interface: ICamera
      Checks if the given entity is the current focus.
      Specified by:
      isFocus in interface ICamera
      Parameters:
      cb - The entity.
      Returns:
      Whether the entity is focus.
    • checkClosestBody

      public void checkClosestBody(IFocus focus)
      Description copied from interface: ICamera
      Called after updating the body's distance to the cam, it updates the closest body in the camera to figure out the camera near
      Specified by:
      checkClosestBody in interface ICamera
      Parameters:
      focus - The body to check
    • checkClosestBody

      public void checkClosestBody(com.badlogic.ashley.core.Entity entity)
      Description copied from interface: ICamera
      Called after updating the body's distance to the cam, it updates the closest body in the camera to figure out the camera near
      Specified by:
      checkClosestBody in interface ICamera
      Parameters:
      entity - The body to check.
    • getFocus

      public IFocus getFocus()
      Description copied from interface: ICamera
      Returns the focus if any.
      Specified by:
      getFocus in interface ICamera
      Returns:
      The focus object if it is in focus mode. Null otherwise.
    • hasFocus

      public boolean hasFocus()
      Description copied from interface: ICamera
      Checks whether the current camera has a focus set.
      Specified by:
      hasFocus in interface ICamera
      Returns:
      True if the camera has a focus.
    • isVisible

      public boolean isVisible(com.badlogic.ashley.core.Entity cb)
      Specified by:
      isVisible in interface ICamera
    • isVisible

      public boolean isVisible(double viewAngle, Vector3d pos, double distToCamera)
      Specified by:
      isVisible in interface ICamera
    • getDistance

      public double getDistance()
      Description copied from interface: ICamera
      Gets the distance from the camera to the centre of our reference frame (Sun)
      Specified by:
      getDistance in interface ICamera
      Returns:
      The distance
    • getCameraStereoLeft

      public com.badlogic.gdx.graphics.PerspectiveCamera getCameraStereoLeft()
      Specified by:
      getCameraStereoLeft in interface ICamera
    • setCameraStereoLeft

      public void setCameraStereoLeft(com.badlogic.gdx.graphics.PerspectiveCamera cam)
      Specified by:
      setCameraStereoLeft in interface ICamera
    • getCameraStereoRight

      public com.badlogic.gdx.graphics.PerspectiveCamera getCameraStereoRight()
      Specified by:
      getCameraStereoRight in interface ICamera
    • setCameraStereoRight

      public void setCameraStereoRight(com.badlogic.gdx.graphics.PerspectiveCamera cam)
      Specified by:
      setCameraStereoRight in interface ICamera
    • getClosestBody

      public IFocus getClosestBody()
      Specified by:
      getClosestBody in interface ICamera
    • getSecondClosestBody

      public IFocus getSecondClosestBody()
      Specified by:
      getSecondClosestBody in interface ICamera
    • getCloseLightSource

      public IFocus getCloseLightSource(int i)
      Description copied from interface: ICamera
      Gets the current i-close light source to this camera
      Specified by:
      getCloseLightSource in interface ICamera
      Returns:
      The i close light source (star?)
    • resize

      public void resize(int width, int height)
      Specified by:
      resize in interface ICamera
    • getShift

      public Vector3d getShift()
      Specified by:
      getShift in interface ICamera
    • setShift

      public void setShift(Vector3d shift)
      Specified by:
      setShift in interface ICamera
    • getProjView

      public com.badlogic.gdx.math.Matrix4 getProjView()
      Specified by:
      getProjView in interface ICamera
    • getPreviousProjView

      public com.badlogic.gdx.math.Matrix4 getPreviousProjView()
      Specified by:
      getPreviousProjView in interface ICamera
    • setPreviousProjView

      public void setPreviousProjView(com.badlogic.gdx.math.Matrix4 mat)
      Specified by:
      setPreviousProjView in interface ICamera
    • getClosestParticle

      public IFocus getClosestParticle()
      Description copied from interface: ICamera
      Gets the current closest particle to this camera
      Specified by:
      getClosestParticle in interface ICamera
      Returns:
      The closest particle
    • checkClosestParticle

      public void checkClosestParticle(IFocus particle)
      Description copied from interface: ICamera
      Sets the current closest particle to this camera. This will be only set if the given particle is closer than the current.
      Specified by:
      checkClosestParticle in interface ICamera
      Parameters:
      particle - The candidate particle
    • getClosest

      public IFocus getClosest()
      Description copied from interface: ICamera
      Returns the current closest object
      Specified by:
      getClosest in interface ICamera
    • setClosest

      public void setClosest(IFocus focus)
      Description copied from interface: ICamera
      Sets the closest of all
      Specified by:
      setClosest in interface ICamera
      Parameters:
      focus - The new closest object
    • speedScaling

      public double speedScaling()
      Specified by:
      speedScaling in interface ICamera
    • updateFrustumPlanes

      public void updateFrustumPlanes()
      Specified by:
      updateFrustumPlanes in interface ICamera
    • getNear

      public double getNear()
      Specified by:
      getNear in interface ICamera
    • getFar

      public double getFar()
      Specified by:
      getFar in interface ICamera
    • getFrustumCornersWorld

      public com.badlogic.gdx.math.Matrix4 getFrustumCornersWorld(com.badlogic.gdx.math.Matrix4 frustumCorners)
      Stores the normalized rays representing the camera frustum in world space in a 4x4 matrix. Each row is a vector.
      Parameters:
      frustumCorners - The matrix to fill
      Returns:
      The same matrix