39 #if defined(OPENGLVIEWPORT_ENABLE_TIMEPROFILING)    57         m_isClonedCamera(false),
    60         m_isTransparent(false),
    68         m_custom_backgb_color(false),
    69         m_background_color(0.6f,0.6f,0.6f),
    74         m_OpenGL_enablePolygonNicest(true),
   175 #if MRPT_HAS_OPENGL_GLUT   235                         glClearColor(old_colors[0],old_colors[1],old_colors[2],old_colors[3]);
   247 #if defined(OPENGLVIEWPORT_ENABLE_TIMEPROFILING)   248                         glv_timlog.enter(
"COpenGLViewport::render imageview");
   260                                 const int img_w = 
img->getWidth();
   261                                 const int img_h = 
img->getHeight();
   263                                 if (img_w!=0 && img_h!=0)
   270                                         const double ratio = vw*img_h/double(vh*img_w);
   271                                         double ortho_w = img_w;
   272                                         double ortho_h = img_h;
   276                                         if (ratio!=0) ortho_h /=ratio;
   287                                                 -vh / 
float(ortho_h) );
   291                                         const int nBytesPerPixel = 
img->isColor() ? 3 : 1;
   292                                         const bool is_RGB_order = (!::strcmp(
img->getChannelsOrder(),
"RGB"));  
   299                                                 img_format, img_type,
   307 #if defined(OPENGLVIEWPORT_ENABLE_TIMEPROFILING)   308                         glv_timlog.leave(
"COpenGLViewport::render imageview");
   331                                 objectsToRender = &view->m_objects;
   345                         if (cam_ptr.present())
   347                                 myCamera = getAs<CCamera>(cam_ptr);
   352                                 myCamera = &viewForGetCamera->
m_camera;
   360                         const float dis = max(0.01f,myCamera->m_distanceZoom);
   366                         if (fabs(fabs(myCamera->m_elevationDeg)-90)>1e-6)
   374                                 float sgn = myCamera->m_elevationDeg>0 ? 1:-1;
   387                         if (myCamera->m_projectiveModel)
   394                                 const double ratio = vw/double(vh);
   395                                 double Ax = myCamera->m_distanceZoom*0.5;
   396                                 double Ay = myCamera->m_distanceZoom*0.5;
   402                                         if (ratio!=0) Ay /=ratio;
   409                         if (myCamera->is6DOFMode())
   416                                 at = pose + viewDirection;
   473                         for (
size_t i=0;i<
m_lights.size();i++)
   520                 else    msg = 
format(
"Exception while rendering:\n%s", e.what() );
   530         THROW_EXCEPTION(
"The MRPT has been compiled with MRPT_HAS_OPENGL_GLUT=0! OpenGL functions are not implemented");
   644                 if ((*it)->m_name == str)
   648                         CRenderizablePtr ret = getAs<CSetOfObjects>(*it)->getByName(str);
   653         return CRenderizablePtr();
   661 #if MRPT_HAS_OPENGL_GLUT   665                         getAs<CTexturedObject>(*it)->loadTextureInOpenGL();
   667                         getAs<CSetOfObjects>(*it)->initializeAllTextures();
   680                 string  s( (*it)->GetRuntimeClass()->className );
   681                 if ((*it)->m_name.size())
   682                         s+= 
string(
" (") +(*it)->m_name + 
string(
")");
   689                         getAs<CSetOfObjects>(*it)->dumpListOfObjects(auxLst);
   691                         for (
size_t i=0;i<auxLst.
size();i++)
   692                                 lst.
add( 
string(
" ")+auxLst(i) );
   703                 if (it->pointer() == 
obj.pointer())
   709                         getAs<CSetOfObjects>(*it)->removeObject(
obj);
   736                 const double x_coord,
   737                 const double y_coord,
   774                         if (ASPECT!=0) Ay /=ASPECT;
   786                 out_ray.
pBase = ray_origin;
   801                 const double FOVx = 2.0*atan(ASPECT*tan(FOVy*0.5));
   806                 const TPoint3D l(tan(ang_horz),tan(ang_vert),1.0); 
   809                         l.
x * cam_x_3d.
x + l.
y * cam_up_3d.
x + l.
z * pointing_dir.
x,
   810                         l.
x * cam_x_3d.
y + l.
y * cam_up_3d.
y + l.
z * pointing_dir.
y,
   811                         l.
x * cam_x_3d.
z + l.
y * cam_up_3d.
z + l.
z * pointing_dir.
z   826                 M.get_unsafe(0,0) = cam_x_3d.
x;
   827                 M.get_unsafe(1,0) = cam_x_3d.
