/usr/include/tulip/Camera.h is in libtulip-dev 4.8.0dfsg-2build2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 | /*
*
* This file is part of Tulip (www.tulip-software.org)
*
* Authors: David Auber and the Tulip development Team
* from LaBRI, University of Bordeaux
*
* Tulip is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation, either version 3
* of the License, or (at your option) any later version.
*
* Tulip is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details.
*
*/
#ifndef TLPCAMERA_H
#define TLPCAMERA_H
#include <tulip/Coord.h>
#include <tulip/Matrix.h>
#include <tulip/BoundingBox.h>
#include <tulip/Observable.h>
namespace tlp {
class GlScene;
/**
* \ingroup OpenGL
* \brief 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 parameters with setSceneRadius, setZoomFactor, setEyes, setCenter and setUp
* - You can transform viewport coordinates to 3D world coordinates with viewportTo3DWorld() function and 3D world coordinates to viewport coordinates with worldTo2DViewport() function
* A camera is a main component of GlLayer and GlScene
* @see GlLayer
* @see GlScene
*/
class TLP_GL_SCOPE Camera : public Observable {
public:
/**
* @brief Constructor
* @param scene A layer is attached to a scene so we have to specify it in the constructor
* @param center 3D coordinates of point visualized by the camera
* @param eye 3D position of the camera
* @param up normalized up 3D coordinates of the camera
* @param zoomFactor level of zoom of the camera
* @param sceneRadius scene radius of the 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);
/**
* @brief Constructor : used to create a 2D camera
*/
Camera(GlScene* scene,bool d3);
Camera& operator=(const Camera& camera);
/**
* @brief Destructor
*/
~Camera();
/**
* @brief Set the camera's scene
* The viewport is store in the scene, so we must attach camera to a scene
*/
void setScene(GlScene *scene);
/**
* @brief Return the camera's scene
*/
GlScene *getScene() const {
return scene;
}
/**
* @brief Load this camera parameters (eye, center, zoom factor) with an other camera parameters
*/
void loadCameraParametersWith(const Camera &camera) {
*this=camera;
}
/**
* @brief Return the camera bounding box
*
* This bounding box is the part of the scene visualized by this camera.
*/
BoundingBox getBoundingBox() const;
/**
* @brief This function moves the camera forward or backward depending on the speed
*/
void move(float speed);
/**
* @brief This function strafes the camera left and right depending on the speed (-/+)
*/
void strafeLeftRight(float speed);
/**
* @brief This function strafes the camera up and down depending on the speed (-/+)
*/
void strafeUpDown(float speed);
/**
* @brief This function rotates the camera's eyes around the center depending on the values passed in.
*/
void rotate(float angle, float x, float y, float z);
/**
* @brief Return if the camera is a 3D one
*/
bool is3D() const {
return d3;
}
/**
* @brief Return the viewport of the attached scene
*/
Vector<int, 4> getViewport() const;
/**
* @brief Return the scene radius
*/
double getSceneRadius() const {
return sceneRadius;
}
/**
* @brief Set the zoom factor
*
* level of zoom of the camera
*/
void setZoomFactor(double zoomFactor);
/**
* @brief Return the zoom factor
*
* level of zoom of the camera
*/
double getZoomFactor() const {
return zoomFactor;
}
/**
* @brief Set the eye
*
* 3D position of the camera
*/
void setEyes(const Coord& eyes);
/**
* @brief Return the eyes
*
* 3D position of the camera
*/
Coord getEyes() const {
return eyes;
}
/**
* @brief Set the center
*
* 3D coordinates of point visualized by the camera
*/
void setCenter(const Coord& center);
/**
* @brief Return the center
*
* 3D coordinates of point visualized by the camera
*/
Coord getCenter() const {
return center;
}
/**
* @brief Set the up vector
*
* normalized up 3D coordinates of the camera
*/
void setUp(const Coord& up);
/**
* @brief Return the up vector
*
* normalized up 3D coordinates of the camera
*/
Coord getUp() const {
return up;
}
/**
* @brief Return the 3D world coordinate for the given viewport point
* \warning This function set up the projection and modelview matrix
*/
Coord viewportTo3DWorld(const Coord &point) const;
/**
* @brief Return the 3D world coordinate for the given viewport point
* \warning This function set up the projection and modelview matrix
*/
Coord screenTo3DWorld(const Coord &point) const {
return viewportTo3DWorld(point);
}
/**
* @brief Return the viewport position for the given 3D coordinate
* \warning This function set up the projection and modelview matrix
*/
Coord worldTo2DViewport(const Coord &obj) const;
/**
* @brief Return the viewport position for the given 3D coordinate
* \warning This function set up the projection and modelview matrix
*/
Coord worldTo2DScreen(const Coord &obj) const {
return worldTo2DViewport(obj);
}
/**
* @brief Function to export data in outString (in XML format)
*/
virtual void getXML(std::string &outString);
/**
* @brief Function to set data with inString (in XML format)
*/
virtual void setWithXML(const std::string &inString, unsigned int ¤tPosition);
///@cond DOXYGEN_HIDDEN
/**
* Get the modelview matrix
*/
void getModelviewMatrix(Matrix<float, 4> &modelviewMatrix) const {
modelviewMatrix=this->modelviewMatrix;
}
/**
* Get the projection matrix
*/
void getProjectionMatrix(Matrix<float, 4> &projectionMatrix) const {
projectionMatrix=this->projectionMatrix;
}
/**
* Get the transform matrix : transformMatrix = projectionMatrix * modelviewMatrix
*/
void getTransformMatrix(Matrix<float, 4> &transformMatrix) const {
transformMatrix=this->transformMatrix;
}
/**
* Get the projection and the modelview matrix generated with the given viewport
*/
void getProjAndMVMatrix(const Vector<int, 4>& viewport,Matrix<float, 4> &projectionMatrix,Matrix<float, 4> &modelviewMatrix) const;
/**
* Get the transform matrix generated with the given viewport
*/
void getTransformMatrix(const Vector<int, 4>& viewport,Matrix<float, 4> &transformMatrix) const;
/**
* @brief Init Gl parameters
*/
void initGl();
/**
* @brief Init light
*/
void initLight();
/**
* @brief Init projection with the gived viewport. Load identity matrix if reset is set as true
*/
void initProjection(const Vector<int, 4>& viewport,bool reset=true);
/**
* @brief Init projection with the scene viewport. Load identity matrix if reset is set as true
*/
void initProjection(bool reset=true);
/**
* @brief Init modelview
*/
void initModelView();
/**
* @brief Set the scene radius
*/
void setSceneRadius(double sceneRadius,const BoundingBox sceneBoundingBox=BoundingBox());
///@endcond
private:
bool matrixCoherent;
Coord center,eyes,up;
double zoomFactor;
double sceneRadius;
BoundingBox sceneBoundingBox;
GlScene* scene;
Matrix<float, 4> modelviewMatrix;
Matrix<float, 4> projectionMatrix;
Matrix<float, 4> transformMatrix;
bool d3;
};
}
#endif
|