29 #include <Eigen/Dense> 39 "out vec4 out_Color;\n" 43 " out_Color = ex_Color;\n" 44 " gl_FragDepth = depth;\n" 50 "layout(location=0) in vec4 in_Position;\n" 51 "out vec4 ex_Color;\n" 53 "uniform mat4 modelMatrix;\n" 54 "uniform mat4 viewMatrix;\n" 55 "uniform mat4 projectionMatrix;\n" 56 "uniform vec4 in_Color;\n" 57 "uniform float nearPlane;\n" 58 "uniform float farPlane;\n" 61 " vec4 pos = (viewMatrix * modelMatrix) * in_Position;\n" 62 " depth = (farPlane+nearPlane)/(farPlane-nearPlane) + ( (2*nearPlane*farPlane)/(farPlane-nearPlane) ) * (1/pos[2]);\n" 63 " depth = (depth+1.0)/2.0;\n" 64 " gl_Position = projectionMatrix * pos;\n" 65 " ex_Color = in_Color;\n" 144 if (shader_dir.empty())
147 use_default_shaders =
true;
151 trackball_shader.
load(
"trackballShader", shader_dir);
152 use_default_shaders =
false;
170 quaternion = Eigen::Quaternion<float>::Identity();
171 default_quaternion = Eigen::Quaternion<float>::Identity();
173 translationVector << 0.0, 0.0, 0.0;
213 default_translation = t;
242 default_quaternion = rot;
271 trackballProjectionMatrix = mat;
301 drawTrackball = flag;
307 if (use_default_shaders)
328 Eigen::Vector2f p = pos;
332 if(p[0]*p[0] + p[1]*p[1] <= (r*r)/2.0) {
333 z = sqrt(r*r - p[0]*p[0] - p[1]*p[1]);
338 z = (r*r)/(2.0*sqrt(p[0]*p[0] + p[1]*p[1]));
341 Eigen::Vector3f position = Eigen::Vector3f(p[0], p[1], z);
360 trackballProjectionMatrix = Eigen::Matrix4f::Identity();
404 if(initialPosition.norm() > 0) {
405 initialPosition.normalize();
407 if(finalPosition.norm() > 0) {
408 finalPosition.normalize();
411 Eigen::Vector3f rotationAxis = initialPosition.cross(finalPosition);
413 if(rotationAxis.norm() != 0) {
414 rotationAxis.normalize();
417 float dot = initialPosition.dot(finalPosition);
419 float rotationAngle = (dot <= 1) ? acos(dot) : 0;
421 rotationAngle *= sensibility;
422 Eigen::Quaternion<float> q (Eigen::AngleAxis<float>(rotationAngle,rotationAxis));
424 quaternion.normalize();
434 Eigen::Vector3f inc = quaternion.inverse() * Eigen::Vector3f(translationFactor[0],translationFactor[1], 0.0);
436 translationVector += inc;
447 return Eigen::Vector2f ((2.0*pos[0]/(
viewport[2])) - 1.0,
455 virtual Eigen::Quaternion<float>
rotateCamera (
const Eigen::Vector2f& pos)
459 Eigen::Quaternion<float> increment = Eigen::Quaternion<float>::Identity();
464 initialPosition = normalized_pos;
466 else if ( pos != initialPosition.head(2))
468 finalPosition = normalized_pos;
484 Eigen::Vector3f increment = Eigen::Vector3f::Zero();
488 initialTranslationPosition = normalized_pos;
490 else if (pos != initialPosition.head(2))
492 finalTranslationPosition = normalized_pos;
542 translationVector += translation;
553 Eigen::Quaternion<float> q (rot.rotation().matrix());
555 quaternion.normalize();
565 rotate(default_quaternion);
578 vector < Eigen::Vector4f > vertices;
580 for (
float theta = 0; theta<2*M_PI; theta += (2*M_PI)/200.0)
582 vertices.push_back ( Eigen::Vector4f (cos(theta), sin(theta), 0.0, 1.0) );
596 virtual void render (Eigen::Affine3f ext_view_matrix = Eigen::Affine3f::Identity(), Eigen::Matrix4f ext_proj_matrix = Eigen::Matrix4f::Identity())
604 if (ext_proj_matrix != Eigen::Matrix4f::Identity())
605 trackballProjectionMatrix = ext_proj_matrix;
607 trackball_shader.
bind();
610 Eigen::Affine3f trackballViewMatrix = ext_view_matrix;
611 trackballViewMatrix.translate(default_translation);
612 trackballViewMatrix.rotate(quaternion);
613 trackballViewMatrix.scale(radius);
614 trackball_shader.
setUniform(
"viewMatrix", trackballViewMatrix);
615 trackball_shader.
setUniform(
"projectionMatrix", trackballProjectionMatrix);
622 Eigen::Vector4f color_vector(1.0, 0.0, 0.0, 1.0);
623 trackball_shader.
setUniform(
"modelMatrix", Eigen::Affine3f::Identity()*Eigen::AngleAxis<float>(M_PI/2.0,Eigen::Vector3f(0.0,1.0,0.0)));
624 trackball_shader.
setUniform(
"in_Color", color_vector);
628 color_vector << 0.0, 1.0, 0.0, 1.0;
629 trackball_shader.
setUniform(
"modelMatrix", Eigen::Affine3f::Identity()*Eigen::AngleAxis<float>(M_PI/2.0,Eigen::Vector3f(1.0,0.0,0.0)));
630 trackball_shader.
setUniform(
"in_Color", color_vector);
634 color_vector << 0.0, 0.0, 1.0, 1.0;
635 trackball_shader.
setUniform(
"modelMatrix", Eigen::Affine3f::Identity());
636 trackball_shader.
setUniform(
"in_Color", color_vector);
641 trackball_shader.
unbind();
670 if(initialPosition.norm() > 0) {
671 initialPosition.normalize();
673 if(finalPosition.norm() > 0) {
674 finalPosition.normalize();
681 ini << initialPosition[0], 0.0, initialPosition[2];
683 fin << finalPosition[0], 0.0, finalPosition[2];
686 angle = (dot <= 1) ? acos(dot) : 0;
687 if (initialPosition[0] > finalPosition[0])
689 angle *= sensibility;
690 Eigen::Quaternion<float> qx (Eigen::AngleAxis<float>(angle, Eigen::Vector3f::UnitY()));
692 ini << 0.0, initialPosition[1], initialPosition[2];
694 fin << 0.0, finalPosition[1], finalPosition[2];
697 angle = (dot <= 1) ? acos(dot) : 0;
698 if (initialPosition[1] < finalPosition[1])
700 angle *= sensibility;
701 Eigen::Quaternion<float> qy (Eigen::AngleAxis<float>(angle, Eigen::Vector3f::UnitX()));
703 quaternion_h = qx * quaternion_h;
704 quaternion_v = qy * quaternion_v;
705 quaternion_h.normalize();
706 quaternion_v.normalize();
708 quaternion = quaternion_h * quaternion_v;
709 quaternion.normalize();
720 arrow.
setColor(Eigen::Vector4f(0.8, 0.8, 0.2, 1.0));
721 quaternion_h = Eigen::Quaternion<float>::Identity();
722 quaternion_v = Eigen::Quaternion<float>::Identity();
746 Eigen::Affine3f rep_view_matrix = Eigen::Affine3f::Identity();
747 rep_view_matrix.translate( Eigen::Vector3f(1.0, 0.75, -5.0));
756 lightcam.
viewMatrix()->translate(Eigen::Vector3f(0.0, 0.0, -3.0));
762 arrow.
modelMatrix()->translate(default_translation);
769 arrow.
modelMatrix()->rotate ( Eigen::AngleAxis<float>(M_PI, Eigen::Vector3f::UnitY()));
773 arrow.
render(ext_camera, lightcam);
775 arrow.
render(rep_camera, lightcam);
816 Eigen::Vector3f sphere_position = Eigen::Vector3f::Zero();
825 default_translation = Eigen::Vector3f::Zero();
834 return sphere_position;
843 sphere_position = pos;
855 external_camera = ext_cam;
879 Eigen::Vector3f sphere_center = (
view_matrix * Eigen::Vector4f(0.0, 0.0, 0.0, 1.0)).head(3);
881 Eigen::Vector3f ray_origin = external_camera->getCenter();
883 Eigen::Vector3f ray_direction =
Tucano::Math::rayDirection(finalTranslationPosition, external_camera->getViewportSize(), external_camera->getProjectionMatrix(), external_camera->getViewMatrix());
886 Eigen::Vector3f normal = external_camera->getViewMatrix().rotation().inverse()*Eigen::Vector3f::UnitZ();
888 Eigen::Vector3f inc = Eigen::Vector3f::Zero();
891 inc = sphere_position - sphere_center;
892 translationVector += inc;
906 Eigen::Vector3f increment = Eigen::Vector3f::Zero();
912 initialTranslationPosition = pos;
914 else if (pos != initialPosition.head(2))
916 finalTranslationPosition = pos;
929 if (!external_camera)
952 Eigen::Vector3f last_position = Eigen::Vector3f::Zero();
955 Eigen::Vector3f sphere_position = Eigen::Vector3f::Zero();
958 float inner_radius = 1.0;
961 float outer_radius = 1.3;
964 int selected_axis = -1;
966 Eigen::Vector3f selected_normal = Eigen::Vector3f::Zero();
972 Eigen::Vector3f ray_direction =
Tucano::Math::rayDirection(pixel, external_camera->getViewportSize(), external_camera->getProjectionMatrix(), external_camera->getViewMatrix());
973 Eigen::Vector3f sphere_center = (
view_matrix * Eigen::Vector4f(0.0, 0.0, 0.0, 1.0)).head(3);
974 Eigen::Vector3f ray_origin = external_camera->getCenter();
977 sphere_pos = sphere_pos - sphere_center;
982 Eigen::Vector3f normal = (sphere_center - ray_origin).normalized();
985 sphere_pos = (sphere_pos - sphere_center).normalized() *
radius;
995 Eigen::Vector3f ray_direction =
Tucano::Math::rayDirection(pixel, external_camera->getViewportSize(), external_camera->getProjectionMatrix(), external_camera->getViewMatrix());
996 Eigen::Vector3f sphere_center = (
view_matrix * Eigen::Vector4f(0.0, 0.0, 0.0, 1.0)).head(3);
997 Eigen::Matrix3f normal_matrix =
view_matrix.linear().inverse().transpose();
998 Eigen::Vector3f ray_origin = external_camera->getCenter();
1000 if (selected_axis == -1)
1002 if (
Tucano::Math::rayRingIntersection(ray_direction, ray_origin, sphere_center, normal_matrix * Eigen::Vector3f::UnitX(), inner_radius, outer_radius, sphere_pos))
1005 selected_normal = Eigen::Vector3f::UnitX();
1006 sphere_pos = sphere_pos - sphere_center;
1009 if (
Tucano::Math::rayRingIntersection(ray_direction, ray_origin, sphere_center, normal_matrix * Eigen::Vector3f::UnitY(), inner_radius, outer_radius, sphere_pos))
1012 selected_normal = Eigen::Vector3f::UnitY();
1013 sphere_pos = sphere_pos - sphere_center;
1016 if (
Tucano::Math::rayRingIntersection(ray_direction, ray_origin, sphere_center, normal_matrix * Eigen::Vector3f::UnitZ(), inner_radius, outer_radius, sphere_pos))
1019 selected_normal = Eigen::Vector3f::UnitZ();
1020 sphere_pos = sphere_pos - sphere_center;
1027 sphere_pos = sphere_pos - sphere_center;
1042 external_camera = 0;
1043 default_translation = Eigen::Vector3f::Zero();
1045 inner_radius = radius * 1.3;
1046 outer_radius = radius * 1.5;
1055 inner_radius = radius * 0.9;
1056 outer_radius = radius * 1.1;
1066 Eigen::Quaternion<float> increment = Eigen::Quaternion<float>::Identity();
1068 if (computeSphere3DPosition(screen_pos, sphere_position))
1073 initialPosition = sphere_position;
1074 last_position = sphere_position;
1076 else if ( screen_pos != initialPosition.head(2))
1080 finalPosition = sphere_position;
1099 if(initialPosition.norm() > 0) {
1100 initialPosition.normalize();
1102 if(finalPosition.norm() > 0) {
1103 finalPosition.normalize();
1106 Eigen::Vector3f rotationAxis = initialPosition.cross(finalPosition);
1108 if(rotationAxis.norm() != 0) {
1109 rotationAxis.normalize();
1112 float dot = initialPosition.dot(finalPosition);
1114 float rotationAngle = (dot <= 1) ? acos(dot) : 0;
1115 Eigen::Quaternion<float> q (Eigen::AngleAxis<float>(rotationAngle,rotationAxis));
1127 Eigen::Vector3f inc = external_camera->getViewMatrix().rotation().inverse()*Eigen::Vector3f(translationFactor[0],translationFactor[1], 0.0);
1128 translationVector += inc;
1138 if (!external_camera)
1145 rotate(default_quaternion);
1166 if(drawTrackball && external_camera)
1168 viewport = external_camera->getViewport();
1172 trackballProjectionMatrix = external_camera->getProjectionMatrix();
1174 trackball_shader.
bind();
1176 Eigen::Affine3f trackballViewMatrix = external_camera->getViewMatrix() *
view_matrix;
1178 trackball_shader.
setUniform(
"viewMatrix", trackballViewMatrix);
1179 trackball_shader.
setUniform(
"projectionMatrix", trackballProjectionMatrix);
1186 Eigen::Vector4f color_vector;
1188 color_vector << 0.8, 0.4, 0.4, 1.0;
1189 trackball_shader.
setUniform(
"modelMatrix", Eigen::Affine3f::Identity()*Eigen::AngleAxis<float>(M_PI/2.0,Eigen::Vector3f(0.0,1.0,0.0)));
1190 trackball_shader.
setUniform(
"in_Color", color_vector);
1194 color_vector << 0.0, 1.0, 0.0, 1.0;
1195 trackball_shader.
setUniform(
"modelMatrix", Eigen::Affine3f::Identity()*Eigen::AngleAxis<float>(M_PI/2.0,Eigen::Vector3f(1.0,0.0,0.0)));
1196 trackball_shader.
setUniform(
"in_Color", color_vector);
1200 color_vector << 0.0, 0.0, 1.0, 1.0;
1201 trackball_shader.
setUniform(
"modelMatrix", Eigen::Affine3f::Identity());
1202 trackball_shader.
setUniform(
"in_Color", color_vector);
1207 trackball_shader.
unbind();
bool raySphereIntersection(const Eigen::Vector3f &ray_direction, const Eigen::Vector3f &ray_origin, const Eigen::Vector3f &sphere_center, float sphere_radius, Eigen::Vector3f &intersection)
Computes the intersection point between a ray and a sphere.
Definition: math.hpp:45
void setColor(const Eigen::Vector4f c)
Sets the arrow color.
Definition: arrow.hpp:134
void setSpherePos(const Eigen::Vector3f &pos)
Sets the manipulator 3D position.
Definition: trackball.hpp:841
void setRotation(Eigen::Quaternion< float > q)
Sets directly the rotation quaternion.
Definition: trackball.hpp:730
bool isRotating(void)
Returns wether the trackball is being rotated or not.
Definition: trackball.hpp:184
void endTranslation(void)
Indicates that a translation has ended. Disable the translating flag, indicating that the mouse callb...
Definition: trackball.hpp:288
RotationManipulator(void)
Default constructor.
Definition: trackball.hpp:1040
virtual void setRadius(float r)
Sets the radius.
Definition: trackball.hpp:249
Eigen::Matrix4f setTrackballOrthographicMatrix(float left, float right, float bottom, float top, float near_plane, float far_plane)
Sets the trackball projection matrix as orthographic.
Definition: trackball.hpp:388
Mainpulator for translating a mesh.
Definition: trackball.hpp:864
bool isTranslating(void)
Returns wether the trackball is being translated or not.
Definition: trackball.hpp:193
virtual void updateViewMatrix(void)
Applies all trackball's transformations to the view matrix.
Definition: trackball.hpp:562
virtual void renderLineLoop(void)
Render all vertices as a continous line loop.
Definition: mesh.hpp:735
Eigen::Affine3f * modelMatrix(void)
Returns a pointer to the model matrix.
Definition: model.hpp:112
void getViewMatrix(GLdouble *matrix)
Return the modelview matrix as a GLdouble array.
Definition: camera.hpp:126
Eigen::Vector2f initialTranslationPosition
Initial position vector used to calculate trackball's translation.
Definition: trackball.hpp:105
DirectionalTrackball(void)
Definition: trackball.hpp:717
virtual void setRadius(float r)
Sets the radius.
Definition: trackball.hpp:1052
float aspect_ratio
Aspect ratio for projection matrix.
Definition: camera.hpp:72
void loadShader(void)
Load Trackball Shader file.
Definition: trackball.hpp:305
Eigen::Matrix4f setTrackballPerspectiveMatrix(float fy, float aspect_ratio, float near_plane, float far_plane)
Sets the trackball projection matrix as perspective.
Definition: trackball.hpp:371
void translateViewMatrix(const Eigen::Vector3f &translation)
Translates the view matrix by a given vector trans. This directly modifies the translation vector of ...
Definition: trackball.hpp:540
virtual Eigen::Quaternion< float > rotateCamera(const Eigen::Vector2f &pos)
Computes and applies the rotation transformations to the trackball given new position.
Definition: trackball.hpp:455
Class for object manipulator.
Definition: trackball.hpp:808
virtual void render(Eigen::Affine3f ext_view_matrix=Eigen::Affine3f::Identity(), Eigen::Matrix4f ext_proj_matrix=Eigen::Matrix4f::Identity())
Renders the trackball representation.
Definition: trackball.hpp:596
static Eigen::Matrix4f createPerspectiveMatrix(float fy, float in_aspect_ratio, float in_near_plane, float in_far_plane)
Returns a perspective projection matrix with the given parameters.
Definition: camera.hpp:377
bool drawTrackball
Flag that indicates wether the trackball's representation should be drawn.
Definition: trackball.hpp:93
void initOpenGLMatrices(void)
Initializes the view and projection matrices. They are all initialized as Identity matrices...
Definition: trackball.hpp:352
Eigen::Vector3f getDefaultTranslation(void)
Returns the default translation for placing the camera outside the trackball sphere.
Definition: trackball.hpp:202
Eigen::Vector3f initialPosition
Initial position vector used to calculate trackball's rotation.
Definition: trackball.hpp:99
Definition: bufferobject.hpp:34
Eigen::Matrix4f trackballProjectionMatrix
Projection matrix used for the trackball's drawing. By default it is defined as an orthogonal project...
Definition: trackball.hpp:96
Eigen::Quaternion< float > getDefaultRotation(void)
Returns the default rotation quaternion.
Definition: trackball.hpp:221
Manipulator(void)
Default constructor.
Definition: trackball.hpp:822
void setDefaultTranslation(Eigen::Vector3f t)
Sets the default translation vector.
Definition: trackball.hpp:211
Trackball class for manipulating a camera.
Definition: trackball.hpp:79
void initialize(void)
Calls all the functions related to the shader initialization, i.e., creates, loads the shaders from t...
Definition: shader.hpp:641
void setShaderName(string name)
Sets the shader name, very useful for debugging.
Definition: shader.hpp:329
void reset(void)
Resets trackball to initial position and orientation.
Definition: trackball.hpp:168
Eigen::Quaternion< float > computeRotationAngle(float sensibility=1.0)
Computes the trackball's rotation, using stored initial and final position vectors.
Definition: trackball.hpp:666
void createTrackballRepresentation(void)
Creates the circle representating rotation around Z axis. The other circles will be created by simply...
Definition: trackball.hpp:576
bool rayPlaneIntersection(const Eigen::Vector3f &ray_direction, const Eigen::Vector3f &ray_origin, const Eigen::Vector3f &plane_point, const Eigen::Vector3f &plane_normal, Eigen::Vector3f &intersection)
Computes the intersection between a ray and a plane.
Definition: math.hpp:84
void render(void)
Renders the trackball representation.
Definition: trackball.hpp:1164
virtual Eigen::Vector3f translateCamera(const Eigen::Vector2f &pos)
Computes and applies the translation transformations to the trackball given new position.
Definition: trackball.hpp:481
Eigen::Quaternion< float > rotateCamera(const Eigen::Vector2f &screen_pos)
Rotates the manipulator given a new 2D screen position.
Definition: trackball.hpp:1064
void setViewport(const Eigen::Vector4f &vp)
Sets the viewport coordinates.
Definition: camera.hpp:274
void updateViewMatrix(void)
Applies all trackball's transformations to the view matrix.
Definition: trackball.hpp:927
A Shader object represents one GLSL program.
Definition: shader.hpp:45
void renderDirection(Tucano::Camera &ext_camera, bool render_from_ext=false)
Renders the camera's view direction at the top right corner of the screen.
Definition: trackball.hpp:739
bool use_default_shaders
Flag to use default shaders set as const strings in class, or pass a directory with custom shaders...
Definition: trackball.hpp:133
float far_plane
Far plane used for projection matrix.
Definition: camera.hpp:57
Eigen::Vector3f getSpherePos(void)
Returns the manipulator 3D position.
Definition: trackball.hpp:832
void applyScaleToViewMatrix(float scale)
Applies a scale factor to the viewMatrix. The current scale used in view matrix will be substituted b...
Definition: trackball.hpp:528
virtual Eigen::Quaternion< float > getRotation(void)
Returns the rotation (without the default part) as a quaternion.
Definition: trackball.hpp:231
Eigen::Vector3f translateCamera(const Eigen::Vector2f &pos)
Computes and applies the translation transformations to the trackball given new position.
Definition: trackball.hpp:904
float near_plane
Near plane used for projection matrix.
Definition: camera.hpp:54
Eigen::Vector2f normalizePosition(const Eigen::Vector2f &pos)
Nomalizes a screen position to range [-1,1].
Definition: trackball.hpp:445
void initializeFromStrings(string in_vertex_code, string in_fragment_code, string in_geometry_code="", string in_tessellation_evaluation_code="", string in_tessellation_control_code="")
Initializes shader directly from string, no files.
Definition: shader.hpp:589
Eigen::Quaternion< float > quaternion
Trackball's quaternion.
Definition: trackball.hpp:111
Eigen::Quaternion< float > computeRotationAngle(float sensibility=1.0)
Computes the trackball's rotation, using stored initial and final position vectors.
Definition: trackball.hpp:1095
virtual Eigen::Vector3f computeSpherePosition(const Eigen::Vector2f &pos)
Computes 3d coordinates on sphere from 2d position.
Definition: trackball.hpp:323
void setViewMatrix(const Eigen::Affine3f &mat)
Sets the view matrix from a given an affine 3x3 matrix.
Definition: camera.hpp:309
void translate(const Eigen::Vector3f &translation)
Translates the view matrix by a given vector.
Definition: camera.hpp:489
void setProjectionMatrix(const Eigen::Matrix4f &mat)
Sets the projection matrix from a given 4x4 matrix.
Definition: camera.hpp:300
Eigen::Vector3f translationVector
Trackball's translation vector.
Definition: trackball.hpp:117
Tucano::Mesh mesh
Trackball visual representation.
Definition: trackball.hpp:127
Eigen::Vector3f rayDirection(const Eigen::Vector2f &pixel, const Eigen::Vector2i &viewport_size, const Eigen::Matrix4f &projection_matrix, const Eigen::Affine3f &view_matrix)
Computes the ray direction given a pixel position and camera matrices.
Definition: math.hpp:136
float radius
The trackball radius. It's defined as 0.8 times the smallest viewport dimension.
Definition: trackball.hpp:130
float zoom
The current scale being applied to the View Matrix.
Definition: trackball.hpp:84
virtual Eigen::Vector3f computeTranslationVector(void)
Compute the trackball's translation, using stored initial and final position vectors.
Definition: trackball.hpp:431
void rotate(const Eigen::Quaternion< float > &rotation)
Rotate the view matrix by a given quaternion.
Definition: camera.hpp:498
A directional trackball, useful for light direction for example.
Definition: trackball.hpp:650
void setExternalCamera(Tucano::Camera *ext_cam)
Sets the pointer to the external camera The external camera is the actual view camera since the track...
Definition: trackball.hpp:853
void updateViewMatrix(void)
Applies all trackball's transformations to the view matrix.
Definition: trackball.hpp:783
Eigen::Quaternion< float > default_quaternion
Trackball's default rotation.
Definition: trackball.hpp:114
void scale(const Eigen::Vector3f &scale_factors)
Scales the view matrix by given factors.
Definition: camera.hpp:507
bool translating
Flag that indicates wether the trackball is being translated.
Definition: trackball.hpp:90
Eigen::Vector4f viewport
Viewport dimensions [minX, minY, width, height].
Definition: camera.hpp:48
void setRenderFlag(bool flag)
Returns wether the trackball representation should be drawn or not.
Definition: trackball.hpp:299
virtual void endRotation(void)
Indicates that a rotation has ended. Disables the rotating flag, indicating that the mouse callback f...
Definition: trackball.hpp:279
virtual Eigen::Vector3f computeTranslationVector(void)
Compute the trackball's translation, using stored initial and final position vectors.
Definition: trackball.hpp:1124
float getZoom(void)
Retuns the zoom factor (the radius of the trackball).
Definition: trackball.hpp:258
void setDefaultAttribLocations(void)
Sets default attribute locations. vertex coords -> location 0 normals -> location 1 colors -> locatio...
Definition: mesh.hpp:474
void resetModelMatrix(void)
Resets the model matrix.
Definition: model.hpp:159
void unbind(void)
Disables the shader program.
Definition: shader.hpp:1184
Eigen::Quaternion< float > quaternion_v
Definition: trackball.hpp:658
void setTrackballProjectionMatrix(const Eigen::Matrix4f &mat)
Sets the projection matrix used for the trackball rendering. Note that this is usually different than...
Definition: trackball.hpp:269
bool computeRing3DPosition(const Eigen::Vector2f &pixel, Eigen::Vector3f &sphere_pos)
Definition: trackball.hpp:993
void render(const Tucano::Camera &camera, const Tucano::Camera &light)
Render arrow.
Definition: arrow.hpp:142
bool computeSphere3DPosition(const Eigen::Vector2f &pixel, Eigen::Vector3f &sphere_pos)
Definition: trackball.hpp:970
bool rayRingIntersection(const Eigen::Vector3f &ray_direction, const Eigen::Vector3f &ray_origin, const Eigen::Vector3f &plane_point, const Eigen::Vector3f &plane_normal, float inner_radius, float outer_radius, Eigen::Vector3f &intersection)
Computes the intersection between a ray and a ring in 3D space.
Definition: math.hpp:110
Tucano::Camera * external_camera
Pointer to external camera.
Definition: trackball.hpp:813
void setDefaultRotation(Eigen::Matrix3f rot)
Sets the default rotation quaternion.
Definition: trackball.hpp:240
virtual void unbindBuffers(void)
Unbinds all buffers.
Definition: mesh.hpp:702
Eigen::Affine3f * viewMatrix(void)
Returns a pointer to the view matrix as an Affine 3x3 matrix.
Definition: camera.hpp:186
void decreaseZoom(float scale)
Decreases the zoom on the scene by appling a scale to the View Matrix. The current scale used in View...
Definition: trackball.hpp:517
Tucano::Shader trackball_shader
Trackball Shader, used just for rendering the trackball's representation.
Definition: trackball.hpp:124
void updateViewMatrix(void)
Applies all trackball's transformations to the view matrix.
Definition: trackball.hpp:1136
Eigen::Vector3f computeTranslationVector(void)
Compute the trackball's translation, using stored initial and final position vectors.
Definition: trackball.hpp:876
void loadVertices(vector< Eigen::Vector4f > &vert)
Load vertices (x,y,z,w) and creates appropriate vertex attribute. The default attribute name is "in_P...
Definition: mesh.hpp:312
void normalizeModelMatrix(void)
Normalize model matrix to center and scale model. The model matrix will include a translation to plac...
Definition: model.hpp:141
void load(string name, string shader_dir="")
Loads a shader given a directory and a name. Searches for all shader extensions in directory...
Definition: shader.hpp:436
void bind(void)
Enables the shader program for usage.
Definition: shader.hpp:1176
void increaseZoom(float scale)
Increases the zoom on the scene by appling a scale to the View Matrix. The current scale used in View...
Definition: trackball.hpp:506
Eigen::Vector3f finalPosition
Final position vector used to calculate trackball's rotation.
Definition: trackball.hpp:102
bool rotating
Flag that indicates wether the trackball is being rotated.
Definition: trackball.hpp:87
Eigen::Quaternion< float > quaternion_h
Definition: trackball.hpp:657
Tucano::Shapes::Arrow arrow
Arrow for visualizing view direction (very useful for light trackball system)
Definition: trackball.hpp:655
Trackball(string shader_dir="")
Default constructor.
Definition: trackball.hpp:141
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 bindBuffers(void)
Binds all buffers.
Definition: mesh.hpp:677
const string trackball_fragment_code
Default fragment shader for rendering trackball representation.
Definition: trackball.hpp:36
void endRotation(void)
Indicates that a rotation has ended. Disables the rotating flag, indicating that the mouse callback f...
Definition: trackball.hpp:1153
A common Mesh, usually containing triagles or points.
Definition: mesh.hpp:194
Defines an abstract camera with a projection and view matrices.
Definition: camera.hpp:37
void resetViewMatrix(void)
Reset view matrix.
Definition: camera.hpp:88
Eigen::Vector4f getViewport(void) const
Returns the viewport coordinates.
Definition: camera.hpp:246
A rounded arrow shape defined by a arrow and a cone.
Definition: arrow.hpp:85
Eigen::Vector2f finalTranslationPosition
Final position vector used to calculate trackball's translation.
Definition: trackball.hpp:108
void rotateViewMatrix(const Eigen::Affine3f &rot)
Rotates the view matrix by a given rotation matrix. This directly modifies the quaternion of the trac...
Definition: trackball.hpp:551
Eigen::Affine3f view_matrix
View, or extrinsic, matrix.
Definition: camera.hpp:45
virtual Eigen::Quaternion< float > computeRotationAngle(float sensibility=1.0)
Computes the trackball's rotation, using stored initial and final position vectors.
Definition: trackball.hpp:400
Eigen::Vector3f default_translation
Default translation to move camera away from center.
Definition: trackball.hpp:120
const string trackball_vertex_code
Default vertex shader for rendering trackball representation.
Definition: trackball.hpp:48
Manipulator for rotating a mesh It works as a spherical manipulator (such as a trackball) or a ring m...
Definition: trackball.hpp:946
void setUniform(GLint location, GLint a, GLint b, GLint c, GLint d)
Sets an uniform integer 4D vector (ivec4) given a location and the vector values. ...
Definition: shader.hpp:1258