SLProject 4.0.000
SLCamera Class Reference

Active or visible camera node class. More...

#include <SLCamera.h>

Inheritance diagram for SLCamera:
[legend]

Public Member Functions

 SLCamera (const SLstring &name="Camera", SLStdShaderProg textureOnlyProgramId=SP_TextureOnly, SLStdShaderProg colorAttributeProgramId=SP_colorAttribute)
 
 ~SLCamera () override
 
void statsRec (SLNodeStats &stats) override
 SLCamera::statsRec updates the statistic parameters. More...
 
void drawMesh (SLSceneView *sv) override
 SLCamera::drawMeshes draws the cameras frustum lines. More...
 
virtual SLbool camUpdate (SLSceneView *sv, SLfloat timeMS)
 
void preShade (SLRay *ray)
 
void calcMinMax (SLVec3f &minV, SLVec3f &maxV) const
 
void buildAABB (SLAABBox &aabb, const SLMat4f &wmNode)
 
SLVec2f frustumSizeAtDistance (SLfloat distance)
 Calculate and return frustum size at distance to camera center. More...
 
SLbool onMouseDown (SLMouseButton button, SLint x, SLint y, SLKey mod) override
 Gets called whenever a mouse button gets pressed. More...
 
SLbool onMouseMove (SLMouseButton button, SLint x, SLint y, SLKey mod) override
 Gets called whenever the mouse is moved. More...
 
SLbool onMouseUp (SLMouseButton button, SLint x, SLint y, SLKey mod) override
 Gets called whenever the mouse button is released. More...
 
SLbool onMouseWheel (SLint delta, SLKey mod) override
 
SLbool onTouch2Down (SLint x1, SLint y1, SLint x2, SLint y2) override
 
SLbool onTouch2Move (SLint x1, SLint y1, SLint x2, SLint y2) override
 
SLbool onTouch2Up (SLint x1, SLint y1, SLint x2, SLint y2) override
 
SLbool onKeyPress (SLKey key, SLKey mod) override
 
SLbool onKeyRelease (SLKey key, SLKey mod) override
 
void eyeToPixelRay (SLfloat x, SLfloat y, SLRay *ray)
 eyeToPixelRay returns the a ray from the eye to the center of a pixel. More...
 
void UVWFrame (SLVec3f &EYE, SLVec3f &U, SLVec3f &V, SLVec3f &W)
 
SLVec2f projectWorldToNDC (const SLVec4f &worldPos) const
 Project a world position into screen coordinates. More...
 
SLVec3f trackballVec (SLint x, SLint y) const
 Returns a vector from the window center to a virtual trackball at [x,y]. More...
 
SLbool isInFrustum (SLAABBox *aabb)
 SLCamera::isInFrustum does a simple and fast frustum culling test for AABBs. More...
 
void passToUniforms (SLGLProgram *program)
 Pass camera parameters to the uniform variables. More...
 
void setViewport (SLSceneView *sv, SLEyeType eye)
 Sets the viewport transform depending on the projection. More...
 
void setProjection (SLSceneView *sv, SLEyeType eye)
 
void setView (SLSceneView *sv, SLEyeType eye)
 
void setFrustumPlanes ()
 SLCamera::setFrustumPlanes set the 6 plane from the view frustum. More...
 
void projType (SLProjType p)
 
void fov (const SLfloat fov)
 vertical field of view More...
 
void camAnim (SLCamAnim ca)
 
void clipNear (const SLfloat cNear)
 
void clipFar (const SLfloat cFar)
 
void lookFrom (const SLVec3f &fromDir, const SLVec3f &upDir=SLVec3f::AXISY)
 Sets the view to look from a direction towards the current focal point. More...
 
void maxSpeed (const SLfloat ms)
 
void moveAccel (const SLfloat accel)
 
void brakeAccel (const SLfloat accel)
 
void drag (const SLfloat drag)
 
void focalDist (const SLfloat f)
 
void lensDiameter (const SLfloat d)
 
void lensSamples (SLuint x, SLuint y)
 
void stereoEyeSeparation (const SLfloat es)
 
void devRotLoc (SLDeviceRotation *devRot, SLDeviceLocation *devLoc)
 
void fogIsOn (const bool isOn)
 
void fogMode (const SLFogMode mode)
 
void fogDensity (const float density)
 
void onCamUpdateCB (function< void(SLSceneView *sv)> callbackFunc)
 
const SLMat4fupdateAndGetVM () const
 
SLProjType projType () const
 
SLstring projTypeStr () const
 
SLfloat unitScaling () const
 
SLfloat fovV () const
 Vertical field of view. More...
 
SLfloat fovH () const
 Horizontal field of view. More...
 
SLRecti viewport () const
 
SLfloat aspect () const
 
SLfloat clipNear () const
 
SLfloat clipFar () const
 
SLCamAnim camAnim () const
 
SLstring animationStr () const
 SLCamera::animationStr() returns the animation enum as string. More...
 
SLfloat stereoEyeSeparation () const
 
SLint stereoEye () const
 
SLMat3f stereoColorFilter () const
 
SLfloat lensDiameter () const
 
SLRaySamples2DlensSamples ()
 
SLfloat focalDist () const
 
