29 CSetOfTexturedTriangles::~CSetOfTexturedTriangles() {}
33 void CSetOfTexturedTriangles::render_texturedobj()
const
35 #if MRPT_HAS_OPENGL_GLUT
42 float ax, ay, az, bx,
by,
bz;
45 for (it = m_triangles.begin(); it != m_triangles.end(); ++it)
49 ax = it->m_v2.m_x - it->m_v1.m_x;
50 ay = it->m_v2.m_y - it->m_v1.m_y;
51 az = it->m_v2.m_z - it->m_v1.m_z;
53 bx = it->m_v3.m_x - it->m_v1.m_x;
54 by = it->m_v3.m_y - it->m_v1.m_y;
55 bz = it->m_v3.m_z - it->m_v1.m_z;
60 float(it->m_v1.m_u) / r_width,
float(it->m_v1.m_v) / r_height);
61 glVertex3f(it->m_v1.m_x, it->m_v1.m_y, it->m_v1.m_z);
63 float(it->m_v2.m_u) / r_width,
float(it->m_v2.m_v) / r_height);
64 glVertex3f(it->m_v2.m_x, it->m_v2.m_y, it->m_v2.m_z);
66 float(it->m_v3.m_u) / r_width,
float(it->m_v3.m_v) / r_height);
67 glVertex3f(it->m_v3.m_x, it->m_v3.m_y, it->m_v3.m_z);
80 void CSetOfTexturedTriangles::writeToStream(
89 writeToStreamRender(out);
90 writeToStreamTexturedObject(out);
96 for (
uint32_t i = 0; i <
n; i++) m_triangles[i].writeToStream(out);
104 void CSetOfTexturedTriangles::readFromStream(
113 readFromStreamRender(
in);
116 readFromStreamTexturedObject(
in);
120 in >> CTexturedObject::m_textureImage;
121 in >> CTexturedObject::m_enableTransparency;
122 if (CTexturedObject::m_enableTransparency)
124 in >> CTexturedObject::m_textureImageAlpha;
126 CTexturedObject::m_textureImage,
127 CTexturedObject::m_textureImageAlpha);
130 assignImage(CTexturedObject::m_textureImage);
135 m_triangles.resize(
n);
137 for (
uint32_t i = 0; i <
n; i++) m_triangles[i].readFromStream(
in);
143 CRenderizableDisplayList::notifyChange();
151 throw std::runtime_error(
152 "TODO: TraceRay not implemented in CSetOfTexturedTriangles");
155 void CSetOfTexturedTriangles::getBoundingBox(
159 std::numeric_limits<double>::max(), std::numeric_limits<double>::max(),
160 std::numeric_limits<double>::max());
162 -std::numeric_limits<double>::max(),
163 -std::numeric_limits<double>::max(),
164 -std::numeric_limits<double>::max());
166 for (
size_t i = 0; i < m_triangles.size(); i++)
193 m_pose.composePoint(bb_min, bb_min);
194 m_pose.composePoint(bb_max, bb_max);
197 CSetOfTexturedTriangles::TVertex::TVertex()
198 : m_x(0.0), m_y(0.0), m_z(0.0), m_u(0), m_v(0)
204 : m_x(
x), m_y(
y), m_z(
z), m_u(u), m_v(
v)
211 out << m_x << m_y << m_z << m_u << m_v;
215 in >> m_x >> m_y >> m_z >> m_u >> m_v;
221 : m_v1(
v1), m_v2(
v2), m_v3(
v3)
228 m_v1.writeToStream(out);
229 m_v2.writeToStream(out);
230 m_v3.writeToStream(out);
235 m_v1.readFromStream(
in);
236 m_v2.readFromStream(
in);
237 m_v3.readFromStream(
in);
IMPLEMENTS_SERIALIZABLE(CSetOfTexturedTriangles, CRenderizableDisplayList, mrpt::opengl) CSetOfTexturedTriangles
A renderizable object suitable for rendering with OpenGL's display lists.
A set of textured triangles.
A class used to store a 3D pose (a 3D translation + a rotation in 3D).
This base class is used to provide a unified interface to files,memory buffers,..Please see the deriv...
const Scalar * const_iterator
GLAPI void GLAPIENTRY glNormal3f(GLfloat nx, GLfloat ny, GLfloat nz)
GLAPI void GLAPIENTRY glBegin(GLenum mode)
GLAPI void GLAPIENTRY glVertex3f(GLfloat x, GLfloat y, GLfloat z)
GLAPI void GLAPIENTRY glTexCoord2d(GLdouble s, GLdouble t)
GLAPI void GLAPIENTRY glEnd(void)
GLAPI void GLAPIENTRY glShadeModel(GLenum mode)
GLfloat GLfloat GLfloat v2
GLfloat GLfloat GLfloat GLfloat v3
bool traceRay(const std::vector< TPolygonWithPlane > &vec, const mrpt::poses::CPose3D &pose, double &dist)
Fast ray tracing method using polygons' properties.
#define MRPT_THROW_UNKNOWN_SERIALIZATION_VERSION(__V)
For use in CSerializable implementations.
#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.
The namespace for 3D scene representation and rendering.
Classes for serialization, sockets, ini-file manipulation, streams, list of properties-values,...
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.
unsigned __int32 uint32_t
double x
X,Y,Z coordinates.
void writeToStream(mrpt::utils::CStream &out) const
void readFromStream(mrpt::utils::CStream &in)
TTriangle()
Default constructor.
void writeToStream(mrpt::utils::CStream &out) const
TVertex()
Default constructor
void readFromStream(mrpt::utils::CStream &in)