2011-09-07 23:06:51 +02:00
|
|
|
#ifndef _LIGHT_H_
|
|
|
|
#define _LIGHT_H_
|
|
|
|
|
|
|
|
#include "object.h"
|
2012-06-07 02:08:59 +02:00
|
|
|
#include "lc_math.h"
|
2011-09-07 23:06:51 +02:00
|
|
|
|
|
|
|
#define LC_LIGHT_HIDDEN 0x01
|
|
|
|
#define LC_LIGHT_SELECTED 0x02
|
|
|
|
#define LC_LIGHT_FOCUSED 0x04
|
|
|
|
#define LC_LIGHT_TARGET_SELECTED 0x08
|
|
|
|
#define LC_LIGHT_TARGET_FOCUSED 0x10
|
|
|
|
#define LC_LIGHT_ENABLED 0x20
|
|
|
|
|
|
|
|
class Light;
|
|
|
|
class LightTarget;
|
|
|
|
|
2012-08-17 01:50:40 +02:00
|
|
|
enum LC_LK_TYPES
|
2011-09-07 23:06:51 +02:00
|
|
|
{
|
2012-08-17 01:50:40 +02:00
|
|
|
LC_LK_POSITION,
|
|
|
|
LC_LK_TARGET,
|
|
|
|
LC_LK_AMBIENT_COLOR,
|
|
|
|
LC_LK_DIFFUSE_COLOR,
|
|
|
|
LC_LK_SPECULAR_COLOR,
|
|
|
|
LC_LK_CONSTANT_ATTENUATION,
|
|
|
|
LC_LK_LINEAR_ATTENUATION,
|
|
|
|
LC_LK_QUADRATIC_ATTENUATION,
|
|
|
|
LC_LK_SPOT_CUTOFF,
|
|
|
|
LC_LK_SPOT_EXPONENT,
|
|
|
|
LC_LK_COUNT
|
|
|
|
};
|
2011-09-07 23:06:51 +02:00
|
|
|
|
|
|
|
class LightTarget : public Object
|
|
|
|
{
|
|
|
|
public:
|
2012-09-10 01:42:57 +02:00
|
|
|
LightTarget(Light *Parent);
|
2012-08-17 01:50:40 +02:00
|
|
|
~LightTarget();
|
2011-09-07 23:06:51 +02:00
|
|
|
|
|
|
|
public:
|
2012-08-17 01:50:40 +02:00
|
|
|
virtual void MinIntersectDist(lcClickLine* ClickLine);
|
2012-08-23 20:47:37 +02:00
|
|
|
virtual bool IntersectsVolume(const lcVector4 Planes[6]) const
|
2011-09-07 23:06:51 +02:00
|
|
|
{ return false; }
|
|
|
|
void Select (bool bSelecting, bool bFocus, bool bMultiple);
|
2014-01-30 04:13:34 +01:00
|
|
|
void Move (unsigned short nTime, bool bAddKey, float x, float y, float z)
|
2011-09-07 23:06:51 +02:00
|
|
|
{
|
|
|
|
// FIXME: move the position handling to the light target
|
|
|
|
}
|
|
|
|
|
|
|
|
const char* GetName() const;
|
|
|
|
|
|
|
|
Light* GetParent () const
|
|
|
|
{ return m_pParent; }
|
|
|
|
|
|
|
|
protected:
|
|
|
|
Light* m_pParent;
|
|
|
|
};
|
|
|
|
|
|
|
|
class Light : public Object
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
Light (float px, float py, float pz);
|
|
|
|
Light (float px, float py, float pz, float tx, float ty, float tz);
|
|
|
|
virtual ~Light ();
|
|
|
|
|
|
|
|
void Select (bool bSelecting, bool bFocus, bool bMultiple);
|
|
|
|
void SelectTarget (bool bSelecting, bool bFocus, bool bMultiple);
|
|
|
|
|
|
|
|
public:
|
|
|
|
bool IsVisible()
|
|
|
|
{ return (m_nState & LC_LIGHT_HIDDEN) == 0; }
|
|
|
|
bool IsSelected()
|
|
|
|
{ return (m_nState & (LC_LIGHT_SELECTED|LC_LIGHT_TARGET_SELECTED)) != 0; }
|
|
|
|
bool IsEyeSelected()
|
|
|
|
{ return (m_nState & LC_LIGHT_SELECTED) != 0; }
|
|
|
|
bool IsTargetSelected()
|
|
|
|
{ return (m_nState & LC_LIGHT_TARGET_SELECTED) != 0; }
|
|
|
|
bool IsEyeFocused()
|
|
|
|
{ return (m_nState & LC_LIGHT_FOCUSED) != 0; }
|
|
|
|
bool IsTargetFocused()
|
|
|
|
{ return (m_nState & LC_LIGHT_TARGET_FOCUSED) != 0; }
|
|
|
|
|
|
|
|
void Select()
|
|
|
|
{ m_nState |= (LC_LIGHT_SELECTED|LC_LIGHT_TARGET_SELECTED); }
|
|
|
|
void UnSelect()
|
|
|
|
{ m_nState &= ~(LC_LIGHT_SELECTED|LC_LIGHT_FOCUSED|LC_LIGHT_TARGET_SELECTED|LC_LIGHT_TARGET_FOCUSED); }
|
|
|
|
void UnFocus()
|
|
|
|
{ m_nState &= ~(LC_LIGHT_FOCUSED|LC_LIGHT_TARGET_FOCUSED); }
|
|
|
|
void FocusEye()
|
|
|
|
{ m_nState |= (LC_LIGHT_FOCUSED|LC_LIGHT_SELECTED); }
|
|
|
|
void FocusTarget()
|
|
|
|
{ m_nState |= (LC_LIGHT_TARGET_FOCUSED|LC_LIGHT_TARGET_SELECTED); }
|
|
|
|
const char* GetName()
|
|
|
|
{ return m_strName; }
|
|
|
|
LightTarget* GetTarget () const
|
|
|
|
{ return m_pTarget; }
|
|
|
|
|
|
|
|
const char* GetName() const
|
2014-01-30 04:13:34 +01:00
|
|
|
{ return m_strName; }
|
2011-09-07 23:06:51 +02:00
|
|
|
|
2014-02-16 08:23:55 +01:00
|
|
|
void Render(const lcMatrix44& ViewMatrix, float LineWidth);
|
|
|
|
void RenderCone(const lcMatrix44& ViewMatrix);
|
2012-09-10 01:42:57 +02:00
|
|
|
void RenderTarget();
|
|
|
|
void RenderSphere();
|
|
|
|
|
2012-08-17 01:50:40 +02:00
|
|
|
virtual void MinIntersectDist(lcClickLine* ClickLine);
|
2012-08-23 20:47:37 +02:00
|
|
|
virtual bool IntersectsVolume(const lcVector4 Planes[6]) const
|
2011-09-07 23:06:51 +02:00
|
|
|
{ return false; }
|
2014-01-30 04:13:34 +01:00
|
|
|
void UpdatePosition(unsigned short nTime);
|
|
|
|
void Move(unsigned short nTime, bool bAddKey, float dx, float dy, float dz);
|
2012-08-17 01:50:40 +02:00
|
|
|
void Setup(int index);
|
2014-04-09 00:34:50 +02:00
|
|
|
void CreateName(const lcArray<Light*>& Lights);
|
2011-09-07 23:06:51 +02:00
|
|
|
|
2012-08-17 01:50:40 +02:00
|
|
|
// Temporary parameters
|
|
|
|
lcMatrix44 mWorldLight;
|
2012-06-07 02:08:59 +02:00
|
|
|
lcVector3 mPosition;
|
|
|
|
lcVector3 mTargetPosition;
|
2012-08-17 01:50:40 +02:00
|
|
|
lcVector4 mAmbientColor;
|
|
|
|
lcVector4 mDiffuseColor;
|
|
|
|
lcVector4 mSpecularColor;
|
|
|
|
float mConstantAttenuation;
|
|
|
|
float mLinearAttenuation;
|
|
|
|
float mQuadraticAttenuation;
|
|
|
|
float mSpotCutoff;
|
|
|
|
float mSpotExponent;
|
2012-06-07 02:08:59 +02:00
|
|
|
|
2011-09-07 23:06:51 +02:00
|
|
|
protected:
|
2012-08-17 01:50:40 +02:00
|
|
|
void Initialize();
|
|
|
|
|
|
|
|
// Camera target
|
|
|
|
LightTarget* m_pTarget;
|
|
|
|
|
|
|
|
// Attributes
|
|
|
|
float m_fCone;
|
|
|
|
unsigned char m_nState;
|
|
|
|
char m_strName[81];
|
|
|
|
bool m_bEnabled;
|
2011-09-07 23:06:51 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // _LIGHT_H_
|