SLfloat focalDistScrW () const
 
SLfloat focalDistScrH () const
 
SLVec3f focalPointWS () const
 
SLVec3f focalPointOS () const
 
SLbool fogIsOn () const
 
SLFogMode fogMode () const
 
SLfloat fogDensity () const
 
SLfloat fogDistStart () const
 
SLfloat fogDistEnd () const
 
SLCol4f fogColor () const
 
SLfloat trackballSize () const
 
SLBackgroundbackground ()
 
SLfloat maxSpeed () const
 
SLfloat moveAccel () const
 
SLfloat brakeAccel () const
 
SLfloat drag () const
 
SLstring toString () const
 SLCamera::to_string returns important camera parameter as a string. More...
 
SLRectfselectRect ()
 
SLRectfdeselectRect ()
 
void updateEnuCorrRenu (SLSceneView *sv, const SLMat3f &enuRc, float &f, SLVec3f &enuOffsetPix)
 Calculate and apply correction from finger x-y-rotation. More...
 
- Public Member Functions inherited from SLNode
 SLNode (const SLstring &name="Node")
 
 SLNode (SLMesh *mesh, const SLstring &name="Node")
 
 SLNode (SLMesh *mesh, const SLVec3f &translation, const SLstring &name)
 
 ~SLNode () override
 
virtual void cull3DRec (SLSceneView *sv)
 
virtual void cullChildren3D (SLSceneView *sv)
 
virtual void cull2DRec (SLSceneView *sv)
 
virtual bool hitRec (SLRay *ray)
 
virtual void statsRec (SLNodeStats &stats)
 
virtual SLNodecopyRec ()
 
virtual SLAABBoxupdateAABBRec (SLbool updateAlsoAABBinOS)
 
virtual void dumpRec ()
 
void setDrawBitsRec (SLuint bit, SLbool state)
 
void setPrimitiveTypeRec (SLGLPrimitiveType primitiveType)
 
virtual void addMesh (SLMesh *mesh)
 
virtual void drawMesh (SLSceneView *sv)
 Draws the single mesh. More...
 
bool removeMesh ()
 Returns true if a mesh was assigned and set it to nullptr. More...
 
bool removeMesh (SLMesh *mesh)
 Returns true if the passed mesh was assigned and sets it to nullptr. More...
 
SLint numChildren ()
 
void addChild (SLNode *child)
 
bool insertChild (SLNode *insertC, SLNode *afterC)
 
void deleteChildren ()
 
bool deleteChild ()
 
bool deleteChild (SLNode *child)
 
bool deleteChild (const SLstring &name)
 
bool removeChild (SLNode *child)
 remove child from vector of children. Removes false if not found, else true. More...
 
template<typename T >
T * find (const SLstring &name="", SLbool findRecursive=true)
 
template<typename T >
T * findChild (const SLstring &name="", SLbool findRecursive=true)
 
template<typename T >
deque< T * > findChildren (const SLstring &name="", SLbool findRecursive=true, SLbool canContain=false)
 
deque< SLNode * > findChildren (const SLMesh *mesh, SLbool findRecursive=true)
 
deque< SLNode * > findChildren (SLuint drawbit, SLbool findRecursive=true)
 
SLVec3f translationOS () const
 
SLVec3f forwardOS () const
 
SLVec3f rightOS () const
 
SLVec3f upOS () const
 
SLVec3f axisXOS () const
 
SLVec3f axisYOS () const
 
SLVec3f axisZOS () const
 
SLVec3f translationWS () const
 
SLVec3f forwardWS () const
 
SLVec3f rightWS () const
 
SLVec3f upWS () const
 
SLVec3f axisXWS () const
 
SLVec3f axisYWS () const
 
SLVec3f axisZWS () const
 
void translation (const SLVec3f &pos, SLTransformSpace relativeTo=TS_parent)
 
void translation (SLfloat x, SLfloat y, SLfloat z, SLTransformSpace relativeTo=TS_parent)
 
void rotation (const SLQuat4f &rot, SLTransformSpace relativeTo=TS_parent)
 
void rotation (SLfloat angleDeg, const SLVec3f &axis, SLTransformSpace relativeTo=TS_parent)
 
void scaling (SLfloat s)
 
void scaling (SLfloat x, SLfloat y, SLfloat z)
 
void scaling (const SLVec3f &scaling)
 
void lookAt (SLfloat targetX, SLfloat targetY, SLfloat targetZ, SLfloat upX=0, SLfloat upY=1, SLfloat upZ=0, SLTransformSpace relativeTo=TS_world)
 
void lookAt (const SLVec3f &target, const SLVec3f &up=SLVec3f::AXISY, SLTransformSpace relativeTo=TS_world)
 
void translate (const SLVec3f &vec, SLTransformSpace relativeTo=TS_object)
 
void translate (SLfloat x, SLfloat y, SLfloat z, SLTransformSpace relativeTo=TS_object)
 
void rotate (const SLQuat4f &rot, SLTransformSpace relativeTo=TS_object)
 
void rotate (SLfloat angleDeg, const SLVec3f &axis, SLTransformSpace relativeTo=TS_object)
 
