88//
99
1010#include " StaticMeshDataPacker.h"
11+ #include " MathUtils.h"
1112
1213#include < assimp/postprocess.h>
1314#include < assimp/scene.h>
1617#include < utils/Logging.h>
1718
1819#include < algorithm>
19- #include < assimp/Importer.hpp>
2020#include < fstream>
2121
2222enum RequestPathStage
@@ -50,7 +50,7 @@ static RequestPathStage GetRequestPathStage(const Siege::String& requestPath,
5050
5151static void GetMeshData (const aiScene* scene,
5252 const aiMesh* mesh,
53- const aiMatrix4x4t<ai_real>& matrix ,
53+ const Siege::Mat4& mat ,
5454 OUT std::vector<Siege::BaseVertex>& vertices,
5555 OUT std::vector<uint32_t >& indices)
5656{
@@ -59,8 +59,11 @@ static void GetMeshData(const aiScene* scene,
5959 Siege::BaseVertex vertex {};
6060
6161 aiVector3t<ai_real> vert = mesh->mVertices [i];
62- vert *= matrix;
63- vertex.position = {vert.x , vert.y , vert.z };
62+ Siege::Vec4 v = {vert.x , vert.y , vert.z , 1 .f };
63+
64+ v = mat * v;
65+
66+ vertex.position = {v.x , v.y , v.z };
6467
6568 aiVector3t<ai_real> norm = mesh->mNormals [i];
6669 vertex.normal = {norm.x , norm.y , norm.z };
@@ -93,7 +96,7 @@ static void GetMeshesForNode(const aiScene* scene,
9396 const aiNode* node,
9497 const Siege::String& requestPath,
9598 Siege::String currentPath,
96- aiMatrix4x4t<ai_real> matrix,
99+ Siege::Mat4 matrix,
97100 OUT std::vector<Siege::BaseVertex>& vertices,
98101 OUT std::vector<uint32_t >& indices)
99102{
@@ -109,7 +112,7 @@ static void GetMeshesForNode(const aiScene* scene,
109112
110113 if (nodePathStage == CHILD || nodePathStage == SELF)
111114 {
112- matrix *= node->mTransformation ;
115+ matrix *= AssimptMat4ToMat4 ( node->mTransformation ) ;
113116 }
114117
115118 for (uint32_t i = 0 ; i < node->mNumMeshes ; i++)
@@ -175,7 +178,7 @@ void* PackStaticMeshFile(const Siege::String& filePath, const Siege::String& ass
175178
176179 CC_LOG_INFO (" Reading static mesh for file {} with node path {}" , it->second , requestedNodePath)
177180
178- aiMatrix4x4t<ai_real> baseXform;
181+ Siege::Mat4 baseXform = Siege::Mat4::Identity () ;
179182 auto flipAxesIt = attributes.find (TOKEN_FLIP_AXES);
180183 if (flipAxesIt != attributes.end ())
181184 {
@@ -186,7 +189,7 @@ void* PackStaticMeshFile(const Siege::String& filePath, const Siege::String& ass
186189
187190 for (int32_t i = 0 ; i < flipAxesIt->second .Size (); ++i)
188191 {
189- aiVector3t<ai_real> scale { 1 .f , 1 .f , 1 .f };
192+ Siege::Vec4 scale = { 1 . f , 1 .f , 1 .f , 1 .f };
190193 switch (flipAxesIt->second [i])
191194 {
192195 case ' x' :
@@ -203,8 +206,7 @@ void* PackStaticMeshFile(const Siege::String& filePath, const Siege::String& ass
203206 flipAxesIt->second [i])
204207 break ;
205208 }
206- aiMatrix4x4t<ai_real> scalingMat;
207- baseXform *= aiMatrix4x4t<ai_real>::Scaling (scale, scalingMat);
209+ baseXform *= Siege::Mat4::Scale (scale);
208210 }
209211 }
210212
0 commit comments