Overview | Modules | Class Hierarchy | Classes | Members

Public Member Functions
tlp::Camera Class Reference

Tulip OpenGL camera object. More...

`#include <Camera.h>`

Collaboration diagram for tlp::Camera:
[legend]

List of all members.

## Public Member Functions

- Camera (GlScene *scene, Coord center=Coord(0, 0, 0), Coord eyes=Coord(0, 0, 10), Coord up=Coord(0,-1, 0), double zoomFactor=0.5, double sceneRadius=10)
- Camera (GlScene *scene, bool d3)
- Camera & operator= (const Camera &camera)
- ~Camera ()
- void setScene (GlScene *scene)
- GlScene * getScene () const
- void move (float speed)
- void strafeLeftRight (float speed)
- void strafeUpDown (float speed)
- void rotate (float angle, float x, float y, float z)
- bool is3D () const
- Vector< int, 4 > getViewport () const
- void initGl ()
- void initLight ()
- void initProjection (const Vector< int, 4 > &viewport, bool reset=true)
- void initProjection (bool reset=true)
- void initModelView ()
- void setSceneRadius (double sceneRadius, const BoundingBox sceneBoundingBox=BoundingBox())
- double getSceneRadius () const
- void setZoomFactor (double zoomFactor)
- double getZoomFactor () const
- void setEyes (const Coord &eyes)
- Coord getEyes () const
- void setCenter (const Coord &center)
- Coord getCenter () const
- void setUp (const Coord &up)
- Coord getUp () const
- void addObjectTransformation (const Coord &translation, const Coord &scale, const Coord &baseCoord)
- void getObjectTransformation (std::vector< Coord > &translation, std::vector< Coord > &scale, std::vector< Coord > &objectCoord)
- bool haveObjectTransformation ()
- void getModelviewMatrix (Matrix< float, 4 > &modelviewMatrix) const
- void getProjectionMatrix (Matrix< float, 4 > &projectionMatrix) const
- void getTransformMatrix (Matrix< float, 4 > &transformMatrix) const
- void getProjAndMVMatrix (const Vector< int, 4 > &viewport, Matrix< float, 4 > &projectionMatrix, Matrix< float, 4 > &modelviewMatrix) const
- void getTransformMatrix (const Vector< int, 4 > &viewport, Matrix< float, 4 > &transformMatrix) const
- Coord screenTo3DWorld (const Coord &point) const
- Coord worldTo2DScreen (const Coord &obj) const
- void getXML (xmlNodePtr rootNode)
- void setWithXML (xmlNodePtr rootNode)

## Detailed Description

Tulip OpenGL camera object.

This camera can be a 2D or 3D camera After setup you can do some basic operation :

- Move, rotate, strafeLeftRight and strafeUpDown to modify poitn of view
- You can directly modify camera infor mation with setSceneRadius, setZoomFactor, setEyes, setCenter and setUp
- You can transform screen coordinates to 3D world coordinates with screenTo3DWorld function and vise versa with worldTo2DScreen function

## Constructor & Destructor Documentation

tlp::Camera::Camera | ( | GlScene * | scene,
|  | Coord | center = `Coord(0, 0, 0)`,
|  | Coord | eyes = `Coord(0, 0, 10)`,
|  | Coord | up = `Coord(0,-1, 0)`,
|  | double | zoomFactor = `0.5`,
|  | double | sceneRadius = `10`
| ) |  |

Constructor

tlp::Camera::Camera | ( | GlScene * | scene,
|  | bool | d3
| ) |  |

Constructor : use for 2D camera

tlp::Camera::~Camera | ( |  | ) |

Destructor

## Member Function Documentation

void tlp::Camera::addObjectTransformation | ( | const Coord & | translation,
|  | const Coord & | scale,
|  | const Coord & | baseCoord
| ) |  |

Set translate/scale transformation of object It use to compute lod of nodes/edges in metanodes

Coord tlp::Camera::getCenter | ( |  | ) | const`[inline]`

Return the center

Coord tlp::Camera::getEyes | ( |  | ) | const`[inline]`

Return the eyes

void tlp::Camera::getModelviewMatrix | ( | Matrix< float, 4 > & | modelviewMatrix | ) | const`[inline]`

Get the modelview matrix

void tlp::Camera::getObjectTransformation | ( | std::vector< Coord > & | translation,
|  | std::vector< Coord > & | scale,
|  | std::vector< Coord > & | objectCoord
| ) |  |

