48 std::vector<float> mVerts;
49 std::vector<float> mVNormals;
50 std::vector<uint32_t> mVColors;
51 std::vector<float> mVTexCoords;
52 std::vector<float> mWTexCoords;
54 std::vector<uint32_t> mTris;
55 std::vector<float> mTNormals;
56 std::vector<uint32_t> mTColors;
57 std::vector<uint32_t> mVTexIds;
58 std::vector<uint32_t> mWTexIds;
60 std::vector<uint32_t> mEdges;
61 std::vector<float> mENormals;
62 std::vector<uint32_t> mEColors;
64 std::vector<uint32_t> mWireframe;
66 std::vector<vcl::Image> mTextures;
68 std::array<float, 4> mMeshColor = {0.5, 0.5, 0.5, 1};
85 swap(mVerts,
other.mVerts);
86 swap(mVNormals,
other.mVNormals);
87 swap(mVColors,
other.mVColors);
88 swap(mVTexCoords,
other.mVTexCoords);
89 swap(mWTexCoords,
other.mWTexCoords);
90 swap(mTris,
other.mTris);
91 swap(mTNormals,
other.mTNormals);
92 swap(mTColors,
other.mTColors);
93 swap(mVTexIds,
other.mVTexIds);
94 swap(mWTexIds,
other.mWTexIds);
95 swap(mEdges,
other.mEdges);
96 swap(mENormals,
other.mENormals);
97 swap(mEColors,
other.mEColors);
98 swap(mWireframe,
other.mWireframe);
99 swap(mTextures,
other.mTextures);
100 swap(mMeshColor,
other.mMeshColor);
103 uint vertexNumber()
const {
return mVerts.size() / 3; }
105 uint triangleNumber()
const {
return mTris.size() / 3; }
107 uint edgeNumber()
const {
return mEdges.size() / 2; }
109 uint wireframeEdgeNumber()
const {
return mWireframe.size() / 2; }
111 uint textureNumber()
const {
return mTextures.size(); }
118 const float* vertexBufferData()
const
122 return mVerts.data();
125 uint vertexBufferSize()
const {
return mVerts.size(); }
127 const uint32_t* triangleBufferData()
const
134 uint triangleBufferSize()
const {
return mTris.size(); }
136 const uint32_t* edgeBufferData()
const
140 return mEdges.data();
143 uint edgeBufferSize()
const {
return mEdges.size(); }
145 const uint32_t* wireframeBufferData()
const
147 if (mWireframe.empty())
149 return mWireframe.data();
152 uint wireframeBufferSize()
const {
return mWireframe.size(); }
154 const float* vertexNormalBufferData()
const
156 if (mVNormals.empty())
158 return mVNormals.data();
161 const uint32_t* vertexColorBufferData()
const
163 if (mVColors.empty())
165 return mVColors.data();
168 const float* triangleNormalBufferData()
const
170 if (mTNormals.empty())
172 return mTNormals.data();
175 const uint32_t* triangleColorBufferData()
const
177 if (mTColors.empty())
179 return mTColors.data();
182 const float* vertexTexCoordsBufferData()
const
184 if (mVTexCoords.empty())
186 return mVTexCoords.data();
189 const uint32_t* vertexTextureIDsBufferData()
const
191 if (mVTexIds.empty())
193 return mVTexIds.data();
196 const float* wedgeTexCoordsBufferData()
const
198 if (mWTexCoords.empty())
200 return mWTexCoords.data();
203 const uint32_t* wedgeTextureIDsBufferData()
const
205 if (mWTexIds.empty())
207 return mWTexIds.data();
210 const float* edgeNormalBufferData()
const
212 if (mENormals.empty())
214 return mENormals.data();
217 const uint32_t* edgeColorBufferData()
const
219 if (mEColors.empty())
221 return mEColors.data();
224 const float* meshColorBufferData()
const {
return mMeshColor.data(); }
226 const unsigned char* textureBufferData(
uint ti)
const
228 return mTextures[
ti].data();
232 void setVertexCoordsBuffer(
const MeshType& mesh)
234 uint nv = Base::numVerts();
236 mVerts.resize(
nv * 3);
238 Base::fillVertexCoords(mesh, mVerts.data());
241 void setVertexNormalsBuffer(
const MeshType& mesh)
243 uint nv = Base::numVerts();
245 mVNormals.resize(
nv * 3);
247 Base::fillVertexNormals(mesh, mVNormals.data());
250 void setVertexColorsBuffer(
const MeshType& mesh)
252 uint nv = Base::numVerts();
256 Base::fillVertexColors(mesh, mVColors.data(), Color::Format::ABGR);
259 void setVertexTexCoordsBuffer(
const MeshType& mesh)
261 uint nv = Base::numVerts();
263 mVTexCoords.resize(
nv * 2);
265 Base::fillVertexTexCoords(mesh, mVTexCoords.data());
268 void setWedgeTexCoordsBuffer(
const MeshType& mesh)
270 uint nv = Base::numVerts();
272 mWTexCoords.resize(
nv * 2);
274 Base::fillWedgeTexCoords(mesh, mWTexCoords.data());
277 void setTriangleIndicesBuffer(
const MeshType& mesh)
279 uint nt = Base::numTris();
281 mTris.resize(
nt * 3);
283 Base::fillTriangleIndices(mesh, mTris.data());
286 void setTriangleNormalsBuffer(
const MeshType& mesh)
288 uint nt = Base::numTris();
290 mTNormals.resize(
nt * 3);
292 Base::fillTriangleNormals(mesh, mTNormals.data());
295 void setTriangleColorsBuffer(
const MeshType& mesh)
297 uint nt = Base::numTris();
301 Base::fillTriangleColors(mesh, mTColors.data(), Color::Format::ABGR);
304 void setVertexTextureIndicesBuffer(
const MeshType& mesh)
306 if (vcl::isPerVertexTexCoordAvailable(mesh)) {
307 uint nt = Base::numTris();
311 Base::fillVertexTextureIndices(mesh, mVTexIds.data());
315 void setWedgeTextureIndicesBuffer(
const MeshType& mesh)
317 uint nt = Base::numTris();
321 Base::fillWedgeTextureIndices(mesh, mWTexIds.data());
324 void setEdgeIndicesBuffer(
const MeshType& mesh)
326 uint ne = Base::numEdges();
328 mEdges.resize(
ne * 2);
330 Base::fillEdgeIndices(mesh, mEdges.data());
333 void setEdgeNormalsBuffer(
const MeshType& mesh)
335 uint ne = Base::numEdges();
337 mENormals.resize(
ne * 3);
339 Base::fillEdgeNormals(mesh, mENormals.data());
342 void setEdgeColorsBuffer(
const MeshType& mesh)
344 uint ne = Base::numEdges();
348 Base::fillEdgeColors(mesh, mEColors.data(), Color::Format::ABGR);
351 void setWireframeIndicesBuffer(
const MeshType& mesh)
353 const uint nw = Base::numWireframeLines();
355 mWireframe.resize(
nw * 2);
357 Base::fillWireframeIndices(mesh, mWireframe.data());
360 void setTextureUnits(
const MeshType& mesh)
365 if (t.image().isNull()) {
368 mTextures.push_back(
txt);
371 mTextures.push_back(t.image());
372 mTextures.back().mirror();
377 for (
uint i = 0;
i < mesh.textureNumber(); ++
i) {
380 mTextures.push_back(
txt);
388 mMeshColor[0] =
m.color().redF();
389 mMeshColor[1] =
m.color().greenF();
390 mMeshColor[2] =
m.color().blueF();
391 mMeshColor[3] =
m.color().alphaF();
Concept that checks if a Mesh has the TextureImages component.
Definition per_mesh.h:103