#include "SubMeshNode.h"

bool SubMeshNode::Initialise()
{
	_resourceManager = DirectXFramework::GetDXFramework()->GetResourceManager();
	_renderer = dynamic_pointer_cast<SubMeshRenderer>(_resourceManager->GetRenderer(L"SMR"));
	if (_subMesh == nullptr)
	{
		return false;
	}
	return _renderer->Initialise();
}

void SubMeshNode::Shutdown()
{	
}

void SubMeshNode::Render()
{
	_renderer->SetSubMesh(_subMesh);
	_renderer->SetWorldTransformation(XMLoadFloat4x4(&_combinedWorldTransformation));
	_renderer->SetCameraPosition(XMFLOAT4(0.0f, 0.0f, -100.0f, 1.0f));
	_renderer->SetAmbientLight(XMFLOAT4(0.5f, 0.5f, 0.5f, 1.0f));
	_renderer->SetDirectionalLight(XMVectorSet(0.0f, -1.0f, 1.0f, 0.0f), XMFLOAT4(1.0f, 1.0f, 1.0f, 1.0f));
	_renderer->Render();
}
