15 #if MRPT_HAS_OPENGL_GLUT    22 #include <GLUT/glut.h>    23 #include <OpenGL/gl.h>    24 #include <OpenGL/glu.h>    29 #ifdef HAVE_FREEGLUT_EXT_H    30 #include <GL/freeglut_ext.h>    33 #endif  // MRPT_HAS_OPENGL_GLUT    54     float zoom = 
params.cameraZoomDistance * exp(0.01 * (
y - m_mouseClickY));
    55     if (zoom <= m_minZoom || (m_maxZoom != -1.0f && m_maxZoom <= zoom)) 
return;
    56     params.cameraZoomDistance = zoom;
    57     if (
params.cameraZoomDistance < 0.01) 
params.cameraZoomDistance = 0.01f;
    59     float Az = -0.05 * (
x - m_mouseClickX);
    60     float D = 0.001 * 
params.cameraZoomDistance;
    61     params.cameraPointingZ += D * Az;
    66     float zoom = 
params.cameraZoomDistance * (1 - 0.03f * (delta / 120.0f));
    67     if (zoom <= m_minZoom || (m_maxZoom != -1.0f && m_maxZoom <= zoom)) 
return;
    69     params.cameraZoomDistance = zoom;
    74     const float dis = max(0.01f, (
params.cameraZoomDistance));
    85     float A_AzimuthDeg = -SENSIBILITY_DEG_PER_PIXEL * (
x - m_mouseClickX);
    86     params.cameraAzimuthDeg += A_AzimuthDeg;
    88     float A_ElevationDeg = SENSIBILITY_DEG_PER_PIXEL * (
y - m_mouseClickY);
    89     params.setElevationDeg(
params.cameraElevationDeg + A_ElevationDeg);
   104     params.cameraAzimuthDeg -= 0.2 * (
x - m_mouseClickX);
   106         params.cameraElevationDeg + 0.2 * (
y - m_mouseClickY));
   117 #if MRPT_HAS_OPENGL_GLUT   118     if (
w == -1 || h == -1) 
return;
   126 #if MRPT_HAS_OPENGL_GLUT   127     glClearColor(clearColorR, clearColorG, clearColorB, clearColorA);
   133     float Ay = -(
x - m_mouseClickX);
   134     float Ax = -(
y - m_mouseClickY);
   135     float D = 0.001 * 
params.cameraZoomDistance;
   144     return m_cameraParams;
   149     return m_cameraParams;
   159     return m_cameraParams.cameraZoomDistance;
   164     m_cameraParams.cameraZoomDistance = zoom;
   170         m_cameraParams.cameraPointingX, m_cameraParams.cameraPointingY,
   171         m_cameraParams.cameraPointingZ);
   185     m_cameraParams.cameraAzimuthDeg = ang;
   190     m_cameraParams.cameraElevationDeg = ang;
   195     return m_cameraParams.cameraAzimuthDeg;
   200     return m_cameraParams.cameraElevationDeg;
   205     m_cameraParams.cameraIsProjective = is;
   210     return m_cameraParams.cameraIsProjective;
   229     m_openGLScene = scene;
   234     m_cameraParams.cameraPointingX = pointX;
   235     m_cameraParams.cameraPointingY = pointY;
   236     m_cameraParams.cameraPointingZ = pointZ;
   241     return m_cameraParams.cameraPointingX;
   246     return m_cameraParams.cameraPointingY;
   251     return m_cameraParams.cameraPointingZ;
   256 #if MRPT_HAS_OPENGL_GLUT   282             if (!useCameraFromScene)
   288                         "Fatal error: there is no 'main' viewport in the 3D "   293                 updateCameraParams(cam);
   305             m_openGLScene->render();
   319     catch (
const std::exception& e)
   323             std::string(
"[CWxGLCanvasBase::Render] Exception!: ") +
   325         std::cerr << err_msg;
   326         renderError(err_msg);
   331         std::cerr << 
"Runtime error!" << std::endl;
   342     cameraElevationDeg = deg;
   344     if (cameraElevationDeg < -90.0f)
   345         cameraElevationDeg = -90.0f;
   346     else if (cameraElevationDeg > 90.0f)
   347         cameraElevationDeg = 90.0f;
 GLAPI void GLAPIENTRY glFlush(void)
 
float getCameraPointingX() const
Returns the x pointing of the camera See also setCameraPointing(float, float, float) ...
 
double Tac() noexcept
Stops the stopwatch. 
 
GLAPI void GLAPIENTRY glMatrixMode(GLenum mode)
 
GLAPI void GLAPIENTRY glClearColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha)
 
virtual void setCameraProjective(bool is)
 
float getClearColorR() const
 
void updateOrbitCamera(CamaraParams ¶ms, int x, int y) const
This function for the mouse event It gets a reference to CamaraParams, x, y and updates the elevation...
 
GLAPI void GLAPIENTRY glEnable(GLenum cap)
 
#define THROW_EXCEPTION(msg)
 
CamaraParams cameraParams() const
Returns a copy of CamaraParams See also getRefCameraParams(), setCameraParams(const CamaraParams &) ...
 
void setElevationDeg(float deg)
 
