Merge remote-tracking branch 'origin/NDK' into NDK-ShadowMapping

Conflicts:
	SDK/include/NDK/Systems/RenderSystem.hpp
	SDK/src/NDK/Systems/RenderSystem.cpp

Former-commit-id: f62e9a27427d96893acd2381bb06ae928a1d3741
This commit is contained in:
Lynix
2015-06-29 21:05:09 +02:00
61 changed files with 434 additions and 2573 deletions

View File

@@ -3,6 +3,7 @@
// For conditions of distribution and use, see copyright notice in Prerequesites.hpp
#include <Nazara/Core/Error.hpp>
#include <Nazara/Math/Algorithm.hpp>
namespace Ndk
{
@@ -130,7 +131,7 @@ namespace Ndk
inline void CameraComponent::SetFOV(float fov)
{
NazaraAssert(fov != 0.f, "FOV must be different from zero");
NazaraAssert(!NzNumberEquals(fov, 0.f), "FOV must be different from zero");
m_fov = fov;
InvalidateProjectionMatrix();

View File

@@ -7,6 +7,7 @@
#ifndef NDK_SYSTEMS_RENDERSYSTEM_HPP
#define NDK_SYSTEMS_RENDERSYSTEM_HPP
#include <Nazara/Graphics/AbstractBackground.hpp>
#include <Nazara/Graphics/DepthRenderTechnique.hpp>
#include <Nazara/Graphics/ForwardRenderTechnique.hpp>
#include <Nazara/Renderer/RenderTexture.hpp>
@@ -26,6 +27,10 @@ namespace Ndk
inline RenderSystem(const RenderSystem& renderSystem);
~RenderSystem() = default;
inline const NzBackgroundRef& GetDefaultBackground() const;
inline void SetDefaultBackground(NzBackgroundRef background);
static SystemIndex systemIndex;
private:
@@ -37,6 +42,7 @@ namespace Ndk
EntityList m_cameras;
EntityList m_drawables;
EntityList m_lights;
NzBackgroundRef m_background;
NzDepthRenderTechnique m_shadowTechnique;
NzForwardRenderTechnique m_renderTechnique;
NzRenderTexture m_shadowRT;

View File

@@ -8,4 +8,14 @@ namespace Ndk
System(renderSystem)
{
}
inline const NzBackgroundRef& RenderSystem::GetDefaultBackground() const
{
return m_background;
}
inline void RenderSystem::SetDefaultBackground(NzBackgroundRef background)
{
m_background = std::move(background);
}
}

View File

@@ -15,6 +15,7 @@ namespace Ndk
{
RenderSystem::RenderSystem()
{
SetDefaultBackground(NzColorBackground::New());
SetUpdateRate(0.f);
}
@@ -27,6 +28,8 @@ namespace Ndk
void RenderSystem::OnEntityValidation(Entity* entity, bool justAdded)
{
NazaraUnused(justAdded);
if (entity->HasComponent<CameraComponent>() && entity->HasComponent<NodeComponent>())
{
m_cameras.Insert(entity);
@@ -51,6 +54,8 @@ namespace Ndk
void RenderSystem::OnUpdate(float elapsedTime)
{
NazaraUnused(elapsedTime);
UpdateShadowMaps();
for (const Ndk::EntityHandle& camera : m_cameras)
@@ -77,11 +82,9 @@ namespace Ndk
lightComponent.AddToRenderQueue(renderQueue, lightNode.GetTransformMatrix());
}
NzColorBackground background;
NzSceneData sceneData;
sceneData.ambientColor = NzColor(25, 25, 25);
sceneData.background = &background;
sceneData.background = m_background;
sceneData.viewer = &camComponent;
m_renderTechnique.Draw(sceneData);