73 inline MeshDescription(uint32_t inNumVertices, uint32_t inNumTriangles);
98 uint32_t
rMax, cMax, rIncrement;
105 template <
typename Real>
113 Mesh(
MeshDescription const& description, std::vector<MeshTopology>
const& validTopologies);
119 Mesh& operator=(
Mesh const&) =
delete;
141 void ComputeIndices();
155 virtual void UpdateNormals();
156 virtual void UpdateFrame();
189 std::vector<Matrix<2, 2, Real>>
mUTU;
190 std::vector<Matrix<3, 2, Real>>
mDTU;
197 numVertices(inNumVertices),
198 numTriangles(inNumTriangles),
199 wantDynamicTangentSpaceUpdate(false),
201 hasTangentSpaceVectors(false),
202 allowUpdateFrame(false),
236 numRows = std::max(inNumRows, 2u);
237 numCols = std::max(inNumCols, 2u);
246 numRows = std::max(inNumRows, 2u);
247 numCols = std::max(inNumCols, 3u);
256 numRows = std::max(inNumRows, 2u);
257 numCols = std::max(inNumCols, 3u);
266 numRows = std::max(inNumRows, 1u);
267 numCols = std::max(inNumCols, 3u);
276 numRows = std::max(inNumRows, 1u);
277 numCols = std::max(inNumCols, 3u);
287 template <
typename Real>
290 mDescription(description),
294 mBitangents(nullptr),
307 for (
auto const& topology : validTopologies)
318 LogError(
"The mesh needs triangles/indices.");
328 if (attribute.source !=
nullptr && attribute.stride > 0)
330 if (attribute.semantic ==
"position")
337 if (attribute.semantic ==
"normal")
344 if (attribute.semantic ==
"tangent")
352 if (attribute.semantic ==
"bitangent")
360 if (attribute.semantic ==
"dpdu")
368 if (attribute.semantic ==
"dpdv")
376 if (attribute.semantic ==
"tcoord")
387 LogError(
"The mesh needs positions.");
432 template <
typename Real>
437 template <
typename Real>
443 template <
typename Real>
448 LogError(
"The Mesh object failed the construction.");
465 template <
typename Real>
468 char* positions =
reinterpret_cast<char*
>(
mPositions);
472 template <
typename Real>
475 char* normals =
reinterpret_cast<char*
>(
mNormals);
479 template <
typename Real>
482 char* tangents =
reinterpret_cast<char*
>(
mTangents);
486 template <
typename Real>
489 char* bitangents =
reinterpret_cast<char*
>(
mBitangents);
493 template <
typename Real>
496 char* dpdus =
reinterpret_cast<char*
>(
mDPDUs);
500 template <
typename Real>
503 char* dpdvs =
reinterpret_cast<char*
>(
mDPDVs);
507 template <
typename Real>
510 char* tcoords =
reinterpret_cast<char*
>(
mTCoords);
514 template <
typename Real>
520 uint32_t
v0 = i,
v1 = v0 + 1;
522 uint32_t
v2 = i,
v3 = v2 + 1;
585 template <
typename Real>
617 Normal(v0) += triangleNormal;
618 Normal(v1) += triangleNormal;
619 Normal(v2) += triangleNormal;
629 template <
typename Real>
644 std::fill(
mUTU.begin(),
mUTU.end(), zero2x2);
645 std::fill(
mDTU.begin(),
mDTU.end(), zero3x2);
677 mUTU[
v0] += outerU10 + outerU20;
678 mUTU[
v1] += outerU10 + outerU21;
679 mUTU[
v2] += outerU20 + outerU21;
680 mDTU[
v0] += outerD10 + outerD20;
681 mDTU[
v1] += outerD10 + outerD21;
682 mDTU[
v2] += outerD20 + outerD21;
718 basis[0] = { jacobian(0, 0), jacobian(1, 0), jacobian(2, 0) };
719 basis[1] = { jacobian(0, 1), jacobian(1, 1), jacobian(2, 1) };
virtual void UpdatePositions()
MeshDescription const & GetDescription() const
std::vector< Matrix< 2, 2, Real > > mUTU
MeshDescription mDescription
void GetTriangle(uint32_t t, uint32_t &v0, uint32_t &v1, uint32_t &v2) const
#define LogAssert(condition, message)
Vector3< Real > * mPositions
Vector3< Real > * mBitangents
virtual void UpdateNormals()
Vector3< Real > & Bitangent(uint32_t i)
IndexAttribute indexAttribute
Vector3< Real > & DPDU(uint32_t i)
Vector3< Real > * mTangents
void SetTriangle(uint32_t t, uint32_t v0, uint32_t v1, uint32_t v2)
std::vector< VertexAttribute > vertexAttributes
bool wantDynamicTangentSpaceUpdate
#define LogError(message)
Vector3< Real > * mNormals
DualQuaternion< Real > Dot(DualQuaternion< Real > const &d0, DualQuaternion< Real > const &d1)
GLfloat GLfloat GLfloat GLfloat v3
Real Normalize(GVector< Real > &v, bool robust=false)
virtual void UpdateFrame()
DualQuaternion< Real > Cross(DualQuaternion< Real > const &d0, DualQuaternion< Real > const &d1)
std::vector< Matrix< 3, 2, Real > > mDTU
Vector2< Real > & TCoord(uint32_t i)
Vector3< Real > & Tangent(uint32_t i)
GLfloat GLfloat GLfloat v2
Vector2< Real > * mTCoords
Vector3< Real > & Normal(uint32_t i)
Vector3< Real > & DPDV(uint32_t i)
bool hasTangentSpaceVectors
Quaternion< Real > Inverse(Quaternion< Real > const &d)
Real ComputeOrthogonalComplement(int numInputs, Vector2< Real > *v, bool robust=false)
Mesh(MeshDescription const &description, std::vector< MeshTopology > const &validTopologies)
Vector3< Real > & Position(uint32_t i)
MeshDescription(uint32_t inNumVertices, uint32_t inNumTriangles)
GMatrix< Real > OuterProduct(GVector< Real > const &U, GVector< Real > const &V)