void rotate (SLfloat angleDeg, SLfloat x, SLfloat y, SLfloat z, SLTransformSpace relativeTo=TS_object)
 
void rotateAround (const SLVec3f &point, SLVec3f &axis, SLfloat angleDeg, SLTransformSpace relativeTo=TS_world)
 
void scale (SLfloat s)
 
void scale (SLfloat x, SLfloat y, SLfloat z)
 
void scale (const SLVec3f &scale)
 
void scaleToCenter (SLfloat maxDim)
 
void setInitialState ()
 
void resetToInitialState ()
 
void parent (SLNode *p)
 
void entityID (SLint entityID)
 
void om (const SLMat4f &mat)
 
void animation (SLAnimation *a)
 
void castsShadows (SLbool castsShadows)
 
virtual void needUpdate ()
 
void needWMUpdate ()
 
void needAABBUpdate ()
 
void isSelected (bool isSelected)
 
void minLodCoverage (SLfloat minLodCoverage)
 
void levelForSM (SLubyte lfsm)
 
void onUpdateCB (function< void()> callbackFunc)
 
SLNodeparent ()
 
SLint depth () const
 
SLint entityID () const
 
const SLMat4fom ()
 
const SLMat4finitialOM ()
 
const SLMat4fupdateAndGetWM () const
 
const SLMat4fupdateAndGetWMI () const
 
SLDrawBitsdrawBits ()
 
SLbool drawBit (SLuint bit)
 
SLAABBoxaabb ()
 
SLAnimationanimation ()
 
SLbool castsShadows ()
 
SLMeshmesh ()
 
SLVNodechildren ()
 
const SLAnimSkeletonskeleton ()
 Returns the first skeleton found in the meshes. More...
 
void updateRec ()
 
virtual void doUpdate ()
 
bool updateMeshSkins (const std::function< void(SLMesh *)> &cbInformNodes)
 Update all skinned meshes recursively. More...
 
void updateMeshAccelStructs ()
 
void updateMeshMat (std::function< void(SLMaterial *m)> setMat, bool recursive)
 Updates the mesh material recursively with a material lambda. More...
 
void setMeshMat (SLMaterial *mat, bool recursive)
 Set the mesh material recursively. More...
 
bool isSelected ()
 
SLfloat minLodCoverage ()
 
SLubyte levelForSM ()
 
- Public Member Functions inherited from SLObject
 SLObject (const SLstring &Name="", const SLstring &url="")
 
virtual ~SLObject ()
 
void name (const SLstring &Name)
 
void url (const SLstring &url)
 
const SLstringname () const
 
const SLstringurl () const
 
- Public Member Functions inherited from SLEventHandler
 SLEventHandler ()
 
virtual ~SLEventHandler ()
 
virtual SLbool onMouseDown (const SLMouseButton button, const SLint x, const SLint y, const SLKey mod)
 
virtual SLbool onMouseUp (const SLMouseButton button, const SLint x, const SLint y, const SLKey mod)
 
virtual SLbool onMouseMove (const SLMouseButton button, const SLint x, const SLint y, const SLKey mod)
 
virtual SLbool onDoubleClick (const SLMouseButton button, const SLint x, const SLint y, const SLKey mod)
 
virtual SLbool onMouseWheel (const SLint delta, const SLKey mod)
 
virtual SLbool onTouch2Down (const SLint x1, const SLint y1, const SLint x2, const SLint y2)
 
virtual SLbool onTouch2Move (const SLint x1, const SLint y1, const SLint x2, const SLint y2)
 
virtual SLbool onTouch2Up (const SLint x1, const SLint y1, const SLint x2, const SLint y2)
 
virtual SLbool onTouch3Down (const SLint x1, const SLint y1)
 
virtual SLbool onTouch3Move (const SLint x1, const SLint y1)
 
virtual SLbool onTouch3Up (const SLint x1, const SLint y1)
 
virtual SLbool onKeyPress (const SLKey key, const SLKey mod)
 
virtual SLbool onKeyRelease (const SLKey key, const SLKey mod)
 
virtual SLbool onRotationPYR (const SLfloat pitchRAD, const SLfloat yawRAD, const SLfloat rollRAD)
 
void mouseRotationFactor (SLfloat rf)
 
SLfloat mouseRotationFactor ()
 

Static Public Member Functions

static SLstring projTypeToStr (SLProjType pt)
 Returns the projection type as string. More...
 

Static Public Attributes

static SLCamAnim currentAnimation = CA_turntableYUp
 
static SLProjType currentProjection = P_monoPerspective
 
static SLfloat currentFOV = 45.0f
 
static SLint currentDevRotation = 0
 
- Static Public Attributes inherited from SLNode
static SLuint numWMUpdates = 0
 NO. of calls to updateWMRec per frame. More...
 
static unsigned int instanceIndex = 0
 ??? More...
 

Protected Attributes

SLProjType _projType
 Projection type. More...
 
SLfloat _fovV
 Current vertical field of view (view angle) in degrees. More...
 
SLfloat _fovInit
 Initial vertical field of view (view angle) in degrees. More...
 
SLfloat _clipNear
 Dist. to the near clipping plane. More...
 
SLfloat _clipFar
 Dist. to the far clipping plane. More...
 