y;
   828                 M.get_unsafe(2,0) = cam_x_3d.
z;
   829                 M.get_unsafe(3,0) = 0;
   831                 M.get_unsafe(0,1) = cam_up_3d.
x;
   832                 M.get_unsafe(1,1) = cam_up_3d.
y;
   833                 M.get_unsafe(2,1) = cam_up_3d.
z;
   834                 M.get_unsafe(3,1) = 0;
   836                 M.get_unsafe(0,2) = pointing_dir.
x;
   837                 M.get_unsafe(1,2) = pointing_dir.
y;
   838                 M.get_unsafe(2,2) = pointing_dir.
z;
   839                 M.get_unsafe(3,2) = 0;
   844                 M.get_unsafe(3,3) = 1;
   850 MRPT_TODO(
"Implement a setCurrentCameraFromPose() method")
   855         get3DRayForPixelCoord(0,0,dum, &out_cameraPose);
   899         bb_min = 
TPoint3D( std::numeric_limits<double>::max(), std::numeric_limits<double>::max(), std::numeric_limits<double>::max() );
   900         bb_max = 
TPoint3D(-std::numeric_limits<double>::max(),-std::numeric_limits<double>::max(),-std::numeric_limits<double>::max() );
   904                 TPoint3D child_bbmin( std::numeric_limits<double>::max(), std::numeric_limits<double>::max(), std::numeric_limits<double>::max() );
   905                 TPoint3D child_bbmax(-std::numeric_limits<double>::max(),-std::numeric_limits<double>::max(),-std::numeric_limits<double>::max() );
   906                 (*it)->getBoundingBox(child_bbmin, child_bbmax);
 
double x() const
Common members of all points & poses classes. 
 
opengl::CListOpenGLObjects m_objects
The list of objects that comprise the 3D scene. 
 
void dumpListOfObjects(mrpt::utils::CStringList &lst)
Retrieves a list of all objects in text form. 
 
Classes for serialization, sockets, ini-file manipulation, streams, list of properties-values, timewatch, extensions to STL. 
 
GLAPI void GLAPIENTRY glMatrixMode(GLenum mode)
 
GLAPI void GLAPIENTRY glClearColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha)
 
A base class for all OpenGL objects with loadable textures. 
 
mrpt::utils::CImagePtr m_imageview_img
The image to display, after calling setImageView() 
 
bool m_isTransparent
Whether to clear color buffer. 
 
void removeObject(const CRenderizablePtr &obj)
Removes the given object from the scene (it also deletes the object to free its memory). 
 
A set of object, which are referenced to the coordinates framework established in this object...
 
GLAPI void GLAPIENTRY glEnable(GLenum cap)
 
uint32_t m_borderWidth
Default=0, the border around the viewport. 
 
void setCloneView(const std::string &clonedViewport)
Set this viewport as a clone of some other viewport, given its name - as a side effect, current list of internal OpenGL objects is cleared. 
 
The virtual base class which provides a unified interface for all persistent objects in MRPT...
 
#define GL_STENCIL_BUFFER_BIT
 
A class for storing images as grayscale or RGB bitmaps. 
 
#define IMPLEMENTS_SERIALIZABLE(class_name, base, NameSpace)
This must be inserted in all CSerializable classes implementation files. 
 
#define GL_FRONT_AND_BACK
 
