scene.cpp 36 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702
  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. *** 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/scene.cpp $*
  25. * *
  26. * Org Author:: Greg_h *
  27. * *
  28. * Author : Kenny Mitchell *
  29. * *
  30. * $Modtime:: 07/01/02 12:55p $*
  31. * *
  32. * $Revision:: 24 $*
  33. * *
  34. * 06/27/02 KM Shader system light environment updates *
  35. * 07/01/02 KM Coltype enum change to avoid MAX conflicts *
  36. *---------------------------------------------------------------------------------------------*
  37. * Functions: *
  38. * SceneClass::SceneClass -- constructor *
  39. * SceneClass::~SceneClass -- destructor *
  40. * SceneClass::Render -- preps the scene for rendering, derived classes should override *
  41. * SceneClass::Add_Render_Object -- base add function *
  42. * SceneClass::Remove_Render_Object -- base remove function *
  43. * SceneClass::Set_Depth_Cue -- set the depth cue values *
  44. * SceneClass::Set_Fog_Range -- set the fog range *
  45. * SceneClass::Get_Fog_Range -- get the fog range *
  46. * SceneClass::Render -- preps the scene for rendering, derived classes should add functional*
  47. * SimpleSceneClass -- Constructor *
  48. * SimpleSceneClass::~SimpleSceneClass -- destructor *
  49. * SimpleSceneClass::Add_Render_Object -- add a render object to the scene *
  50. * SimpleSceneClass::Remove_Render_Object -- remove a render object from this scene *
  51. * SimpleSceneClass::Visiblity_Check -- set the visiblity status of the render objects *
  52. * SimpleSceneClass::Render -- internal scene rendering function *
  53. * SimpleSceneClass::Render -- Render this scene *
  54. * SimpleSceneClass::Create_Iterator -- create an iterator for this scene *
  55. * SimpleSceneClass::Destroy_Iterator -- destroy an iterater of this scene *
  56. * SceneClass::Save -- saves scene settings into a chunk *
  57. * SceneClass::Load -- loads scene settings from a chunk *
  58. * SimpleSceneClass::Compute_Point_Visibility -- returns visibility of a point *
  59. * SimpleSceneClass::Remove_All_Render_Objects -- Removes all render objects from the scene *
  60. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  61. #include "scene.h"
  62. #include "plane.h"
  63. #include "camera.h"
  64. #include "ww3d.h"
  65. #include "rinfo.h"
  66. #include "chunkio.h"
  67. #include "dx8renderer.h"
  68. #include "dx8wrapper.h"
  69. #include "sortingrenderer.h"
  70. #include "coltest.h"
  71. /*
  72. ** Chunk ID's used by SceneClass
  73. */
  74. enum
  75. {
  76. SCENECLASS_CHUNK_VARIABLES = 0x00042300,
  77. SCENECLASS_VARIABLE_AMBIENTLIGHT = 0x00,
  78. SCENECLASS_VARIABLE_POLYRENDERMODE,
  79. SCENECLASS_VARIABLE_FOGCOLOR,
  80. SCENECLASS_VARIABLE_FOGENABLED,
  81. SCENECLASS_VARIABLE_FOGSTART,
  82. SCENECLASS_VARIABLE_FOGEND,
  83. };
  84. /*
  85. ** SimpleSceneIterator
  86. ** This iterator is used by the SimpleSceneClass to allow
  87. ** the user to iterate through its render objects.
  88. */
  89. class SimpleSceneIterator : public SceneIterator
  90. {
  91. public:
  92. virtual void First(void);
  93. virtual void Next(void);
  94. virtual bool Is_Done(void);
  95. virtual RenderObjClass * Current_Item(void);
  96. protected:
  97. SimpleSceneIterator(RefRenderObjListClass * renderlist,bool onlyvis);
  98. RefRenderObjListIterator RobjIterator;
  99. SimpleSceneClass * Scene;
  100. bool OnlyVis;
  101. friend class SimpleSceneClass;
  102. };
  103. /***********************************************************************************************
  104. * SceneClass::SceneClass -- constructor *
  105. * *
  106. * INPUT: *
  107. * *
  108. * OUTPUT: *
  109. * *
  110. * WARNINGS: *
  111. * *
  112. * HISTORY: *
  113. * 12/10/98 GTH : Created. *
  114. *=============================================================================================*/
  115. SceneClass::SceneClass(void) :
  116. AmbientLight(0.5f,0.5f,0.5f),
  117. PolyRenderMode(FILL),
  118. ExtraPassPolyRenderMode(EXTRA_PASS_DISABLE),
  119. FogEnabled(false),
  120. FogColor(0,0,0),
  121. FogStart(0.0f),
  122. FogEnd(1000.0f) // Arbitrary default value
  123. {
  124. }
  125. /***********************************************************************************************
  126. * SceneClass::~SceneClass -- destructor *
  127. * *
  128. * INPUT: *
  129. * *
  130. * OUTPUT: *
  131. * *
  132. * WARNINGS: *
  133. * *
  134. * HISTORY: *
  135. * 12/10/98 GTH : Created. *
  136. *=============================================================================================*/
  137. SceneClass::~SceneClass(void)
  138. {
  139. }
  140. /***********************************************************************************************
  141. * SceneClass::Add_Render_Object -- base add function *
  142. * *
  143. * This function only sets the render object's scene pointer and calls the notify method. *
  144. * Derived classes must add the functionality of actually storing a pointer to the object *
  145. * and doing something with it :) *
  146. * *
  147. * INPUT: *
  148. * obj - pointer to the object to add *
  149. * *
  150. * OUTPUT: *
  151. * *
  152. * WARNINGS: *
  153. * *
  154. * HISTORY: *
  155. * 2/25/99 GTH : Created. *
  156. *=============================================================================================*/
  157. void SceneClass::Add_Render_Object(RenderObjClass * obj)
  158. {
  159. obj->Notify_Added(this);
  160. }
  161. /***********************************************************************************************
  162. * SceneClass::Remove_Render_Object -- base remove function *
  163. * *
  164. * Similar to the add function; concrete derived classes must override and actually remove *
  165. * the object... *
  166. * *
  167. * INPUT: *
  168. * obj - pointer to the object to remove *
  169. * *
  170. * OUTPUT: *
  171. * *
  172. * WARNINGS: *
  173. * *
  174. * HISTORY: *
  175. * 2/25/99 GTH : Created. *
  176. *=============================================================================================*/
  177. void SceneClass::Remove_Render_Object(RenderObjClass * obj)
  178. {
  179. obj->Notify_Removed(this);
  180. }
  181. /***********************************************************************************************
  182. * SceneClass::Render -- preps the scene for rendering, derived classes should add functionalit*
  183. * *
  184. * INPUT: *
  185. * *
  186. * OUTPUT: *
  187. * *
  188. * WARNINGS: *
  189. * *
  190. * HISTORY: *
  191. * 12/10/98 GTH : Created. *
  192. *=============================================================================================*/
  193. void SceneClass::Render(RenderInfoClass & rinfo)
  194. {
  195. // Any stuff that needs to get done before anything else
  196. Pre_Render_Processing(rinfo);
  197. DX8Wrapper::Set_Fog(FogEnabled, FogColor, FogStart, FogEnd);
  198. if (Get_Extra_Pass_Polygon_Mode()==EXTRA_PASS_DISABLE) {
  199. Customized_Render(rinfo);
  200. }
  201. else {
  202. bool old_enable=WW3D::Is_Texturing_Enabled();
  203. DX8Wrapper::Set_DX8_Render_State (D3DRS_ZBIAS, 0);
  204. Customized_Render(rinfo);
  205. switch (Get_Extra_Pass_Polygon_Mode()) {
  206. case EXTRA_PASS_LINE:
  207. WW3D::Enable_Texturing(false);
  208. DX8Wrapper::Set_DX8_Render_State(D3DRS_FILLMODE,D3DFILL_WIREFRAME);
  209. DX8Wrapper::Set_DX8_Render_State (D3DRS_ZBIAS, 7);
  210. Customized_Render(rinfo);
  211. break;
  212. case EXTRA_PASS_CLEAR_LINE:
  213. DX8Wrapper::Clear(true, false, Vector3(0.0f,0.0f,0.0f)); // Clear color but not z
  214. WW3D::Enable_Texturing(false);
  215. DX8Wrapper::Set_DX8_Render_State(D3DRS_FILLMODE,D3DFILL_WIREFRAME);
  216. DX8Wrapper::Set_DX8_Render_State (D3DRS_ZBIAS, 7);
  217. Customized_Render(rinfo);
  218. break;
  219. }
  220. WW3D::Enable_Texturing(old_enable);
  221. }
  222. // Any stuff that needs to get done after anything else
  223. Post_Render_Processing(rinfo);
  224. }
  225. /***********************************************************************************************
  226. * SceneClass::Save -- saves scene settings into a chunk *
  227. * *
  228. * INPUT: *
  229. * *
  230. * OUTPUT: *
  231. * *
  232. * WARNINGS: *
  233. * *
  234. * HISTORY: *
  235. *=============================================================================================*/
  236. void SceneClass::Save(ChunkSaveClass & csave)
  237. {
  238. csave.Begin_Chunk(SCENECLASS_CHUNK_VARIABLES);
  239. WRITE_MICRO_CHUNK(csave,SCENECLASS_VARIABLE_AMBIENTLIGHT,AmbientLight);
  240. WRITE_MICRO_CHUNK(csave,SCENECLASS_VARIABLE_POLYRENDERMODE,PolyRenderMode);
  241. WRITE_MICRO_CHUNK(csave,SCENECLASS_VARIABLE_FOGCOLOR,FogColor);
  242. WRITE_MICRO_CHUNK(csave,SCENECLASS_VARIABLE_FOGENABLED,FogEnabled);
  243. WRITE_MICRO_CHUNK(csave,SCENECLASS_VARIABLE_FOGSTART,FogStart);
  244. WRITE_MICRO_CHUNK(csave,SCENECLASS_VARIABLE_FOGEND,FogEnd);
  245. csave.End_Chunk();
  246. }
  247. /***********************************************************************************************
  248. * SceneClass::Load -- loads scene settings from a chunk *
  249. * *
  250. * INPUT: *
  251. * *
  252. * OUTPUT: *
  253. * *
  254. * WARNINGS: *
  255. * *
  256. * HISTORY: *
  257. *=============================================================================================*/
  258. void SceneClass::Load(ChunkLoadClass & cload)
  259. {
  260. cload.Open_Chunk();
  261. if (cload.Cur_Chunk_ID() == SCENECLASS_CHUNK_VARIABLES) {
  262. while (cload.Open_Micro_Chunk()) {
  263. switch(cload.Cur_Micro_Chunk_ID()) {
  264. READ_MICRO_CHUNK(cload,SCENECLASS_VARIABLE_AMBIENTLIGHT,AmbientLight);
  265. READ_MICRO_CHUNK(cload,SCENECLASS_VARIABLE_POLYRENDERMODE,PolyRenderMode);
  266. READ_MICRO_CHUNK(cload,SCENECLASS_VARIABLE_FOGCOLOR,FogColor);
  267. READ_MICRO_CHUNK(cload,SCENECLASS_VARIABLE_FOGENABLED,FogEnabled);
  268. READ_MICRO_CHUNK(cload,SCENECLASS_VARIABLE_FOGSTART,FogStart);
  269. READ_MICRO_CHUNK(cload,SCENECLASS_VARIABLE_FOGEND,FogEnd);
  270. }
  271. cload.Close_Micro_Chunk();
  272. }
  273. } else {
  274. WWDEBUG_SAY(("Unhandled Chunk: 0x%X in file: %s line: %d\r\n",cload.Cur_Chunk_ID(),__FILE__,__LINE__));
  275. }
  276. cload.Close_Chunk();
  277. }
  278. /***********************************************************************************************
  279. * SimpleSceneClass -- Constructor *
  280. * *
  281. * INPUT: *
  282. * *
  283. * OUTPUT: *
  284. * *
  285. * WARNINGS: *
  286. * *
  287. * HISTORY: *
  288. * 3/24/98 GTH : Created. *
  289. * 9/10/99 GTH : Created. *
  290. *=============================================================================================*/
  291. SimpleSceneClass::SimpleSceneClass(void) :
  292. Visibility_Checked(false)
  293. {
  294. }
  295. /***********************************************************************************************
  296. * SimpleSceneClass::~SimpleSceneClass -- destructor *
  297. * *
  298. * INPUT: *
  299. * *
  300. * OUTPUT: *
  301. * *
  302. * WARNINGS: *
  303. * *
  304. * HISTORY: *
  305. * 3/24/98 GTH : Created. *
  306. *=============================================================================================*/
  307. SimpleSceneClass::~SimpleSceneClass(void)
  308. {
  309. Remove_All_Render_Objects();
  310. }
  311. /***********************************************************************************************
  312. * SimpleSceneClass::Remove_All_Render_Objects -- Removes all render objects from the scene *
  313. * *
  314. * *
  315. * *
  316. * *
  317. * INPUT: *
  318. * *
  319. * OUTPUT: *
  320. * *
  321. * WARNINGS: *
  322. * *
  323. * HISTORY: *
  324. * 8/27/2001 hy : Created. *
  325. *=============================================================================================*/
  326. void SimpleSceneClass::Remove_All_Render_Objects(void)
  327. {
  328. RenderObjClass * obj;
  329. while ( ( obj = RenderList.Remove_Head() ) != NULL ) {
  330. SceneClass::Remove_Render_Object(obj);
  331. obj->Release_Ref(); // remove head gets a ref
  332. }
  333. }
  334. /***********************************************************************************************
  335. * SimpleSceneClass::Add_Render_Object -- add a render object to the scene *
  336. * *
  337. * INPUT: *
  338. * *
  339. * OUTPUT: *
  340. * *
  341. * WARNINGS: *
  342. * *
  343. * HISTORY: *
  344. * 3/24/98 GTH : Created. *
  345. *=============================================================================================*/
  346. void SimpleSceneClass::Add_Render_Object(RenderObjClass * obj)
  347. {
  348. SceneClass::Add_Render_Object(obj);
  349. RenderList.Add(obj);
  350. }
  351. /***********************************************************************************************
  352. * SimpleSceneClass::Remove_Render_Object -- remove a render object from this scene *
  353. * *
  354. * INPUT: *
  355. * *
  356. * OUTPUT: *
  357. * *
  358. * WARNINGS: *
  359. * *
  360. * HISTORY: *
  361. * 3/24/98 GTH : Created. *
  362. *=============================================================================================*/
  363. void SimpleSceneClass::Remove_Render_Object(RenderObjClass * obj)
  364. {
  365. SceneClass::Remove_Render_Object(obj);
  366. // HY
  367. // this line must come last because otherwise it might cause
  368. // a premature release ref and cause a crash
  369. RenderList.Remove(obj);
  370. }
  371. void SimpleSceneClass::Register(RenderObjClass * obj,RegType for_what)
  372. {
  373. switch (for_what) {
  374. case ON_FRAME_UPDATE:
  375. UpdateList.Add(obj);
  376. break;
  377. case LIGHT:
  378. LightList.Add_Tail(obj);
  379. break;
  380. case RELEASE:
  381. ReleaseList.Add(obj);
  382. break;
  383. };
  384. }
  385. void SimpleSceneClass::Unregister(RenderObjClass * obj,RegType for_what)
  386. {
  387. switch (for_what) {
  388. case ON_FRAME_UPDATE:
  389. UpdateList.Remove(obj);
  390. break;
  391. case LIGHT:
  392. LightList.Remove(obj);
  393. break;
  394. case RELEASE:
  395. ReleaseList.Remove(obj);
  396. break;
  397. }
  398. }
  399. /***********************************************************************************************
  400. * SimpleSceneClass::Visiblity_Check -- set the visiblity status of the render objects *
  401. * *
  402. * INPUT: *
  403. * *
  404. * OUTPUT: *
  405. * *
  406. * WARNINGS: *
  407. * *
  408. * HISTORY: *
  409. * 3/24/98 GTH : Created. *
  410. * 4/13/98 NH : Added non-trivial checking (sphere vs. frustum). *
  411. *=============================================================================================*/
  412. void SimpleSceneClass::Visibility_Check(CameraClass * camera)
  413. {
  414. RefRenderObjListIterator it(&RenderList);
  415. // Loop over all top-level RenderObjects in this scene. If the bounding sphere is not in front
  416. // of all the frustum planes, it is invisible.
  417. for (it.First(); !it.Is_Done(); it.Next()) {
  418. RenderObjClass * robj = it.Peek_Obj();
  419. if (robj->Is_Force_Visible()) {
  420. robj->Set_Visible(true);
  421. } else {
  422. robj->Set_Visible(!camera->Cull_Sphere(robj->Get_Bounding_Sphere()));
  423. }
  424. // Prepare visible objects for LOD:
  425. if(robj->Is_Really_Visible() && !robj->Is_Ignoring_LOD_Cost()) {
  426. robj->Prepare_LOD(*camera);
  427. }
  428. }
  429. Visibility_Checked = true;
  430. }
  431. /***********************************************************************************************
  432. * SimpleSceneClass::Compute_Point_Visibility -- returns visibility of a point *
  433. * *
  434. * This function is used by the default dazzle behavior. SimpleSceneClass's implementation *
  435. * casts a ray against every object in the scene to see if the dazzle is occluded. *
  436. * *
  437. * INPUT: *
  438. * *
  439. * OUTPUT: *
  440. * *
  441. * WARNINGS: *
  442. * *
  443. * HISTORY: *
  444. * 6/13/2001 gth : Created. *
  445. *=============================================================================================*/
  446. float SimpleSceneClass::Compute_Point_Visibility
  447. (
  448. RenderInfoClass & rinfo,
  449. const Vector3 & point
  450. )
  451. {
  452. CastResultStruct res;
  453. LineSegClass ray(rinfo.Camera.Get_Position(),point);
  454. RayCollisionTestClass raytest(ray,&res,COLL_TYPE_PROJECTILE);
  455. RefRenderObjListIterator it(&RenderList);
  456. for (it.First(); !it.Is_Done(); it.Next()) {
  457. RenderObjClass * robj = it.Peek_Obj();
  458. robj->Cast_Ray(raytest);
  459. }
  460. if (res.Fraction == 1.0f) {
  461. return 1.0f;
  462. } else {
  463. return 0.0f;
  464. }
  465. }
  466. /***********************************************************************************************
  467. * SimpleSceneClass::Render -- Render this scene *
  468. * *
  469. * passes the gerd and camera to all render objects for rendering... *
  470. * *
  471. * INPUT: *
  472. * *
  473. * OUTPUT: *
  474. * *
  475. * WARNINGS: *
  476. * *
  477. * HISTORY: *
  478. * 12/10/98 GTH : Created. *
  479. * 06/27/02 KM Shader system light environment updates *
  480. *=============================================================================================*/
  481. void SimpleSceneClass::Customized_Render(RenderInfoClass & rinfo)
  482. {
  483. // SceneClass::Render(rinfo);
  484. // If visibility has not been checked for this scene since the last
  485. // Render() call, check it (set/clear the visibility bit in all render
  486. // objects in the scene).
  487. if (!Visibility_Checked) {
  488. // set the visibility bit in all render objects in all layers.
  489. Visibility_Check(&rinfo.Camera);
  490. }
  491. Visibility_Checked = false;
  492. RefRenderObjListIterator it(&UpdateList);
  493. // allow all objects in the update list to do their "every frame" processing
  494. for (it.First(); !it.Is_Done(); it.Next()) {
  495. it.Peek_Obj()->On_Frame_Update();
  496. }
  497. // apply only the first four lights in the scene
  498. // derived classes should use light environment
  499. WWASSERT(rinfo.light_environment==NULL);
  500. int count=0;
  501. // Turn off lights in case we have none
  502. DX8Wrapper::Set_Light(0,NULL);
  503. DX8Wrapper::Set_Light(1,NULL);
  504. DX8Wrapper::Set_Light(2,NULL);
  505. DX8Wrapper::Set_Light(3,NULL);
  506. // (gth) WWShade only works with light environments. We need to upgrade LightEnvironment to
  507. // support real point lights, etc. It will likely just evolve into "the n most important" lights
  508. // rather than optimizing lights into directional lights...
  509. #if 0
  510. for (it.First(&LightList); !it.Is_Done(); it.Next())
  511. {
  512. if (count<4)
  513. {
  514. DX8Wrapper::Set_Light(count,*(LightClass*)it.Peek_Obj());
  515. } else
  516. {
  517. // Simple scene only supports 4 global lights
  518. WWDEBUG_SAY(("Light %d ignored\n",count));
  519. }
  520. count++;
  521. }
  522. #endif
  523. // adding light environment for new shader system
  524. if (!rinfo.light_environment)
  525. {
  526. static LightEnvironmentClass lenv;
  527. lenv.Reset(Vector3(0,0,0),AmbientLight);
  528. for (it.First(&LightList); !it.Is_Done(); it.Next())
  529. {
  530. lenv.Add_Light(*(LightClass*)it.Peek_Obj());
  531. }
  532. lenv.Pre_Render_Update(rinfo.Camera.Get_Transform());
  533. rinfo.light_environment=&lenv;
  534. }
  535. // loop through all render objects in the list:
  536. for (it.First(&RenderList); !it.Is_Done(); it.Next()) {
  537. // get the render object
  538. RenderObjClass * robj = it.Peek_Obj();
  539. if (robj->Is_Really_Visible()) {
  540. if (robj->Get_Render_Hook()) {
  541. if (robj->Get_Render_Hook()->Pre_Render(robj, rinfo)) {
  542. robj->Render(rinfo);
  543. }
  544. robj->Get_Render_Hook()->Post_Render(robj, rinfo);
  545. } else {
  546. robj->Render(rinfo);
  547. }
  548. }
  549. }
  550. }
  551. void SimpleSceneClass::Post_Render_Processing(RenderInfoClass& rinfo)
  552. {
  553. // process the 'Release' list. These are objects that have notified us that they
  554. // want to be released. We have to walk this list twice, first un-linking the
  555. // object from the scene or its container. And then removing them all from
  556. // the list. (this last removal will destroy any auto-created objects)
  557. RefRenderObjListIterator it(&ReleaseList);
  558. for (it.First(&ReleaseList); !it.Is_Done(); it.Next()) {
  559. RenderObjClass * robj = it.Peek_Obj();
  560. if (robj->Get_Container()) {
  561. robj->Get_Container()->Remove_Sub_Object(robj);
  562. } else {
  563. robj->Remove();
  564. }
  565. }
  566. while(!ReleaseList.Is_Empty()) {
  567. ReleaseList.Release_Head();
  568. }
  569. }
  570. /***********************************************************************************************
  571. * SimpleSceneClass::Create_Iterator -- create an iterator for this scene *
  572. * *
  573. * INPUT: *
  574. * *
  575. * OUTPUT: *
  576. * *
  577. * WARNINGS: *
  578. * *
  579. * HISTORY: *
  580. * 3/27/98 GTH : Created. *
  581. *=============================================================================================*/
  582. SceneIterator * SimpleSceneClass::Create_Iterator(bool onlyvisible)
  583. {
  584. SimpleSceneIterator * it = W3DNEW SimpleSceneIterator(&RenderList,onlyvisible);
  585. return it;
  586. }
  587. /***********************************************************************************************
  588. * SimpleSceneClass::Destroy_Iterator -- destroy an iterater of this scene *
  589. * *
  590. * INPUT: *
  591. * *
  592. * OUTPUT: *
  593. * *
  594. * WARNINGS: *
  595. * *
  596. * HISTORY: *
  597. * 3/27/98 GTH : Created. *
  598. *=============================================================================================*/
  599. void SimpleSceneClass::Destroy_Iterator(SceneIterator * it)
  600. {
  601. delete it;
  602. }
  603. SimpleSceneIterator::SimpleSceneIterator(RefRenderObjListClass * list,bool onlyvis) :
  604. RobjIterator(list)
  605. {
  606. // TODO: make SimpleSceneIterator able to iterate through only the visible nodes.
  607. OnlyVis = onlyvis;
  608. }
  609. void SimpleSceneIterator::First(void)
  610. {
  611. RobjIterator.First();
  612. }
  613. void SimpleSceneIterator::Next(void)
  614. {
  615. RobjIterator.Next();
  616. }
  617. bool SimpleSceneIterator::Is_Done(void)
  618. {
  619. return RobjIterator.Is_Done();
  620. }
  621. RenderObjClass * SimpleSceneIterator::Current_Item(void)
  622. {
  623. return RobjIterator.Peek_Obj();
  624. }