5 #include <unordered_map>
24 using std::unordered_map;
69 xAxis.
set(matrix[0], matrix[1], matrix[2]);
70 yAxis.
set(matrix[4], matrix[5], matrix[6]);
71 zAxis.
set(matrix[8], matrix[9], matrix[10]);
73 return Vector3::computeDotProduct(Vector3::computeCrossProduct(
xAxis,
yAxis),
zAxis) < 0.0f;
94 auto normal = Vector3::computeCrossProduct(
95 (vertices)[1].clone().sub((vertices)[0]),
96 (vertices)[2].clone().sub((vertices)[0])
99 if (normal.computeLengthSquared() < Math::EPSILON * Math::EPSILON) {
101 normal.set(0.0f, 1.0f, 0.0f);
120 array<Vector3,3> normals;
121 for (
auto i = 0; i < vertices.size(); i++) {
122 normals[i].set(normal);
215 static void cloneNode(
Node* sourceNode,
Model* targetModel,
Node* targetParentNode =
nullptr,
bool cloneMesh =
true);
226 static void partitionNode(
Node* sourceNode, unordered_map<string, Model*>& modelsByPartition, unordered_map<string, Vector3>& modelsPosition,
const Matrix4x4& parentTransformMatrix);
242 array<Vector3, 3> vertices;
243 auto normalCount = 0;
244 normal.
set(0.0f, 0.0f, 0.0f);
246 for (
const auto& face: facesEntity.getFaces()) {
247 for (
auto i = 0; i < vertices.size(); i++) {
249 normal.
add(normals[face.getNormalIndices()[0]]);
254 if (normalCount == 6)
break;
256 if (normalCount == 6)
break;
258 if (normalCount > 1) {
286 static void partition(
Model* model,
const Transform& transform, unordered_map<string, Model*>& modelsByPartition, unordered_map<string, Vector3>& modelsPosition);
318 static Model*
optimizeModel(
Model* model,
const string& texturePathName =
string(),
const vector<string>& excludeDiffuseTextureFileNamePatterns = vector<string>());
369 static void checkForOptimization(
Node* node, unordered_map<string, int>& materialUseCount,
const vector<string>& excludeDiffuseTextureFileNamePatterns);
387 static void optimizeNode(
Node* sourceNode,
Model* targetModel,
int diffuseTextureAtlasSize,
const unordered_map<string, int>& diffuseTextureAtlasIndices,
const vector<string>& excludeDiffuseTextureFileNamePatterns);
Representation of a 3D model.
const vector< Vector3 > & getVertices() const
const vector< FacesEntity > & getFacesEntities() const
Skinning definition for nodes.
Matrix4x4 class representing matrix4x4 mathematical structure and operations for 3d space.
Vector2 class representing vector2 mathematical structure and operations with x, y components.
Vector3 class representing vector3 mathematical structure and operations with x, y,...
Vector3 & add(float scalar)
Adds a scalar.
Vector3 & set(float x, float y, float z)
Sets this vector3 by its components.
bool equals(const Vector3 &vector3, float tolerance=Math::EPSILON) const
Compares this vector3 with given vector3.
Vector3 & normalize()
Normalizes this vector3.