47 std::vector<float> mVerts;
48 std::vector<float> mVNormals;
49 std::vector<uint32_t> mVColors;
50 std::vector<float> mVTexCoords;
51 std::vector<float> mWTexCoords;
53 std::vector<uint32_t> mTris;
54 std::vector<float> mTNormals;
55 std::vector<uint32_t> mTColors;
56 std::vector<uint32_t> mVTexIds;
57 std::vector<uint32_t> mWTexIds;
59 std::vector<uint32_t> mEdges;
60 std::vector<float> mENormals;
61 std::vector<uint32_t> mEColors;
63 std::vector<uint32_t> mWireframe;
65 std::vector<vcl::Image> mTextures;
67 std::array<float, 4> mMeshColor = {0.5, 0.5, 0.5, 1};
84 swap(mVerts,
other.mVerts);
85 swap(mVNormals,
other.mVNormals);
86 swap(mVColors,
other.mVColors);
87 swap(mVTexCoords,
other.mVTexCoords);
88 swap(mWTexCoords,
other.mWTexCoords);
89 swap(mTris,
other.mTris);
90 swap(mTNormals,
other.mTNormals);
91 swap(mTColors,
other.mTColors);
92 swap(mVTexIds,
other.mVTexIds);
93 swap(mWTexIds,
other.mWTexIds);
94 swap(mEdges,
other.mEdges);
95 swap(mENormals,
other.mENormals);
96 swap(mEColors,
other.mEColors);
97 swap(mWireframe,
other.mWireframe);
98 swap(mTextures,
other.mTextures);
99 swap(mMeshColor,
other.mMeshColor);
102 uint vertexNumber()
const {
return mVerts.
size() / 3; }
104 uint triangleNumber()
const {
return mTris.
size() / 3; }
106 uint edgeNumber()
const {
return mEdges.
size() / 2; }
108 uint wireframeEdgeNumber()
const {
return mWireframe.
size() / 2; }
110 uint textureNumber()
const {
return mTextures.
size(); }
117 const float* vertexBufferData()
const
121 return mVerts.data();
124 uint vertexBufferSize()
const {
return mVerts.
size(); }
126 const uint32_t* triangleBufferData()
const
133 uint triangleBufferSize()
const {
return mTris.
size(); }
135 const uint32_t* edgeBufferData()
const
139 return mEdges.data();
142 uint edgeBufferSize()
const {
return mEdges.
size(); }
144 const uint32_t* wireframeBufferData()
const
146 if (mWireframe.empty())
148 return mWireframe.data();
151 uint wireframeBufferSize()
const {
return mWireframe.
size(); }
153 const float* vertexNormalBufferData()
const
155 if (mVNormals.empty())
157 return mVNormals.data();
160 const uint32_t* vertexColorBufferData()
const
162 if (mVColors.empty())
164 return mVColors.data();
167 const float* triangleNormalBufferData()
const
169 if (mTNormals.empty())
171 return mTNormals.data();
174 const uint32_t* triangleColorBufferData()
const
176 if (mTColors.empty())
178 return mTColors.data();
181 const float* vertexTexCoordsBufferData()
const
183 if (mVTexCoords.empty())
185 return mVTexCoords.data();
188 const uint32_t* vertexTextureIDsBufferData()
const
190 if (mVTexIds.empty())
192 return mVTexIds.data();
195 const float* wedgeTexCoordsBufferData()
const
197 if (mWTexCoords.empty())
199 return mWTexCoords.data();
202 const uint32_t* wedgeTextureIDsBufferData()
const
204 if (mWTexIds.empty())
206 return mWTexIds.data();
209 const float* edgeNormalBufferData()
const
211 if (mENormals.empty())
213 return mENormals.data();
216 const uint32_t* edgeColorBufferData()
const
218 if (mEColors.empty())
220 return mEColors.data();
223 const float* meshColorBufferData()
const {
return mMeshColor.data(); }
225 const unsigned char* textureBufferData(
uint ti)
const
227 return mTextures[
ti].data();
231 void setVertexPositionsBuffer(
const MeshType& mesh)
233 uint nv = Base::numVerts();
235 mVerts.resize(
nv * 3);
237 Base::fillVertexPositions(mesh, mVerts.data());
240 void setVertexNormalsBuffer(
const MeshType& mesh)
242 uint nv = Base::numVerts();
244 mVNormals.resize(
nv * 3);
246 Base::fillVertexNormals(mesh, mVNormals.data());
249 void setVertexColorsBuffer(
const MeshType& mesh)
251 uint nv = Base::numVerts();
255 Base::fillVertexColors(mesh, mVColors.data(), Color::Format::ABGR);
258 void setVertexTexCoordsBuffer(
const MeshType& mesh)
260 uint nv = Base::numVerts();
262 mVTexCoords.resize(
nv * 2);
264 Base::fillVertexTexCoords(mesh, mVTexCoords.data());
267 void setWedgeTexCoordsBuffer(
const MeshType& mesh)
269 uint nv = Base::numVerts();
271 mWTexCoords.resize(
nv * 2);
273 Base::fillWedgeTexCoords(mesh, mWTexCoords.data());
276 void setTriangleIndicesBuffer(
const MeshType& mesh)
278 uint nt = Base::numTris();
280 mTris.resize(
nt * 3);
282 Base::fillTriangleIndices(mesh, mTris.data());
285 void setTriangleNormalsBuffer(
const MeshType& mesh)
287 uint nt = Base::numTris();
289 mTNormals.resize(
nt * 3);
291 Base::fillTriangleNormals(mesh, mTNormals.data());
294 void setTriangleColorsBuffer(
const MeshType& mesh)
296 uint nt = Base::numTris();
300 Base::fillTriangleColors(mesh, mTColors.data(), Color::Format::ABGR);
303 void setVertexTextureIndicesBuffer(
const MeshType& mesh)
305 if (vcl::isPerVertexTexCoordAvailable(mesh)) {
306 uint nt = Base::numTris();
310 Base::fillVertexTextureIndices(mesh, mVTexIds.data());
314 void setWedgeTextureIndicesBuffer(
const MeshType& mesh)
316 uint nt = Base::numTris();
320 Base::fillWedgeTextureIndices(mesh, mWTexIds.data());
323 void setEdgeIndicesBuffer(
const MeshType& mesh)
325 uint ne = Base::numEdges();
327 mEdges.resize(
ne * 2);
329 Base::fillEdgeIndices(mesh, mEdges.data());
332 void setEdgeNormalsBuffer(
const MeshType& mesh)
334 uint ne = Base::numEdges();
336 mENormals.resize(
ne * 3);
338 Base::fillEdgeNormals(mesh, mENormals.data());
341 void setEdgeColorsBuffer(
const MeshType& mesh)
343 uint ne = Base::numEdges();
347 Base::fillEdgeColors(mesh, mEColors.data(), Color::Format::ABGR);
350 void setWireframeIndicesBuffer(
const MeshType& mesh)
352 const uint nw = Base::numWireframeLines();
354 mWireframe.resize(
nw * 2);
356 Base::fillWireframeIndices(mesh, mWireframe.data());
359 void setTextureUnits(
const MeshType& mesh)
362 mTextures.reserve(mesh.textureNumber());
363 for (
uint i = 0;
i < mesh.textureNumber(); ++
i) {
366 if (mesh.texture(
i).image().isNull()) {
367 txt = vcl::loadImage(
368 mesh.meshBasePath() + mesh.texturePath(
i));
371 txt = mesh.texture(
i).image();
375 txt = vcl::loadImage(mesh.meshBasePath() + mesh.texturePath(
i));
381 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 mesh_requirements.h:96