Added the ASSIMP library
Added the files provided for the tutorial Added the SplitMeshNode and SubMeshNode classes
This commit is contained in:
63
Graphics2/SplitMeshNode.cpp
Normal file
63
Graphics2/SplitMeshNode.cpp
Normal file
@ -0,0 +1,63 @@
|
||||
#include "SplitMeshNode.h"
|
||||
|
||||
SplitMeshNode::SplitMeshNode(wstring name, wstring modelName)
|
||||
{
|
||||
_modelName = modelName;
|
||||
}
|
||||
|
||||
bool SplitMeshNode::Initialise()
|
||||
{
|
||||
bool currentStatus = true;
|
||||
|
||||
_resourceManager = DirectXFramework::GetDXFramework()->GetResourceManager();
|
||||
_mesh = _resourceManager->GetMesh(_modelName);
|
||||
if (_mesh == nullptr)
|
||||
{
|
||||
currentStatus = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
Add(AddMeshNode(_mesh->GetRootNode()));
|
||||
}
|
||||
|
||||
if (currentStatus)
|
||||
{
|
||||
currentStatus = SceneGraph::Initialise();
|
||||
}
|
||||
|
||||
return currentStatus;
|
||||
}
|
||||
|
||||
SceneGraphPointer SplitMeshNode::AddMeshNode(shared_ptr<Node> node)
|
||||
{
|
||||
unsigned int subMeshCount = (unsigned int)node->GetMeshCount();
|
||||
SceneGraphPointer currentNodeGraph = make_shared<SceneGraph>(node->GetName());
|
||||
|
||||
/*string nameString;
|
||||
for (char x : node->GetName())
|
||||
{
|
||||
nameString += x;
|
||||
}
|
||||
|
||||
fileOut << string(depth, '-') + " " + nameString << endl;*/
|
||||
|
||||
// Loop through all submeshes in the mesh
|
||||
for (unsigned int i = 0; i < subMeshCount; i++)
|
||||
{
|
||||
unsigned int meshIndex = node->GetMesh(i);
|
||||
shared_ptr<SubMesh> subMesh = _mesh->GetSubMesh(meshIndex);
|
||||
shared_ptr<SubMeshNode> subNode = make_shared<SubMeshNode>(node->GetName() + L"_" + to_wstring(i), subMesh);
|
||||
subNode->SetWorldTransform(XMMatrixIdentity());
|
||||
currentNodeGraph->Add(subNode);
|
||||
}
|
||||
|
||||
// Render the children
|
||||
unsigned int childrenCount = (unsigned int)node->GetChildrenCount();
|
||||
// Loop through all submeshes in the mesh, rendering them
|
||||
for (unsigned int i = 0; i < childrenCount; i++)
|
||||
{
|
||||
currentNodeGraph->Add(AddMeshNode(node->GetChild(i)));
|
||||
}
|
||||
|
||||
return currentNodeGraph;
|
||||
}
|
Reference in New Issue
Block a user