MCPcopy Create free account
hub / github.com/FlaxEngine/FlaxEngine / ImportMesh

Function ImportMesh

Source/Engine/Tools/ModelTool/ModelTool.Assimp.cpp:588–635  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

586}
587
588bool ImportMesh(int32 index, ModelData& result, AssimpImporterData& data, String& errorMsg)
589{
590 const auto aMesh = data.Scene->mMeshes[index];
591
592 // Skip invalid meshes
593 if (IsMeshInvalid(aMesh))
594 return false;
595
596 // Skip unused meshes
597 if (!data.MeshIndexToNodeIndex.ContainsKey(index))
598 return false;
599
600 // Import mesh data
601 MeshData* meshData = New<MeshData>();
602 if (ProcessMesh(result, data, aMesh, *meshData, errorMsg))
603 {
604 Delete(meshData);
605 return true;
606 }
607
608 auto& nodesWithMesh = data.MeshIndexToNodeIndex[index];
609 for (int32 i = 0; i < nodesWithMesh.Count(); i++)
610 {
611 const auto nodeIndex = nodesWithMesh[i];
612 auto& node = data.Nodes[nodeIndex];
613 const int32 lodIndex = node.LodIndex;
614
615 // The first mesh instance uses meshData directly while others have to clone it
616 if (i != 0)
617 {
618 meshData = New<MeshData>(*meshData);
619 }
620
621 // Link mesh
622 meshData->NodeIndex = nodeIndex;
623 AssimpNode* curNode = &data.Nodes[meshData->NodeIndex];
624
625 meshData->OriginTranslation = curNode->LocalTransform.Translation;
626 meshData->OriginOrientation = curNode->LocalTransform.Orientation;
627 meshData->Scaling = curNode->LocalTransform.Scale;
628
629 if (result.LODs.Count() <= lodIndex)
630 result.LODs.Resize(lodIndex + 1);
631 result.LODs[lodIndex].Meshes.Add(meshData);
632 }
633
634 return false;
635}
636
637void ImportCurve(aiVectorKey* keys, uint32 keysCount, LinearCurve<Float3>& curve)
638{

Callers 1

ImportDataAssimpMethod · 0.70

Calls 7

DeleteFunction · 0.85
IsMeshInvalidFunction · 0.70
ProcessMeshFunction · 0.70
ContainsKeyMethod · 0.45
CountMethod · 0.45
ResizeMethod · 0.45
AddMethod · 0.45

Tested by

no test coverage detected