Graphics: Update Light and Model to new interface

Former-commit-id: 5643f20261524f93a5d080404de5ab0b29151acb
This commit is contained in:
Lynix 2015-06-04 00:18:43 +02:00
parent 349b322834
commit 8c6806eacb
6 changed files with 50 additions and 13 deletions

View File

@ -9,12 +9,19 @@
#include <Nazara/Prerequesites.hpp> #include <Nazara/Prerequesites.hpp>
#include <Nazara/Core/Color.hpp> #include <Nazara/Core/Color.hpp>
#include <Nazara/Core/ObjectLibrary.hpp>
#include <Nazara/Core/ObjectRef.hpp>
#include <Nazara/Graphics/Enums.hpp> #include <Nazara/Graphics/Enums.hpp>
#include <Nazara/Graphics/Renderable.hpp> #include <Nazara/Graphics/Renderable.hpp>
class NzLight;
class NzShader; class NzShader;
struct NzLightUniforms; struct NzLightUniforms;
using NzLightConstRef = NzObjectRef<const NzLight>;
using NzLightLibrary = NzObjectLibrary<NzLight>;
using NzLightRef = NzObjectRef<NzLight>;
class NAZARA_API NzLight : public NzRenderable class NAZARA_API NzLight : public NzRenderable
{ {
public: public:
@ -55,6 +62,8 @@ class NAZARA_API NzLight : public NzRenderable
NzLight& operator=(const NzLight& light) = default; NzLight& operator=(const NzLight& light) = default;
template<typename... Args> static NzLightRef New(Args&&... args);
private: private:
void MakeBoundingVolume() const override; void MakeBoundingVolume() const override;
@ -70,6 +79,8 @@ class NAZARA_API NzLight : public NzRenderable
float m_outerAngleCosine; float m_outerAngleCosine;
float m_outerAngleTangent; float m_outerAngleTangent;
float m_radius; float m_radius;
static NzLightLibrary::LibraryMap s_library;
}; };
struct NzLightUniforms struct NzLightUniforms

View File

@ -2,6 +2,9 @@
// This file is part of the "Nazara Engine - Graphics module" // This file is part of the "Nazara Engine - Graphics module"
// For conditions of distribution and use, see copyright notice in Config.hpp // For conditions of distribution and use, see copyright notice in Config.hpp
#include <memory>
#include <Nazara/Renderer/Debug.hpp>
inline float NzLight::GetAmbientFactor() const inline float NzLight::GetAmbientFactor() const
{ {
return m_ambientFactor; return m_ambientFactor;
@ -90,3 +93,14 @@ inline void NzLight::SetRadius(float radius)
InvalidateBoundingVolume(); InvalidateBoundingVolume();
} }
template<typename... Args>
NzLightRef NzLight::New(Args&&... args)
{
std::unique_ptr<NzLight> object(new NzLight(std::forward<Args>(args)...));
object->SetPersistent(false);
return object.release();
}
#include <Nazara/Renderer/DebugOff.hpp>

View File

@ -27,7 +27,9 @@ struct NAZARA_API NzModelParameters
class NzModel; class NzModel;
using NzModelConstRef = NzObjectRef<const NzModel>;
using NzModelLoader = NzResourceLoader<NzModel, NzModelParameters>; using NzModelLoader = NzResourceLoader<NzModel, NzModelParameters>;
using NzModelRef = NzObjectRef<NzModel>;
class NAZARA_API NzModel : public NzRenderable, public NzResource class NAZARA_API NzModel : public NzRenderable, public NzResource
{ {
@ -42,9 +44,6 @@ class NAZARA_API NzModel : public NzRenderable, public NzResource
void AddToRenderQueue(NzAbstractRenderQueue* renderQueue, const NzMatrix4f& transformMatrix) const override; void AddToRenderQueue(NzAbstractRenderQueue* renderQueue, const NzMatrix4f& transformMatrix) const override;
NzModel* Clone() const;
NzModel* Create() const;
NzMaterial* GetMaterial(const NzString& subMeshName) const; NzMaterial* GetMaterial(const NzString& subMeshName) const;
NzMaterial* GetMaterial(unsigned int matIndex) const; NzMaterial* GetMaterial(unsigned int matIndex) const;
NzMaterial* GetMaterial(unsigned int skinIndex, const NzString& subMeshName) const; NzMaterial* GetMaterial(unsigned int skinIndex, const NzString& subMeshName) const;
@ -75,6 +74,8 @@ class NAZARA_API NzModel : public NzRenderable, public NzResource
NzModel& operator=(const NzModel& node) = default; NzModel& operator=(const NzModel& node) = default;
NzModel& operator=(NzModel&& node) = default; NzModel& operator=(NzModel&& node) = default;
template<typename... Args> static NzModelRef New(Args&&... args);
protected: protected:
void MakeBoundingVolume() const override; void MakeBoundingVolume() const override;
@ -87,4 +88,6 @@ class NAZARA_API NzModel : public NzRenderable, public NzResource
static NzModelLoader::LoaderList s_loaders; static NzModelLoader::LoaderList s_loaders;
}; };
#include <Nazara/Graphics/Model.inl>
#endif // NAZARA_MODEL_HPP #endif // NAZARA_MODEL_HPP

View File

@ -0,0 +1,17 @@
// Copyright (C) 2015 Jérôme Leclercq
// This file is part of the "Nazara Engine - Graphics module"
// For conditions of distribution and use, see copyright notice in Config.hpp
#include <memory>
#include <Nazara/Renderer/Debug.hpp>
template<typename... Args>
NzModelRef NzModel::New(Args&&... args)
{
std::unique_ptr<NzModel> object(new NzModel(std::forward<Args>(args)...));
object->SetPersistent(false);
return object.release();
}
#include <Nazara/Renderer/DebugOff.hpp>

View File

@ -179,3 +179,5 @@ void NzLight::MakeBoundingVolume() const
break; break;
} }
} }
NzLightLibrary::LibraryMap NzLight::s_library;

View File

@ -53,16 +53,6 @@ void NzModel::AddToRenderQueue(NzAbstractRenderQueue* renderQueue, const NzMatri
} }
} }
NzModel* NzModel::Clone() const
{
return new NzModel(*this);
}
NzModel* NzModel::Create() const
{
return new NzModel;
}
NzMaterial* NzModel::GetMaterial(const NzString& subMeshName) const NzMaterial* NzModel::GetMaterial(const NzString& subMeshName) const
{ {
#if NAZARA_GRAPHICS_SAFE #if NAZARA_GRAPHICS_SAFE