Package gaiasky.scenegraph.camera
Class CameraManager
java.lang.Object
gaiasky.scenegraph.camera.CameraManager
public class CameraManager extends java.lang.Object implements ICamera, IObserver
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classCameraManager.CameraModeConvenience enum to describe the camera mode -
Field Summary
Fields Modifier and Type Field Description ICameracurrentFovCamerafovCameraCameraManager.CameraModemodeNaturalCameranaturalCameraIFocuspreviousClosestRelativisticCamerarelativisticCameraSpacecraftCameraspacecraftCameraprotected doublespeedCurrent velocity in km/hprotected Vector3dvelocityVelocity vectorprotected Vector3dvelocitynorVelocity vector -
Constructor Summary
Constructors Constructor Description CameraManager(com.badlogic.gdx.assets.AssetManager manager, CameraManager.CameraMode mode, boolean vr) -
Method Summary
Modifier and Type Method Description voidcheckClosestBody(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.floatgetAngleEdge()Gets the angle of the edge of the screen, diagonally.com.badlogic.gdx.graphics.PerspectiveCameragetCamera()Returns the perspective camera.com.badlogic.gdx.graphics.PerspectiveCameragetCameraStereoLeft()com.badlogic.gdx.graphics.PerspectiveCameragetCameraStereoRight()IFocusgetCloseLightSource(int i)Gets the current i-close light source to this cameraIFocusgetClosest()Returns the current closest objectIFocusgetClosestBody()IFocusgetClosestParticle()Gets the current closest particle to this cameraICameragetCurrent()Vector3dgetDirection()Vector3d[]getDirections()doublegetDistance()Gets the distance from the camera to the centre of our reference frame (Sun)doublegetFar()IFocusgetFocus()Returns the foucs if anyfloatgetFovFactor()com.badlogic.gdx.graphics.PerspectiveCamera[]getFrontCameras()static com.badlogic.gdx.math.Matrix4getFrustumCornersEye(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.Vector3bgetInversePos()CameraManagergetManager()CameraManager.CameraModegetMode()intgetNCameras()doublegetNear()Vector3bgetPos()Vector3bgetPreviousPos()com.badlogic.gdx.math.Matrix4getPreviousProjView()com.badlogic.gdx.math.Matrix4getProjView()IFocusgetSecondClosestBody()Vector3dgetShift()doublegetSpeed()Gets the current velocity of the camera in km/h.Vector3dgetUp()Vector3dgetVelocity()booleanisFocus(IFocus cb)Checks if this body is the current focusbooleanisNatural()booleanisVisible(double viewAngle, Vector3d pos, double distToCamera)booleanisVisible(CelestialBody cb)voidnotify(Events event, java.lang.Object... data)voidrender(int rw, int rh)voidresize(int width, int height)voidsetCamera(com.badlogic.gdx.graphics.PerspectiveCamera cam)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)voidsetPos(Vector3b pos)voidsetPos(Vector3d pos)voidsetPreviousPos(Vector3b prevpos)voidsetPreviousPos(Vector3d prevpos)voidsetPreviousProjView(com.badlogic.gdx.math.Matrix4 mat)voidsetShift(Vector3d shift)doublespeedScaling()voidswapBuffers()voidupdate(double dt, ITimeFrameProvider time)Update method.voidupdateAngleEdge(int width, int height)voidupdateCurrentCamera(CameraManager.CameraMode previousMode)voidupdateFrustumPlanes()voidupdateMode(ICamera previousCam, CameraManager.CameraMode previousMode, CameraManager.CameraMode mode, boolean centerFocus, boolean postEvent)Runs on each camera after a mode change.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Field Details
-
mode
-
current
-
naturalCamera
-
fovCamera
-
spacecraftCamera
-
relativisticCamera
-
previousClosest
-
speed
protected double speedCurrent velocity in km/h -
velocity
Velocity vector -
velocitynor
Velocity vector
-
-
Constructor Details
-
CameraManager
public CameraManager(com.badlogic.gdx.assets.AssetManager manager, CameraManager.CameraMode mode, boolean vr)
-
-
Method Details
-
updateCurrentCamera
-
isNatural
public boolean isNatural() -
getCamera
public com.badlogic.gdx.graphics.PerspectiveCamera getCamera()Description copied from interface:ICameraReturns the perspective 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
-
update
Update method. -
updateMode
public void updateMode(ICamera previousCam, CameraManager.CameraMode previousMode, CameraManager.CameraMode mode, boolean centerFocus, boolean postEvent)Runs on each camera after a mode change.- Specified by:
updateModein interfaceICamera
-
notify
-
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
Description copied from interface:ICameraChecks if this body 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
-
getFocus
Description copied from interface:ICameraReturns the foucs if any -
isVisible
-
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
-
setCamera
public void setCamera(com.badlogic.gdx.graphics.PerspectiveCamera cam)Description copied from interface:ICameraSets the active camera -
setCameraStereoLeft
public void setCameraStereoLeft(com.badlogic.gdx.graphics.PerspectiveCamera cam)- Specified by:
setCameraStereoLeftin interfaceICamera
-
setCameraStereoRight
public void setCameraStereoRight(com.badlogic.gdx.graphics.PerspectiveCamera cam)- Specified by:
setCameraStereoRightin interfaceICamera
-
getCameraStereoLeft
public com.badlogic.gdx.graphics.PerspectiveCamera getCameraStereoLeft()- Specified by:
getCameraStereoLeftin interfaceICamera
-
getCameraStereoRight
public com.badlogic.gdx.graphics.PerspectiveCamera getCameraStereoRight()- Specified by:
getCameraStereoRightin 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) -
setShift
-
getShift
-
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
-
getFrustumCornersEye
public static com.badlogic.gdx.math.Matrix4 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- Returns:
- The same matrix
-