layer.cpp 17 KB

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