SLPlane _plane [6]
 6 frustum planes (l, r, t, b, n, f) More...
 
SLRecti _viewport
 framebuffer rectangle More...
 
SLfloat _viewportRatio
 viewport.width / viewport.height = screen ratio More...
 
SLfloat _fx
 horizontal focal length More...
 
SLfloat _fy
 vertical focal length More...
 
SLfloat _cx
 sensor center in x direction More...
 
SLfloat _cy
 sensor center in y direction More...
 
SLBackground _background
 Colors or texture displayed in the background. More...
 
SLGLVertexArrayExt _vao
 OpenGL Vertex array for rendering. More...
 
SLbool _movedLastFrame
 
SLCamAnim _camAnim
 did the camera updateRec in the last frame? More...
 
SLVec2f _oldTouchPos1
 Old mouse/touch position in pixels. More...
 
SLVec2f _oldTouchPos2
 Old 2nd finger touch position in pixels. More...
 
SLVec3f _trackballStartVec
 Trackball vector at mouse down. More...
 
SLfloat _trackballSize
 Size of trackball (0.8 = 80% of window size) More...
 
SLVec3f _moveDir
 accumulated movement directions based on pressed buttons More...
 
SLfloat _drag
 simple constant drag that affects velocity More...
 
SLfloat _maxSpeed
 maximum speed in m/s, with high drag values this speed might not be achievable at all More...
 
SLVec3f _velocity
 current velocity vector More...
 
SLVec3f _acceleration
 current acceleration vector More...
 
SLfloat _brakeAccel
 brake acceleration More...
 
SLfloat _moveAccel
 move acceleration More...
 
SLfloat _focalDist
 distance to lookAt point on the focal plane from lens More...
 
SLfloat _lensDiameter
 Lens diameter. More...
 
SLRaySamples2D _lensSamples
 sample points for lens sampling (DOF) More...
 
SLfloat _stereoEyeSeparation
 eye separation for stereo mode More...
 
SLfloat _unitScaling
 indicate what the current unit scale is More...
 
SLint _stereoEye
 -1=left, 0=center, 1=right More...
 
SLMat3f _stereoColorFilter
 color filter matrix for anaglyphling is to adjust movement and stereo rendering correctly More...
 
SLbool _fogIsOn
 Flag if fog blending is enabled. More...
 
SLFogMode _fogMode
 0=LINEAR, 1=EXP, 2=EXP2 More...
 
SLfloat _fogDensity
 Fog density for exponential modes. More...
 
SLfloat _fogStart
 Fog start distance for linear mode. More...
 
SLfloat _fogEnd
 Fog end distance for linear mode. More...
 
SLCol4f _fogColor
 fog color blended to the final color More...
 
SLbool _fogColorIsBack
 fog color blended to the final color More...
 
SLDeviceRotation_devRot = nullptr
 
SLDeviceLocation_devLoc = nullptr
 
SLRectf _selectRect
 Mouse selection rectangle. See SLMesh::handleRectangleSelection. More...
 
SLRectf _deselectRect
 Mouse deselection rectangle. See SLMesh::handleRectangleSelection. More...
 
SLint _xOffsetPix = 0
 parameter for manual finger rotation and translation More...
 
SLint _yOffsetPix = 0
 
SLMat3f _enucorrRenu
 
function< void(SLSceneView *sv)> _onCamUpdateCB
 
- Protected Attributes inherited from SLNode
SLNode_parent
 pointer to the parent node More...
 
SLVNode _children
 vector of children nodes More...
 
SLMesh_mesh
 pointer to a single mesh More...
 
SLint _depth
 depth of the node in a scene tree More...
 
SLint _entityID
 ID in the SLVEntity graph for Data Oriented Design. More...
 
SLMat4f _om
 object matrix for local transforms More...
 
SLMat4f _initialOM
 the initial om state More...
 
SLMat4f _wm
 world matrix for world transform More...
 
SLMat4f _wmI
 inverse world matrix More...
 
SLbool _isWMUpToDate
 is the WM of this node still valid More...
 
SLbool _isWMIUpToDate
 is the inverse WM of this node still valid More...
 
SLbool _isAABBUpToDate
 is the saved aabb still valid More...
 
bool _castsShadows
 flag if meshes of node should cast shadows More...
 
bool _isSelected
 flag if node and one or more of its meshes are selected More...
 
SLDrawBits _drawBits
 node level drawing flags More...
 
SLAABBox _aabb
 axis aligned bounding box More...
 
SLAnimation_animation
 animation of the node More...
 
SLfloat _minLodCoverage
 Min. LOD coverage for visibility (0.0 < _minLodCoverage < 1.0) More...
 
SLubyte _levelForSM
 Level of LOD to use for shadow mapping (0 = the visible one will be drawn) More...
 
function< void()> _onUpdateCB
 Optional lambda callback once per update. More...
 
- Protected Attributes inherited from SLObject
SLstring _name
 name of an object More...
 
SLstring _url
 uniform resource locator More...
 
- Protected Attributes inherited from SLEventHandler
SLfloat _mouseRotationFactor
 Mouse rotation sensibility. More...
 
SLfloat _keyboardDeltaPos
 Delta dist. for keyboard translation. More...
 