Get translate/scale transformation of object It use to compute lod of nodes/edges in metanodes

void tlp::Camera::getProjAndMVMatrix | ( | const Vector< int, 4 > & | viewport,
|  | Matrix< float, 4 > & | projectionMatrix,
|  | Matrix< float, 4 > & | modelviewMatrix
| ) |  | const

Get the projection and the modelview matrix generated with the given viewport

void tlp::Camera::getProjectionMatrix | ( | Matrix< float, 4 > & | projectionMatrix | ) | const`[inline]`

Get the projection matrix

GlScene* tlp::Camera::getScene | ( |  | ) | const`[inline]`

Return the camera's scene

double tlp::Camera::getSceneRadius | ( |  | ) | const`[inline]`

Return the scene radius

void tlp::Camera::getTransformMatrix | ( | const Vector< int, 4 > & | viewport,
|  | Matrix< float, 4 > & | transformMatrix
| ) |  | const

Get the transform matrix generated with the given viewport

void tlp::Camera::getTransformMatrix | ( | Matrix< float, 4 > & | transformMatrix | ) | const`[inline]`

Get the transform matrix : transformMatrix = projectionMatrix * modelviewMatrix

Coord tlp::Camera::getUp | ( |  | ) | const`[inline]`

Return the up vector

Vector<int, 4> tlp::Camera::getViewport | ( |  | ) | const

Return the viewport of the attached scene

void tlp::Camera::getXML | ( | xmlNodePtr | rootNode | ) |

Get the camera's data in XML form

double tlp::Camera::getZoomFactor | ( |  | ) | const`[inline]`

Return the zoom factor

bool tlp::Camera::haveObjectTransformation | ( |  | ) |

Return true if object transformation is set

void tlp::Camera::initGl | ( |  | ) |

Init Gl parameters

void tlp::Camera::initLight | ( |  | ) |

Init light

void tlp::Camera::initModelView | ( |  | ) |

Init modelview

void tlp::Camera::initProjection | ( | bool | reset = `true` | ) |

Init projection with the scene viewport. Load identity matrix if reset is set as true

void tlp::Camera::initProjection | ( | const Vector< int, 4 > & | viewport,
|  | bool | reset = `true`
| ) |  |

Init projection with the gived viewport. Load identity matrix if reset is set as true

bool tlp::Camera::is3D | ( |  | ) | const`[inline]`

Return if the camera is a 3D one

void tlp::Camera::move | ( | float | speed | ) |

This moves the camera forward or backward depending on the speed

Camera& tlp::Camera::operator= | ( | const Camera & | camera | ) |

void tlp::Camera::rotate | ( | float | angle,
|  | float | x,
|  | float | y,
|  | float | z
| ) |  |

This rotates the camera's eyes around the center depending on the values passed in.

Coord tlp::Camera::screenTo3DWorld | ( | const Coord & | point | ) | const

Return the 3D world coordinate for the given screen point

Warning:
  This function set up the projection and modelview matrix

void tlp::Camera::setCenter | ( | const Coord & | center | ) |

Set the center

void tlp::Camera::setEyes | ( | const Coord & | eyes | ) |

Set the eye

void tlp::Camera::setScene | ( | GlScene * | scene | ) |

Set the camera's scene : the viewport is store in the scene, so we must attach camera to a scene

void tlp::Camera::setSceneRadius | ( | double | sceneRadius,
|  | const BoundingBox | sceneBoundingBox = `BoundingBox()`
| ) |  |

Set the scene radius

void tlp::Camera::setUp | ( | const Coord & | up | ) |

Set the up vector

void tlp::Camera::setWithXML | ( | xmlNodePtr | rootNode | ) |

Set the camera's data with XML

void tlp::Camera::setZoomFactor | ( | double | zoomFactor | ) |

Set the zoom factor

void tlp::Camera::strafeLeftRight | ( | float | speed | ) |

This strafes the camera left and right depending on the speed (-/+)

void tlp::Camera::strafeUpDown | ( | float | speed | ) |

This strafes the camera up and down depending on the speed (-/+)

Coord tlp::Camera::worldTo2DScreen | ( | const Coord & | obj | ) | const

Return the screen position for the given 3D coordinate

Warning:
  This function set up the projection and modelview matrix

Tulip Software by LaBRI Visualization Team 2001 - 2012