29 #include <Eigen/Dense> 78 start_mouse_pos = Eigen::Vector2f::Zero();
79 translation_vector = Eigen::Vector3f::Zero();
80 rotation_matrix = Eigen::Matrix3f::Identity();
81 default_translation = Eigen::Vector3f (0.0, 0.0, -2.0);
82 default_rotation = Eigen::Matrix3f::Identity();
83 rotation_X_axis = 0.0;
84 rotation_Y_axis = 0.0;
120 default_rotation = view.rotation();
121 default_translation = view.translation();
123 cout <<
"R = " << endl << default_rotation << endl << endl;
124 cout <<
"T = " << default_translation.transpose() << endl << endl;
146 Eigen::Affine3f rep_view_matrix = Eigen::Affine3f::Identity();
147 rep_view_matrix.translate( Eigen::Vector3f(1.0, -0.75, -5.0));
157 axes.
modelMatrix()->rotate(rotation_matrix.inverse());
159 axes.
render(cam, lightcam);
171 Eigen::Vector3f rotX = Eigen::AngleAxisf(rotation_Y_axis, Eigen::Vector3f::UnitY()) * Eigen::Vector3f::UnitX();
175 Eigen::Vector3f rotZ = Eigen::AngleAxisf(rotation_Y_axis, Eigen::Vector3f::UnitY()) * Eigen::Vector3f::UnitZ();
176 rotZ = Eigen::AngleAxisf(rotation_X_axis, rotX) * rotZ;
180 Eigen::Vector3f rotY = Eigen::AngleAxisf(rotation_X_axis, rotX) * Eigen::Vector3f::UnitY();
183 rotation_matrix.row(0) = rotX;
184 rotation_matrix.row(1) = rotY;
185 rotation_matrix.row(2) = rotZ;
198 Eigen::Vector3f dir = (Eigen::AngleAxisf(rotation_Y_axis, Eigen::Vector3f::UnitY())) * Eigen::Vector3f(1.0, 0.0, 0.0);
199 translation_vector += dir *
speed;
207 Eigen::Vector3f dir = (Eigen::AngleAxisf(rotation_Y_axis, Eigen::Vector3f::UnitY())) * Eigen::Vector3f(-1.0, 0.0, 0.0);
208 translation_vector += dir *
speed;
216 Eigen::Vector3f dir = (Eigen::AngleAxisf(rotation_Y_axis, Eigen::Vector3f::UnitY())) * Eigen::Vector3f(0.0, 0.0, -1.0);
217 translation_vector += dir *
speed;
225 Eigen::Vector3f dir = (Eigen::AngleAxisf(rotation_Y_axis, Eigen::Vector3f::UnitY())) * Eigen::Vector3f(0.0, 0.0, 1.0);
226 translation_vector += dir *
speed;
234 translation_vector += Eigen::Vector3f::UnitY() *
speed;
242 translation_vector -= Eigen::Vector3f::UnitY() *
speed;
269 virtual void rotate ( Eigen::Vector2f new_mouse_pos )
274 start_mouse_pos = new_position;
276 float anglex = -dir2d[1]*M_PI;
277 float angley = -dir2d[0]*M_PI;
279 rotation_X_axis += anglex;
280 rotation_Y_axis += angley;
282 if (rotation_X_axis > 2*M_PI)
283 rotation_X_axis -= 2*M_PI;
284 if (rotation_X_axis < 0)
285 rotation_X_axis += 2*M_PI;
286 if (rotation_Y_axis > 2*M_PI)
287 rotation_Y_axis -= 2*M_PI;
288 if (rotation_Y_axis < 0)
289 rotation_Y_axis += 2*M_PI;
297 virtual void rotateZ ( Eigen::Vector2f new_mouse_pos )
305 { this->speed =
speed; }
float rotation_Y_axis
Rotation angles.
Definition: flycamera.hpp:65
Eigen::Affine3f * modelMatrix(void)
Returns a pointer to the model matrix.
Definition: model.hpp:112
Eigen::Vector2f normalizePosition(const Eigen::Vector2f &pos)
Nomalizes a screen position to range [-1,1].
Definition: flycamera.hpp:250
Eigen::Matrix3f rotation_matrix
Camera rotation (view direction)
Definition: flycamera.hpp:53
Eigen::Vector3f translation_vector
Camera position.
Definition: flycamera.hpp:59
Definition: bufferobject.hpp:34
void setViewport(const Eigen::Vector4f &vp)
Sets the viewport coordinates.
Definition: camera.hpp:274
virtual void rotate(Eigen::Vector2f new_mouse_pos)
Rotates the camera view direction.
Definition: flycamera.hpp:269
Flythrough camera class for manipulating a camera.
Definition: flycamera.hpp:41
void render(const Tucano::Camera &camera, const Tucano::Camera &light)
Render camera representation.
Definition: coordinateaxes.hpp:67
float speed
Global movement speed.
Definition: flycamera.hpp:47
Visual representation of a 3D coordinate axes.
Definition: coordinateaxes.hpp:44
void setViewMatrix(const Eigen::Affine3f &mat)
Sets the view matrix from a given an affine 3x3 matrix.
Definition: camera.hpp:309
void initOpenGLMatrices(void)
Initializes the view and projection matrices. They are all initialized as Identity matrices...
Definition: flycamera.hpp:96
float rotation_X_axis
Definition: flycamera.hpp:66
void setProjectionMatrix(const Eigen::Matrix4f &mat)
Sets the projection matrix from a given 4x4 matrix.
Definition: camera.hpp:300
virtual void moveBack(void)
Translates the view matrix back.
Definition: flycamera.hpp:214
virtual void moveDown(void)
Translates the view matrix down.
Definition: flycamera.hpp:232
Eigen::Vector3f default_translation
Definition: flycamera.hpp:62
Eigen::Vector4f viewport
Viewport dimensions [minX, minY, width, height].
Definition: camera.hpp:48
virtual void moveForward(void)
Translates the view matrix forward.
Definition: flycamera.hpp:223
void resetModelMatrix(void)
Resets the model matrix.
Definition: model.hpp:159
~Flycamera()
Default destructor.
Definition: flycamera.hpp:89
Tucano::Shapes::CoordinateAxes axes
Definition: flycamera.hpp:69
Flycamera()
Default constructor.
Definition: flycamera.hpp:105
void setDefaultView(Eigen::Affine3f view)
Set default rotation and translation from and Affine3f matrix.
Definition: flycamera.hpp:118
virtual void moveUp(void)
Translates the view matrix up.
Definition: flycamera.hpp:240
virtual void strideLeft(void)
Translates the view matrix to the left.
Definition: flycamera.hpp:196
void setSpeed(const float &speed)
Changes the camera speed.
Definition: flycamera.hpp:304
virtual void rotateZ(Eigen::Vector2f new_mouse_pos)
Rotates the camera view direction around Z axis. Default implementation does nothing.
Definition: flycamera.hpp:297
void startRotation(Eigen::Vector2f pos)
Begin view direction rotation.
Definition: flycamera.hpp:260
Eigen::Vector2f start_mouse_pos
Current mouse position.
Definition: flycamera.hpp:50
static Eigen::Matrix4f createOrthographicMatrix(float left, float right, float bottom, float top, float near_plane, float far_plane)
Returns an orthographic projection matrix with the given parameters.
Definition: camera.hpp:438
virtual void strideRight(void)
Translates the view matrix to the right.
Definition: flycamera.hpp:205
Defines an abstract camera with a projection and view matrices.
Definition: camera.hpp:37
void resetViewMatrix(void)
Reset view matrix.
Definition: camera.hpp:88
virtual void updateViewMatrix()
Compose rotation and translation.
Definition: flycamera.hpp:166
virtual void reset(void)
Resets camera to initial position and orientation.
Definition: flycamera.hpp:76
Eigen::Vector3f getDefaultTranslation(void)
Returns the default translation for placing the camera outside the trackball sphere.
Definition: flycamera.hpp:131
Eigen::Matrix3f default_rotation
Default start rotation matrix.
Definition: flycamera.hpp:56
Eigen::Affine3f view_matrix
View, or extrinsic, matrix.
Definition: camera.hpp:45
void renderAtCorner(void)
Renders the camera's coordinate axis at the lower right corner of the screen.
Definition: flycamera.hpp:140