Richard Boegli's CnC_Generals_Zero_Hour Fork WIP
This is documentation of Richard Boegil's Zero Hour Fork
 
Loading...
Searching...
No Matches
layer.cpp
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:: /VSS_Sync/ww3d2/layer.cpp $*
26 * *
27 * $Author:: Vss_sync $*
28 * *
29 * $Modtime:: 8/29/01 7:29p $*
30 * *
31 * $Revision:: 3 $*
32 * *
33 *---------------------------------------------------------------------------------------------*
34 * Functions: *
35 * LayerClass::LayerClass -- constructor *
36 * LayerClass::~LayerClass -- destructor *
37 * LayerClass::Set_Scene -- Set the scene used by this layer *
38 * LayerClass::Get_Scene -- get the scene being rendered by this layer *
39 * LayerClass::Peek_Scene -- get the scene being rendered by this layer w/o a ref *
40 * LayerClass::Set_Camera -- Set the camera being used by this layer *
41 * LayerClass::Get_Camera -- get the camera being used by this layer *
42 * LayerClass::LayerClass -- default constructor *
43 * LC::Peek_Camera -- Get copy of camera. *
44 * LC::Set -- Kinda like an assignment operator. *
45 * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
46
47
48#include "layer.h"
49#include "scene.h"
50#include "camera.h"
51
52
53/***********************************************************************************************
54 * LayerClass::LayerClass -- default constructor *
55 * *
56 * INPUT: *
57 * *
58 * OUTPUT: *
59 * *
60 * WARNINGS: *
61 * *
62 * HISTORY: *
63 * 3/27/98 GTH : Created. *
64 *=============================================================================================*/
66 Scene(NULL),
67 Camera(NULL),
68 Clear(false),
69 ClearZ(true),
70 ClearColor(0,0,0)
71{
72}
73
75 Scene(src.Get_Scene()),
76 Camera(src.Get_Camera()),
77 Clear(src.Clear),
78 ClearZ(src.ClearZ),
80{
81}
82
83/***********************************************************************************************
84 * LayerClass::LayerClass -- constructor *
85 * *
86 * simply constructs a layer class, initialized with the desired settings *
87 * *
88 * *
89 * INPUT: *
90 * *
91 * OUTPUT: *
92 * *
93 * WARNINGS: *
94 * *
95 * HISTORY: *
96 * 3/27/98 GTH : Created. *
97 *=============================================================================================*/
99(
100 SceneClass * scene,
101 CameraClass * cam,
102 bool clear,
103 bool clearz,
104 const Vector3 & color
105)
106{
107 if (scene) scene->Add_Ref();
108 Scene = scene;
109
110 if (cam) cam->Add_Ref();
111 Camera = cam;
112
113 Clear = clear;
114 ClearZ = clearz;
115 ClearColor = color;
116}
117
118
119/***********************************************************************************************
120 * LayerClass::~LayerClass -- destructor *
121 * *
122 * INPUT: *
123 * *
124 * OUTPUT: *
125 * *
126 * WARNINGS: *
127 * *
128 * HISTORY: *
129 * 3/27/98 GTH : Created. *
130 *=============================================================================================*/
132{
133 if (Scene) {
134 Scene->Release_Ref();
135 Scene=0;
136 }
137 if (Camera) {
138 Camera->Release_Ref();
139 Camera=0;
140 }
141}
142
143
144/***********************************************************************************************
145 * LayerClass::Set_Scene -- Set the scene used by this layer *
146 * *
147 * INPUT: *
148 * *
149 * OUTPUT: *
150 * *
151 * WARNINGS: *
152 * *
153 * HISTORY: *
154 * 3/27/98 GTH : Created. *
155 *=============================================================================================*/
157{
158 if (Scene) {
159 Scene->Release_Ref();
160 }
161 Scene = scene;
162 if (Scene) {
163 Scene->Add_Ref();
164 }
165}
166
167
168/***********************************************************************************************
169 * LayerClass::Get_Scene -- get the scene being rendered by this layer *
170 * *
171 * INPUT: *
172 * *
173 * OUTPUT: *
174 * *
175 * WARNINGS: *
176 * *
177 * HISTORY: *
178 * 3/27/98 GTH : Created. *
179 *=============================================================================================*/
181{
182 if (Scene) {
183 Scene->Add_Ref();
184 }
185 return Scene;
186}
187
188
189/***********************************************************************************************
190 * LayerClass::Peek_Scene -- get the scene being rendered by this layer *
191 * *
192 * INPUT: *
193 * *
194 * OUTPUT: *
195 * *
196 * WARNINGS: *
197 * *
198 * HISTORY: *
199 * 3/8/99 NH : Created. *
200 *=============================================================================================*/
202{
203 return Scene;
204}
205
206
207/***********************************************************************************************
208 * LayerClass::Set_Camera -- Set the camera being used by this layer *
209 * *
210 * INPUT: *
211 * *
212 * OUTPUT: *
213 * *
214 * WARNINGS: *
215 * *
216 * HISTORY: *
217 * 3/27/98 GTH : Created. *
218 *=============================================================================================*/
220{
221 if (Camera) {
222 Camera->Release_Ref();
223 }
224 Camera = cam;
225 if (Camera) {
226 Camera->Add_Ref();
227 }
228}
229
230
231/***********************************************************************************************
232 * LayerClass::Get_Camera -- get the camera being used by this layer *
233 * *
234 * INPUT: *
235 * *
236 * OUTPUT: *
237 * *
238 * WARNINGS: *
239 * *
240 * HISTORY: *
241 * 3/27/98 GTH : Created. *
242 *=============================================================================================*/
244{
245 if (Camera) {
246 Camera->Add_Ref();
247 }
248 return Camera;
249}
250
251
252/***********************************************************************************************
253 * LC::Peek_Camera -- Get copy of camera. *
254 * *
255 * INPUT: *
256 * *
257 * OUTPUT: *
258 * *
259 * WARNINGS: *
260 * *
261 * HISTORY: *
262 * 08/14/2001 SKB : Created. *
263 *=============================================================================================*/
265{
266 return Camera;
267}
268
269
270/***********************************************************************************************
271 * LC::Set -- Kinda like an assignment operator. *
272 * *
273 * INPUT: *
274 * *
275 * OUTPUT: *
276 * *
277 * WARNINGS: *
278 * *
279 * HISTORY: *
280 * 08/14/2001 SKB : Created. *
281 *=============================================================================================*/
282void LayerClass::Set(const LayerClass & layer)
283{
284 Set_Camera(layer.Peek_Camera());
285 Set_Scene(layer.Peek_Scene());
286 Clear = layer.Clear;
287 ClearZ = layer.ClearZ;
288 ClearColor = layer.ClearColor;
289}
#define NULL
Definition BaseType.h:92
@ true
Definition bool.h:59
@ false
Definition bool.h:59
CameraClass * Camera
Definition layer.h:91
void Set_Scene(SceneClass *scene)
Definition layer.cpp:156
void Set(const LayerClass &layer)
Definition layer.cpp:282
CameraClass * Peek_Camera(void) const
Definition layer.cpp:264
~LayerClass(void)
Definition layer.cpp:131
Vector3 ClearColor
Definition layer.h:88
bool Clear
Definition layer.h:86
SceneClass * Scene
Definition layer.h:90
void Set_Camera(CameraClass *cam)
Definition layer.cpp:219
LayerClass(void)
Definition layer.cpp:65
SceneClass * Get_Scene(void) const
Definition layer.cpp:180
bool ClearZ
Definition layer.h:87
CameraClass * Get_Camera(void) const
Definition layer.cpp:243
SceneClass * Peek_Scene(void) const
Definition layer.cpp:201
void Add_Ref(void) const
Definition refcount.cpp:171