Class NaturalCamera
java.lang.Object
gaiasky.scene.camera.AbstractCamera
gaiasky.scene.camera.NaturalCamera
The basic camera of Gaia Sky. Implements focus, free and game modes. It also incorporates the
cinematic and the non-cinematic behaviours.
-
Field Summary
FieldsModifier and TypeFieldDescriptionfinal Vector3DAcceleration and velocity.final Vector3DbooleanIndicates whether the camera is facing the focus or not.The focus entity.Reference to focus, backup.final Vector3DAcceleration and velocity.final Vector3Dfinal Vector3DAcceleration and velocity.final Vector3DVR offset.Fields inherited from class AbstractCamera
angleEdgeRad, ar, CAM_FAR, CAM_NEAR, camera, cameras, camLeft, camRight, closest, closestBody, closestStar, closestStarView, distance, dPos, fovFactor, gamepadInput, logger, parent, pos, posInv, prevCombined, prevPos, proximity, shift, tmp -
Constructor Summary
ConstructorsConstructorDescriptionNaturalCamera(com.badlogic.gdx.assets.AssetManager assetManager, CameraManager parent, boolean vr, com.badlogic.gdx.graphics.glutils.ShaderProgram spriteShader, com.badlogic.gdx.graphics.glutils.ShaderProgram shapeShader) -
Method Summary
Modifier and TypeMethodDescriptionvoidvoidaddForwardForce(double amount) Adds a forward movement by the given amount.voidvoidaddHorizontal(double amount, boolean acceleration) Adds the given amount to camera horizontal rotation around the focus acceleration, or pan in free modevoidaddPitch(double amount, boolean acceleration) Adds the given amount to the camera pitch accelerationvoidaddRoll(double amount, boolean acceleration) Adds the given amount to the camera roll accelerationvoidaddRotateMovement(double deltaX, double deltaY, boolean focusLookKeyPressed, boolean acceleration) Adds a rotation force to the camera.voidaddVertical(double amount, boolean acceleration) Adds the given amount to camera vertical rotation around the focus acceleration, or pan in free modevoidaddYaw(double amount, boolean acceleration) Adds the given amount to the camera yaw accelerationprotected voidapplyForce(Vector3Q force) Applies the given force to this entity's acceleration.voidcamOrientProjection(float yaw, float pitch, float roll) Does a pre-transformation to the camera to orient it using the given yaw, pitch and roll angles.voidClears the velocityVR vectorvoiddoneLoading(com.badlogic.gdx.assets.AssetManager manager) Loading is finished, gather resources.voidforward(double amount) voidforward(double amount, double minTu) com.badlogic.gdx.graphics.PerspectiveCameraReturns the perspective camera.Vector3D[]getFocus()Returns the focus if any.com.badlogic.gdx.graphics.PerspectiveCamera[]getMode()intgetScene()doublegetSpeed()Gets the current velocity of the camera in km/h.doubledoublegetUp()booleanhasFocus()Checks whether the current camera has a focus set.voidinitialize(com.badlogic.gdx.graphics.glutils.ShaderProgram spriteShader, com.badlogic.gdx.graphics.glutils.ShaderProgram shapeShader) booleanisFocus(com.badlogic.ashley.core.Entity focus) Checks if the given entity is the current focus.booleanCheck whether the camera is currently rotating around the (possible) focus object.voidEvent notification call.voidvoidrender(int rw, int rh) voidresize(int width, int height) voidvoidrotateAround(Vector3Q 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.voidsetCamera(com.badlogic.gdx.graphics.PerspectiveCamera perspectiveCamera) Sets the active cameravoidsetCameraMultipliers(double movementMultiplier, double speedMultiplier) voidsetCenterFocus(boolean centerFocus) voidsetDirection(Vector3D dir) voidsetDiverted(boolean diverted) voidvoidsetHorizontal(double amount) voidsetPitch(double amount) voidsetPointerProjectionOnFocus(com.badlogic.gdx.math.Vector3 point) Sets the current pointer coordinates, as projected on the current focus object.voidsetRoll(double amount) voidsetThrust(double thrust, int direction) voidvoidsetVelocity(double amount) Sets the gamepad velocity as it comes from the joystick sensor.voidsetVelocityVR(Vector3D p0, Vector3D p1, double amountX, double amountY) Sets the velocity of the VR controller as a vector.voidsetVertical(double amount) voidsetYaw(double amount) doubleThe speed scaling function.doublespeedScaling(double min) The speed scaling function.voidStops the camera movement.booleanStops the camera movement.voidvoidStops the camera movement.voidstrafe(double amount, double minTu) voidtranslate(double x, double y, double z) Moves the camera by the given amount on each axis.voidMoves the camera by the given vector.voidupdate(double dt, ITimeFrameProvider time) Updates the camera.voidupdateMode(ICamera previousCam, CameraManager.CameraMode previousMode, CameraManager.CameraMode newMode, boolean centerFocus) Updates the camera mode.voidSets the perspective camera float values from the computed double vectors, and recalculates the camera matrices.protected voidupdatePosition(double dt, double multiplier, double speedScaling) Updates the position of this entity using the current forceprotected voidupdateVelocity(double dt, double multiplier, double speedScaling) voidvertical(double amount) voidvertical(double amount, double minTu) Methods inherited from class AbstractCamera
checkClosestBody, checkClosestBody, checkClosestParticle, copyParamsFrom, getAngleEdge, getAngleEdge, getCameraStereoLeft, getCameraStereoRight, getCloseLightSource, getClosest, getClosestBody, getClosestParticle, getCurrent, getDistance, getDPos, getFar, getFovFactor, getInversePos, getManager, getNear, getPos, getPreviousPos, getPreviousProjView, getProjView, getSecondClosestBody, getShift, isVisible, isVisible, isVisible, setCameraStereoLeft, setCameraStereoRight, setClosest, setDPos, setDPos, setFrustumPlanes, setGamepadInput, setPos, setPos, setPreviousPos, setPreviousPos, setPreviousProjView, setShift, swapBuffers, updateAngleEdge, updateFrustumPlanes
-
Field Details
-
vrOffset
VR offset. -
accel
Acceleration and velocity. -
vel
Acceleration and velocity. -
posBak
Acceleration and velocity. -
direction
-
up
-
facingFocus
public boolean facingFocusIndicates whether the camera is facing the focus or not. -
focus
The focus entity. -
focusBak
Reference to focus, backup.
-
-
Constructor Details
-
NaturalCamera
public NaturalCamera(com.badlogic.gdx.assets.AssetManager assetManager, CameraManager parent, boolean vr, com.badlogic.gdx.graphics.glutils.ShaderProgram spriteShader, com.badlogic.gdx.graphics.glutils.ShaderProgram shapeShader)
-
-
Method Details
-
initialize
public void initialize(com.badlogic.gdx.graphics.glutils.ShaderProgram spriteShader, com.badlogic.gdx.graphics.glutils.ShaderProgram shapeShader) -
doneLoading
public void doneLoading(com.badlogic.gdx.assets.AssetManager manager) Description copied from interface:ICameraLoading is finished, gather resources.- Specified by:
doneLoadingin interfaceICamera- Parameters:
manager- The asset manager.
-
update
Description copied from interface:ICameraUpdates the camera. -
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.- Parameters:
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.- Parameters:
amount- Positive for forward force, negative for backward force.
-
setVelocityVR
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 -
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).- Parameters:
deltaX- The yaw amount.deltaY- The pitch amount.focusLookKeyPressed- The key to look around when on focus mode is pressed.
-
addAmount
-
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 void stopTotalMovement()Stops the camera movement. -
stopRotateMovement
public void stopRotateMovement() -
stopForwardMovement
public void stopForwardMovement()Stops the camera movement. -
updateVelocity
protected void updateVelocity(double dt, double multiplier, double speedScaling) -
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) Updates the camera mode.- Specified by:
updateModein interfaceICamera
-
getGamepadListener
-
addGamepadListener
public void addGamepadListener() -
removeGamepadListener
public void removeGamepadListener() -
setFocus
-
speedScaling
public double speedScaling(double min) The speed scaling function.- Parameters:
min- The minimum speed.- Returns:
- The speed scaling.
-
speedScaling
public double speedScaling()The speed scaling function.- Specified by:
speedScalingin interfaceICamera- Returns:
- The speed scaling.
-
notify
-
rotateAround
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.- Parameters:
rotationCenter- the point to attach the axis torotationAxis- the axis to rotate aroundangle- the angle, in degrees
-
rotate
-
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
Moves the camera by the given vector.- Parameters:
vec- the displacement vector
-
applyForce
Applies the given force to this entity's acceleration.- Parameters:
force- The force.
-
getFrontCameras
public com.badlogic.gdx.graphics.PerspectiveCamera[] getFrontCameras()- Specified by:
getFrontCamerasin interfaceICamera
-
getCamera
-
setCamera
-
getDirection
- Specified by:
getDirectionin interfaceICamera
-
setDirection
- Specified by:
setDirectionin interfaceICamera
-
getUp
-
setUp
-
getDirections
- Specified by:
getDirectionsin interfaceICamera
-
getNCameras
public int getNCameras()- Specified by:
getNCamerasin interfaceICamera
-
getMode
-
getSpeed
-
isFocus
-
getFocus
-
hasFocus
-
setCenterFocus
public void setCenterFocus(boolean centerFocus) -
setThrust
public void setThrust(double thrust, int direction) -
render
public void render(int rw, int rh) - Specified by:
renderin interfaceICamera- Overrides:
renderin classAbstractCamera
-
resize
-
setPointerProjectionOnFocus
public void setPointerProjectionOnFocus(com.badlogic.gdx.math.Vector3 point) Description copied from interface:ICameraSets 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:
setPointerProjectionOnFocusin interfaceICamera- Overrides:
setPointerProjectionOnFocusin classAbstractCamera- Parameters:
point- The Cartesian coordinates of the pointer on the sphere representing the focus object.
-
getSpeedScaling
public double getSpeedScaling()- Specified by:
getSpeedScalingin interfaceICamera- Overrides:
getSpeedScalingin classAbstractCamera
-
getSpeedScalingCapped
public double getSpeedScalingCapped()- Specified by:
getSpeedScalingCappedin interfaceICamera- Overrides:
getSpeedScalingCappedin classAbstractCamera
-
getVelocity
- Specified by:
getVelocityin interfaceICamera- Overrides:
getVelocityin classAbstractCamera
-
setVelocity
public void setVelocity(double amount) Sets the gamepad velocity as it comes from the joystick sensor.- Parameters:
amount- The amount in [-1, 1].
-
setDiverted
public void setDiverted(boolean diverted) -
setCameraMultipliers
public void setCameraMultipliers(double movementMultiplier, double speedMultiplier) -
getCurrentMouseKbdListener
-
getScene
-
isRotating
public boolean isRotating()Description copied from interface:ICameraCheck whether the camera is currently rotating around the (possible) focus object.- Specified by:
isRotatingin interfaceICamera- Overrides:
isRotatingin classAbstractCamera- Returns:
- Whether the camera is rotating.
-