Detailed Description

Active or visible camera node class.

An instance of this SLNode derived class serves as an active camera with all its view and projection parameters or if inactive as a visible scene graph node with camera body and its view frustum. The position and orientation of the active camera is set in the setView method by loading the view matrix _vm into the OpenGL modelview matrix. The view matrix _vm is simply the inverse of the shapes world matrix _wm. Every SLSceneView instance has a pointer _camera to its active camera.
Because the SLNode class is inherited from the abstract SLEventHandler class a camera can handle mouse & keyboard event. All camera animations are handled in these event handlers.
The following camera animations are available:

  • SLCamAnim::CA_turntableYUp
  • SLCamAnim::CA_turntableZUp
  • SLCamAnim::CA_trackball
  • SLCamAnim::CA_walkingYUp
  • SLCamAnim::CA_walkingZUp
  • SLCamAnim::CA_deviceRotYUp
    Every camera has an instance of SLBackground that defines the views background if the camera is the active one. If the camera is inactive the background gets drawn on the far clipping plane of the visualized view frustum.

Constructor & Destructor Documentation

◆ SLCamera()

SLCamera::SLCamera ( const SLstring name = "Camera",
SLStdShaderProg  textureOnlyProgramId = SP_TextureOnly,
SLStdShaderProg  colorAttributeProgramId = SP_colorAttribute 
)
explicit

◆ ~SLCamera()

SLCamera::~SLCamera ( )
override

Member Function Documentation

◆ animationStr()

SLstring SLCamera::animationStr ( ) const

SLCamera::animationStr() returns the animation enum as string.

◆ aspect()

SLfloat SLCamera::aspect ( ) const
inline

◆ background()

SLBackground & SLCamera::background ( )
inline

◆ brakeAccel() [1/2]

SLfloat SLCamera::brakeAccel ( ) const
inline

◆ brakeAccel() [2/2]

void SLCamera::brakeAccel ( const SLfloat  accel)
inline

◆ buildAABB()

void SLCamera::buildAABB ( SLAABBox aabb,
const SLMat4f wmNode 
)

SLCamera::buildAABB builds the passed axis-aligned bounding box in OS and updates the min & max points in WS with the passed WM of the node. The camera node has no mesh associated, so we have to calculate the min and max point from the camera frustum.

◆ calcMinMax()

void SLCamera::calcMinMax ( SLVec3f minV,
SLVec3f maxV 
) const

SLCamera::calcMinMax calculates the axis aligned minimum and maximum point of the camera position and the 4 near clipping plane points in object space (OS).

◆ camAnim() [1/2]

SLCamAnim SLCamera::camAnim ( ) const
inline

◆ camAnim() [2/2]

void SLCamera::camAnim ( SLCamAnim  ca)
inline

◆ camUpdate()

SLbool SLCamera::camUpdate ( SLSceneView sv,
SLfloat  elapsedTimeMS 
)
virtual

SLCamera::camUpdate does the smooth transition for the walk animation. It is called in every frame. It moves the camera after the key was released and smoothly stops the motion by decreasing the speed every frame.

◆ clipFar() [1/2]

SLfloat SLCamera::clipFar ( ) const
inline

◆ clipFar() [2/2]

void SLCamera::clipFar ( const SLfloat  cFar)
inline

◆ clipNear() [1/2]

SLfloat SLCamera::clipNear ( ) const
inline

◆ clipNear() [2/2]

void SLCamera::clipNear ( const SLfloat  cNear)
inline

◆ deselectRect()

SLRectf & SLCamera::deselectRect ( )
inline

◆ devRotLoc()

void SLCamera::devRotLoc ( SLDeviceRotation devRot,
SLDeviceLocation devLoc 
)
inline

◆ drag() [1/2]

SLfloat SLCamera::drag ( ) const
inline

◆ drag() [2/2]

void SLCamera::drag ( const SLfloat  drag)
inline

◆ drawMesh()

void SLCamera::drawMesh ( SLSceneView sv)
overridevirtual

SLCamera::drawMeshes draws the cameras frustum lines.

Only draws the frustum lines without lighting when the camera is not the active one. This means that it can be seen from the active view point.

Reimplemented from SLNode.

Reimplemented in SLKeyframeCamera.

◆ eyeToPixelRay()

void SLCamera::eyeToPixelRay ( SLfloat  x,
SLfloat  y,
SLRay ray 
)

eyeToPixelRay returns the a ray from the eye to the center of a pixel.

This method is used for object picking. The calculation is the same as for primary rays in Ray Tracing.

◆ focalDist() [1/2]

SLfloat SLCamera::focalDist ( ) const
inline

◆ focalDist() [2/2]

void SLCamera::focalDist ( const SLfloat  f)
inline

◆ focalDistScrH()

SLfloat SLCamera::focalDistScrH ( ) const

Returns the height of the screen at focal distance. In stereo rendering this should correspond to the height of the projection plane.

◆ focalDistScrW()

SLfloat SLCamera::focalDistScrW ( ) const

Returns the width of the screen at focal distance. In stereo rendering this should correspond to the width of the projection plane.

◆ focalPointOS()

