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);
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 (
size_t i = 0; i < m_triangles.size(); i++)
181 m_pose.composePoint(bb_min, bb_min);
182 m_pose.composePoint(bb_max, bb_max);
185 CSetOfTexturedTriangles::TVertex::TVertex()
186 : m_x(0.0), m_y(0.0), m_z(0.0), m_u(0), m_v(0)
192 : m_x(
x), m_y(
y), m_z(
z), m_u(u), m_v(
v)
199 out << m_x << m_y << m_z << m_u << m_v;
204 in >> m_x >> m_y >> m_z >> m_u >> m_v;
210 : m_v1(
v1), m_v2(
v2), m_v3(
v3)
217 m_v1.writeToStream(out);
218 m_v2.writeToStream(out);
219 m_v3.writeToStream(out);
224 m_v1.readFromStream(
in);
225 m_v2.readFromStream(
in);
226 m_v3.readFromStream(
in);