Package gaiasky.scene.camera
Class CameraManager
java.lang.Object
gaiasky.scene.camera.CameraManager
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classstatic enumConvenience enum to describe the camera mode -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionCameraManager(com.badlogic.gdx.assets.AssetManager manager, CameraManager.CameraMode mode, boolean vr, GlobalResources globalResources) -
Method Summary
Modifier and TypeMethodDescriptionvoidvoidcheckClosestBody(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 nearvoidcheckClosestBody(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 nearvoidcheckClosestParticle(IFocus particle) Sets the current closest particle to this camera.floatGets the angle of the edge of the screen, diagonally.com.badlogic.gdx.graphics.PerspectiveCameraReturns the perspective camera.com.badlogic.gdx.graphics.PerspectiveCameracom.badlogic.gdx.graphics.PerspectiveCameragetCloseLightSource(int i) Gets the current i-close light source to this cameraReturns the current closest objectGets the current closest particle to this cameraVector3d[]doubleGets the distance from the camera to the centre of our reference frame (Sun)doublegetFar()getFocus()Returns the focus if any.floatcom.badlogic.gdx.graphics.PerspectiveCamera[]static voidgetFrustumCornersEye(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.com.badlogic.gdx.math.Matrix4getFrustumCornersWorld(com.badlogic.gdx.math.Matrix4 frustumCorners) Stores the normalized rays representing the camera frustum in world space in a 4x4 matrix.getMode()intdoublegetNear()getPos()com.badlogic.gdx.math.Matrix4com.badlogic.gdx.math.Matrix4getShift()doublegetSpeed()Gets the current velocity of the camera in km/h.getUp()booleanhasFocus()Checks whether the current camera has a focus set.booleanisFocus(com.badlogic.ashley.core.Entity cb) Checks if the given entity is the current focus.booleanbooleanbooleanisVisible(com.badlogic.ashley.core.Entity cb) voidEvent notification call.voidrender(int rw, int rh) voidresize(int width, int height) voidvoidsetCamera(com.badlogic.gdx.graphics.PerspectiveCamera perspectiveCamera) Sets the active cameravoidsetCameraStereoLeft(com.badlogic.gdx.graphics.PerspectiveCamera cam) voidsetCameraStereoRight(com.badlogic.gdx.graphics.PerspectiveCamera cam) voidsetClosest(IFocus focus) Sets the closest of allvoidsetDirection(Vector3d dir) voidsetGamepadInput(boolean state) Main input mode is a gamepad.voidvoidvoidsetPreviousPos(Vector3b prevpos) voidsetPreviousPos(Vector3d prevpos) voidsetPreviousProjView(com.badlogic.gdx.math.Matrix4 mat) voiddoublevoidvoidupdate(double dt, ITimeFrameProvider time) Update method.voidupdateAngleEdge(int width, int height) voidvoidvoidupdateMode(ICamera previousCam, CameraManager.CameraMode previousMode, CameraManager.CameraMode newMode, boolean centerFocus, boolean postEvent) Runs on each camera after a mode change.
-
Field Details
-
mode
-
current
-
naturalCamera
-
fovCamera
-
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
-
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:ICameraReturns the perspective camera. -
setCamera
public void setCamera(com.badlogic.gdx.graphics.PerspectiveCamera perspectiveCamera) Description copied from interface:ICameraSets the active camera -
getFovFactor
public float getFovFactor()- Specified by:
getFovFactorin interfaceICamera
-
getPos
-
setPos
-
setPos
-
getPreviousPos
- Specified by:
getPreviousPosin interfaceICamera
-
setPreviousPos
- Specified by:
setPreviousPosin interfaceICamera
-
setPreviousPos
- Specified by:
setPreviousPosin interfaceICamera
-
getInversePos
- Specified by:
getInversePosin interfaceICamera
-
getVelocity
- Specified by:
getVelocityin interfaceICamera
-
getDirection
- Specified by:
getDirectionin interfaceICamera
-
setDirection
- Specified by:
setDirectionin interfaceICamera
-
getUp
-
swapBuffers
public void swapBuffers()- Specified by:
swapBuffersin interfaceICamera
-
setGamepadInput
public void setGamepadInput(boolean state) Description copied from interface:ICameraMain input mode is a gamepad.- Specified by:
setGamepadInputin 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, boolean postEvent) Runs on each camera after a mode change.- Specified by:
updateModein interfaceICamera
-
notify
Description copied from interface:IObserverEvent notification call. -
getDirections
- Specified by:
getDirectionsin interfaceICamera
-
getNCameras
public int getNCameras()- Specified by:
getNCamerasin interfaceICamera
-
getFrontCameras
public com.badlogic.gdx.graphics.PerspectiveCamera[] getFrontCameras()- Specified by:
getFrontCamerasin interfaceICamera
-
getMode
-
updateAngleEdge
public void updateAngleEdge(int width, int height) - Specified by:
updateAngleEdgein interfaceICamera
-
getAngleEdge
public float getAngleEdge()Description copied from interface:ICameraGets 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:
getAngleEdgein interfaceICamera- Returns:
- The angle in radians.
-
getManager
- Specified by:
getManagerin interfaceICamera
-
render
public void render(int rw, int rh) -
getCurrent
- Specified by:
getCurrentin interfaceICamera
-
getSpeed
public double getSpeed()Description copied from interface:ICameraGets the current velocity of the camera in km/h. -
isFocus
public boolean isFocus(com.badlogic.ashley.core.Entity cb) Description copied from interface:ICameraChecks if the given entity is the current focus. -
checkClosestBody
Description copied from interface:ICameraCalled 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:
checkClosestBodyin interfaceICamera- Parameters:
focus- The body to check
-
checkClosestBody
public void checkClosestBody(com.badlogic.ashley.core.Entity entity) Description copied from interface:ICameraCalled 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:
checkClosestBodyin interfaceICamera- Parameters:
entity- The body to check.
-
getFocus
Description copied from interface:ICameraReturns the focus if any. -
hasFocus
public boolean hasFocus()Description copied from interface:ICameraChecks 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:ICameraGets the distance from the camera to the centre of our reference frame (Sun)- Specified by:
getDistancein interfaceICamera- Returns:
- The distance
-
getCameraStereoLeft
public com.badlogic.gdx.graphics.PerspectiveCamera getCameraStereoLeft()- Specified by:
getCameraStereoLeftin interfaceICamera
-
setCameraStereoLeft
public void setCameraStereoLeft(com.badlogic.gdx.graphics.PerspectiveCamera cam) - Specified by:
setCameraStereoLeftin interfaceICamera
-
getCameraStereoRight
public com.badlogic.gdx.graphics.PerspectiveCamera getCameraStereoRight()- Specified by:
getCameraStereoRightin interfaceICamera
-
setCameraStereoRight
public void setCameraStereoRight(com.badlogic.gdx.graphics.PerspectiveCamera cam) - Specified by:
setCameraStereoRightin interfaceICamera
-
getClosestBody
- Specified by:
getClosestBodyin interfaceICamera
-
getSecondClosestBody
- Specified by:
getSecondClosestBodyin interfaceICamera
-
getCloseLightSource
Description copied from interface:ICameraGets the current i-close light source to this camera- Specified by:
getCloseLightSourcein 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:
getProjViewin interfaceICamera
-
getPreviousProjView
public com.badlogic.gdx.math.Matrix4 getPreviousProjView()- Specified by:
getPreviousProjViewin interfaceICamera
-
setPreviousProjView
public void setPreviousProjView(com.badlogic.gdx.math.Matrix4 mat) - Specified by:
setPreviousProjViewin interfaceICamera
-
getClosestParticle
Description copied from interface:ICameraGets the current closest particle to this camera- Specified by:
getClosestParticlein interfaceICamera- Returns:
- The closest particle
-
checkClosestParticle
Description copied from interface:ICameraSets the current closest particle to this camera. This will be only set if the given particle is closer than the current.- Specified by:
checkClosestParticlein interfaceICamera- Parameters:
particle- The candidate particle
-
getClosest
Description copied from interface:ICameraReturns the current closest object- Specified by:
getClosestin interfaceICamera
-
setClosest
Description copied from interface:ICameraSets the closest of all- Specified by:
setClosestin interfaceICamera- Parameters:
focus- The new closest object
-
speedScaling
public double speedScaling()- Specified by:
speedScalingin interfaceICamera
-
updateFrustumPlanes
public void updateFrustumPlanes()- Specified by:
updateFrustumPlanesin interfaceICamera
-
getNear
public double getNear() -
getFar
public double getFar() -
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
-