SLVec3f SLCamera::focalPointOS ( ) const
inline

◆ focalPointWS()

SLVec3f SLCamera::focalPointWS ( ) const
inline

◆ fogColor()

SLCol4f SLCamera::fogColor ( ) const
inline

◆ fogDensity() [1/2]

SLfloat SLCamera::fogDensity ( ) const
inline

◆ fogDensity() [2/2]

void SLCamera::fogDensity ( const float  density)
inline

◆ fogDistEnd()

SLfloat SLCamera::fogDistEnd ( ) const
inline

◆ fogDistStart()

SLfloat SLCamera::fogDistStart ( ) const
inline

◆ fogIsOn() [1/2]

SLbool SLCamera::fogIsOn ( ) const
inline

◆ fogIsOn() [2/2]

void SLCamera::fogIsOn ( const bool  isOn)
inline

◆ fogMode() [1/2]

SLFogMode SLCamera::fogMode ( ) const
inline

◆ fogMode() [2/2]

void SLCamera::fogMode ( const SLFogMode  mode)
inline

◆ fov()

void SLCamera::fov ( const SLfloat  fov)
inline

vertical field of view

◆ fovH()

SLfloat SLCamera::fovH ( ) const

Horizontal field of view.

< Horizontal field of view

◆ fovV()

SLfloat SLCamera::fovV ( ) const
inline

Vertical field of view.

◆ frustumSizeAtDistance()

SLVec2f SLCamera::frustumSizeAtDistance ( SLfloat  distance)

Calculate and return frustum size at distance to camera center.

◆ isInFrustum()

SLbool SLCamera::isInFrustum ( SLAABBox aabb)

SLCamera::isInFrustum does a simple and fast frustum culling test for AABBs.

SLCamera::isInFrustum checks if the bounding sphere of an AABB is within the view frustum defined by its 6 planes by simply testing the distance of the AABBs center minus its radius. This is faster than the AABB in frustum test but not as precise. Please refer to the nice tutorial on frustum culling on: https://cgvr.cs.uni-bremen.de/teaching/cg_literatur/lighthouse3d_view_frustum_culling/

◆ lensDiameter() [1/2]

SLfloat SLCamera::lensDiameter ( ) const
inline

◆ lensDiameter() [2/2]

void SLCamera::lensDiameter ( const SLfloat  d)
inline

◆ lensSamples() [1/2]

SLRaySamples2D * SLCamera::lensSamples ( )
inline

◆ lensSamples() [2/2]

void SLCamera::lensSamples ( SLuint  x,
SLuint  y 
)
inline

◆ lookFrom()

void SLCamera::lookFrom ( const SLVec3f fromDir,
const SLVec3f upDir = SLVec3f::AXISY 
)

Sets the view to look from a direction towards the current focal point.

◆ maxSpeed() [1/2]

SLfloat SLCamera::maxSpeed ( ) const
inline

◆ maxSpeed() [2/2]

void SLCamera::maxSpeed ( const SLfloat  ms)
inline

◆ moveAccel() [1/2]

SLfloat SLCamera::moveAccel ( ) const
inline

◆ moveAccel() [2/2]

void SLCamera::moveAccel ( const SLfloat  accel)
inline

◆ onCamUpdateCB()

void SLCamera::onCamUpdateCB ( function< void(SLSceneView *sv)>  callbackFunc)
inline

◆ onKeyPress()

SLbool SLCamera::onKeyPress ( SLKey  key,
SLKey  mod 
)
overridevirtual

SLCamera::onKeyPress applies the keyboard view navigation to the view matrix. The key code constants are defined in SL.h

Reimplemented from SLEventHandler.

◆ onKeyRelease()

SLbool SLCamera::onKeyRelease ( SLKey  key,
SLKey  mod 
)
overridevirtual

SLCamera::onKeyRelease gets called when a key is released

Reimplemented from SLEventHandler.

◆ onMouseDown()

SLbool SLCamera::onMouseDown ( SLMouseButton  button,
SLint  x,
SLint  y,
SLKey  mod 
)
overridevirtual

Gets called whenever a mouse button gets pressed.

Reimplemented from SLEventHandler.

◆ onMouseMove()

SLbool SLCamera::onMouseMove ( SLMouseButton  button,
SLint  x,
SLint  y,
SLKey  mod 
)
overridevirtual

Gets called whenever the mouse is moved.

Reimplemented from SLEventHandler.

◆ onMouseUp()

SLbool SLCamera::onMouseUp ( SLMouseButton  button,
SLint  x,
SLint  y,
SLKey  mod 
)
overridevirtual

Gets called whenever the mouse button is released.

Reimplemented from SLEventHandler.

◆ onMouseWheel()

SLbool SLCamera::onMouseWheel ( SLint  delta,
SLKey  mod 
)
overridevirtual

SLCamera::onMouseWheel event handler moves camera forwards or backwards

Reimplemented from SLEventHandler.

◆ onTouch2Down()

SLbool SLCamera::onTouch2Down ( SLint  x1,
SLint  y1,
SLint  x2,
SLint  y2 
)
overridevirtual

SLCamera::onDoubleTouch gets called whenever two fingers touch a handheld screen.

Reimplemented from SLEventHandler.

