29 CSetOfTexturedTriangles::~CSetOfTexturedTriangles() =
default;
33 void CSetOfTexturedTriangles::render_texturedobj()
const 35 #if MRPT_HAS_OPENGL_GLUT 42 float ax, ay, az, bx,
by,
bz;
44 vector<TTriangle>::const_iterator it;
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);
76 uint8_t CSetOfTexturedTriangles::serializeGetVersion()
const {
return 2; }
77 void CSetOfTexturedTriangles::serializeTo(
82 writeToStreamRender(out);
83 writeToStreamTexturedObject(out);
89 for (
uint32_t i = 0; i <
n; i++) m_triangles[i].writeToStream(out);
92 void CSetOfTexturedTriangles::serializeFrom(
101 readFromStreamRender(
in);
104 readFromStreamTexturedObject(
in);
108 in >> CTexturedObject::m_textureImage;
109 in >> CTexturedObject::m_enableTransparency;
110 if (CTexturedObject::m_enableTransparency)
112 in >> CTexturedObject::m_textureImageAlpha;
114 CTexturedObject::m_textureImage,
115 CTexturedObject::m_textureImageAlpha);
118 assignImage(CTexturedObject::m_textureImage);
123 m_triangles.resize(
n);
125 for (
uint32_t i = 0; i <
n; i++) m_triangles[i].readFromStream(
in);
131 CRenderizableDisplayList::notifyChange();
139 throw std::runtime_error(
140 "TODO: TraceRay not implemented in CSetOfTexturedTriangles");
143 void CSetOfTexturedTriangles::getBoundingBox(
147 std::numeric_limits<double>::max(), std::numeric_limits<double>::max(),
148 std::numeric_limits<double>::max());
150 -std::numeric_limits<double>::max(),
151 -std::numeric_limits<double>::max(),
152 -std::numeric_limits<double>::max());
154 for (
const auto&
t : m_triangles)
183 CSetOfTexturedTriangles::TVertex::TVertex()
187 CSetOfTexturedTriangles::TVertex::TVertex(
189 : m_x(
x), m_y(
y), m_z(
z), m_u(u), m_v(
v)
196 out << m_x << m_y << m_z << m_u << m_v;
201 in >> m_x >> m_y >> m_z >> m_u >> m_v;
207 : m_v1(
v1), m_v2(
v2), m_v3(
v3)
214 m_v1.writeToStream(out);
215 m_v2.writeToStream(out);
216 m_v3.writeToStream(out);
221 m_v1.readFromStream(
in);
222 m_v2.readFromStream(
in);
223 m_v3.readFromStream(
in);
bool traceRay(const std::vector< TPolygonWithPlane > &vec, const mrpt::math::TPose3D &pose, double &dist)
Fast ray tracing method using polygons' properties.
#define IMPLEMENTS_SERIALIZABLE(class_name, base, NameSpace)
To be added to all CSerializable-classes implementation files.
GLAPI void GLAPIENTRY glNormal3f(GLfloat nx, GLfloat ny, GLfloat nz)
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...
GLAPI void GLAPIENTRY glShadeModel(GLenum mode)
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...
GLfloat GLfloat GLfloat GLfloat v3
GLAPI void GLAPIENTRY glBegin(GLenum mode)
void writeToStream(mrpt::serialization::CArchive &out) const
void readFromStream(mrpt::serialization::CArchive &in)
GLAPI void GLAPIENTRY glVertex3f(GLfloat x, GLfloat y, GLfloat z)
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
TTriangle()
Default constructor.
Virtual base class for "archives": classes abstracting I/O streams.
A class used to store a 3D pose (a 3D translation + a rotation in 3D).
void readFromStream(mrpt::serialization::CArchive &in)
The namespace for 3D scene representation and rendering.
GLAPI void GLAPIENTRY glEnd(void)
void writeToStream(mrpt::serialization::CArchive &out) const
GLAPI void GLAPIENTRY glTexCoord2d(GLdouble s, GLdouble t)
GLfloat GLfloat GLfloat v2
unsigned __int32 uint32_t
A set of textured triangles.
#define MRPT_UNUSED_PARAM(a)
Determines whether this is an X86 or AMD64 platform.