Ndk/RenderSystem: Finish first implementation

Huge WIP, but I have a first render with it


Former-commit-id: 82ecea8b6ce5c452818f1585c61af7623c28e958
This commit is contained in:
Lynix 2015-06-04 00:20:51 +02:00
parent fac893f379
commit 80ed8c48bd
4 changed files with 31 additions and 0 deletions

View File

@ -7,6 +7,7 @@
#ifndef NDK_SYSTEMS_RENDERSYSTEM_HPP
#define NDK_SYSTEMS_RENDERSYSTEM_HPP
#include <Nazara/Graphics/ForwardRenderTechnique.hpp>
#include <NDK/EntityList.hpp>
#include <NDK/System.hpp>
#include <unordered_map>
@ -20,6 +21,7 @@ namespace Ndk
{
public:
RenderSystem();
inline RenderSystem(const RenderSystem& renderSystem);
~RenderSystem() = default;
void Update(float elapsedTime);
@ -32,6 +34,7 @@ namespace Ndk
EntityList m_cameras;
EntityList m_drawables;
NzForwardRenderTechnique m_renderTechnique;
};
}

View File

@ -1,3 +1,11 @@
// Copyright (C) 2015 Jérôme Leclercq
// This file is part of the "Nazara Development Kit"
// For conditions of distribution and use, see copyright notice in Prerequesites.hpp
namespace Ndk
{
inline RenderSystem::RenderSystem(const RenderSystem& renderSystem) :
System(renderSystem)
{
}
}

View File

@ -11,6 +11,8 @@ namespace Ndk
{
if (addDefaultSystems)
AddDefaultSystems();
m_entities.reserve(100); // Temporaire, je le jure
}
inline BaseSystem& World::AddSystem(std::unique_ptr<BaseSystem>&& system)

View File

@ -3,6 +3,7 @@
// For conditions of distribution and use, see copyright notice in Prerequesites.hpp
#include <NDK/Systems/RenderSystem.hpp>
#include <Nazara/Graphics/Scene.hpp>
#include <NDK/Components/CameraComponent.hpp>
#include <NDK/Components/GraphicsComponent.hpp>
#include <NDK/Components/NodeComponent.hpp>
@ -21,6 +22,23 @@ namespace Ndk
NodeComponent& cameraNode = camera->GetComponent<NodeComponent>();
camComponent.ApplyView();
NzScene dummyScene;
dummyScene.SetViewer(camComponent);
NzAbstractRenderQueue* renderQueue = m_renderTechnique.GetRenderQueue();
renderQueue->Clear();
for (const Ndk::EntityHandle& drawable : m_drawables)
{
GraphicsComponent& graphicsComponent = drawable->GetComponent<GraphicsComponent>();
NodeComponent& drawableNode = drawable->GetComponent<NodeComponent>();
graphicsComponent.AddToRenderQueue(renderQueue, drawableNode.GetTransformMatrix());
}
m_renderTechnique.Clear(&dummyScene);
m_renderTechnique.Draw(&dummyScene);
}
}