◆ onTouch2Move()

SLbool SLCamera::onTouch2Move ( SLint  x1,
SLint  y1,
SLint  x2,
SLint  y2 
)
overridevirtual

SLCamera::onTouch2Move gets called whenever two fingers move on a handheld screen.

Reimplemented from SLEventHandler.

◆ onTouch2Up()

SLbool SLCamera::onTouch2Up ( SLint  x1,
SLint  y1,
SLint  x2,
SLint  y2 
)
overridevirtual

SLCamera::onDoubleTouch gets called whenever two fingers touch a handheld screen.

Reimplemented from SLEventHandler.

◆ passToUniforms()

void SLCamera::passToUniforms ( SLGLProgram program)

Pass camera parameters to the uniform variables.

◆ preShade()

void SLCamera::preShade ( SLRay ray)
inline

◆ projectWorldToNDC()

SLVec2f SLCamera::projectWorldToNDC ( const SLVec4f worldPos) const

Project a world position into screen coordinates.

◆ projType() [1/2]

SLProjType SLCamera::projType ( ) const
inline

◆ projType() [2/2]

void SLCamera::projType ( SLProjType  p)
inline

◆ projTypeStr()

SLstring SLCamera::projTypeStr ( ) const
inline

◆ projTypeToStr()

SLstring SLCamera::projTypeToStr ( SLProjType  pt)
static

Returns the projection type as string.

◆ selectRect()

SLRectf & SLCamera::selectRect ( )
inline

◆ setFrustumPlanes()

void SLCamera::setFrustumPlanes ( )

SLCamera::setFrustumPlanes set the 6 plane from the view frustum.

SLCamera::setFrustumPlanes set the 6 frustum planes by extracting the plane coefficients from the combined view and projection matrix.

◆ setProjection()

void SLCamera::setProjection ( SLSceneView sv,
SLEyeType  eye 
)

Sets the projection transformation matrix and the drawing buffer. In case of a stereographic projection it additionally sets the stereo splitting parameters such as the color masks and the color filter matrix for stereo color anaglyph.

◆ setView()

void SLCamera::setView ( SLSceneView sv,
SLEyeType  eye 
)

Applies the view transform to the modelview matrix depending on the eye: eye=-1 for the left and eye=1 for the right eye. The view matrix that projects all points from the world coordinate system to the camera coordinate system (that means relative to the camera) is the camera nodes inverse world matrix.

◆ setViewport()

void SLCamera::setViewport ( SLSceneView sv,
SLEyeType  eye 
)

Sets the viewport transform depending on the projection.

◆ statsRec()

void SLCamera::statsRec ( SLNodeStats stats)
overridevirtual

SLCamera::statsRec updates the statistic parameters.

Reimplemented from SLNode.

◆ stereoColorFilter()

SLMat3f SLCamera::stereoColorFilter ( ) const
inline

◆ stereoEye()

SLint SLCamera::stereoEye ( ) const
inline

◆ stereoEyeSeparation() [1/2]

SLfloat SLCamera::stereoEyeSeparation ( ) const
inline

◆ stereoEyeSeparation() [2/2]

void SLCamera::stereoEyeSeparation ( const SLfloat  es)
inline

◆ toString()

SLstring SLCamera::toString ( ) const

SLCamera::to_string returns important camera parameter as a string.

◆ trackballSize()

SLfloat SLCamera::trackballSize ( ) const
inline

◆ trackballVec()

SLVec3f SLCamera::trackballVec ( SLint  x,
SLint  y 
) const

Returns a vector from the window center to a virtual trackball at [x,y].

The trackball vector is a vector from the window center to a hemisphere over the window at the specified cursor position. With two trackball vectors you can calculate a single rotation axis with the cross product. This routine is used for the trackball camera animation.

◆ unitScaling()

SLfloat SLCamera::unitScaling ( ) const
inline

◆ updateAndGetVM()

const SLMat4f & SLCamera::updateAndGetVM ( ) const
inline

◆ updateEnuCorrRenu()

void SLCamera::updateEnuCorrRenu ( SLSceneView sv,
const SLMat3f enuRc,
float &  f,
SLVec3f enuOffsetPix 
)

Calculate and apply correction from finger x-y-rotation.

◆ UVWFrame()

void SLCamera::UVWFrame ( SLVec3f EYE,
SLVec3f U,
SLVec3f V,
SLVec3f W 
)

◆ viewport()

SLRecti SLCamera::viewport ( ) const
inline

Member Data Documentation

◆ _acceleration

SLVec3f SLCamera::_acceleration
protected

current acceleration vector

◆ _background

SLBackground SLCamera::_background
protected

Colors or texture displayed in the background.

◆ _brakeAccel

SLfloat SLCamera::_brakeAccel
protected

brake acceleration

◆ _camAnim

SLCamAnim SLCamera::_camAnim
protected

did the camera updateRec in the last frame?

Type of camera animation

◆ _clipFar

SLfloat SLCamera::_clipFar
protected

Dist. to the far clipping plane.

◆ _clipNear

SLfloat SLCamera::_clipNear
protected

Dist. to the near clipping plane.

◆ _cx

SLfloat SLCamera::_cx
protected

