24 vec3 min = Vertices[0].Position;
25 vec3 max = Vertices[0].Position;
27 for (
INT i = 1; i < Vertices.size(); i++)
28 min =
vec3::Min(min, Vertices[i].Position),
29 max =
vec3::Max(max, Vertices[i].Position);
35 for (
INT i = 0; i < Indices.size(); i += 3)
37 vec3 A = Vertices[Indices[i + 1]].Position - Vertices[Indices[i]].Position;
38 vec3 B = Vertices[Indices[i + 2]].Position - Vertices[Indices[i]].Position;
39 vec3 N =
A.Cross(
B).Normalized();
41 Vertices[Indices[i + 0]].Normal =
vec3(Vertices[Indices[i + 0]].Normal +
N).
Normalized();
42 Vertices[Indices[i + 1]].Normal =
vec3(Vertices[Indices[i + 1]].Normal +
N).
Normalized();
43 Vertices[Indices[i + 2]].Normal =
vec3(Vertices[Indices[i + 2]].Normal +
N).
Normalized();
50 for (
INT i = 0; i < Indices.size() && is_ok; i += 3)
51 is_ok = EvaluateTriangleTangentSpace(Vertices[Indices[i + 0]],
52 Vertices[Indices[i + 1]],
53 Vertices[Indices[i + 2]]);
55 for (
auto &
V : Vertices) EvaluateVertexOrthoganalTBNBasis(
V);
57 for (
auto &
V : Vertices)
61 if (
N.Z >
N.X &&
N.Z >
N.Y ||
N.Y >
N.X &&
N.Y >
N.Z)
63 V.Tangent =
vec3(1, 0, 0);
66 V.Tangent =
vec3(0, 1, 0);
67 V.Bitangent =
N.Cross(
V.Tangent).Normalized();
68 V.Tangent =
V.Bitangent.Cross(
N).Normalized();
78 float det = s1 * t2 - s2 * t1;
84 vec3 T = ((E1 * t2 - E2 * t1) / det).Normalized();
85 vec3 B = ((E2 * s1 - E1 * s2) / det).Normalized();
97 P.Normal.Normalize(),
P.Tangent.Normalize(),
P.Bitangent.Normalize();
99 P.Tangent = (
P.Tangent -
P.Normal *
P.Normal.Dot(
P.Tangent)).Normalized();
100 P.Bitangent = (
P.Bitangent -
P.Normal *
P.Normal.Dot(
P.Bitangent) -
P.Tangent *
P.Tangent.Dot(
P.Bitangent)).Normalized();
static vec3 Max(const vec3 &A, const vec3 &B)
static vec3 Min(const vec3 &A, const vec3 &B)
virtual void EvaluateBoundBox()
virtual void EvaluateNormals()
virtual void EvaluateTangentSpace()
static bool EvaluateTriangleTangentSpace(vertex &P0, vertex &P1, vertex &P2)
static void EvaluateVertexOrthoganalTBNBasis(vertex &P)
Sculpto library prehompiled header. Defines common definitions, includes commonly used modules.
Topology object triangles mesh class declaration module.