2015-07-26 21:39:49 +00:00
|
|
|
#ifndef CLIGHT_H
|
|
|
|
#define CLIGHT_H
|
|
|
|
|
|
|
|
#include <FileIO/CInputStream.h>
|
|
|
|
#include <Common/CColor.h>
|
|
|
|
#include <Common/CVector3f.h>
|
|
|
|
#include <GL/glew.h>
|
|
|
|
|
2015-12-07 04:23:52 +00:00
|
|
|
/* CLight is currently heavily based on the lights system from Metroid Prime,
|
2015-07-26 21:39:49 +00:00
|
|
|
* including code reverse engineered from the game's executable. Not yet sure
|
2015-12-07 04:23:52 +00:00
|
|
|
* how much needs to be modified to properly support DKCR. */
|
2015-07-26 21:39:49 +00:00
|
|
|
enum ELightType
|
|
|
|
{
|
|
|
|
eLocalAmbient = 0,
|
|
|
|
eDirectional = 1,
|
|
|
|
eSpot = 3,
|
|
|
|
eCustom = 2
|
|
|
|
};
|
|
|
|
|
|
|
|
class CLight
|
|
|
|
{
|
|
|
|
ELightType mType;
|
2015-10-26 05:36:53 +00:00
|
|
|
u32 mLayerIndex;
|
2015-07-26 21:39:49 +00:00
|
|
|
CVector3f mPosition;
|
|
|
|
CVector3f mDirection;
|
|
|
|
CColor mColor;
|
|
|
|
float mSpotCutoff;
|
|
|
|
CVector3f mDistAttenCoefficients;
|
|
|
|
CVector3f mAngleAttenCoefficients;
|
2015-10-26 05:36:53 +00:00
|
|
|
|
2015-12-07 04:23:52 +00:00
|
|
|
mutable float mCachedRadius;
|
|
|
|
mutable float mCachedIntensity;
|
|
|
|
mutable u8 mDirtyFlags;
|
2015-07-26 21:39:49 +00:00
|
|
|
|
|
|
|
public:
|
|
|
|
CLight();
|
|
|
|
|
|
|
|
private:
|
|
|
|
// Data Manipulation
|
2015-12-07 04:23:52 +00:00
|
|
|
float CalculateRadius() const;
|
|
|
|
float CalculateIntensity() const;
|
2015-07-26 21:39:49 +00:00
|
|
|
CVector3f CalculateSpotAngleAtten();
|
|
|
|
|
|
|
|
public:
|
|
|
|
// Getters
|
|
|
|
ELightType GetType() const;
|
2015-10-26 05:36:53 +00:00
|
|
|
u32 GetLayerIndex() const;
|
2015-07-26 21:39:49 +00:00
|
|
|
CVector3f GetPosition() const;
|
|
|
|
CVector3f GetDirection() const;
|
|
|
|
CColor GetColor() const;
|
|
|
|
CVector3f GetDistAttenuation() const;
|
|
|
|
CVector3f GetAngleAttenuation() const;
|
2015-12-07 04:23:52 +00:00
|
|
|
float GetRadius() const;
|
|
|
|
float GetIntensity() const;
|
2015-07-26 21:39:49 +00:00
|
|
|
|
|
|
|
// Setters
|
2015-10-26 05:36:53 +00:00
|
|
|
void SetLayer(u32 index);
|
2015-07-26 21:39:49 +00:00
|
|
|
void SetPosition(const CVector3f& Position);
|
|
|
|
void SetDirection(const CVector3f& Direction);
|
|
|
|
void SetColor(const CColor& Color);
|
|
|
|
void SetSpotCutoff(float Cutoff);
|
|
|
|
void SetDistAtten(float DistCoefA, float DistCoefB, float DistCoefC);
|
|
|
|
void SetAngleAtten(float AngleCoefA, float AngleCoefB, float AngleCoefC);
|
|
|
|
|
|
|
|
// Other
|
|
|
|
void Load() const;
|
|
|
|
|
|
|
|
// Static
|
|
|
|
static CLight* BuildLocalAmbient(const CVector3f& Position, const CColor& Color);
|
|
|
|
static CLight* BuildDirectional(const CVector3f& Position, const CVector3f& Direction, const CColor& Color);
|
|
|
|
static CLight* BuildSpot(const CVector3f& Position, const CVector3f& Direction, const CColor& Color, float Cutoff);
|
|
|
|
static CLight* BuildCustom(const CVector3f& Position, const CVector3f& Direction, const CColor& Color,
|
|
|
|
float DistAttenA, float DistAttenB, float DistAttenC,
|
|
|
|
float AngleAttenA, float AngleAttenB, float AngleAttenC);
|
|
|
|
|
|
|
|
// Constants
|
|
|
|
static const CVector3f skDefaultLightPos;
|
|
|
|
static const CVector3f skDefaultLightDir;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // CLIGHT_H
|