Added Light::GetLightType

Former-commit-id: 22739eaaed4daf0651860c34af30bbfad87f538f
This commit is contained in:
Lynix 2013-01-27 18:41:20 +01:00
parent 85c3224752
commit 861c1b6a38
2 changed files with 12 additions and 4 deletions

View File

@ -19,13 +19,14 @@ class NAZARA_API NzLight : public NzSceneNode
NzLight(const NzLight& light); NzLight(const NzLight& light);
~NzLight(); ~NzLight();
void Apply(unsigned int i = 0) const; void Apply(unsigned int unit) const;
const NzAxisAlignedBox& GetAABB() const; const NzAxisAlignedBox& GetAABB() const;
NzColor GetAmbientColor() const; NzColor GetAmbientColor() const;
float GetAttenuation() const; float GetAttenuation() const;
NzColor GetDiffuseColor() const; NzColor GetDiffuseColor() const;
float GetInnerAngle() const; float GetInnerAngle() const;
nzLightType GetLightType() const;
float GetOuterAngle() const; float GetOuterAngle() const;
float GetRadius() const; float GetRadius() const;
nzSceneNodeType GetSceneNodeType() const; nzSceneNodeType GetSceneNodeType() const;

View File

@ -10,6 +10,8 @@
#include <cstring> #include <cstring>
#include <Nazara/3D/Debug.hpp> #include <Nazara/3D/Debug.hpp>
///TODO: Utilisation des UBOs
NzLight::NzLight(nzLightType type) : NzLight::NzLight(nzLightType type) :
m_type(type), m_type(type),
m_ambientColor((type == nzLightType_Directional) ? NzColor(50, 50, 50) : NzColor::Black), m_ambientColor((type == nzLightType_Directional) ? NzColor(50, 50, 50) : NzColor::Black),
@ -29,7 +31,7 @@ NzLight::NzLight(const NzLight& light)
NzLight::~NzLight() = default; NzLight::~NzLight() = default;
void NzLight::Apply(unsigned int i) const void NzLight::Apply(unsigned int unit) const
{ {
/* /*
struct Light struct Light
@ -66,10 +68,10 @@ void NzLight::Apply(unsigned int i) const
int parameters2Location = shader->GetUniformLocation("Lights[0].parameters2"); int parameters2Location = shader->GetUniformLocation("Lights[0].parameters2");
int parameters3Location = shader->GetUniformLocation("Lights[0].parameters3"); int parameters3Location = shader->GetUniformLocation("Lights[0].parameters3");
if (i > 0) if (unit > 0)
{ {
int type2Location = shader->GetUniformLocation("Lights[1].type"); int type2Location = shader->GetUniformLocation("Lights[1].type");
int offset = i * (type2Location - typeLocation); // type2Location - typeLocation donne la taille de la structure int offset = unit * (type2Location - typeLocation); // type2Location - typeLocation donne la taille de la structure
// On applique cet offset // On applique cet offset
typeLocation += offset; typeLocation += offset;
@ -133,6 +135,11 @@ float NzLight::GetInnerAngle() const
return m_innerAngle; return m_innerAngle;
} }
nzLightType NzLight::GetLightType() const
{
return m_type;
}
float NzLight::GetOuterAngle() const float NzLight::GetOuterAngle() const
{ {
return m_outerAngle; return m_outerAngle;