sensor center in x direction

◆ _cy

SLfloat SLCamera::_cy
protected

sensor center in y direction

◆ _deselectRect

SLRectf SLCamera::_deselectRect
protected

Mouse deselection rectangle. See SLMesh::handleRectangleSelection.

◆ _devLoc

SLDeviceLocation* SLCamera::_devLoc = nullptr
protected

◆ _devRot

SLDeviceRotation* SLCamera::_devRot = nullptr
protected

◆ _drag

SLfloat SLCamera::_drag
protected

simple constant drag that affects velocity

◆ _enucorrRenu

SLMat3f SLCamera::_enucorrRenu
protected

◆ _focalDist

SLfloat SLCamera::_focalDist
protected

distance to lookAt point on the focal plane from lens

◆ _fogColor

SLCol4f SLCamera::_fogColor
protected

fog color blended to the final color

◆ _fogColorIsBack

SLbool SLCamera::_fogColorIsBack
protected

fog color blended to the final color

◆ _fogDensity

SLfloat SLCamera::_fogDensity
protected

Fog density for exponential modes.

◆ _fogEnd

SLfloat SLCamera::_fogEnd
protected

Fog end distance for linear mode.

◆ _fogIsOn

SLbool SLCamera::_fogIsOn
protected

Flag if fog blending is enabled.

◆ _fogMode

SLFogMode SLCamera::_fogMode
protected

0=LINEAR, 1=EXP, 2=EXP2

◆ _fogStart

SLfloat SLCamera::_fogStart
protected

Fog start distance for linear mode.

◆ _fovInit

SLfloat SLCamera::_fovInit
protected

Initial vertical field of view (view angle) in degrees.

◆ _fovV

SLfloat SLCamera::_fovV
protected

Current vertical field of view (view angle) in degrees.

◆ _fx

SLfloat SLCamera::_fx
protected

horizontal focal length

◆ _fy

SLfloat SLCamera::_fy
protected

vertical focal length

◆ _lensDiameter

SLfloat SLCamera::_lensDiameter
protected

Lens diameter.

◆ _lensSamples

SLRaySamples2D SLCamera::_lensSamples
protected

sample points for lens sampling (DOF)

◆ _maxSpeed

SLfloat SLCamera::_maxSpeed
protected

maximum speed in m/s, with high drag values this speed might not be achievable at all

◆ _moveAccel

SLfloat SLCamera::_moveAccel
protected

move acceleration

◆ _moveDir

SLVec3f SLCamera::_moveDir
protected

accumulated movement directions based on pressed buttons

◆ _movedLastFrame

SLbool SLCamera::_movedLastFrame
protected

◆ _oldTouchPos1

SLVec2f SLCamera::_oldTouchPos1
protected

Old mouse/touch position in pixels.

◆ _oldTouchPos2

SLVec2f SLCamera::_oldTouchPos2
protected

Old 2nd finger touch position in pixels.

◆ _onCamUpdateCB

function<void(SLSceneView* sv)> SLCamera::_onCamUpdateCB
protected

◆ _plane

SLPlane SLCamera::_plane[6]
protected

6 frustum planes (l, r, t, b, n, f)

◆ _projType

SLProjType SLCamera::_projType
protected

Projection type.

◆ _selectRect

SLRectf SLCamera::_selectRect
protected

Mouse selection rectangle. See SLMesh::handleRectangleSelection.

◆ _stereoColorFilter

SLMat3f SLCamera::_stereoColorFilter
protected

color filter matrix for anaglyphling is to adjust movement and stereo rendering correctly

◆ _stereoEye

SLint SLCamera::_stereoEye
protected

-1=left, 0=center, 1=right

◆ _stereoEyeSeparation

SLfloat SLCamera::_stereoEyeSeparation
protected

eye separation for stereo mode

◆ _trackballSize

SLfloat SLCamera::_trackballSize
protected

Size of trackball (0.8 = 80% of window size)

◆ _trackballStartVec

SLVec3f SLCamera::_trackballStartVec
protected

Trackball vector at mouse down.

◆ _unitScaling

SLfloat SLCamera::_unitScaling
protected

indicate what the current unit scale is

◆ _vao

SLGLVertexArrayExt SLCamera::_vao
protected

OpenGL Vertex array for rendering.

◆ _velocity

SLVec3f SLCamera::_velocity
protected

current velocity vector

◆ _viewport

SLRecti SLCamera::_viewport
protected

framebuffer rectangle

◆ _viewportRatio

SLfloat SLCamera::_viewportRatio
protected

viewport.width / viewport.height = screen ratio

◆ _xOffsetPix

SLint SLCamera::_xOffsetPix = 0
protected

parameter for manual finger rotation and translation

◆ _yOffsetPix

SLint SLCamera::_yOffsetPix = 0
protected

◆ currentAnimation

SLCamAnim SLCamera::currentAnimation = CA_turntableYUp
static

◆ currentDevRotation

SLint SLCamera::currentDevRotation = 0
static

◆ currentFOV

SLfloat SLCamera::currentFOV = 45.0f
static

◆ currentProjection

SLProjType SLCamera::currentProjection = P_monoPerspective
static

The documentation for this class was generated from the following files: