Privacy
An open-source, flexible 3D physical simulation framework
mars::graphics::GraphicsCamera Class Reference

#include <GraphicsCamera.h>

Public Types

enum  Direction { FORWARD, BACKWARD, LEFT, RIGHT }
 

Public Member Functions

 GraphicsCamera (osg::ref_ptr< osg::Camera > _camera, int width=720, int height=505)
 
 ~GraphicsCamera (void)
 
virtual void setFrustum (double left, double right, double bottom, double top, double near, double far)
 
virtual void setFrustumFromRad (double horizontalOpeningAngle, double verticalOpeningAngle, double near, double far)
 
virtual void getFrustum (std::vector< double > &frustum)
 
virtual void updateViewport (double rx, double ry, double tx, double ty, double tz, double rz=0, bool remember=0)
 
virtual void updateViewportQuat (double tx, double ty, double tz, double rx, double ry, double rz, double rw)
 
virtual void lookAtIso (double x, double y, double z=0)
 switches the camera to iso mode and looks at the given position(x, y) at the given height(z) More...
 
virtual void getViewport (double *rx, double *ry, double *tx, double *ty, double *tz, double *rz)
 
virtual void getViewportQuat (double *tx, double *ty, double *tz, double *rx, double *ry, double *rz, double *rw)
 
void setEyeSep (double value)
 
double getEyeSep (void) const
 
virtual void setCamera (int type)
 sets the camera type More...
 
virtual int getCameraType (void) const
 
virtual int getCamera (void) const
 
osg::ref_ptr< osg::Camera > getOSGCamera ()
 
utils::Vector getCameraPosition ()
 sets the camera view More...
 
void setCameraView (interfaces::cameraStruct cs)
 
virtual void getCameraInfo (interfaces::cameraStruct *s)
 returns the cameraStruct More...
 
void update (void)
 
void setViewport (int x, int y, int width, int height)
 
void eventStartPos (int x, int y)
 
void setKeyswitchManipulator (osg::ref_ptr< osgGA::KeySwitchMatrixManipulator > keyswitchManipulator)
 
void mouseDrag (int button, unsigned int modkey, int x, int y)
 
void move (bool isMoving, Direction dir)
 sets the camera motion state More...
 
void zoom (float speed)
 moves camera up and donwn in iso mode More...
 
virtual void changeCameraTypeToPerspective ()
 set camera type by context menu More...
 
virtual void changeCameraTypeToOrtho ()
 
void openSetCamViewport ()
 
void context_setCamPredefLeft ()
 
void context_setCamPredefRight ()
 
void context_setCamPredefFront ()
 
void context_setCamPredefRear ()
 
void context_setCamPredefTop ()
 
void context_setCamPredefBottom ()
 
void setStereoMode (bool _stereo)
 
void toggleStereoMode (void)
 
void setFocalLength (double value)
 
double getFocalLength (void) const
 
void setSwitchEye (bool val)
 
void setLeftEye (void)
 
void setRightEye (void)
 
void deactivateCam ()
 
void activateCam ()
 
void setPivot (osg::Vec3f p)
 
void toggleTrackball ()
 
void setupDistortion (osg::Texture2D *texture, osg::Image *image, osg::Group *mainScene, double factor)
 
- Public Member Functions inherited from mars::interfaces::GraphicsCameraInterface
virtual ~GraphicsCameraInterface ()
 

Private Member Functions

void calcEyeSep (void)
 
void moveForward (float speed)
 moves the camera forward with positive speed and backwards with negative speed More...
 
void moveRight (float speed)
 moves te camera left with positive speed and right with negative speed More...
 
osg::Vec3f getClickedPoint (int x, int y)
 

Private Attributes

interfaces::local_settingsl_settings
 
osg::ref_ptr< osg::Camera > mainCamera
 
osg::ref_ptr< osg::Camera > hudCamera
 
osg::Matrixd myCameraMatrix
 
osg::Matrixd cameraRotation
 
osg::Matrixd cameraTrans
 
osg::ref_ptr< osgGA::KeySwitchMatrixManipulator > keyswitchManipulator
 
osg::Vec3f pivot
 
int camera
 
int camType
 
int previousType
 
double actOrtH
 
int width
 
int height
 
int xpos
 
int ypos
 
int xrot
 
int yrot
 
double d_xp
 
double d_yp
 
double d_zp
 
double d_xr
 
double d_yr
 
double d_zr
 
double f_nearPlane
 
double f_farPlane
 
double f_aperture
 
double f_focal
 
double f_left [2]
 
double f_right [2]
 
double f_top
 
double f_bottom
 
double f_ratio
 
double f_win_ratio
 
double separation
 
double eyeSep
 
bool stereo
 
bool switch_eyes
 
short left
 
int nodeMask
 
bool isMovingForward
 
bool isMovingBack
 
bool isMovingLeft
 
bool isMovingRight
 
double isoMinHeight
 
double isoMaxHeight
 

Detailed Description

Definition at line 45 of file GraphicsCamera.h.

Member Enumeration Documentation

◆ Direction

Enumerator
FORWARD 
BACKWARD 
LEFT 
RIGHT 

Definition at line 54 of file GraphicsCamera.h.

Constructor & Destructor Documentation

◆ GraphicsCamera()

mars::graphics::GraphicsCamera::GraphicsCamera ( osg::ref_ptr< osg::Camera >  _camera,
int  width = 720,
int  height = 505 
)

Definition at line 49 of file GraphicsCamera.cpp.

◆ ~GraphicsCamera()

mars::graphics::GraphicsCamera::~GraphicsCamera ( void  )

Definition at line 117 of file GraphicsCamera.cpp.

Member Function Documentation

◆ activateCam()

void mars::graphics::GraphicsCamera::activateCam ( )
virtual

Implements mars::interfaces::GraphicsCameraInterface.

Definition at line 957 of file GraphicsCamera.cpp.

◆ calcEyeSep()

void mars::graphics::GraphicsCamera::calcEyeSep ( void  )
private

Definition at line 607 of file GraphicsCamera.cpp.

◆ changeCameraTypeToOrtho()

void mars::graphics::GraphicsCamera::changeCameraTypeToOrtho ( )
virtual

Implements mars::interfaces::GraphicsCameraInterface.

Definition at line 133 of file GraphicsCamera.cpp.

◆ changeCameraTypeToPerspective()

void mars::graphics::GraphicsCamera::changeCameraTypeToPerspective ( )
virtual

set camera type by context menu

Implements mars::interfaces::GraphicsCameraInterface.

Definition at line 121 of file GraphicsCamera.cpp.

◆ context_setCamPredefBottom()

void mars::graphics::GraphicsCamera::context_setCamPredefBottom ( )
virtual

Implements mars::interfaces::GraphicsCameraInterface.

Definition at line 592 of file GraphicsCamera.cpp.

◆ context_setCamPredefFront()

void mars::graphics::GraphicsCamera::context_setCamPredefFront ( )
virtual

Implements mars::interfaces::GraphicsCameraInterface.

Definition at line 581 of file GraphicsCamera.cpp.

◆ context_setCamPredefLeft()

void mars::graphics::GraphicsCamera::context_setCamPredefLeft ( )
virtual

Implements mars::interfaces::GraphicsCameraInterface.

Definition at line 573 of file GraphicsCamera.cpp.

◆ context_setCamPredefRear()

void mars::graphics::GraphicsCamera::context_setCamPredefRear ( )
virtual

Implements mars::interfaces::GraphicsCameraInterface.

Definition at line 585 of file GraphicsCamera.cpp.

◆ context_setCamPredefRight()

void mars::graphics::GraphicsCamera::context_setCamPredefRight ( )
virtual

Implements mars::interfaces::GraphicsCameraInterface.

Definition at line 577 of file GraphicsCamera.cpp.

◆ context_setCamPredefTop()

void mars::graphics::GraphicsCamera::context_setCamPredefTop ( )
virtual

Implements mars::interfaces::GraphicsCameraInterface.

Definition at line 588 of file GraphicsCamera.cpp.

◆ deactivateCam()

void mars::graphics::GraphicsCamera::deactivateCam ( )
virtual

Implements mars::interfaces::GraphicsCameraInterface.

Definition at line 952 of file GraphicsCamera.cpp.

◆ eventStartPos()

void mars::graphics::GraphicsCamera::eventStartPos ( int  x,
int  y 
)

Definition at line 904 of file GraphicsCamera.cpp.

◆ getCamera()

int mars::graphics::GraphicsCamera::getCamera ( void  ) const
virtual

Implements mars::interfaces::GraphicsCameraInterface.

Definition at line 940 of file GraphicsCamera.cpp.

◆ getCameraInfo()

void mars::graphics::GraphicsCamera::getCameraInfo ( interfaces::cameraStruct s)
virtual

returns the cameraStruct

Implements mars::interfaces::GraphicsCameraInterface.

Definition at line 334 of file GraphicsCamera.cpp.

◆ getCameraPosition()

Vector mars::graphics::GraphicsCamera::getCameraPosition ( )

sets the camera view

Definition at line 176 of file GraphicsCamera.cpp.

◆ getCameraType()

int mars::graphics::GraphicsCamera::getCameraType ( void  ) const
virtual

Implements mars::interfaces::GraphicsCameraInterface.

Definition at line 948 of file GraphicsCamera.cpp.

◆ getClickedPoint()

osg::Vec3f mars::graphics::GraphicsCamera::getClickedPoint ( int  x,
int  y 
)
private

Definition at line 702 of file GraphicsCamera.cpp.

◆ getEyeSep()

double mars::graphics::GraphicsCamera::getEyeSep ( void  ) const
virtual

Implements mars::interfaces::GraphicsCameraInterface.

Definition at line 620 of file GraphicsCamera.cpp.

◆ getFocalLength()

double mars::graphics::GraphicsCamera::getFocalLength ( void  ) const
virtual

Implements mars::interfaces::GraphicsCameraInterface.

Definition at line 935 of file GraphicsCamera.cpp.

◆ getFrustum()

void mars::graphics::GraphicsCamera::getFrustum ( std::vector< double > &  frustum)
virtual

Implements mars::interfaces::GraphicsCameraInterface.

Definition at line 412 of file GraphicsCamera.cpp.

◆ getOSGCamera()

osg::ref_ptr< osg::Camera > mars::graphics::GraphicsCamera::getOSGCamera ( )

Definition at line 944 of file GraphicsCamera.cpp.

◆ getViewport()

void mars::graphics::GraphicsCamera::getViewport ( double *  rx,
double *  ry,
double *  tx,
double *  ty,
double *  tz,
double *  rz 
)
virtual

Implements mars::interfaces::GraphicsCameraInterface.

Definition at line 550 of file GraphicsCamera.cpp.

◆ getViewportQuat()

void mars::graphics::GraphicsCamera::getViewportQuat ( double *  tx,
double *  ty,
double *  tz,
double *  rx,
double *  ry,
double *  rz,
double *  rw 
)
virtual

Implements mars::interfaces::GraphicsCameraInterface.

Definition at line 560 of file GraphicsCamera.cpp.

◆ lookAtIso()

void mars::graphics::GraphicsCamera::lookAtIso ( double  x,
double  y,
double  z = 0 
)
virtual

switches the camera to iso mode and looks at the given position(x, y) at the given height(z)

Implements mars::interfaces::GraphicsCameraInterface.

Definition at line 520 of file GraphicsCamera.cpp.

◆ mouseDrag()

void mars::graphics::GraphicsCamera::mouseDrag ( int  button,
unsigned int  modkey,
int  x,
int  y 
)

Definition at line 728 of file GraphicsCamera.cpp.

◆ move()

void mars::graphics::GraphicsCamera::move ( bool  isMoving,
GraphicsCamera::Direction  dir 
)

sets the camera motion state

Definition at line 638 of file GraphicsCamera.cpp.

◆ moveForward()

void mars::graphics::GraphicsCamera::moveForward ( float  speed)
private

moves the camera forward with positive speed and backwards with negative speed

Definition at line 656 of file GraphicsCamera.cpp.

◆ moveRight()

void mars::graphics::GraphicsCamera::moveRight ( float  speed)
private

moves te camera left with positive speed and right with negative speed

Definition at line 682 of file GraphicsCamera.cpp.

◆ openSetCamViewport()

void mars::graphics::GraphicsCamera::openSetCamViewport ( )

◆ setCamera()

void mars::graphics::GraphicsCamera::setCamera ( int  type)
virtual

sets the camera type

Implements mars::interfaces::GraphicsCameraInterface.

Definition at line 153 of file GraphicsCamera.cpp.

◆ setCameraView()

void mars::graphics::GraphicsCamera::setCameraView ( interfaces::cameraStruct  cs)

Definition at line 366 of file GraphicsCamera.cpp.

◆ setEyeSep()

void mars::graphics::GraphicsCamera::setEyeSep ( double  value)
virtual

Implements mars::interfaces::GraphicsCameraInterface.

Definition at line 596 of file GraphicsCamera.cpp.

◆ setFocalLength()

void mars::graphics::GraphicsCamera::setFocalLength ( double  value)
virtual

Implements mars::interfaces::GraphicsCameraInterface.

Definition at line 924 of file GraphicsCamera.cpp.

◆ setFrustum()

void mars::graphics::GraphicsCamera::setFrustum ( double  left,
double  right,
double  bottom,
double  top,
double  near,
double  far 
)
virtual

Implements mars::interfaces::GraphicsCameraInterface.

Definition at line 401 of file GraphicsCamera.cpp.

◆ setFrustumFromRad()

void mars::graphics::GraphicsCamera::setFrustumFromRad ( double  horizontalOpeningAngle,
double  verticalOpeningAngle,
double  near,
double  far 
)
virtual

Implements mars::interfaces::GraphicsCameraInterface.

Definition at line 387 of file GraphicsCamera.cpp.

◆ setKeyswitchManipulator()

void mars::graphics::GraphicsCamera::setKeyswitchManipulator ( osg::ref_ptr< osgGA::KeySwitchMatrixManipulator >  keyswitchManipulator)

Definition at line 909 of file GraphicsCamera.cpp.

◆ setLeftEye()

void mars::graphics::GraphicsCamera::setLeftEye ( void  )
inlinevirtual

Implements mars::interfaces::GraphicsCameraInterface.

Definition at line 120 of file GraphicsCamera.h.

◆ setPivot()

void mars::graphics::GraphicsCamera::setPivot ( osg::Vec3f  p)

Definition at line 963 of file GraphicsCamera.cpp.

◆ setRightEye()

void mars::graphics::GraphicsCamera::setRightEye ( void  )
inlinevirtual

Implements mars::interfaces::GraphicsCameraInterface.

Definition at line 121 of file GraphicsCamera.h.

◆ setStereoMode()

void mars::graphics::GraphicsCamera::setStereoMode ( bool  _stereo)
virtual

Implements mars::interfaces::GraphicsCameraInterface.

Definition at line 916 of file GraphicsCamera.cpp.

◆ setSwitchEye()

void mars::graphics::GraphicsCamera::setSwitchEye ( bool  val)
inlinevirtual

Implements mars::interfaces::GraphicsCameraInterface.

Definition at line 119 of file GraphicsCamera.h.

◆ setupDistortion()

void mars::graphics::GraphicsCamera::setupDistortion ( osg::Texture2D *  texture,
osg::Image *  image,
osg::Group *  mainScene,
double  factor 
)

Definition at line 977 of file GraphicsCamera.cpp.

◆ setViewport()

void mars::graphics::GraphicsCamera::setViewport ( int  x,
int  y,
int  width,
int  height 
)
virtual

Implements mars::interfaces::GraphicsCameraInterface.

Definition at line 325 of file GraphicsCamera.cpp.

◆ toggleStereoMode()

void mars::graphics::GraphicsCamera::toggleStereoMode ( void  )
virtual

Implements mars::interfaces::GraphicsCameraInterface.

Definition at line 920 of file GraphicsCamera.cpp.

◆ toggleTrackball()

void mars::graphics::GraphicsCamera::toggleTrackball ( )
virtual

Implements mars::interfaces::GraphicsCameraInterface.

Definition at line 143 of file GraphicsCamera.cpp.

◆ update()

void mars::graphics::GraphicsCamera::update ( void  )

Definition at line 181 of file GraphicsCamera.cpp.

◆ updateViewport()

void mars::graphics::GraphicsCamera::updateViewport ( double  rx,
double  ry,
double  tx,
double  ty,
double  tz,
double  rz = 0,
bool  remember = 0 
)
virtual

Implements mars::interfaces::GraphicsCameraInterface.

Definition at line 428 of file GraphicsCamera.cpp.

◆ updateViewportQuat()

void mars::graphics::GraphicsCamera::updateViewportQuat ( double  tx,
double  ty,
double  tz,
double  rx,
double  ry,
double  rz,
double  rw 
)
virtual

Implements mars::interfaces::GraphicsCameraInterface.

Definition at line 479 of file GraphicsCamera.cpp.

◆ zoom()

void mars::graphics::GraphicsCamera::zoom ( float  speed)

moves camera up and donwn in iso mode

Definition at line 624 of file GraphicsCamera.cpp.

Member Data Documentation

◆ actOrtH

double mars::graphics::GraphicsCamera::actOrtH
private

Definition at line 142 of file GraphicsCamera.h.

◆ camera

int mars::graphics::GraphicsCamera::camera
private

Definition at line 140 of file GraphicsCamera.h.

◆ cameraRotation

osg::Matrixd mars::graphics::GraphicsCamera::cameraRotation
private

Definition at line 136 of file GraphicsCamera.h.

◆ cameraTrans

osg::Matrixd mars::graphics::GraphicsCamera::cameraTrans
private

Definition at line 137 of file GraphicsCamera.h.

◆ camType

int mars::graphics::GraphicsCamera::camType
private

Definition at line 141 of file GraphicsCamera.h.

◆ d_xp

double mars::graphics::GraphicsCamera::d_xp
private

Definition at line 146 of file GraphicsCamera.h.

◆ d_xr

double mars::graphics::GraphicsCamera::d_xr
private

Definition at line 146 of file GraphicsCamera.h.

◆ d_yp

double mars::graphics::GraphicsCamera::d_yp
private

Definition at line 146 of file GraphicsCamera.h.

◆ d_yr

double mars::graphics::GraphicsCamera::d_yr
private

Definition at line 146 of file GraphicsCamera.h.

◆ d_zp

double mars::graphics::GraphicsCamera::d_zp
private

Definition at line 146 of file GraphicsCamera.h.

◆ d_zr

double mars::graphics::GraphicsCamera::d_zr
private

Definition at line 146 of file GraphicsCamera.h.

◆ eyeSep

double mars::graphics::GraphicsCamera::eyeSep
private

Definition at line 152 of file GraphicsCamera.h.

◆ f_aperture

double mars::graphics::GraphicsCamera::f_aperture
private

Definition at line 147 of file GraphicsCamera.h.

◆ f_bottom

double mars::graphics::GraphicsCamera::f_bottom
private

Definition at line 148 of file GraphicsCamera.h.

◆ f_farPlane

double mars::graphics::GraphicsCamera::f_farPlane
private

Definition at line 147 of file GraphicsCamera.h.

◆ f_focal

double mars::graphics::GraphicsCamera::f_focal
private

Definition at line 147 of file GraphicsCamera.h.

◆ f_left

double mars::graphics::GraphicsCamera::f_left[2]
private

Definition at line 148 of file GraphicsCamera.h.

◆ f_nearPlane

double mars::graphics::GraphicsCamera::f_nearPlane
private

Definition at line 147 of file GraphicsCamera.h.

◆ f_ratio

double mars::graphics::GraphicsCamera::f_ratio
private

Definition at line 149 of file GraphicsCamera.h.

◆ f_right

double mars::graphics::GraphicsCamera::f_right[2]
private

Definition at line 148 of file GraphicsCamera.h.

◆ f_top

double mars::graphics::GraphicsCamera::f_top
private

Definition at line 148 of file GraphicsCamera.h.

◆ f_win_ratio

double mars::graphics::GraphicsCamera::f_win_ratio
private

Definition at line 150 of file GraphicsCamera.h.

◆ height

int mars::graphics::GraphicsCamera::height
private

Definition at line 143 of file GraphicsCamera.h.

◆ hudCamera

osg::ref_ptr<osg::Camera> mars::graphics::GraphicsCamera::hudCamera
private

Definition at line 134 of file GraphicsCamera.h.

◆ isMovingBack

bool mars::graphics::GraphicsCamera::isMovingBack
private

Definition at line 159 of file GraphicsCamera.h.

◆ isMovingForward

bool mars::graphics::GraphicsCamera::isMovingForward
private

Definition at line 159 of file GraphicsCamera.h.

◆ isMovingLeft

bool mars::graphics::GraphicsCamera::isMovingLeft
private

Definition at line 159 of file GraphicsCamera.h.

◆ isMovingRight

bool mars::graphics::GraphicsCamera::isMovingRight
private

Definition at line 159 of file GraphicsCamera.h.

◆ isoMaxHeight

double mars::graphics::GraphicsCamera::isoMaxHeight
private

Definition at line 161 of file GraphicsCamera.h.

◆ isoMinHeight

double mars::graphics::GraphicsCamera::isoMinHeight
private

Definition at line 161 of file GraphicsCamera.h.

◆ keyswitchManipulator

osg::ref_ptr<osgGA::KeySwitchMatrixManipulator> mars::graphics::GraphicsCamera::keyswitchManipulator
private

Definition at line 138 of file GraphicsCamera.h.

◆ l_settings

interfaces::local_settings* mars::graphics::GraphicsCamera::l_settings
private

Definition at line 131 of file GraphicsCamera.h.

◆ left

short mars::graphics::GraphicsCamera::left
private

Definition at line 155 of file GraphicsCamera.h.

◆ mainCamera

osg::ref_ptr<osg::Camera> mars::graphics::GraphicsCamera::mainCamera
private

Definition at line 133 of file GraphicsCamera.h.

◆ myCameraMatrix

osg::Matrixd mars::graphics::GraphicsCamera::myCameraMatrix
private

Definition at line 135 of file GraphicsCamera.h.

◆ nodeMask

int mars::graphics::GraphicsCamera::nodeMask
private

Definition at line 156 of file GraphicsCamera.h.

◆ pivot

osg::Vec3f mars::graphics::GraphicsCamera::pivot
private

Definition at line 139 of file GraphicsCamera.h.

◆ previousType

int mars::graphics::GraphicsCamera::previousType
private

Definition at line 141 of file GraphicsCamera.h.

◆ separation

double mars::graphics::GraphicsCamera::separation
private

Definition at line 151 of file GraphicsCamera.h.

◆ stereo

bool mars::graphics::GraphicsCamera::stereo
private

Definition at line 153 of file GraphicsCamera.h.

◆ switch_eyes

bool mars::graphics::GraphicsCamera::switch_eyes
private

Definition at line 154 of file GraphicsCamera.h.

◆ width

int mars::graphics::GraphicsCamera::width
private

Definition at line 143 of file GraphicsCamera.h.

◆ xpos

int mars::graphics::GraphicsCamera::xpos
private

Definition at line 145 of file GraphicsCamera.h.

◆ xrot

int mars::graphics::GraphicsCamera::xrot
private

Definition at line 145 of file GraphicsCamera.h.

◆ ypos

int mars::graphics::GraphicsCamera::ypos
private

Definition at line 145 of file GraphicsCamera.h.

◆ yrot

int mars::graphics::GraphicsCamera::yrot
private

Definition at line 145 of file GraphicsCamera.h.


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