25 CFrustumPtr
CFrustum::Create(
float near_distance,
float far_distance,
float horz_FOV_degrees,
float vert_FOV_degrees,
float lineWidth,
bool draw_lines,
bool draw_planes)
27 return CFrustumPtr(
new CFrustum(near_distance,far_distance,horz_FOV_degrees,vert_FOV_degrees,lineWidth,draw_lines,draw_planes));
34 #if MRPT_HAS_OPENGL_GLUT
35 if (m_color.A!=255 || (m_draw_planes && m_planes_color.A!=255) )
50 const float r = j==0 ? m_min_distance : m_max_distance;
53 pts[4*j+0].
y = -
r*tan(m_fov_horz_left);
54 pts[4*j+1].
y = -
r*tan(m_fov_horz_left);
55 pts[4*j+2].
y =
r*tan(m_fov_horz_right);
56 pts[4*j+3].
y =
r*tan(m_fov_horz_right);
57 pts[4*j+0].
z = -
r*tan(m_fov_vert_down);
58 pts[4*j+1].
z =
r*tan(m_fov_vert_up);
59 pts[4*j+2].
z = -
r*tan(m_fov_vert_down);
60 pts[4*j+3].
z =
r*tan(m_fov_vert_up);
68 const int draw_path[] = {
75 glColor4ub(m_color.R,m_color.G,m_color.B,m_color.A);
77 for (
size_t i=0;i<
sizeof(draw_path)/
sizeof(draw_path[0]);i++)
89 glColor4ub(m_planes_color.R,m_planes_color.G,m_planes_color.B,m_planes_color.A);
108 m_min_distance(0.1f),
115 m_draw_planes(false),
117 m_planes_color(0xE0,0x00,0x00, 0x50)
125 CFrustum::CFrustum(
float near_distance,
float far_distance,
float horz_FOV_degrees,
float vert_FOV_degrees,
float lineWidth,
bool draw_lines,
bool draw_planes) :
126 m_min_distance(near_distance),
127 m_max_distance(far_distance),
128 m_fov_horz_left(
mrpt::utils::
DEG2RAD(.5f*horz_FOV_degrees)),
129 m_fov_horz_right(
mrpt::utils::
DEG2RAD(.5f*horz_FOV_degrees)),
130 m_fov_vert_down(
mrpt::utils::
DEG2RAD(.5f*vert_FOV_degrees)),
131 m_fov_vert_up(
mrpt::utils::
DEG2RAD(.5f*vert_FOV_degrees)),
132 m_draw_lines(draw_lines),
133 m_draw_planes(draw_planes),
134 m_lineWidth(lineWidth),
135 m_planes_color(0xE0,0x00,0x00, 0x50)
230 for (
int j=0;j<2;j++)
233 for (
int i=0;i<4;i++)
245 bb_min =
TPoint3D( std::numeric_limits<double>::max(), std::numeric_limits<double>::max(), std::numeric_limits<double>::max() );
246 bb_max =
TPoint3D(-std::numeric_limits<double>::max(),-std::numeric_limits<double>::max(),-std::numeric_limits<double>::max() );
247 for (
int i=0;i<8;i++)
#define IMPLEMENTS_SERIALIZABLE(class_name, base, NameSpace)
This must be inserted in all CSerializable classes implementation files.
A solid or wireframe frustum in 3D (a rectangular truncated pyramid), with arbitrary (possibly assyme...
void setNearFarPlanes(const float near_distance, const float far_distance)
Changes distance of near & far planes.
void setHorzFOV(const float fov_horz_degrees)
Changes horizontal FOV (symmetric)
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...
void getBoundingBox(mrpt::math::TPoint3D &bb_min, mrpt::math::TPoint3D &bb_max) const MRPT_OVERRIDE
Evaluates the bounding box of this object (including possible children) in the coordinate frame of th...
void setVertFOV(const float fov_vert_degrees)
Changes vertical FOV (symmetric)
bool traceRay(const mrpt::poses::CPose3D &o, double &dist) const MRPT_OVERRIDE
Ray tracing.
void writeToStream(mrpt::utils::CStream &out, int *getVersion) const
Introduces a pure virtual method responsible for writing to a CStream.
void setVertFOVAsymmetric(const float fov_vert_down_degrees, const float fov_vert_up_degrees)
Changes vertical FOV (asymmetric)
float m_fov_horz_right
Semi FOVs (in radians)
CFrustum()
Basic empty constructor.
void render_dl() const MRPT_OVERRIDE
Render.
float m_fov_vert_up
Semi FOVs (in radians)
mrpt::utils::TColor m_planes_color
float m_max_distance
Near and far planes.
void setHorzFOVAsymmetric(const float fov_horz_left_degrees, const float fov_horz_right_degrees)
Changes horizontal FOV (asymmetric)
A renderizable object suitable for rendering with OpenGL's display lists.
EIGEN_STRONG_INLINE void notifyChange() const
Must be called to notify that the object has changed (so, the display list must be updated)
void readFromStreamRender(mrpt::utils::CStream &in)
mrpt::poses::CPose3D m_pose
6D pose wrt the parent coordinate reference. This class automatically holds the cached 3x3 rotation m...
void writeToStreamRender(utils::CStream &out) const
A class used to store a 3D pose (a 3D translation + a rotation in 3D).
void composePoint(double lx, double ly, double lz, double &gx, double &gy, double &gz, mrpt::math::CMatrixFixedNumeric< double, 3, 3 > *out_jacobian_df_dpoint=NULL, mrpt::math::CMatrixFixedNumeric< double, 3, 6 > *out_jacobian_df_dpose=NULL, mrpt::math::CMatrixFixedNumeric< double, 3, 6 > *out_jacobian_df_dse3=NULL, bool use_small_rot_approx=false) const
An alternative, slightly more efficient way of doing with G and L being 3D points and P this 6D pose...
This base class is used to provide a unified interface to files,memory buffers,..Please see the deriv...
GLAPI void GLAPIENTRY glEnable(GLenum cap)
GLAPI void GLAPIENTRY glLineWidth(GLfloat width)
GLAPI void GLAPIENTRY glBlendFunc(GLenum sfactor, GLenum dfactor)
GLAPI void GLAPIENTRY glBegin(GLenum mode)
GLAPI void GLAPIENTRY glVertex3fv(const GLfloat *v)
#define GL_ONE_MINUS_SRC_ALPHA
GLAPI void GLAPIENTRY glEnd(void)
GLAPI void GLAPIENTRY glDisable(GLenum cap)
GLAPI void GLAPIENTRY glColor4ub(GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha)
GLdouble GLdouble GLdouble r
#define MRPT_THROW_UNKNOWN_SERIALIZATION_VERSION(__V)
For use in CSerializable implementations.
#define THROW_EXCEPTION(msg)
#define MRPT_UNUSED_PARAM(a)
Can be used to avoid "not used parameters" warnings from the compiler.
This base provides a set of functions for maths stuff.
void OPENGL_IMPEXP checkOpenGLError()
Checks glGetError and throws an exception if an error situation is found.
void OPENGL_IMPEXP renderQuadWithNormal(const mrpt::math::TPoint3Df &p1, const mrpt::math::TPoint3Df &p2, const mrpt::math::TPoint3Df &p3, const mrpt::math::TPoint3Df &p4)
Can be used by derived classes to draw a quad with a normal vector computed automatically - to be cal...
The namespace for 3D scene representation and rendering.
Classes for serialization, sockets, ini-file manipulation, streams, list of properties-values,...
double DEG2RAD(const double x)
Degrees to radians.
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.
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.
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
double z
X,Y,Z coordinates.
Lightweight 3D point (float version).