double DEG2RAD(const double x)
Degrees to radians. 
 
A high-performance stopwatch, with typical resolution of nanoseconds. 
 
void setProjectiveModel(bool v=true)
Enable/Disable projective mode (vs. 
 
void setMaximumZoom(float zoom)
Sets the maximum of the zoom See also setMinimumZoom(float) 
 
float getZoomDistance() const
Returns a zoom See also setZoomDistance(float) 
 
virtual void setCameraParams(const CamaraParams ¶ms)
Sets the CamaraParams See also cameraParams(), getRefCameraParams() 
 
GLAPI void GLAPIENTRY glPopAttrib(void)
 
void resizeViewport(int w, int h)
Calls the glViewport function. 
 
const CamaraParams & getRefCameraParams() const
Returns a reference to CamaraParams See also cameraParams(), setCameraParams(const CamaraParams &) ...
 
GLAPI void GLAPIENTRY glLoadIdentity(void)
 
void setMousePos(int x, int y)
Saves the click position of the mouse See also setMouseClicked(bool) 
 
virtual void setElevationDegrees(float ang)
Saves the degrees of the elevation camera See also getElevationDegrees() 
 
GLubyte GLubyte GLubyte GLubyte w
 
void setZoomDistance(float z)
 
mrpt::system::CTicTac CTicTac
 
void setAzimuthDegrees(float ang)
 
void setOpenGLSceneRef(mrpt::opengl::COpenGLScene::Ptr scene)
 
virtual void setAzimuthDegrees(float ang)
Saves the degrees of the azimuth camera See also getAzimuthDegrees() 
 
virtual double renderCanvas(int width=-1, int height=-1)
 
virtual void setCameraPointing(float pointX, float pointY, float pointZ)
Saves the pointing of the camera See also getCameraPointingX(), getCameraPointingY(), getCameraPointingZ() 
 
void clearColors()
Calls the glClearColor function See also setClearColors(float, float, float, float) ...
 
void setProjectiveFOVdeg(float ang)
Field-of-View in degs, only when projectiveModel=true (default=30 deg). 
 
float getCameraPointingZ() const
Returns the z pointing of the camera See also setCameraPointing(float, float, float) ...
 
virtual void setCameraFOV(float FOV)
 
void setClearColors(float r, float g, float b, float a=1.0f)
Sets the RGBA colors for glClearColor See also clearColors(), getClearColorR(), getClearColorG(),getClearColorB(), getClearColorA() 
 
float getClearColorB() const
 
virtual void setZoomDistance(float zoom)
Saves camera zooming See also getZoomDistance() 
 
GLsizei const GLchar ** string
 
bool getUseCameraFromScene() const
See also void setUseCameraFromScene(bool) 
 
float getAzimuthDegrees() const
Returns a azimuth degrees See also setAzimuthDegrees(float) 
 
float getCameraPointingY() const
Returns the y pointing of the camera See also setCameraPointing(float, float, float) ...
 
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries. 
 
GLAPI void GLAPIENTRY glViewport(GLint x, GLint y, GLsizei width, GLsizei height)
 
void setElevationDegrees(float ang)
 
GLdouble GLdouble GLdouble r
 
GLAPI void GLAPIENTRY glPushAttrib(GLbitfield mask)
 
void setMouseClicked(bool is)
Sets the property mouseClicked By default, this property is false. 
 
void updateLastPos(int x, int y)
Sets the last mouse position. 
 
float getElevationDegrees() const
Returns a elevation degrees See also setElevationDegrees(float) 
 
void updateRotate(CamaraParams ¶ms, int x, int y) const
This function for the mouse event It gets a reference to CamaraParams, x, y and updates the elevation...
 
void setMinimumZoom(float zoom)
Sets the minimum of the zoom See also setMaximumZoom(float) 
 
The namespace for 3D scene representation and rendering. 
 
float getClearColorG() const
 
void setUseCameraFromScene(bool is)
If set to true (default=false), the cameraPointingX,... 
 
#define GL_ALL_ATTRIB_BITS
 
Classes for creating GUI windows for 2D and 3D visualization. 
 
bool isCameraProjective() const
 
void Tic() noexcept
Starts the stopwatch. 
 
A camera: if added to a scene, the viewpoint defined by this camera will be used instead of the camer...
 
GLenum GLsizei GLsizei height
 
static float SENSIBILITY_DEG_PER_PIXEL
 
void updatePan(CamaraParams ¶ms, int x, int y) const
This function for the mouse event It gets a reference to CamaraParams, x, y and updates the pointing ...
 
GLubyte GLubyte GLubyte a
 
GLenum const GLfloat * params
 
mrpt::opengl::CCamera & updateCameraParams(mrpt::opengl::CCamera &cam) const
This function gets a reference to mrpt::opengl::CCamera and updates the camera parameters(pointing, zoom, azimuth, elevation, IsProjective, FOV) 
 
float getClearColorA() const
 
void updateZoom(CamaraParams ¶ms, int x, int y) const
This function for the mouse event It gets a reference to CamaraParams, x, y and updates the zoom of t...
 
void setPointingAt(float x, float y, float z)