
Added ability to hold shift and skip the terrain generation when loading Added ability for the perlin terrain to save a raw image of the terrain to use as a cache
96 lines
1.8 KiB
C++
96 lines
1.8 KiB
C++
#include "SceneGraph.h"
|
|
|
|
bool SceneGraph::Initialise()
|
|
{
|
|
bool currentStatus = true;
|
|
|
|
for (SceneNodePointer& currentSceneGraphPtr : _children)
|
|
{
|
|
currentStatus = currentSceneGraphPtr->Initialise();
|
|
if (!currentStatus)
|
|
{
|
|
break;
|
|
}
|
|
}
|
|
|
|
return currentStatus;
|
|
}
|
|
|
|
void SceneGraph::Update(FXMMATRIX& currentWorldTransformation)
|
|
{
|
|
SceneNode::Update(currentWorldTransformation);
|
|
|
|
XMMATRIX combinedWorldTransform = XMLoadFloat4x4(&_combinedWorldTransformation);
|
|
for (SceneNodePointer& currentSceneGraphPtr : _children)
|
|
{
|
|
currentSceneGraphPtr->Update(combinedWorldTransform);
|
|
}
|
|
}
|
|
|
|
void SceneGraph::Render()
|
|
{
|
|
for (SceneNodePointer& currentSceneGraphPtr : _children)
|
|
{
|
|
currentSceneGraphPtr->Render();
|
|
}
|
|
}
|
|
|
|
void SceneGraph::Shutdown()
|
|
{
|
|
for (SceneNodePointer& currentSceneGraphPtr : _children)
|
|
{
|
|
currentSceneGraphPtr->Shutdown();
|
|
}
|
|
}
|
|
|
|
void SceneGraph::Add(SceneNodePointer node)
|
|
{
|
|
_children.push_back(node);
|
|
}
|
|
|
|
void SceneGraph::Remove(SceneNodePointer node)
|
|
{
|
|
for (SceneNodePointer& currentSceneGraphPtr : _children)
|
|
{
|
|
if (currentSceneGraphPtr == node)
|
|
{
|
|
_children.remove(currentSceneGraphPtr);
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
|
|
SceneNodePointer SceneGraph::Find(wstring name)
|
|
{
|
|
if (_name == name)
|
|
{
|
|
return shared_from_this();
|
|
}
|
|
|
|
SceneNodePointer foundValue = nullptr;
|
|
for (SceneNodePointer& currentSceneGraphPtr : _children)
|
|
{
|
|
foundValue = currentSceneGraphPtr->Find(name);
|
|
// Keep going til we find a value, then break the loop all the way down
|
|
if (foundValue != nullptr)
|
|
{
|
|
break;
|
|
}
|
|
}
|
|
return foundValue;
|
|
}
|
|
|
|
SceneNodePointer SceneGraph::GetFirstChild()
|
|
{
|
|
SceneNodePointer firstChild = nullptr;
|
|
if (_children.size() > 0)
|
|
{
|
|
firstChild = _children.front();
|
|
}
|
|
return firstChild;
|
|
}
|
|
|
|
list<SceneNodePointer>& SceneGraph::GetChildren()
|
|
{
|
|
return _children;
|
|
} |