31 #include "model_data_draw_range.h"
61 std::vector<Vec3f> tan1, tan2;
64 for (
size_t i = 0; i + 2 <
elements.size(); i += 3)
78 float x1 = v2.
x - v1.
x;
79 float x2 = v3.
x - v1.
x;
80 float y1 = v2.
y - v1.
y;
81 float y2 = v3.
y - v1.
y;
82 float z1 = v2.
z - v1.
z;
83 float z2 = v3.
z - v1.
z;
85 float s1 = w2.
x - w1.
x;
86 float s2 = w3.
x - w1.
x;
87 float t1 = w2.
y - w1.
y;
88 float t2 = w3.
y - w1.
y;
90 float r = 1.0f / (s1 * t2 - s2 * t1);
91 Vec3f sdir((t2 * x1 - t1 * x2) * r, (t2 * y1 - t1 * y2) * r, (t2 * z1 - t1 * z2) * r);
92 Vec3f tdir((s1 * x2 - s2 * x1) * r, (s1 * y2 - s2 * y1) * r, (s1 * z2 - s2 * z1) * r);
103 for (
size_t i = 0; i <
vertices.size(); i++)
106 const Vec3f &t = tan1[i];
std::vector< unsigned int > elements
Definition: model_data_mesh.h:48
static Vec3< float > cross(const Vec3< float > &vector1, const Vec3< float > &vector2)
Calculate the cross product between two vectors.
Type x
Definition: vec3.h:81
Type y
Definition: vec3.h:82
std::vector< Vec3f > tangents
Definition: model_data_mesh.h:42
void calculate_tangents()
Definition: model_data_mesh.h:54
std::vector< Vec4ub > bone_selectors
Definition: model_data_mesh.h:45
std::vector< Vec4ub > bone_weights
Definition: model_data_mesh.h:44
std::vector< Vec3f > normals
Definition: model_data_mesh.h:41
Type x
Definition: vec2.h:82
std::vector< Vec3f > bitangents
Definition: model_data_mesh.h:43
std::vector< ModelDataDrawRange > draw_ranges
Definition: model_data_mesh.h:49
static float dot(const Vec3< float > &vector1, const Vec3< float > &vector2)
Dot products between two vectors.
Definition: vec3.h:107
std::vector< Vec3f > vertices
Definition: model_data_mesh.h:40
std::vector< Vec4ub > colors
Definition: model_data_mesh.h:46
std::vector< std::vector< Vec2f > > channels
Definition: model_data_mesh.h:47
Vertex attributes and draw ranges required to draw a mesh.
Definition: model_data_mesh.h:37
Type z
Definition: vec3.h:83
Type y
Definition: vec2.h:83