Package gaiasky.scene.camera
Class CameraManager
java.lang.Object
gaiasky.scene.camera.CameraManager
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
static enum
Convenience enum to describe the camera mode -
Field Summary
-
Constructor Summary
ConstructorDescriptionCameraManager
(com.badlogic.gdx.assets.AssetManager manager, CameraManager.CameraMode mode, boolean vr, GlobalResources globalResources) -
Method Summary
Modifier and TypeMethodDescriptionvoid
void
checkClosestBody
(com.badlogic.ashley.core.Entity entity) Called after updating the body's distance to the cam, it updates the closest body in the camera to figure out the camera nearvoid
checkClosestBody
(IFocus focus) Called after updating the body's distance to the cam, it updates the closest body in the camera to figure out the camera nearvoid
checkClosestParticle
(IFocus particle) Sets the current closest particle to this camera.void
doneLoading
(com.badlogic.gdx.assets.AssetManager manager) Loading is finished, gather resources.float
Gets the angle of the edge of the screen, diagonally.com.badlogic.gdx.graphics.PerspectiveCamera
Returns the perspective camera.com.badlogic.gdx.graphics.PerspectiveCamera
com.badlogic.gdx.graphics.PerspectiveCamera
getCloseLightSource
(int i) Gets the current i-close light source to this cameraReturns the current closest objectGets the current closest particle to this cameraVector3d[]
double
Gets the distance from the camera to the centre of our reference frame (Sun)getDPos()
double
getFar()
getFocus()
Returns the focus if any.float
com.badlogic.gdx.graphics.PerspectiveCamera[]
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.getMode()
int
double
getNear()
getPos()
com.badlogic.gdx.math.Matrix4
com.badlogic.gdx.math.Matrix4
getShift()
double
getSpeed()
Gets the current velocity of the camera in km/h.double
double
getUp()
boolean
hasFocus()
Checks whether the current camera has a focus set.boolean
isFocus
(com.badlogic.ashley.core.Entity cb) Checks if the given entity is the current focus.boolean
boolean
boolean
isVisible
(com.badlogic.ashley.core.Entity cb) void
Event notification call.void
render
(int rw, int rh) void
resize
(int width, int height) void
void
setCamera
(com.badlogic.gdx.graphics.PerspectiveCamera perspectiveCamera) Sets the active cameravoid
setCameraStereoLeft
(com.badlogic.gdx.graphics.PerspectiveCamera cam) void
setCameraStereoRight
(com.badlogic.gdx.graphics.PerspectiveCamera cam) void
setClosest
(IFocus focus) Sets the closest of allvoid
setDirection
(Vector3d dir) void
void
void
setGamepadInput
(boolean state) Main input mode is a gamepad.void
setPointerProjectionOnFocus
(com.badlogic.gdx.math.Vector3 point) Sets the current pointer coordinates, as projected on the current focus object.void
void
void
setPreviousPos
(Vector3b prevPos) void
setPreviousPos
(Vector3d prevPos) void
setPreviousProjView
(com.badlogic.gdx.math.Matrix4 mat) void
double
void
void
update
(double dt, ITimeFrameProvider time) Update method.void
updateAngleEdge
(int width, int height) void
void
void
updateMode
(ICamera previousCam, CameraManager.CameraMode previousMode, CameraManager.CameraMode newMode, boolean centerFocus) Runs on each camera after a mode change.
-
Field Details
-
mode
-
current
-
naturalCamera
-
spacecraftCamera
-
relativisticCamera
-
previousClosest
-
speed
protected double speedCurrent velocity in km/h -
velocity
Velocity vector -
velocityNormalized
Velocity vector
-
-
Constructor Details
-
CameraManager
public CameraManager(com.badlogic.gdx.assets.AssetManager manager, CameraManager.CameraMode mode, boolean vr, GlobalResources globalResources)
-
-
Method Details
-
doneLoading
public void doneLoading(com.badlogic.gdx.assets.AssetManager manager) Description copied from interface:ICamera
Loading is finished, gather resources.- Specified by:
doneLoading
in interfaceICamera
- Parameters:
manager
- The asset manager.
-
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 camerafrustumCorners
- 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. -
setCamera
public void setCamera(com.badlogic.gdx.graphics.PerspectiveCamera perspectiveCamera) Description copied from interface:ICamera
Sets the active camera -
getFovFactor
public float getFovFactor()- Specified by:
getFovFactor
in interfaceICamera
-
getPos
-
setPos
-
setPos
-
getPreviousPos
- Specified by:
getPreviousPos
in interfaceICamera
-
setPreviousPos
- Specified by:
setPreviousPos
in interfaceICamera
-
setPreviousPos
- Specified by:
setPreviousPos
in interfaceICamera
-
getDPos
-
setDPos
-
setDPos
-
getInversePos
- Specified by:
getInversePos
in interfaceICamera
-
getVelocity
- Specified by:
getVelocity
in interfaceICamera
-
getDirection
- Specified by:
getDirection
in interfaceICamera
-
setDirection
- Specified by:
setDirection
in interfaceICamera
-
getUp
-
swapBuffers
public void swapBuffers()- Specified by:
swapBuffers
in interfaceICamera
-
setGamepadInput
public void setGamepadInput(boolean state) Description copied from interface:ICamera
Main input mode is a gamepad.- Specified by:
setGamepadInput
in interfaceICamera
-
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 interfaceICamera
- Parameters:
point
- The Cartesian coordinates of the pointer on the sphere representing the focus object.
-
getSpeedScaling
public double getSpeedScaling()- Specified by:
getSpeedScaling
in interfaceICamera
-
getSpeedScalingCapped
public double getSpeedScalingCapped()- Specified by:
getSpeedScalingCapped
in interfaceICamera
-
backupCamera
public void backupCamera() -
restoreCamera
public void restoreCamera() -
update
Update method. -
updateMode
public void updateMode(ICamera previousCam, CameraManager.CameraMode previousMode, CameraManager.CameraMode newMode, boolean centerFocus) Runs on each camera after a mode change.- Specified by:
updateMode
in interfaceICamera
-
notify
Description copied from interface:IObserver
Event notification call. -
getDirections
- Specified by:
getDirections
in interfaceICamera
-
getNCameras
public int getNCameras()- Specified by:
getNCameras
in interfaceICamera
-
getFrontCameras
public com.badlogic.gdx.graphics.PerspectiveCamera[] getFrontCameras()- Specified by:
getFrontCameras
in interfaceICamera
-
getMode
-
updateAngleEdge
public void updateAngleEdge(int width, int height) - Specified by:
updateAngleEdge
in interfaceICamera
-
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 interfaceICamera
- Returns:
- The angle in radians.
-
getManager
- Specified by:
getManager
in interfaceICamera
-
render
public void render(int rw, int rh) -
getCurrent
- Specified by:
getCurrent
in interfaceICamera
-
getSpeed
public double getSpeed()Description copied from interface:ICamera
Gets the current velocity of the camera 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. -
checkClosestBody
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 interfaceICamera
- 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 interfaceICamera
- Parameters:
entity
- The body to check.
-
getFocus
Description copied from interface:ICamera
Returns the focus if any. -
hasFocus
public boolean hasFocus()Description copied from interface:ICamera
Checks whether the current camera has a focus set. -
isVisible
public boolean isVisible(com.badlogic.ashley.core.Entity cb) -
isVisible
-
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 interfaceICamera
- Returns:
- The distance
-
getCameraStereoLeft
public com.badlogic.gdx.graphics.PerspectiveCamera getCameraStereoLeft()- Specified by:
getCameraStereoLeft
in interfaceICamera
-
setCameraStereoLeft
public void setCameraStereoLeft(com.badlogic.gdx.graphics.PerspectiveCamera cam) - Specified by:
setCameraStereoLeft
in interfaceICamera
-
getCameraStereoRight
public com.badlogic.gdx.graphics.PerspectiveCamera getCameraStereoRight()- Specified by:
getCameraStereoRight
in interfaceICamera
-
setCameraStereoRight
public void setCameraStereoRight(com.badlogic.gdx.graphics.PerspectiveCamera cam) - Specified by:
setCameraStereoRight
in interfaceICamera
-
getClosestBody
- Specified by:
getClosestBody
in interfaceICamera
-
getSecondClosestBody
- Specified by:
getSecondClosestBody
in interfaceICamera
-
getCloseLightSource
Description copied from interface:ICamera
Gets the current i-close light source to this camera- Specified by:
getCloseLightSource
in interfaceICamera
- Returns:
- The i close light source (star?)
-
resize
public void resize(int width, int height) -
getShift
-
setShift
-
getProjView
public com.badlogic.gdx.math.Matrix4 getProjView()- Specified by:
getProjView
in interfaceICamera
-
getPreviousProjView
public com.badlogic.gdx.math.Matrix4 getPreviousProjView()- Specified by:
getPreviousProjView
in interfaceICamera
-
setPreviousProjView
public void setPreviousProjView(com.badlogic.gdx.math.Matrix4 mat) - Specified by:
setPreviousProjView
in interfaceICamera
-
getClosestParticle
Description copied from interface:ICamera
Gets the current closest particle to this camera- Specified by:
getClosestParticle
in interfaceICamera
- Returns:
- The closest particle
-
checkClosestParticle
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 interfaceICamera
- Parameters:
particle
- The candidate particle
-
getClosest
Description copied from interface:ICamera
Returns the current closest object- Specified by:
getClosest
in interfaceICamera
-
setClosest
Description copied from interface:ICamera
Sets the closest of all- Specified by:
setClosest
in interfaceICamera
- Parameters:
focus
- The new closest object
-
speedScaling
public double speedScaling()- Specified by:
speedScaling
in interfaceICamera
-
updateFrustumPlanes
public void updateFrustumPlanes()- Specified by:
updateFrustumPlanes
in interfaceICamera
-
getNear
public double getNear() -
getFar
public double getFar()
-