Class NaturalCamera

All Implemented Interfaces:
IObserver, ICamera

public class NaturalCamera extends AbstractCamera implements IObserver
  • Field Details

    • vrOffset

      public final Vector3d vrOffset
      VR offset.
    • accel

      public final Vector3d accel
      Acceleration and velocity.
    • vel

      public final Vector3d vel
      Acceleration and velocity.
    • posBak

      public final Vector3d posBak
      Acceleration and velocity.
    • direction

      public final Vector3d direction
    • up

      public final Vector3d up
    • facingFocus

      public boolean facingFocus
      Indicates whether the camera is facing the focus or not.
    • focus

      public FocusView focus
      The focus entity.
    • focusBak

      public FocusView focusBak
      Reference to focus, backup.
    • hudScales

      public double[] hudScales
    • hudColors

      public[] hudColors
    • hudWidth

      public float hudWidth
    • hudHeight

      public float hudHeight
  • Constructor Details

    • NaturalCamera

      public NaturalCamera(com.badlogic.gdx.assets.AssetManager assetManager, CameraManager parent, boolean vr, spriteShader, shapeShader)
  • Method Details

    • initialize

      public void initialize( spriteShader, shapeShader)
    • update

      public void update(double dt, ITimeFrameProvider time)
      Description copied from interface: ICamera
      Updates the camera.
      Specified by:
      update in interface ICamera
      dt - The time since the las frame in seconds.
      time - The frame time provider (simulation time).
    • camOrientProjection

      public void camOrientProjection(float yaw, float pitch, float roll)
      Does a pre-transformation to the camera to orient it using the given yaw, pitch and roll angles.
      yaw - The yaw angle (to the right)
      pitch - The pitch angle (up)
      roll - The roll angle (clockwise)
    • updatePerspectiveCamera

      public void updatePerspectiveCamera()
      Sets the perspective camera float values from the computed double vectors, and recalculates the camera matrices.
    • addForwardForce

      public void addForwardForce(double amount)
      Adds a forward movement by the given amount.
      amount - Positive for forward force, negative for backward force.
    • setVelocityVR

      public void setVelocityVR(Vector3d p0, Vector3d p1, double amountX, double amountY)
      Sets the velocity of the VR controller as a vector. The magnitude of this vector should not be larger than 1
      p0 - Start point of the beam
      p1 - End point of the beam
      amountX - Amount in the perpendicular direction of p0-p1
      amountY - Amount in the direction of p0-p1
    • clearVelocityVR

      public void clearVelocityVR()
      Clears the velocityVR vector
    • forward

      public void forward(double amount)
    • forward

      public void forward(double amount, double minTu)
    • strafe

      public void strafe(double amount, double minTu)
    • vertical

      public void vertical(double amount)
    • vertical

      public void vertical(double amount, double minTu)
    • addRotateMovement

      public void addRotateMovement(double deltaX, double deltaY, boolean focusLookKeyPressed, boolean acceleration)
      Adds a rotation force to the camera. DeltaX corresponds to yaw (right/left) and deltaY corresponds to pitch (up/down).
      deltaX - The yaw amount.
      deltaY - The pitch amount.
      focusLookKeyPressed - The key to look around when on focus mode is pressed.
    • addAmount

      public void addAmount(Vector3d vec, double amount, boolean x)
    • addYaw

      public void addYaw(double amount, boolean acceleration)
      Adds the given amount to the camera yaw acceleration
    • setYaw

      public void setYaw(double amount)
    • addPitch

      public void addPitch(double amount, boolean acceleration)
      Adds the given amount to the camera pitch acceleration
    • setPitch

      public void setPitch(double amount)
    • addRoll

      public void addRoll(double amount, boolean acceleration)
      Adds the given amount to the camera roll acceleration
    • setRoll

      public void setRoll(double amount)
    • addHorizontal

      public void addHorizontal(double amount, boolean acceleration)
      Adds the given amount to camera horizontal rotation around the focus acceleration, or pan in free mode
    • setHorizontal

      public void setHorizontal(double amount)
    • addVertical

      public void addVertical(double amount, boolean acceleration)
      Adds the given amount to camera vertical rotation around the focus acceleration, or pan in free mode
    • setVertical

      public void setVertical(double amount)
    • stopMovement

      public boolean stopMovement()
      Stops the camera movement.
      True if the camera had any movement at all and it has been stopped. False if camera was already still.
    • stopTotalMovement

      public void stopTotalMovement()
      Stops the camera movement.
    • stopRotateMovement

      public void stopRotateMovement()
    • stopForwardMovement

      public void stopForwardMovement()
      Stops the camera movement.
    • updatePosition

      protected void updatePosition(double dt, double multiplier, double speedScaling)
      Updates the position of this entity using the current force
    • updateMode

      public void updateMode(ICamera previousCam, CameraManager.CameraMode previousMode, CameraManager.CameraMode newMode, boolean centerFocus, boolean postEvent)
      Updates the camera mode.
      Specified by:
      updateMode in interface ICamera
    • getGamepadListener

      public MainGamepadListener getGamepadListener()
    • addGamepadListener

      public void addGamepadListener()
    • removeGamepadListener

      public void removeGamepadListener()
    • setFocus

      public void setFocus(String focusName, com.badlogic.ashley.core.Entity newFocus)
    • speedScaling

      public double speedScaling(double min)
      The speed scaling function.
      min - The minimum speed.
      The speed scaling.
    • speedScaling

      public double speedScaling()
      The speed scaling function.
      Specified by:
      speedScaling in interface ICamera
      The speed scaling.
    • notify

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

      public void rotateAround(Vector3b rotationCenter, Vector3d rotationAxis, double angle)
      Rotates the direction and up vector of this camera by the given angle around the given axis, with the axis attached to given point. The direction and up vector will not be orthogonal.
      rotationCenter - the point to attach the axis to
      rotationAxis - the axis to rotate around
      angle - the angle, in degrees
    • rotate

      public void rotate(Vector3d axis, double angle)
    • translate

      public void translate(double x, double y, double z)
      Moves the camera by the given amount on each axis.
      x - the displacement on the x-axis
      y - the displacement on the y-axis
      z - the displacement on the z-axis
    • translate

      public void translate(Vector3d vec)
      Moves the camera by the given vector.
      vec - the displacement vector
    • applyForce

      protected void applyForce(Vector3b force)
      Applies the given force to this entity's acceleration.
      force - The force.
    • getFrontCameras

      public[] getFrontCameras()
      Specified by:
      getFrontCameras in interface ICamera
    • getCamera

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

      public void setCamera( perspectiveCamera)
      Description copied from interface: ICamera
      Sets the active camera
      Specified by:
      setCamera in interface ICamera
      perspectiveCamera - The perspective camera.
    • 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
    • setUp

      public void setUp(Vector3d up)
    • getDirections

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

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

      public CameraManager.CameraMode getMode()
      Specified by:
      getMode 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
      The velocity in km/h.
    • isFocus

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

      public IFocus getFocus()
      Description copied from interface: ICamera
      Returns the focus if any.
      Specified by:
      getFocus in interface ICamera
      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
      True if the camera has a focus.
    • setCenterFocus

      public void setCenterFocus(boolean centerFocus)
    • setThrust

      public void setThrust(double thrust, int direction)
    • render

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

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

      public void setPointerProjectionOnFocus(com.badlogic.gdx.math.Vector3 point)
      Description copied from interface: ICamera
      Sets the current pointer coordinates, as projected on the current focus object. This only applies when the camera is in focus mode, and the focus is a planet.
      Specified by:
      setPointerProjectionOnFocus in interface ICamera
      setPointerProjectionOnFocus in class AbstractCamera
      point - The Cartesian coordinates of the pointer on the sphere representing the focus object.
    • getVelocity

      public Vector3d getVelocity()
      Specified by:
      getVelocity in interface ICamera
      getVelocity in class AbstractCamera
    • setVelocity

      public void setVelocity(double amount)
      Sets the gamepad velocity as it comes from the joystick sensor.
      amount - The amount in [-1, 1].
    • setDiverted

      public void setDiverted(boolean diverted)
    • setCameraMultipliers

      public void setCameraMultipliers(double movementMultiplier, double speedMultiplier)
    • getCurrentMouseKbdListener

      public AbstractMouseKbdListener getCurrentMouseKbdListener()
    • getScene

      public Scene getScene()