Class NaturalCamera
- java.lang.Object
-
- gaia.cu9.ari.gaiaorbit.scenegraph.camera.AbstractCamera
-
- gaia.cu9.ari.gaiaorbit.scenegraph.camera.NaturalCamera
-
public class NaturalCamera extends AbstractCamera implements IObserver
Models the movement of the camera
-
-
Field Summary
Fields Modifier and Type Field Description Vector3d
accel
Acceleration and velocityVector3d
direction
protected CelestialBody
entity1
Entities for the GAIA_SCENE_MODE modeprotected CelestialBody
entity2
Entities for the GAIA_SCENE_MODE modeprotected CelestialBody
entity3
Entities for the GAIA_SCENE_MODE modeboolean
facingFocus
Indicates whether the camera is facing the focus or notIFocus
focus
The focus entityIFocus
focusBak
The focus entityVector3d
focusDirection
int
hudColor
com.badlogic.gdx.graphics.Color[]
hudColors
float
hudh
double[]
hudScales
float
hudw
Vector3d
posbak
Acceleration and velocityVector3d
up
Vector3d
vel
Acceleration and velocityVector3d
vroffset
VR offset-
Fields inherited from class gaia.cu9.ari.gaiaorbit.scenegraph.camera.AbstractCamera
angleEdgeRad, ar, CAM_FAR, CAM_NEAR, camera, cameras, camLeft, camRight, closest, closestBody, closestStar, combined, distance, fovFactor, frustumd, logger, parent, pos, posinv, projection, shift, tmp, view
-
-
Constructor Summary
Constructors Constructor Description NaturalCamera(com.badlogic.gdx.assets.AssetManager assetManager, CameraManager parent, boolean vr)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addAmount(Vector3d vec, double amount, boolean x)
void
addForwardForce(double amount)
Adds a forward movement by the given amount.void
addHorizontal(double amount, boolean acceleration)
Adds the given amount to camera horizontal rotation around the focus acceleration, or pan in free modevoid
addPanMovement(double deltaX, double deltaY)
Adds a pan movement to the camera.void
addPitch(double amount, boolean acceleration)
Adds the given amount to the camera pitch accelerationvoid
addRoll(double amount, boolean acceleration)
Adds the given amount to the camera roll accelerationvoid
addRotateMovement(double deltaX, double deltaY, boolean focusLookKeyPressed, boolean acceleration)
Adds a rotation force to the camera.void
addVertical(double amount, boolean acceleration)
Adds the given amount to camera vertical rotation around the focus acceleration, or pan in free modevoid
addYaw(double amount, boolean acceleration)
Adds the given amount to the camera yaw accelerationprotected void
applyForce(Vector3d force)
Applies the given force to this entity's accelerationprotected void
cameraUpdate(com.badlogic.gdx.graphics.PerspectiveCamera camera)
Does the camera math in higher precision Matrix4d objects and then down-casts the results into the perspective cameravoid
checkFocus()
Checks the position of the camera does not collide with the focus object.void
clearVelocityVR()
Clears the velocityVR vectorvoid
forward(double amount)
void
forward(double amount, double minTu)
com.badlogic.gdx.graphics.PerspectiveCamera
getCamera()
Returns the perspective camera.MouseKbdListener
getCurrentMouseKbdListener()
Vector3d
getDirection()
Vector3d[]
getDirections()
IFocus
getFocus()
Returns the foucs if anycom.badlogic.gdx.graphics.PerspectiveCamera[]
getFrontCameras()
CameraManager.CameraMode
getMode()
int
getNCameras()
double
getRotationUnits()
Depends on the distance to the focusdouble
getSpeed()
Gets the current velocity of the camera in km/h.double
getTranslateUnits()
This depends on the distance from the focus.double
getTranslateUnits(double min)
Vector3d
getUp()
Vector3d
getVelocity()
void
initialize(com.badlogic.gdx.assets.AssetManager assetManager)
boolean
isFocus(IFocus focus)
Checks if this body is the current focusvoid
notify(Events event, java.lang.Object... data)
void
render(int rw, int rh)
void
resetState()
void
resize(int width, int height)
void
rotate(Vector3d axis, double angle)
void
rotateAround(Vector3d 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.void
setCamera(com.badlogic.gdx.graphics.PerspectiveCamera cam)
Sets the active cameravoid
setDirection(Vector3d dir)
void
setDiverted(boolean diverted)
void
setFocus(IFocus focus)
void
setGamepadMultiplier(double amount)
void
setHorizontal(double amount)
void
setInputByController(boolean controller)
void
setPitch(double amount)
void
setRoll(double amount)
void
setThrust(double thrust, int direction)
void
setUp(Vector3d up)
void
setVelocity(double amount)
Sets the gamepad velocity as it comes from the joystick sensor.void
setVelocityVR(com.badlogic.gdx.math.Vector3 p0, com.badlogic.gdx.math.Vector3 p1, double amountX, double amountY)
Sets the velocity of the VR controller as a vector.void
setVertical(double amount)
void
setYaw(double amount)
boolean
stopForwardMovement()
Stops the camera movement.boolean
stopMovement()
Stops the camera movement.boolean
stopRollMovement()
boolean
stopRotateMovement()
boolean
stopTotalMovement()
Stops the camera movement.boolean
stopTurnMovement()
void
strafe(double amount)
void
strafe(double amount, double minTu)
void
translate(double x, double y, double z)
Moves the camera by the given amount on each axis.void
translate(Vector3d vec)
Moves the camera by the given vector.void
update(double dt, ITimeFrameProvider time)
Updates the camera.void
updateHUD(float dt)
void
updateMode(CameraManager.CameraMode mode, boolean centerFocus, boolean postEvent)
Updates the camera modeprotected void
updatePerspectiveCamera()
protected void
updatePosition(double dt, double multiplier, double transUnits)
Updates the position of this entity using the current forcevoid
vertical(double amount)
void
vertical(double amount, double minTu)
-
Methods inherited from class gaia.cu9.ari.gaiaorbit.scenegraph.camera.AbstractCamera
checkClosestBody, checkClosestStar, computeGaiaScan, computeVisibleFovs, copyParamsFrom, getAngleEdge, getAngleEdge, getCameraStereoLeft, getCameraStereoRight, getClosest, getClosestBody, getClosestStar, getCurrent, getDistance, getFar, getFovFactor, getInversePos, getManager, getNear, getPos, getSecondClosestBody, getShift, isVisible, isVisible, setCameraStereoLeft, setCameraStereoRight, setClosest, setFrustumPlanes, setPos, setShift, update, updateAngleEdge, updateFrustumPlanes
-
-
-
-
Field Detail
-
vroffset
public Vector3d vroffset
VR offset
-
accel
public Vector3d accel
Acceleration and velocity
-
vel
public Vector3d vel
Acceleration and velocity
-
posbak
public Vector3d posbak
Acceleration and velocity
-
direction
public Vector3d direction
-
up
public Vector3d up
-
focusDirection
public Vector3d focusDirection
-
facingFocus
public boolean facingFocus
Indicates whether the camera is facing the focus or not
-
entity1
protected CelestialBody entity1
Entities for the GAIA_SCENE_MODE mode
-
entity2
protected CelestialBody entity2
Entities for the GAIA_SCENE_MODE mode
-
entity3
protected CelestialBody entity3
Entities for the GAIA_SCENE_MODE mode
-
focus
public IFocus focus
The focus entity
-
focusBak
public IFocus focusBak
The focus entity
-
hudScales
public double[] hudScales
-
hudColors
public com.badlogic.gdx.graphics.Color[] hudColors
-
hudColor
public int hudColor
-
hudw
public float hudw
-
hudh
public float hudh
-
-
Constructor Detail
-
NaturalCamera
public NaturalCamera(com.badlogic.gdx.assets.AssetManager assetManager, CameraManager parent, boolean vr)
-
-
Method Detail
-
initialize
public void initialize(com.badlogic.gdx.assets.AssetManager assetManager)
-
update
public void update(double dt, ITimeFrameProvider time)
Description copied from interface:ICamera
Updates the camera.
-
updateHUD
public void updateHUD(float dt)
-
updatePerspectiveCamera
protected void updatePerspectiveCamera()
-
cameraUpdate
protected void cameraUpdate(com.badlogic.gdx.graphics.PerspectiveCamera camera)
Does the camera math in higher precision Matrix4d objects and then down-casts the results into the perspective camera
-
addForwardForce
public void addForwardForce(double amount)
Adds a forward movement by the given amount.- Parameters:
amount
- Positive for forward force, negative for backward force.
-
setVelocity
public void setVelocity(double amount)
Sets the gamepad velocity as it comes from the joystick sensor.- Parameters:
amount
- The amount in [-1, 1].
-
setVelocityVR
public void setVelocityVR(com.badlogic.gdx.math.Vector3 p0, com.badlogic.gdx.math.Vector3 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- Parameters:
p0
- Start point of the beamp1
- End point of the beamamountX
- Amount in the perpendicular direction of p0-p1amountY
- Amount in the direction of p0-p1
-
clearVelocityVR
public void clearVelocityVR()
Clears the velocityVR vector
-
addPanMovement
public void addPanMovement(double deltaX, double deltaY)
Adds a pan movement to the camera.- Parameters:
deltaX
- Amount of horizontal movement.deltaY
- Amount of vertical movement.
-
forward
public void forward(double amount)
-
forward
public void forward(double amount, double minTu)
-
strafe
public void strafe(double amount)
-
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).- Parameters:
deltaX
- The yaw amount.deltaY
- The pitch amount.focusLookKeyPressed
- The key to look around when on focus mode is pressed.
-
setGamepadMultiplier
public void setGamepadMultiplier(double amount)
-
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.- Returns:
- True if the camera had any movement at all and it has been stopped. False if camera was already still.
-
stopTotalMovement
public boolean stopTotalMovement()
Stops the camera movement.- Returns:
- True if the camera had any movement at all and it has been stopped. False if camera was already still.
-
stopRotateMovement
public boolean stopRotateMovement()
-
stopRollMovement
public boolean stopRollMovement()
-
stopTurnMovement
public boolean stopTurnMovement()
-
stopForwardMovement
public boolean stopForwardMovement()
Stops the camera movement.- Returns:
- True if the camera had any movement at all and it has been stopped. False if camera was already still.
-
updatePosition
protected void updatePosition(double dt, double multiplier, double transUnits)
Updates the position of this entity using the current force- Parameters:
dt
-multiplier
-
-
updateMode
public void updateMode(CameraManager.CameraMode mode, boolean centerFocus, boolean postEvent)
Updates the camera mode- Specified by:
updateMode
in interfaceICamera
-
setFocus
public void setFocus(IFocus focus)
-
getTranslateUnits
public double getTranslateUnits(double min)
-
getTranslateUnits
public double getTranslateUnits()
This depends on the distance from the focus.- Specified by:
getTranslateUnits
in interfaceICamera
- Returns:
- The translate units
-
getRotationUnits
public double getRotationUnits()
Depends on the distance to the focus- Returns:
- The rotation units
-
notify
public void notify(Events event, java.lang.Object... data)
-
rotateAround
public void rotateAround(Vector3d 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 orthogonalized.- Parameters:
rotationCenter
- the point to attach the axis torotationAxis
- the axis to rotate aroundangle
- 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.- Parameters:
x
- the displacement on the x-axisy
- the displacement on the y-axisz
- the displacement on the z-axis
-
translate
public void translate(Vector3d vec)
Moves the camera by the given vector.- Parameters:
vec
- the displacement vector
-
applyForce
protected void applyForce(Vector3d force)
Applies the given force to this entity's acceleration- Parameters:
force
-
-
getFrontCameras
public com.badlogic.gdx.graphics.PerspectiveCamera[] getFrontCameras()
- Specified by:
getFrontCameras
in interfaceICamera
-
getCamera
public com.badlogic.gdx.graphics.PerspectiveCamera getCamera()
Description copied from interface:ICamera
Returns the perspective camera.
-
getDirection
public Vector3d getDirection()
- Specified by:
getDirection
in interfaceICamera
-
setDirection
public void setDirection(Vector3d dir)
- Specified by:
setDirection
in interfaceICamera
-
setUp
public void setUp(Vector3d up)
-
getDirections
public Vector3d[] getDirections()
- Specified by:
getDirections
in interfaceICamera
-
getNCameras
public int getNCameras()
- Specified by:
getNCameras
in interfaceICamera
-
getMode
public CameraManager.CameraMode getMode()
-
getSpeed
public double getSpeed()
Description copied from interface:ICamera
Gets the current velocity of the camera in km/h.
-
isFocus
public boolean isFocus(IFocus focus)
Description copied from interface:ICamera
Checks if this body is the current focus
-
getFocus
public IFocus getFocus()
Description copied from interface:ICamera
Returns the foucs if any
-
checkFocus
public void checkFocus()
Checks the position of the camera does not collide with the focus object.
-
resetState
public void resetState()
-
setInputByController
public void setInputByController(boolean controller)
-
setCamera
public void setCamera(com.badlogic.gdx.graphics.PerspectiveCamera cam)
Description copied from interface:ICamera
Sets the active camera
-
setThrust
public void setThrust(double thrust, int direction)
-
render
public void render(int rw, int rh)
- Specified by:
render
in interfaceICamera
- Overrides:
render
in classAbstractCamera
-
getVelocity
public Vector3d getVelocity()
- Specified by:
getVelocity
in interfaceICamera
- Overrides:
getVelocity
in classAbstractCamera
-
setDiverted
public void setDiverted(boolean diverted)
-
getCurrentMouseKbdListener
public MouseKbdListener getCurrentMouseKbdListener()
-
-