| 195 | }; |
| 196 | |
| 197 | void ProcessNodes(AssimpImporterData& data, aiNode* aNode, int32 parentIndex) |
| 198 | { |
| 199 | const int32 nodeIndex = data.Nodes.Count(); |
| 200 | |
| 201 | // Assign the index of the node to the index of the mesh |
| 202 | for (unsigned i = 0; i < aNode->mNumMeshes; i++) |
| 203 | { |
| 204 | int meshIndex = aNode->mMeshes[i]; |
| 205 | data.MeshIndexToNodeIndex[meshIndex].Add(nodeIndex); |
| 206 | } |
| 207 | |
| 208 | // Create node |
| 209 | AssimpNode node; |
| 210 | node.ParentIndex = parentIndex; |
| 211 | node.Name = aNode->mName.C_Str(); |
| 212 | |
| 213 | // Pick node LOD index |
| 214 | if (parentIndex == -1 || !data.Options.ImportLODs) |
| 215 | { |
| 216 | node.LodIndex = 0; |
| 217 | } |
| 218 | else |
| 219 | { |
| 220 | node.LodIndex = data.Nodes[parentIndex].LodIndex; |
| 221 | if (node.LodIndex == 0) |
| 222 | { |
| 223 | node.LodIndex = ModelTool::DetectLodIndex(node.Name); |
| 224 | } |
| 225 | ASSERT(Math::IsInRange(node.LodIndex, 0, MODEL_MAX_LODS - 1)); |
| 226 | } |
| 227 | |
| 228 | Matrix transform = ToMatrix(aNode->mTransformation); |
| 229 | transform.Decompose(node.LocalTransform); |
| 230 | if (data.Options.IgnoreNodesScale) |
| 231 | node.LocalTransform.Scale = Float3::One; |
| 232 | data.Nodes.Add(node); |
| 233 | |
| 234 | // Process the children |
| 235 | for (unsigned i = 0; i < aNode->mNumChildren; i++) |
| 236 | { |
| 237 | ProcessNodes(data, aNode->mChildren[i], nodeIndex); |
| 238 | } |
| 239 | } |
| 240 | |
| 241 | bool ProcessMesh(ModelData& result, AssimpImporterData& data, const aiMesh* aMesh, MeshData& mesh, String& errorMsg) |
| 242 | { |