metaforce/Runtime/Graphics/CLight.hpp

127 lines
3.2 KiB
C++
Raw Normal View History

2016-04-13 06:07:23 +00:00
#ifndef __URDE_CLIGHT_HPP__
#define __URDE_CLIGHT_HPP__
2015-08-21 00:06:39 +00:00
2016-03-04 23:04:53 +00:00
#include "zeus/CVector3f.hpp"
#include "zeus/CColor.hpp"
2016-03-16 20:49:35 +00:00
#include "RetroTypes.hpp"
2016-03-04 23:04:53 +00:00
namespace urde
{
enum class ELightType
{
2016-03-16 20:49:35 +00:00
Spot = 0,
Point = 1,
Directional = 2,
LocalAmbient = 3,
Custom = 4,
2016-03-04 23:04:53 +00:00
};
enum class EFalloffType
{
Constant,
Linear,
Quadratic
};
2015-08-21 00:06:39 +00:00
class CLight
{
2016-03-16 20:49:35 +00:00
friend class CGuiLight;
2016-04-04 02:32:57 +00:00
friend class CBooModel;
2016-07-28 04:55:06 +00:00
friend class CBooRenderer;
2016-03-16 20:49:35 +00:00
zeus::CVector3f x0_pos;
zeus::CVector3f xc_dir;
zeus::CColor x18_color;
ELightType x1c_type;
float x20_spotCutoff;
float x24_distC;
float x28_distL;
float x2c_distQ;
float x30_angleC;
float x34_angleL;
float x38_angleQ;
u32 x3c_ = 0;
u32 x40_loadedIdx = 0;
float x44_cachedRadius;
float x48_cachedIntensity;
bool x4c_24_intensityDirty : 1;
bool x4c_25_radiusDirty : 1;
float CalculateLightRadius() const;
2016-03-04 23:04:53 +00:00
public:
2016-03-16 20:49:35 +00:00
CLight(const zeus::CVector3f& pos,
const zeus::CVector3f& dir,
const zeus::CColor& color,
float distC, float distL, float distQ,
2016-04-04 02:32:57 +00:00
float angleC, float angleL, float angleQ);
2016-03-16 20:49:35 +00:00
CLight(ELightType type,
const zeus::CVector3f& pos,
const zeus::CVector3f& dir,
const zeus::CColor& color,
2016-04-04 02:32:57 +00:00
float cutoff);
2016-03-16 20:49:35 +00:00
void SetPosition(const zeus::CVector3f& pos)
{
x0_pos = pos;
}
void SetDirection(const zeus::CVector3f& dir)
{
xc_dir = dir;
}
void SetColor(const zeus::CColor& col)
{
x18_color = col;
x4c_24_intensityDirty = true;
x4c_25_radiusDirty = true;
}
void SetAttenuation(float constant, float linear, float quadratic)
{
x24_distC = constant;
x28_distL = linear;
x2c_distQ = quadratic;
x4c_24_intensityDirty = true;
x4c_25_radiusDirty = true;
}
void SetAngleAttenuation(float constant, float linear, float quadratic)
{
x30_angleC = constant;
x34_angleL = linear;
x38_angleQ = quadratic;
x4c_24_intensityDirty = true;
x4c_25_radiusDirty = true;
}
float GetRadius() const
{
if (x4c_25_radiusDirty)
{
2016-08-29 04:22:54 +00:00
const_cast<CLight*>(this)->x44_cachedRadius = CalculateLightRadius();
const_cast<CLight*>(this)->x4c_25_radiusDirty = false;
2016-03-16 20:49:35 +00:00
}
return x44_cachedRadius;
}
float GetIntensity() const;
2016-08-21 00:04:50 +00:00
const zeus::CColor& GetColor() const { return x18_color; }
2016-03-16 20:49:35 +00:00
2016-03-04 23:04:53 +00:00
static CLight BuildDirectional(const zeus::CVector3f& dir, const zeus::CColor& color);
static CLight BuildSpot(const zeus::CVector3f& pos, const zeus::CVector3f& dir,
const zeus::CColor& color, float angle);
2016-03-16 20:49:35 +00:00
static CLight BuildPoint(const zeus::CVector3f& pos, const zeus::CColor& color);
2016-03-04 23:04:53 +00:00
static CLight BuildCustom(const zeus::CVector3f& pos, const zeus::CVector3f& dir,
2016-03-16 20:49:35 +00:00
const zeus::CColor& color,
float distC, float distL, float distQ,
float angleC, float angleL, float angleQ);
static CLight BuildLocalAmbient(const zeus::CVector3f& pos, const zeus::CColor& color);
2015-08-21 00:06:39 +00:00
};
2016-03-04 23:04:53 +00:00
}
2016-04-13 06:07:23 +00:00
#endif // __URDE_CLIGHT_HPP__