void copyFastFrom(CImage &o)
Moves an image from another object, erasing the origin image in the process (this is much faster than...
 
#define THROW_EXCEPTION(msg)
 
std::vector< CLight > m_lights
 
#define THROW_EXCEPTION_FMT(_FORMAT_STRING,...)
 
void setImageView_fast(mrpt::utils::CImage &img)
Just like setImageView but moves the internal image memory instead of making a copy, so it's faster but empties the input image. 
 
void getViewportClipDistances(double &clip_min, double &clip_max) const
Get the current min/max clip depth distances of the rendering frustum (default: 0.1 - 10000) 
 
The base class of 3D objects that can be directly rendered through OpenGL. 
 
bool m_custom_backgb_color
 
std::deque< CRenderizablePtr > CListOpenGLObjects
A list of objects pointers, automatically managing memory free at destructor, and managing copies cor...
 
void setViewportClipDistances(const double clip_min, const double clip_max)
Set the min/max clip depth distances of the rendering frustum (default: 0.1 - 10000) ...
 
TPoint3D pBase
Base point. 
 
#define GL_PERSPECTIVE_CORRECTION_HINT
 
const Scalar * const_iterator
 
bool hasSubscribers() const
Can be called by a derived class before preparing an event for publishing with publishEvent to determ...
 
double z
X,Y,Z coordinates. 
 
#define GL_COLOR_MATERIAL
 
mrpt::utils::TColorf m_background_color
used only if m_custom_backgb_color 
 
mrpt::math::TPoint3D eye
The camera is here. 
 
GLAPI void GLAPIENTRY glShadeModel(GLenum mode)
 
GLsizei GLsizei GLuint * obj
 
GLAPI void GLAPIENTRY glLineWidth(GLfloat width)
 
A viewport within a COpenGLScene, containing a set of OpenGL objects to render. 
 
GLAPI void GLAPIENTRY glLoadIdentity(void)
 
size_t viewport_height
In pixels. This may be smaller than the total render window. 
 
void crossProduct3D(const T &v0, const U &v1, V &vOut)
Computes the cross product of two 3D vectors, returning a vector normal to both. 
 
Each of the possible lights of a 3D scene. 
 
bool m_isClonedCamera
Set by setCloneCamera. 
 
void publishEvent(const mrptEvent &e) const
Called when you want this object to emit an event to all the observers currently subscribed to this o...
 
GLAPI void GLAPIENTRY glDrawPixels(GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels)
 
void writeToStream(mrpt::utils::CStream &out, int *getVersion) const
Introduces a pure virtual method responsible for writing to a CStream. 
 
GLAPI void GLAPIENTRY glGetDoublev(GLenum pname, GLdouble *params)
 
#define GL_DEPTH_BUFFER_BIT
 
#define IS_DERIVED(ptrObj, class_name)
Evaluates to true if the given pointer to an object (derived from mrpt::utils::CSerializable) is an i...
 
#define GL_COLOR_BUFFER_BIT
 
This base class is used to provide a unified interface to files,memory buffers,..Please see the deriv...
 
void insert(const CRenderizablePtr &newObject)
Insert a new object into the list. 
 
A class for storing a list of text lines. 
 
A numeric matrix of compile-time fixed size. 
 
This base provides a set of functions for maths stuff. 
 
bool m_isImageView
Set by setImageView. 
 
#define GL_COLOR_CLEAR_VALUE
 
void getBoundingBox(mrpt::math::TPoint3D &bb_min, mrpt::math::TPoint3D &bb_max) const
Evaluates the bounding box of this object (including possible children) in the coordinate frame of th...
 
GLAPI void GLAPIENTRY glDepthFunc(GLenum func)
 
#define MRPT_UNUSED_PARAM(a)
Can be used to avoid "not used parameters" warnings from the compiler. 
 
virtual const mrpt::utils::TRuntimeClassId * GetRuntimeClass() const
Returns information about the class of an object in runtime. 
 
void render(const int render_width, const int render_height) const
Render the objects in this viewport (called from COpenGLScene only) 
 
#define MRPT_THROW_UNKNOWN_SERIALIZATION_VERSION(__V)
For use in CSerializable implementations. 
 
GLAPI void GLAPIENTRY glColorMaterial(GLenum face, GLenum mode)
 
GLAPI void GLAPIENTRY glPixelZoom(GLfloat xfactor, GLfloat yfactor)
 
std::string BASE_IMPEXP format(const char *fmt,...) MRPT_printf_format_check(1
A std::string version of C sprintf. 
 
void readFromStream(mrpt::utils::CStream &in, int version)
Introduces a pure virtual method responsible for loading from a CStream This can not be used directly...
 
mrpt::math::TPoint3D up
Up vector of the camera. 
 
TLastProjectiveMatrixInfo m_lastProjMat
Info updated with each "render()" and used in "get3DRayForPixelCoord". 
 
void setNormalMode()
Resets the viewport to a normal 3D viewport. 
 
GLAPI void GLAPIENTRY glBegin(GLenum mode)
 
bool m_OpenGL_enablePolygonNicest
 
GLsizei const GLchar ** string
 
GLAPI void GLAPIENTRY glHint(GLenum target, GLenum mode)
 
void keep_max(T &var, const K test_val)
If the second argument is above the first one, set the first argument to this higher value...
 
Classes for 2D/3D geometry representation, both of single values and probability density distribution...
 
size_t size() const
Returns the number of text lines in the list. 
 
virtual ~COpenGLViewport()
Destructor: clears all objects. 
 
mrpt::math::TPoint3D pointing
The camera points to here. 
 
double director[3]
Director vector. 
 
void initializeAllTextures()
Initializes all textures in the scene (See opengl::CTexturedPlane::loadTextureInOpenGL) ...
 
#define CLASS_ID_NAMESPACE(class_name, namespaceName)
Access to runtime class ID for a defined class name. 
 
GLAPI void GLAPIENTRY glLightModeli(GLenum pname, GLint param)
 
static void checkOpenGLError()
Checks glGetError and throws an exception if an error situation is found. 
 
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries. 
 
GLAPI void GLAPIENTRY glScissor(GLint x, GLint y, GLsizei width, GLsizei height)
 
GLAPI void GLAPIENTRY glViewport(GLint x, GLint y, GLsizei width, GLsizei height)
 
#define GL_UNPACK_ROW_LENGTH
 
#define ASSERTDEB_(f)
Defines an assertion mechanism - only when compiled in debug. 
 
static CImagePtr Create()
 
void clear()
Delete all internal obejcts. 
 
An event sent by an mrpt::opengl::COpenGLViewport just after clearing the viewport and setting the GL...
 
void keep_min(T &var, const K test_val)
If the second argument is below the first one, set the first argument to this lower value...
 
A class used to store a 3D pose (a 3D translation + a rotation in 3D). 
 
void setImageView(const mrpt::utils::CImage &img)
Set this viewport into "image view"-mode, where an image is efficiently drawn (fitting the viewport a...
 
float elev
Camera elev & azimuth, in radians. 
 
#define IS_CLASS(ptrObj, class_name)
Evaluates to true if the given pointer to an object (derived from mrpt::utils::CSerializable) is of t...
 
An event sent by an mrpt::opengl::COpenGLViewport after calling the scene OpenGL drawing primitives a...
 
GLAPI void GLAPIENTRY glClear(GLbitfield mask)
 
The namespace for 3D scene representation and rendering. 
 
GLuint const GLchar * name
 
This class allows the user to create, load, save, and render 3D scenes using OpenGL primitives...
 
A versatile "profiler" that logs the time spent within each pair of calls to enter(X)-leave(X), among other stats. 
 
GLAPI void GLAPIENTRY glEnd(void)
 
std::string m_clonedViewport
Only if m_isCloned=true. 
 
void get3DRayForPixelCoord(const double x_coord, const double y_coord, mrpt::math::TLine3D &out_ray, mrpt::poses::CPose3D *out_cameraPose=NULL) const
Compute the 3D ray corresponding to a given pixel; this can be used to allow the user to pick and sel...
 
#define GL_POLYGON_SMOOTH_HINT
 
#define GL_LIGHT_MODEL_TWO_SIDE
 
typedef void(APIENTRYP PFNGLBLENDCOLORPROC)(GLclampf red
 
T::Ptr getByClass(const size_t &ith=0) const
Returns the i'th object of a given class (or of a descendant class), or NULL (an empty smart pointer)...
 
double m_clip_max
The min/max clip depth distances (default: 0.1 - 10000) 
 
CRenderizablePtr getByName(const std::string &str)
Returns the first object with a given name, or NULL if not found. 
 
GLAPI void GLAPIENTRY glColor4f(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha)
 
GLAPI void GLAPIENTRY glOrtho(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar)
 
void internal_setImageView_fast(const mrpt::utils::CImage &img, bool is_fast)
 
void getRotationMatrix(mrpt::math::CMatrixDouble33 &ROT) const
Get the 3x3 rotation matrix. 
 
void OPENGL_IMPEXP renderSetOfObjects(const mrpt::opengl::CListOpenGLObjects &objs)
For each object in the list: 
 
A camera: if added to a scene, the viewpoint defined by this camera will be used instead of the camer...
 
GLenum GLsizei GLsizei height
 
unsigned __int32 uint32_t
 
GLAPI void GLAPIENTRY glVertex2f(GLfloat x, GLfloat y)
 
GLAPI void GLAPIENTRY glDisable(GLenum cap)
 
void setViewportPosition(const double x, const double y, const double width, const double height)
Change the viewport position and dimension on the rendering window. 
 
#define GL_AMBIENT_AND_DIFFUSE
 
double m_view_height
The viewport position [0,1]. 
 
#define GL_ACCUM_BUFFER_BIT
 
GLAPI void GLAPIENTRY glPixelStorei(GLenum pname, GLint param)
 
void getViewportPosition(double &x, double &y, double &width, double &height)
Get the current viewport position and dimension on the rendering window. 
 
GLAPI void GLAPIENTRY glRasterPos2f(GLfloat x, GLfloat y)
 
utils::safe_ptr< COpenGLScene > m_parent
The scene that contains this viewport. 
 
opengl::CCamera m_camera
The camera associated to the viewport. 
 
std::string m_name
The viewport's name. 
 
void add(const std::string &str)
Appends a new string at the end of the string list. 
 
bool m_isCloned
Set by setCloneView. 
 
3D line, represented by a base point and a director vector.