Polygon Crucher SDK - Documentation
Documentation
Loading...
Searching...
No Matches
3DLight.h
Go to the documentation of this file.
1//! @file 3DLight.h
2//! @brief C3DLight implementation for a light object
3//!
4//////////////////////////////////////////////////////////////////////
5
6#if !defined(AFX_3DLIGHT_H__5C85DAE7_BE95_4F8B_B661_B0CF9BE55255__INCLUDED_)
7#define AFX_3DLIGHT_H__5C85DAE7_BE95_4F8B_B661_B0CF9BE55255__INCLUDED_
8
9#ifdef _MSC_VER
10#pragma once
11#endif // _MSC_VER
12
13#include "3DBaseObject.h"
14#include "3DObject.h"
15
16BEGIN_MOOTOOLS_NAMESPACE
17
18typedef enum _LIGHT_TYPE
19{
20 LIGHT_DIRECTIONAL = 0,
21 LIGHT_OMNI,
22 LIGHT_SPOT,
23
24 NB_LIGHT_TYPES //Keep it last !
26
27#define C3DLIGHT_KIND MAKE_CUSTOM_ID('l','k','n','d') // LIGHT_TYPE
28#define C3DLIGHT_COLOR MAKE_CUSTOM_ID('l','c','l','r') // CRGBColor
29#define C3DLIGHT_INTENSITY MAKE_CUSTOM_ID('l','i','n','t') // Double
30#define C3DLIGHT_INNER_RADIUS MAKE_CUSTOM_ID('l','i','n','r') // Double
31#define C3DLIGHT_OUTER_RADIUS MAKE_CUSTOM_ID('l','o','u','r') // Double
32#define C3DLIGHT_INNER_ANGLE MAKE_CUSTOM_ID('l','i','n','a') // Double
33#define C3DLIGHT_OUTER_ANGLE MAKE_CUSTOM_ID('l','o','u','a') // Double
34
35// Defaults
36
37#define DEFAULT_LIGHT_KIND LIGHT_DIRECTIONAL
38#define DEFAULT_LIGHT_COLOR CRGBColor(1.0, 1.0, 1.0, 255)
39#define DEFAULT_LIGHT_INTENSITY 1.0
40#define DEFAULT_LIGHT_INNER_RADIUS 0.0
41#define DEFAULT_LIGHT_OUTER_RADIUS 0.0 // 0 or minus -> No limit !
42#define DEFAULT_LIGHT_INNER_ANGLE 0.0
43#define DEFAULT_LIGHT_OUTER_ANGLE DEG2RAD(30)
44
45#define C3DLIGHT_RADIUS_INFINITE -1
46
47//! @class C3DLight
48//! @brief This class implements a light object in the scene (OBJECT_LIGHT)
49class DLL_3DFUNCTION C3DLight : public C3DBaseObject
50{
51 DECLARE_SERIAL_XOBJECT(C3DLight);
52
53public:
54
55 int GetLightKind();
56 void SetLightKind(int kind);
57 CRGBColor GetColor();
58 void SetColor(CRGBColor col);
59 double GetIntensity();
60 void SetIntensity(double v);
61 double GetInnerRadius();
62 void SetInnerRadius(double v);
63 double GetOuterRadius();
64 void SetOuterRadius(double v);
65 void ClearAttenuation();
66 double GetInnerAngle();
67 void SetInnerAngle(double v);
68 double GetOuterAngle();
69 void SetOuterAngle(double v);
70
71 C3DLight();
72 virtual ~C3DLight();
73
74 virtual bool IsFinalObject() const { return false; }
75 virtual C3DBaseObject *GetFinalObject(bool detach = false, bool computeIfNeeded = true)
76 {
77 if(!displayable && computeIfNeeded)
78 {
79 switch(GetLightKind())
80 {
81 case LIGHT_DIRECTIONAL:
82 GenerateDirectionalLight();
83 break;
84 case LIGHT_OMNI:
85 GenerateOmniLight();
86 break;
87 case LIGHT_SPOT:
88 GenerateSpotLight();
89 break;
90 default:
91 XASSERT(0);
92 }
93
94 if (displayable)
95 displayable->SetScene(scene); // Create a guid
96 }
97
98 return displayable;
99 };
100
101private:
102
103 C3DObject* displayable;
104
105 void GenerateOmniLight();
106 void GenerateDirectionalLight();
107 void GenerateSpotLight();
108};
109
110END_MOOTOOLS_NAMESPACE
111
112#endif // !defined(AFX_3DLIGHT_H__5C85DAE7_BE95_4F8B_B661_B0CF9BE55255__INCLUDED_)
C3DBaseObject class which is the common base class for all object types.
The file contains C3DObject class definition which handles N-Gons polygonal object.
This is the base class for any kind of object.
Definition 3DBaseObject.h:106
This class implements a light object in the scene (OBJECT_LIGHT)
Definition 3DLight.h:50
virtual C3DBaseObject * GetFinalObject(bool detach=false, bool computeIfNeeded=true)
Returns the object itself or any kind of object. For example for a patch it can returns a C3DObject o...
Definition 3DLight.h:75
C3DObject handles polygonal mesh.
Definition 3DObject.h:24
The class defines an x, y, z 3D point which can use int, float or double.
Definition 3DPoint.h:27
CRGBColor handles an r, g, b, a color that can be initialized in different way.
Definition RGBColor.h:22