30 #if MRPT_HAS_OPENGL_GLUT 31 if (m_color.A != 255 || (m_draw_planes && m_planes_color.A != 255))
44 for (
int j = 0; j < 2; j++)
46 const float r = j == 0 ? m_min_distance : m_max_distance;
47 for (
int i = 0; i < 4; i++) pts[4 * j + i].
x =
r;
48 pts[4 * j + 0].
y = -
r * tan(m_fov_horz_left);
49 pts[4 * j + 1].
y = -
r * tan(m_fov_horz_left);
50 pts[4 * j + 2].
y =
r * tan(m_fov_horz_right);
51 pts[4 * j + 3].
y =
r * tan(m_fov_horz_right);
52 pts[4 * j + 0].
z = -
r * tan(m_fov_vert_down);
53 pts[4 * j + 1].
z =
r * tan(m_fov_vert_up);
54 pts[4 * j + 2].
z = -
r * tan(m_fov_vert_down);
55 pts[4 * j + 3].
z =
r * tan(m_fov_vert_up);
63 const int draw_path[] = {0, 1, 3, 2, 0, 4, 6, 2,
64 3, 7, 6, 4, 5, 7, 5, 1};
70 glColor4ub(m_color.R, m_color.G, m_color.B, m_color.A);
72 for (
size_t i = 0; i <
sizeof(draw_path) /
sizeof(draw_path[0]); i++)
85 m_planes_color.R, m_planes_color.G, m_planes_color.B,
105 : m_min_distance(0.1f),
112 m_draw_planes(false),
114 m_planes_color(0xE0, 0x00, 0x00, 0x50)
127 float near_distance,
float far_distance,
float horz_FOV_degrees,
128 float vert_FOV_degrees,
float lineWidth,
bool draw_lines,
bool draw_planes)
129 : m_min_distance(near_distance),
130 m_max_distance(far_distance),
131 m_fov_horz_left(
mrpt::
DEG2RAD(.5f * horz_FOV_degrees)),
132 m_fov_horz_right(
mrpt::
DEG2RAD(.5f * horz_FOV_degrees)),
133 m_fov_vert_down(
mrpt::
DEG2RAD(.5f * vert_FOV_degrees)),
134 m_fov_vert_up(
mrpt::
DEG2RAD(.5f * vert_FOV_degrees)),
135 m_draw_lines(draw_lines),
136 m_draw_planes(draw_planes),
137 m_lineWidth(lineWidth),
138 m_planes_color(0xE0, 0x00, 0x00, 0x50)
180 const float near_distance,
const float far_distance)
205 const float fov_horz_left_degrees,
const float fov_horz_right_degrees)
216 const float fov_vert_down_degrees,
const float fov_vert_up_degrees)
232 for (
int j = 0; j < 2; j++)
235 for (
int i = 0; i < 4; i++) pts[4 * j + i].
x =
r;
247 std::numeric_limits<double>::max(), std::numeric_limits<double>::max(),
248 std::numeric_limits<double>::max());
250 -std::numeric_limits<double>::max(),
251 -std::numeric_limits<double>::max(),
252 -std::numeric_limits<double>::max());
253 for (
int i = 0; i < 8; i++)
bool traceRay(const mrpt::poses::CPose3D &o, double &dist) const override
Ray tracing.
GLAPI void GLAPIENTRY glVertex3fv(const GLfloat *v)
GLAPI void GLAPIENTRY glEnable(GLenum cap)
#define THROW_EXCEPTION(msg)
void 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...
#define IMPLEMENTS_SERIALIZABLE(class_name, base, NameSpace)
This must be inserted in all CSerializable classes implementation files.
double DEG2RAD(const double x)
Degrees to radians.
float m_min_distance
Near and far planes.
void setVertFOV(const float fov_vert_degrees)
Changes vertical FOV (symmetric)
EIGEN_STRONG_INLINE void notifyChange() const
Must be called to notify that the object has changed (so, the display list must be updated) ...
#define GL_ONE_MINUS_SRC_ALPHA
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...
void setHorzFOV(const float fov_horz_degrees)
Changes horizontal FOV (symmetric)
GLAPI void GLAPIENTRY glLineWidth(GLfloat width)
mrpt::poses::CPose3D m_pose
6D pose wrt the parent coordinate reference.
GLAPI void GLAPIENTRY glBlendFunc(GLenum sfactor, GLenum dfactor)
A renderizable object suitable for rendering with OpenGL's display lists.
#define MRPT_THROW_UNKNOWN_SERIALIZATION_VERSION(__V)
For use in CSerializable implementations.
This base provides a set of functions for maths stuff.
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 writeToStreamRender(mrpt::serialization::CArchive &out) const
Lightweight 3D point (float version).
void serializeFrom(mrpt::serialization::CArchive &in, uint8_t serial_version) override
Pure virtual method for reading (deserializing) from an abstract archive.
CFrustum()
Basic empty constructor.
double x
X,Y,Z coordinates.
GLAPI void GLAPIENTRY glBegin(GLenum mode)
GLAPI void GLAPIENTRY glColor4ub(GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha)
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
Virtual base class for "archives": classes abstracting I/O streams.
GLdouble GLdouble GLdouble r
mrpt::img::TColor m_planes_color
float m_fov_horz_left
Semi FOVs (in radians)
A class used to store a 3D pose (a 3D translation + a rotation in 3D).
void setNearFarPlanes(const float near_distance, const float far_distance)
Changes distance of near & far planes.
void composePoint(double lx, double ly, double lz, double &gx, double &gy, double &gz, mrpt::math::CMatrixFixedNumeric< double, 3, 3 > *out_jacobian_df_dpoint=nullptr, mrpt::math::CMatrixFixedNumeric< double, 3, 6 > *out_jacobian_df_dpose=nullptr, mrpt::math::CMatrixFixedNumeric< double, 3, 6 > *out_jacobian_df_dse3=nullptr, 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...
void checkOpenGLError()
Checks glGetError and throws an exception if an error situation is found.
uint8_t serializeGetVersion() const override
Must return the current versioning number of the object.
The namespace for 3D scene representation and rendering.
void setVertFOVAsymmetric(const float fov_vert_down_degrees, const float fov_vert_up_degrees)
Changes vertical FOV (asymmetric)
GLAPI void GLAPIENTRY glEnd(void)
A solid or wireframe frustum in 3D (a rectangular truncated pyramid), with arbitrary (possibly assyme...
void getBoundingBox(mrpt::math::TPoint3D &bb_min, mrpt::math::TPoint3D &bb_max) const override
Evaluates the bounding box of this object (including possible children) in the coordinate frame of th...
typedef void(APIENTRYP PFNGLBLENDCOLORPROC)(GLclampf red
void setHorzFOVAsymmetric(const float fov_horz_left_degrees, const float fov_horz_right_degrees)
Changes horizontal FOV (asymmetric)
GLAPI void GLAPIENTRY glDisable(GLenum cap)
void serializeTo(mrpt::serialization::CArchive &out) const override
Pure virtual method for writing (serializing) to an abstract archive.
void readFromStreamRender(mrpt::serialization::CArchive &in)
float m_fov_vert_down
Semi FOVs (in radians)
#define MRPT_UNUSED_PARAM(a)
Determines whether this is an X86 or AMD64 platform.