My Project
LightObject.h
1 #pragma once
2 #include "ParaXEntity.h"
3 #include "SphereObject.h"
4 #include <string>
5 namespace ParaEngine
6 {
7  class CParaXModel;
8  class CLightParam;
9 
13  class CLightObject : public CSphereObject
14  {
15  public:
16  virtual CBaseObject::_SceneObjectType GetType(){return CBaseObject::LightObject;};
17  CLightObject(void);
18  virtual ~CLightObject(void);
19  public:
21  // implementation of IAttributeFields
22  ATTRIBUTE_DEFINE_CLASS(CLightObject);
23  ATTRIBUTE_SUPPORT_CREATE_FACTORY(CLightObject);
24 
26  virtual int InstallFields(CAttributeClass* pClass, bool bOverride);
27 
28  ATTRIBUTE_METHOD1(CLightObject, GetLightType_s, int*) {*p1 = cls->GetLightType(); return S_OK;}
29  ATTRIBUTE_METHOD1(CLightObject, SetLightType_s, int) {cls->SetLightType(p1); return S_OK;}
30 
31  ATTRIBUTE_METHOD1(CLightObject, GetRange_s, float*) {*p1 = cls->GetRange(); return S_OK;}
32  ATTRIBUTE_METHOD1(CLightObject, SetRange_s, float) {cls->SetRange(p1); return S_OK;}
33 
34  ATTRIBUTE_METHOD1(CLightObject, GetDiffuse_s, Vector3*) {*p1 = *(Vector3*)(&cls->GetDiffuse()); return S_OK;}
35  ATTRIBUTE_METHOD1(CLightObject, SetDiffuse_s, Vector3) {LinearColor c(p1.x, p1.y,p1.z,1); cls->SetDiffuse(c); return S_OK;}
36 
37  ATTRIBUTE_METHOD1(CLightObject, GetAttenuation0_s, float*) {*p1 = cls->GetAttenuation0(); return S_OK;}
38  ATTRIBUTE_METHOD1(CLightObject, SetAttenuation0_s, float) {cls->SetAttenuation0(p1); return S_OK;}
39 
40  ATTRIBUTE_METHOD1(CLightObject, GetAttenuation1_s, float*) {*p1 = cls->GetAttenuation1(); return S_OK;}
41  ATTRIBUTE_METHOD1(CLightObject, SetAttenuation1_s, float) {cls->SetAttenuation1(p1); return S_OK;}
42 
43  ATTRIBUTE_METHOD1(CLightObject, GetAttenuation2_s, float*) {*p1 = cls->GetAttenuation2(); return S_OK;}
44  ATTRIBUTE_METHOD1(CLightObject, SetAttenuation2_s, float) {cls->SetAttenuation2(p1); return S_OK;}
45 
46  ATTRIBUTE_METHOD1(CLightObject, IsDeferredLightOnly_s, bool*) { *p1 = cls->IsDeferredLightOnly(); return S_OK; }
47  ATTRIBUTE_METHOD1(CLightObject, SetDeferredLightOnly_s, bool) { cls->SetDeferredLightOnly(p1); return S_OK; }
48 
49  public:
50  virtual std::string ToString(DWORD nMethod);
51 
59  virtual void Rotate(float x, float y, float z);
60 
63  virtual void SetScaling(float s);
64 
66  virtual void Reset();
67 
68 
80  HRESULT InitObject(CLightParam* pLight, MeshEntity* ppMesh, const Vector3& vCenter, const Matrix4& mat, bool bCopyParams = true);
81 
86  virtual int PrepareRender(CBaseCamera* pCamera, SceneState * sceneState);
87 
89  virtual HRESULT Draw(SceneState * sceneState);
90 
91  HRESULT RenderMesh(SceneState * sceneState);
92 
93 
94  virtual void Cleanup();
95 
97  void SetLocalTransform(const Matrix4& mXForm);
99  void SetLocalTransform(float fScale, float fRotX, float fRotY, float fRotZ);
101  void SetLocalTransform(float fScale, const Quaternion& quat);
103  void GetLocalTransform(Matrix4* localTransform);
104 
107 
108  virtual AssetEntity* GetPrimaryAsset();
109  virtual void SetAssetFileName(const std::string& sFilename);
110  virtual Matrix4* GetAttachmentMatrix(Matrix4& pOut, int nAttachmentID = 0, int nRenderNumber = 0);
111 
118  virtual Matrix4* GetRenderMatrix(Matrix4& out, int nRenderNumber = 0);
119  virtual void RenderDeferredLightMesh(SceneState * sceneState);
120  public:
128  void SetLightType(int nType);
133  int GetLightType();
134 
139  void SetDiffuse(const LinearColor& color);
141  const LinearColor& GetDiffuse();
142 
147  void SetRange(float range);
148 
153  float GetRange();
154 
159  void SetAttenuation0(float Attenuation0);
160 
165  float GetAttenuation0();
166 
167 
172  void SetAttenuation1(float Attenuation1);
173 
178  float GetAttenuation1();
179 
184  void SetAttenuation2(float Attenuation2);
185 
190  float GetAttenuation2();
191 
193  bool IsDeferredLightOnly() const;
194  void SetDeferredLightOnly(bool val);
195  protected:
197  //Vector3 m_vPos;
200 
201  AnimIndex m_CurrentAnim;
202 
205  ref_ptr<MeshEntity> m_pDeferredShadingMesh;
206 
209 
212 
215  };
216 }
bool m_bDeleteLightParams
if true, the light object will delete the m_pLightParams object at destruction time.
Definition: LightObject.h:211
float GetAttenuation0()
Definition: LightObject.cpp:248
float GetAttenuation1()
Definition: LightObject.cpp:261
this is an independent local light scene object.
Definition: LightObject.h:13
a CBaseObject whose position is at the center, instead of at the bottom.
Definition: SphereObject.h:12
bool m_bDeferredLightOnly
whether the light is enabled for deferred render pipeline only.
Definition: LightObject.h:214
an attribute class is a collection of attribute fields.
Definition: AttributeClass.h:10
const LinearColor & GetDiffuse()
Definition: LightObject.cpp:199
It&#39;s used as parameter to Draw method of each scene object.
Definition: SceneState.h:284
virtual void Reset()
reset the object to its default settings.
Definition: LightObject.cpp:140
virtual AssetEntity * GetPrimaryAsset()
Set scaling.
Definition: LightObject.cpp:408
void SetLocalTransform(const Matrix4 &mXForm)
set local transform directly
Definition: LightObject.cpp:88
virtual void Cleanup()
clean up the object.
Definition: LightObject.cpp:35
void SetAttenuation1(float Attenuation1)
Linear attenuation.
Definition: LightObject.cpp:253
virtual void SetAssetFileName(const std::string &sFilename)
set asset file name
Definition: LightObject.cpp:413
different physics engine has different winding order.
Definition: EventBinding.h:32
CLightParam * m_pLightParams
light parameters.
Definition: LightObject.h:208
virtual HRESULT Draw(SceneState *sceneState)
it only draws an arrow, when the scene&#39;s show local light parameter is true.
Definition: LightObject.cpp:302
void SetRange(float range)
Cutoff range.
Definition: LightObject.cpp:205
Implementation of a Quaternion, i.e.
Definition: ParaQuaternion.h:10
virtual std::string ToString(DWORD nMethod)
convert the object to an NPL string by which this object may be created or deleted.
Definition: LightObject.cpp:40
Standard 3-dimensional vector.
Definition: ParaVector3.h:16
float GetAttenuation2()
Definition: LightObject.cpp:274
Definition: BaseCamera.h:70
bool IsDeferredLightOnly() const
whether the light is enabled for deferred render pipeline only.
Definition: LightObject.cpp:581
virtual Matrix4 * GetAttachmentMatrix(Matrix4 &pOut, int nAttachmentID=0, int nRenderNumber=0)
Get the specified attachment matrix of the current model.
Definition: LightObject.cpp:424
void SetLightType(int nType)
Set type.
Definition: LightObject.cpp:178
virtual Matrix4 * GetRenderMatrix(Matrix4 &out, int nRenderNumber=0)
return the world matrix of the object for rendering
Definition: LightObject.cpp:448
CLightParam * GetLightParams()
return the global light in render coordinate system.
Definition: LightObject.cpp:74
The ref_ptr class template stores a pointer to a dynamically allocated (AssetEntity|CRefCounted|BaseA...
Definition: PERefPtr.h:13
Class encapsulating a standard 4x4 homogeneous matrix.
Definition: ParaMatrix4.h:23
float GetRange()
Definition: LightObject.cpp:235
virtual void Rotate(float x, float y, float z)
Rotate the object.This only takes effects on objects having 3D orientation, such as static mesh and p...
Definition: LightObject.cpp:115
virtual void SetScaling(float s)
set the scale of the object.
Definition: LightObject.cpp:130
void SetAttenuation0(float Attenuation0)
Constant attenuation.
Definition: LightObject.cpp:240
it presents a given in bone animation providers or parax local model bone animation pools ...
Definition: AnimInstanceBase.h:13
void SetDiffuse(const LinearColor &color)
set diffuse color of the light
Definition: LightObject.cpp:191
ref_ptr< ParaXEntity > m_pAnimatedMesh
mesh geometry
Definition: LightObject.h:204
HRESULT InitObject(CLightParam *pLight, MeshEntity *ppMesh, const Vector3 &vCenter, const Matrix4 &mat, bool bCopyParams=true)
Init from light struct.
Definition: LightObject.cpp:145
MeshEntity distinguish one template from other.
Definition: MeshEntity.h:38
virtual int InstallFields(CAttributeClass *pClass, bool bOverride)
this class should be implemented if one wants to add new attribute.
Definition: LightObject.cpp:592
a single light in ParaEngine.
Definition: LightParam.h:6
int GetLightType()
see SetLightType()
Definition: LightObject.cpp:186
A linear, 32-bit/component floating point RGBA color.
Definition: ParaColor.h:12
void GetLocalTransform(Matrix4 *localTransform)
get local transform
Definition: LightObject.cpp:110
Base class for managed asset entity in ParaEngine.
Definition: AssetEntity.h:25
void SetAttenuation2(float Attenuation2)
Quadratic attenuation.
Definition: LightObject.cpp:266
Matrix4 m_mxLocalTransform
current position in the map
Definition: LightObject.h:199
virtual int PrepareRender(CBaseCamera *pCamera, SceneState *sceneState)
derived class can override this function to place the object in to the render pipeline.
Definition: LightObject.cpp:279