Richard Boegli's CnC_Generals_Zero_Hour Fork WIP
This is documentation of Richard Boegil's Zero Hour Fork
 
Loading...
Searching...
No Matches
light.h
Go to the documentation of this file.
1/*
2** Command & Conquer Generals Zero Hour(tm)
3** Copyright 2025 Electronic Arts Inc.
4**
5** This program is free software: you can redistribute it and/or modify
6** it under the terms of the GNU General Public License as published by
7** the Free Software Foundation, either version 3 of the License, or
8** (at your option) any later version.
9**
10** This program is distributed in the hope that it will be useful,
11** but WITHOUT ANY WARRANTY; without even the implied warranty of
12** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13** GNU General Public License for more details.
14**
15** You should have received a copy of the GNU General Public License
16** along with this program. If not, see <http://www.gnu.org/licenses/>.
17*/
18
19/***********************************************************************************************
20 *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S ***
21 ***********************************************************************************************
22 * *
23 * Project Name : WW3D *
24 * *
25 * $Archive:: /Commando/Code/ww3d2/light.h $*
26 * *
27 * $Author:: Jani_p $*
28 * *
29 * $Modtime:: 5/05/01 6:10p $*
30 * *
31 * $Revision:: 7 $*
32 * *
33 *---------------------------------------------------------------------------------------------*
34 * Functions: *
35 * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
36
37
38#if defined(_MSC_VER)
39#pragma once
40#endif
41
42#ifndef LIGHT_H
43#define LIGHT_H
44
45#include "always.h"
46#include "rendobj.h"
47#include "w3derr.h"
48
49class ChunkLoadClass;
50class ChunkSaveClass;
51
52
58{
59public:
60
67
73
75 LightClass(const LightClass & src);
77 virtual ~LightClass(void);
78 RenderObjClass * Clone(void) const;
79 virtual int Class_ID(void) const { return CLASSID_LIGHT; }
80
82 // Render Object Interface - Rendering
83 // Lights do not "Render" but they are vertex processors.
85 virtual void Render(RenderInfoClass & rinfo) { }
86 virtual bool Is_Vertex_Processor(void) { return true; }
87
89 // Render Object Interface - "Scene Graph"
90 // Lights register themselves with the scene as VertexProcessors.
92 virtual void Notify_Added(SceneClass * scene);
93 virtual void Notify_Removed(SceneClass * scene);
94
96 // Render Object Interface - Bounding Volumes
97 // Bounding volume of a light extends to its attenuation radius
99 virtual void Get_Obj_Space_Bounding_Sphere(SphereClass & sphere) const;
100 virtual void Get_Obj_Space_Bounding_Box(AABoxClass & box) const;
101
103 // LightClass Interface
105 LightType Get_Type() {return (Type);}
106
107 void Set_Intensity(float inten) { Intensity = inten; }
108 float Get_Intensity(void) const { return Intensity; }
109
110 void Set_Ambient(const Vector3 & color) { Ambient = color; }
111 void Get_Ambient(Vector3 * set_c) const { if (set_c) { *set_c = Ambient; } }
112
113 void Set_Diffuse(const Vector3 & color) { Diffuse = color; }
114 void Get_Diffuse(Vector3 * set_c) const { if (set_c) { *set_c = Diffuse; } }
115
116 void Set_Specular(const Vector3 & color) { Specular = color; }
117 void Get_Specular(Vector3 * set_c) const { if (set_c) { *set_c = Specular; } }
118
119 void Set_Far_Attenuation_Range(double fStart, double fEnd) { FarAttenStart = fStart; FarAttenEnd = fEnd; }
120 void Get_Far_Attenuation_Range(double& fStart, double& fEnd) const { fStart = FarAttenStart; fEnd = FarAttenEnd; }
121 void Get_Far_Attenuation_Range(float & fStart, float & fEnd) const { fStart = FarAttenStart; fEnd = FarAttenEnd; }
122 void Set_Near_Attenuation_Range(double nStart, double nEnd) { NearAttenStart = nStart; NearAttenEnd = nEnd; }
123 void Get_Near_Attenuation_Range(double& nStart, double& nEnd) const { nStart = NearAttenStart; nEnd = NearAttenEnd; }
124 float Get_Attenuation_Range(void) const { return FarAttenEnd; }
125
127 // Control over the light flags
129 void Set_Flag(FlagsType flag,bool onoff) { if (onoff) { Flags |= flag; } else { Flags &= ~flag; } }
130 int Get_Flag(FlagsType flag) const { return ((Flags & flag) != 0); }
131 void Enable_Shadows(bool onoff) { CastShadows = onoff; }
132 bool Are_Shadows_Enabled(void) const { return CastShadows; }
133 LightType Get_Type (void) const { return Type; }
134
136 // Spotlight controls:
139 float Get_Spot_Angle(void) const { return SpotAngle; }
140 float Get_Spot_Angle_Cos(void) const { return SpotAngleCos; }
143 void Set_Spot_Exponent(float k) { SpotExponent = k; }
144 float Get_Spot_Exponent(void) const { return SpotExponent; }
145
147 // Save/Load
151
153 // Persistant object save-load interface
155 virtual const PersistFactoryClass & Get_Factory (void) const;
156 virtual bool Save (ChunkSaveClass &csave);
157 virtual bool Load (ChunkLoadClass &cload);
158 //bool isDonut(void) {return Donut; };
159 //void setDonut(bool donut) { Donut = donut; };
160
161protected:
162
164 unsigned int Flags;
166
171
176
181 //bool Donut; ///does this light only apply at edges
182};
183
184#endif
char dir[_MAX_DIR]
Definition autorun.cpp:215
float SpotAngleCos
Definition light.h:178
virtual bool Load(ChunkLoadClass &cload)
Definition light.cpp:549
virtual void Notify_Removed(SceneClass *scene)
Definition light.cpp:264
float Get_Intensity(void) const
Definition light.h:108
void Set_Diffuse(const Vector3 &color)
Definition light.h:113
void Get_Far_Attenuation_Range(double &fStart, double &fEnd) const
Definition light.h:120
float FarAttenEnd
Definition light.h:175
float Get_Spot_Exponent(void) const
Definition light.h:144
unsigned int Flags
Definition light.h:164
Vector3 Specular
Definition light.h:170
void Set_Flag(FlagsType flag, bool onoff)
Definition light.h:129
bool Are_Shadows_Enabled(void) const
Definition light.h:132
RenderObjClass * Clone(void) const
Definition light.cpp:227
void Set_Spot_Direction(const Vector3 &dir)
Definition light.h:141
WW3DErrorType Save_W3D(ChunkSaveClass &csave)
Definition light.cpp:402
void Get_Spot_Direction(Vector3 &dir) const
Definition light.h:142
virtual void Render(RenderInfoClass &rinfo)
Definition light.h:85
float Get_Spot_Angle(void) const
Definition light.h:139
void Get_Ambient(Vector3 *set_c) const
Definition light.h:111
void Enable_Shadows(bool onoff)
Definition light.h:131
Vector3 SpotDirection
Definition light.h:180
float SpotAngle
Definition light.h:177
LightClass(LightType type=POINT)
Definition light.cpp:104
float NearAttenEnd
Definition light.h:173
virtual ~LightClass(void)
Definition light.cpp:210
float FarAttenStart
Definition light.h:174
float Get_Spot_Angle_Cos(void) const
Definition light.h:140
Vector3 Diffuse
Definition light.h:169
void Set_Near_Attenuation_Range(double nStart, double nEnd)
Definition light.h:122
virtual bool Is_Vertex_Processor(void)
Definition light.h:86
@ POINT
Definition light.h:63
@ DIRECTIONAL
Definition light.h:64
void Set_Spot_Exponent(float k)
Definition light.h:143
WW3DErrorType Load_W3D(ChunkLoadClass &cload)
Definition light.cpp:323
@ NEAR_ATTENUATION
Definition light.h:70
@ FAR_ATTENUATION
Definition light.h:71
void Set_Ambient(const Vector3 &color)
Definition light.h:110
virtual int Class_ID(void) const
Definition light.h:79
virtual const PersistFactoryClass & Get_Factory(void) const
Definition light.cpp:504
void Set_Spot_Angle(float a)
Definition light.h:138
LightType Get_Type(void) const
Definition light.h:133
float NearAttenStart
Definition light.h:172
void Get_Near_Attenuation_Range(double &nStart, double &nEnd) const
Definition light.h:123
float Intensity
Definition light.h:167
void Set_Intensity(float inten)
Definition light.h:107
LightType Type
Definition light.h:163
virtual bool Save(ChunkSaveClass &csave)
Definition light.cpp:522
void Set_Far_Attenuation_Range(double fStart, double fEnd)
Definition light.h:119
LightType Get_Type()
Definition light.h:105
int Get_Flag(FlagsType flag) const
Definition light.h:130
virtual void Notify_Added(SceneClass *scene)
Definition light.cpp:245
LightClass & operator=(const LightClass &)
Definition light.cpp:173
Vector3 Ambient
Definition light.h:168
virtual void Get_Obj_Space_Bounding_Box(AABoxClass &box) const
Definition light.cpp:303
void Get_Far_Attenuation_Range(float &fStart, float &fEnd) const
Definition light.h:121
bool CastShadows
Definition light.h:165
void Get_Diffuse(Vector3 *set_c) const
Definition light.h:114
void Set_Specular(const Vector3 &color)
Definition light.h:116
float SpotExponent
Definition light.h:179
void Get_Specular(Vector3 *set_c) const
Definition light.h:117
virtual void Get_Obj_Space_Bounding_Sphere(SphereClass &sphere) const
Definition light.cpp:284
float Get_Attenuation_Range(void) const
Definition light.h:124
RenderObjClass(void)
Definition rendobj.cpp:170
static WWINLINE float Fast_Cos(float val)
Definition wwmath.h:435
unsigned char flag
Definition vchannel.cpp:273
WW3DErrorType
Definition w3derr.h:51