From b10fe1f2bb4f8648f6366dd987ec43733198cc27 Mon Sep 17 00:00:00 2001 From: xezon <4720891+xezon@users.noreply.github.com> Date: Sun, 4 May 2025 17:25:24 +0200 Subject: [PATCH] [CORE] Move many unified WW3D2 library files to Core --- Core/Libraries/Source/WWVegas/CMakeLists.txt | 6 +- .../Source/WWVegas/WW3D2/CMakeLists.txt | 248 +++ .../WWVegas/WW3D2/DX8 Rationalizations.txt | 0 .../Source/WWVegas/WW3D2/DX8 Status.txt | 0 .../WWVegas/WW3D2/DX8ToolModifications.txt | 0 .../Source/WWVegas/WW3D2/FramGrab.cpp | 0 .../Source/WWVegas/WW3D2/MAPPERS.TXT | 0 .../WWVegas/WW3D2/RenderObjectGuide.txt | 0 .../RequiredAssets/AddProjectorGradient.tga | Bin .../WWVegas/WW3D2/RequiredAssets/Dazzle.INI | 0 .../RequiredAssets/MultProjectorGradient.tga | Bin .../WW3D2/RequiredAssets/ShatterAVel.tbl | Bin .../WW3D2/RequiredAssets/ShatterPlanes0.w3d | Bin .../WW3D2/RequiredAssets/ShatterVel.tbl | Bin .../RequiredAssets/w3d_missing_texture.tga | Bin .../Source/WWVegas/WW3D2/State Management.txt | 0 .../Source/WWVegas/WW3D2/aabtree.cpp | 0 .../Libraries/Source/WWVegas/WW3D2/aabtree.h | 0 .../Source/WWVegas/WW3D2/agg_def.cpp | 0 .../Libraries/Source/WWVegas/WW3D2/agg_def.h | 0 .../Source/WWVegas/WW3D2/animatedsoundmgr.cpp | 0 .../Source/WWVegas/WW3D2/animatedsoundmgr.h | 0 .../Source/WWVegas/WW3D2/assetstatus.cpp | 0 .../Source/WWVegas/WW3D2/assetstatus.h | 0 .../Source/WWVegas/WW3D2/bitmaphandler.cpp | 0 .../Source/WWVegas/WW3D2/bitmaphandler.h | 0 .../Source/WWVegas/WW3D2/bwrender.cpp | 0 .../Libraries/Source/WWVegas/WW3D2/bwrender.h | 0 .../Libraries/Source/WWVegas/WW3D2/classid.h | 0 .../Source/WWVegas/WW3D2/collect.cpp | 0 .../Libraries/Source/WWVegas/WW3D2/collect.h | 0 .../Source/WWVegas/WW3D2/colorspace.h | 0 .../Source/WWVegas/WW3D2/coltest.cpp | 0 .../Libraries/Source/WWVegas/WW3D2/coltest.h | 0 .../Libraries/Source/WWVegas/WW3D2/coltype.h | 0 .../Source/WWVegas/WW3D2/composite.cpp | 0 .../Source/WWVegas/WW3D2/composite.h | 0 .../Source/WWVegas/WW3D2/decalsys.cpp | 0 .../Libraries/Source/WWVegas/WW3D2/decalsys.h | 0 .../Source/WWVegas/WW3D2/distlod.cpp | 0 .../Libraries/Source/WWVegas/WW3D2/distlod.h | 0 .../Libraries/Source/WWVegas/WW3D2/dllist.h | 0 .../Libraries/Source/WWVegas/WW3D2/dx8list.h | 0 .../WWVegas/WW3D2/dx8polygonrenderer.cpp | 0 .../Source/WWVegas/WW3D2/dx8polygonrenderer.h | 0 .../Source/WWVegas/WW3D2/dx8webbrowser.cpp | 0 .../Source/WWVegas/WW3D2/dx8webbrowser.h | 0 .../Source/WWVegas/WW3D2/dynamesh.cpp | 0 .../Libraries/Source/WWVegas/WW3D2/dynamesh.h | 0 .../Libraries/Source/WWVegas/WW3D2/font3d.cpp | 0 .../Libraries/Source/WWVegas/WW3D2/font3d.h | 0 .../Source/WWVegas/WW3D2/formconv.cpp | 0 .../Libraries/Source/WWVegas/WW3D2/formconv.h | 0 .../Libraries/Source/WWVegas/WW3D2/framgrab.h | 0 .../Libraries/Source/WWVegas/WW3D2/hanim.cpp | 0 .../Libraries/Source/WWVegas/WW3D2/hanim.h | 0 .../Libraries/Source/WWVegas/WW3D2/hcanim.cpp | 0 .../Libraries/Source/WWVegas/WW3D2/hcanim.h | 0 .../Libraries/Source/WWVegas/WW3D2/hmdldef.H | 0 .../Source/WWVegas/WW3D2/hmdldef.cpp | 0 .../Libraries/Source/WWVegas/WW3D2/htree.cpp | 0 .../Libraries/Source/WWVegas/WW3D2/htree.h | 0 .../Source/WWVegas/WW3D2/intersec.cpp | 0 .../Libraries/Source/WWVegas/WW3D2/intersec.h | 0 .../Source/WWVegas/WW3D2/intersec.inl | 0 .../Libraries/Source/WWVegas/WW3D2/inttest.h | 0 .../Libraries/Source/WWVegas/WW3D2/layer.cpp | 0 .../Libraries/Source/WWVegas/WW3D2/layer.h | 0 .../Libraries/Source/WWVegas/WW3D2/line3d.cpp | 0 .../Libraries/Source/WWVegas/WW3D2/line3d.h | 0 .../Source/WWVegas/WW3D2/matinfo.cpp | 0 .../Libraries/Source/WWVegas/WW3D2/matinfo.h | 0 .../Source/WWVegas/WW3D2/meshdam.cpp | 0 .../Libraries/Source/WWVegas/WW3D2/meshdam.h | 0 .../Source/WWVegas/WW3D2/metalmap.cpp | 0 .../Libraries/Source/WWVegas/WW3D2/metalmap.h | 0 .../Source/WWVegas/WW3D2/missingtexture.cpp | 0 .../Source/WWVegas/WW3D2/missingtexture.h | 0 .../Libraries/Source/WWVegas/WW3D2/pivot.cpp | 0 .../Libraries/Source/WWVegas/WW3D2/pivot.h | 0 .../Source/WWVegas/WW3D2/pointgr.cpp | 0 .../Libraries/Source/WWVegas/WW3D2/pointgr.h | 0 .../Source/WWVegas/WW3D2/polyinfo.cpp | 0 .../Libraries/Source/WWVegas/WW3D2/polyinfo.h | 0 .../Source/WWVegas/WW3D2/predlod.cpp | 0 .../Libraries/Source/WWVegas/WW3D2/predlod.h | 0 .../Source/WWVegas/WW3D2/prim_anim.cpp | 0 .../Source/WWVegas/WW3D2/prim_anim.h | 0 .../Source/WWVegas/WW3D2/projector.cpp | 0 .../Source/WWVegas/WW3D2/projector.h | 0 .../Libraries/Source/WWVegas/WW3D2/proto.cpp | 0 .../Libraries/Source/WWVegas/WW3D2/proto.h | 0 .../Libraries/Source/WWVegas/WW3D2/proxy.h | 0 .../Libraries/Source/WWVegas/WW3D2/rddesc.h | 0 .../Source/WWVegas/WW3D2/render2dsentence.cpp | 0 .../Source/WWVegas/WW3D2/render2dsentence.h | 0 .../WWVegas/WW3D2/renderobjectrecycler.cpp | 0 .../WWVegas/WW3D2/renderobjectrecycler.h | 0 .../Source/WWVegas/WW3D2/rendobj.cpp | 0 .../Libraries/Source/WWVegas/WW3D2/rendobj.h | 0 .../Source/WWVegas/WW3D2/ringobj.cpp | 0 .../Libraries/Source/WWVegas/WW3D2/ringobj.h | 0 .../Libraries/Source/WWVegas/WW3D2/robjlist.h | 0 .../Source/WWVegas/WW3D2/segline.cpp | 0 .../Libraries/Source/WWVegas/WW3D2/segline.h | 0 .../Source/WWVegas/WW3D2/seglinerenderer.cpp | 0 .../Source/WWVegas/WW3D2/seglinerenderer.h | 0 .../Source/WWVegas/WW3D2/shattersystem.cpp | 0 .../Source/WWVegas/WW3D2/shattersystem.h | 0 .../Libraries/Source/WWVegas/WW3D2/snapPts.h | 0 .../Source/WWVegas/WW3D2/snappts.cpp | 0 .../Source/WWVegas/WW3D2/soundlibrarybridge.h | 0 .../Source/WWVegas/WW3D2/soundrobj.cpp | 0 .../Source/WWVegas/WW3D2/soundrobj.h | 0 .../Source/WWVegas/WW3D2/sphereobj.cpp | 0 .../Source/WWVegas/WW3D2/sphereobj.h | 0 .../Source/WWVegas/WW3D2/static_sort_list.cpp | 0 .../Source/WWVegas/WW3D2/static_sort_list.h | 0 .../Source/WWVegas/WW3D2/statistics.cpp | 0 .../Source/WWVegas/WW3D2/statistics.h | 0 .../Libraries/Source/WWVegas/WW3D2/streak.cpp | 0 .../Libraries/Source/WWVegas/WW3D2/streak.h | 0 .../Source/WWVegas/WW3D2/streakRender.cpp | 0 .../Source/WWVegas/WW3D2/streakRender.h | 0 .../Source/WWVegas/WW3D2/stripoptimizer.cpp | 0 .../Source/WWVegas/WW3D2/stripoptimizer.h | 0 .../Source/WWVegas/WW3D2/surfaceclass.cpp | 0 .../Source/WWVegas/WW3D2/surfaceclass.h | 0 .../Source/WWVegas/WW3D2/textdraw.cpp | 0 .../Libraries/Source/WWVegas/WW3D2/textdraw.h | 0 .../Source/WWVegas/WW3D2/visrasterizer.cpp | 0 .../Source/WWVegas/WW3D2/visrasterizer.h | 0 .../Source/WWVegas/WW3D2/w3d_dep.cpp | 0 .../Libraries/Source/WWVegas/WW3D2/w3d_dep.h | 0 .../Source/WWVegas/WW3D2/w3d_obsolete.h | 0 .../Source/WWVegas/WW3D2/w3d_util.cpp | 0 .../Libraries/Source/WWVegas/WW3D2/w3d_util.h | 0 .../Libraries/Source/WWVegas/WW3D2/w3derr.h | 0 .../Source/WWVegas/WW3D2/w3dexclusionlist.cpp | 0 .../Source/WWVegas/WW3D2/w3dexclusionlist.h | 0 .../Source/WWVegas/WW3D2/ww3dformat.cpp | 0 .../Source/WWVegas/WW3D2/ww3dformat.h | 0 .../Libraries/Source/WWVegas/WW3D2/ww3dids.h | 0 .../Libraries/Source/WWVegas/WW3D2/ww3dtrig.h | 0 .../Source/WWVegas/WW3D2/CMakeLists.txt | 262 ++- .../Source/WWVegas/WW3D2/FramGrab.cpp | 191 -- .../Source/WWVegas/WW3D2/aabtree.cpp | 1236 ----------- .../Libraries/Source/WWVegas/WW3D2/aabtree.h | 354 --- .../Source/WWVegas/WW3D2/agg_def.cpp | 894 -------- .../Libraries/Source/WWVegas/WW3D2/agg_def.h | 259 --- .../Source/WWVegas/WW3D2/animatedsoundmgr.cpp | 566 ----- .../Source/WWVegas/WW3D2/animatedsoundmgr.h | 136 -- .../Source/WWVegas/WW3D2/bitmaphandler.cpp | 448 ---- .../Source/WWVegas/WW3D2/bitmaphandler.h | 484 ----- .../Source/WWVegas/WW3D2/bwrender.cpp | 242 --- .../Libraries/Source/WWVegas/WW3D2/bwrender.h | 96 - .../Libraries/Source/WWVegas/WW3D2/classid.h | 65 - .../Source/WWVegas/WW3D2/collect.cpp | 1109 ---------- .../Libraries/Source/WWVegas/WW3D2/collect.h | 149 -- .../Source/WWVegas/WW3D2/colorspace.h | 161 -- .../Source/WWVegas/WW3D2/coltest.cpp | 375 ---- .../Libraries/Source/WWVegas/WW3D2/coltest.h | 317 --- .../Libraries/Source/WWVegas/WW3D2/coltype.h | 94 - .../Source/WWVegas/WW3D2/composite.cpp | 561 ----- .../Source/WWVegas/WW3D2/composite.h | 99 - .../Source/WWVegas/WW3D2/decalsys.cpp | 489 ----- .../Libraries/Source/WWVegas/WW3D2/decalsys.h | 308 --- .../Source/WWVegas/WW3D2/distlod.cpp | 1166 ---------- .../Libraries/Source/WWVegas/WW3D2/distlod.h | 246 --- .../Libraries/Source/WWVegas/WW3D2/dllist.h | 211 -- .../Libraries/Source/WWVegas/WW3D2/dx8list.h | 74 - .../WWVegas/WW3D2/dx8polygonrenderer.cpp | 115 - .../Source/WWVegas/WW3D2/dx8polygonrenderer.h | 161 -- .../Source/WWVegas/WW3D2/dx8webbrowser.cpp | 260 --- .../Source/WWVegas/WW3D2/dx8webbrowser.h | 93 - .../Source/WWVegas/WW3D2/dynamesh.cpp | 835 ------- .../Libraries/Source/WWVegas/WW3D2/dynamesh.h | 582 ----- .../Libraries/Source/WWVegas/WW3D2/font3d.cpp | 429 ---- .../Libraries/Source/WWVegas/WW3D2/font3d.h | 223 -- .../Source/WWVegas/WW3D2/formconv.cpp | 252 --- .../Libraries/Source/WWVegas/WW3D2/formconv.h | 62 - .../Libraries/Source/WWVegas/WW3D2/framgrab.h | 117 - .../Libraries/Source/WWVegas/WW3D2/hanim.cpp | 468 ---- .../Libraries/Source/WWVegas/WW3D2/hanim.h | 273 --- .../Libraries/Source/WWVegas/WW3D2/hcanim.cpp | 710 ------ .../Libraries/Source/WWVegas/WW3D2/hcanim.h | 139 -- .../Libraries/Source/WWVegas/WW3D2/hmdldef.H | 112 - .../Source/WWVegas/WW3D2/hmdldef.cpp | 257 --- .../Libraries/Source/WWVegas/WW3D2/htree.cpp | 1231 ----------- .../Libraries/Source/WWVegas/WW3D2/htree.h | 212 -- .../Source/WWVegas/WW3D2/intersec.cpp | 444 ---- .../Libraries/Source/WWVegas/WW3D2/intersec.h | 404 ---- .../Source/WWVegas/WW3D2/intersec.inl | 1096 ---------- .../Libraries/Source/WWVegas/WW3D2/inttest.h | 256 --- .../Libraries/Source/WWVegas/WW3D2/layer.cpp | 289 --- .../Libraries/Source/WWVegas/WW3D2/layer.h | 100 - .../Libraries/Source/WWVegas/WW3D2/line3d.cpp | 514 ----- .../Libraries/Source/WWVegas/WW3D2/line3d.h | 124 -- .../Source/WWVegas/WW3D2/matinfo.cpp | 429 ---- .../Libraries/Source/WWVegas/WW3D2/matinfo.h | 335 --- .../Source/WWVegas/WW3D2/meshdam.cpp | 266 --- .../Libraries/Source/WWVegas/WW3D2/meshdam.h | 108 - .../Source/WWVegas/WW3D2/metalmap.cpp | 423 ---- .../Libraries/Source/WWVegas/WW3D2/metalmap.h | 121 -- .../Source/WWVegas/WW3D2/missingtexture.cpp | 711 ------ .../Source/WWVegas/WW3D2/missingtexture.h | 42 - .../Libraries/Source/WWVegas/WW3D2/pivot.cpp | 171 -- .../Libraries/Source/WWVegas/WW3D2/pivot.h | 114 - .../Source/WWVegas/WW3D2/pointgr.cpp | 1916 ----------------- .../Libraries/Source/WWVegas/WW3D2/pointgr.h | 242 --- .../Source/WWVegas/WW3D2/polyinfo.cpp | 85 - .../Libraries/Source/WWVegas/WW3D2/polyinfo.h | 94 - .../Source/WWVegas/WW3D2/predlod.cpp | 406 ---- .../Libraries/Source/WWVegas/WW3D2/predlod.h | 86 - .../Source/WWVegas/WW3D2/prim_anim.cpp | 40 - .../Source/WWVegas/WW3D2/prim_anim.h | 391 ---- .../Source/WWVegas/WW3D2/projector.cpp | 236 -- .../Source/WWVegas/WW3D2/projector.h | 92 - .../Libraries/Source/WWVegas/WW3D2/proto.cpp | 180 -- .../Libraries/Source/WWVegas/WW3D2/proto.h | 183 -- .../Libraries/Source/WWVegas/WW3D2/proxy.h | 115 - .../Libraries/Source/WWVegas/WW3D2/rddesc.h | 172 -- .../Source/WWVegas/WW3D2/render2dsentence.cpp | 1795 --------------- .../Source/WWVegas/WW3D2/render2dsentence.h | 276 --- .../WWVegas/WW3D2/renderobjectrecycler.cpp | 188 -- .../WWVegas/WW3D2/renderobjectrecycler.h | 84 - .../Source/WWVegas/WW3D2/rendobj.cpp | 1318 ------------ .../Libraries/Source/WWVegas/WW3D2/rendobj.h | 658 ------ .../Source/WWVegas/WW3D2/ringobj.cpp | 1650 -------------- .../Libraries/Source/WWVegas/WW3D2/ringobj.h | 370 ---- .../Libraries/Source/WWVegas/WW3D2/robjlist.h | 67 - .../Source/WWVegas/WW3D2/segline.cpp | 591 ----- .../Libraries/Source/WWVegas/WW3D2/segline.h | 182 -- .../Source/WWVegas/WW3D2/seglinerenderer.cpp | 1320 ------------ .../Source/WWVegas/WW3D2/seglinerenderer.h | 212 -- .../Source/WWVegas/WW3D2/shattersystem.cpp | 1268 ----------- .../Source/WWVegas/WW3D2/shattersystem.h | 103 - .../Libraries/Source/WWVegas/WW3D2/snapPts.h | 64 - .../Source/WWVegas/WW3D2/snappts.cpp | 65 - .../Source/WWVegas/WW3D2/soundlibrarybridge.h | 49 - .../Source/WWVegas/WW3D2/soundrobj.cpp | 772 ------- .../Source/WWVegas/WW3D2/soundrobj.h | 285 --- .../Source/WWVegas/WW3D2/sphereobj.cpp | 1754 --------------- .../Source/WWVegas/WW3D2/sphereobj.h | 479 ----- .../Source/WWVegas/WW3D2/static_sort_list.cpp | 97 - .../Source/WWVegas/WW3D2/static_sort_list.h | 99 - .../Source/WWVegas/WW3D2/statistics.cpp | 394 ---- .../Source/WWVegas/WW3D2/statistics.h | 80 - .../Libraries/Source/WWVegas/WW3D2/streak.cpp | 745 ------- .../Libraries/Source/WWVegas/WW3D2/streak.h | 220 -- .../Source/WWVegas/WW3D2/streakRender.cpp | 1425 ------------ .../Source/WWVegas/WW3D2/streakRender.h | 227 -- .../Source/WWVegas/WW3D2/stripoptimizer.cpp | 1019 --------- .../Source/WWVegas/WW3D2/stripoptimizer.h | 48 - .../Source/WWVegas/WW3D2/surfaceclass.cpp | 1036 --------- .../Source/WWVegas/WW3D2/surfaceclass.h | 154 -- .../Source/WWVegas/WW3D2/textdraw.cpp | 344 --- .../Libraries/Source/WWVegas/WW3D2/textdraw.h | 120 -- .../Source/WWVegas/WW3D2/visrasterizer.cpp | 730 ------- .../Source/WWVegas/WW3D2/visrasterizer.h | 213 -- .../Source/WWVegas/WW3D2/w3d_dep.cpp | 575 ----- .../Libraries/Source/WWVegas/WW3D2/w3d_dep.h | 54 - .../Source/WWVegas/WW3D2/w3d_obsolete.h | 333 --- .../Source/WWVegas/WW3D2/w3d_util.cpp | 142 -- .../Libraries/Source/WWVegas/WW3D2/w3d_util.h | 80 - .../Libraries/Source/WWVegas/WW3D2/w3derr.h | 60 - .../Source/WWVegas/WW3D2/w3dexclusionlist.cpp | 105 - .../Source/WWVegas/WW3D2/w3dexclusionlist.h | 84 - .../Source/WWVegas/WW3D2/ww3dformat.cpp | 455 ---- .../Source/WWVegas/WW3D2/ww3dformat.h | 209 -- .../Libraries/Source/WWVegas/WW3D2/ww3dids.h | 77 - .../Libraries/Source/WWVegas/WW3D2/ww3dtrig.h | 61 - .../Source/WWVegas/WW3D2/CMakeLists.txt | 262 ++- .../WWVegas/WW3D2/DX8 Rationalizations.txt | 25 - .../Source/WWVegas/WW3D2/DX8 Status.txt | 274 --- .../WWVegas/WW3D2/DX8ToolModifications.txt | 7 - .../Source/WWVegas/WW3D2/MAPPERS.TXT | 148 -- .../WWVegas/WW3D2/RenderObjectGuide.txt | 25 - .../RequiredAssets/AddProjectorGradient.tga | Bin 1068 -> 0 bytes .../WWVegas/WW3D2/RequiredAssets/Dazzle.INI | 161 -- .../RequiredAssets/MultProjectorGradient.tga | Bin 1068 -> 0 bytes .../WW3D2/RequiredAssets/ShatterAVel.tbl | Bin 209 -> 0 bytes .../WW3D2/RequiredAssets/ShatterPlanes0.w3d | Bin 2444 -> 0 bytes .../WW3D2/RequiredAssets/ShatterVel.tbl | Bin 209 -> 0 bytes .../RequiredAssets/w3d_missing_texture.tga | Bin 49196 -> 0 bytes .../Source/WWVegas/WW3D2/State Management.txt | 173 -- .../Source/WWVegas/WW3D2/assetstatus.cpp | 115 - .../Source/WWVegas/WW3D2/assetstatus.h | 68 - 288 files changed, 507 insertions(+), 51049 deletions(-) create mode 100644 Core/Libraries/Source/WWVegas/WW3D2/CMakeLists.txt rename {Generals/Code => Core}/Libraries/Source/WWVegas/WW3D2/DX8 Rationalizations.txt (100%) rename {Generals/Code => Core}/Libraries/Source/WWVegas/WW3D2/DX8 Status.txt (100%) rename {Generals/Code => Core}/Libraries/Source/WWVegas/WW3D2/DX8ToolModifications.txt (100%) rename {GeneralsMD/Code => Core}/Libraries/Source/WWVegas/WW3D2/FramGrab.cpp (100%) rename {Generals/Code => Core}/Libraries/Source/WWVegas/WW3D2/MAPPERS.TXT (100%) rename {Generals/Code => Core}/Libraries/Source/WWVegas/WW3D2/RenderObjectGuide.txt (100%) rename {Generals/Code => Core}/Libraries/Source/WWVegas/WW3D2/RequiredAssets/AddProjectorGradient.tga (100%) rename {Generals/Code => Core}/Libraries/Source/WWVegas/WW3D2/RequiredAssets/Dazzle.INI (100%) rename {Generals/Code => Core}/Libraries/Source/WWVegas/WW3D2/RequiredAssets/MultProjectorGradient.tga (100%) rename {Generals/Code => Core}/Libraries/Source/WWVegas/WW3D2/RequiredAssets/ShatterAVel.tbl (100%) rename {Generals/Code => Core}/Libraries/Source/WWVegas/WW3D2/RequiredAssets/ShatterPlanes0.w3d (100%) rename {Generals/Code => Core}/Libraries/Source/WWVegas/WW3D2/RequiredAssets/ShatterVel.tbl (100%) rename {Generals/Code => Core}/Libraries/Source/WWVegas/WW3D2/RequiredAssets/w3d_missing_texture.tga (100%) rename {Generals/Code => Core}/Libraries/Source/WWVegas/WW3D2/State Management.txt (100%) rename {GeneralsMD/Code => Core}/Libraries/Source/WWVegas/WW3D2/aabtree.cpp (100%) rename {GeneralsMD/Code => Core}/Libraries/Source/WWVegas/WW3D2/aabtree.h (100%) rename {GeneralsMD/Code => Core}/Libraries/Source/WWVegas/WW3D2/agg_def.cpp (100%) rename {GeneralsMD/Code => Core}/Libraries/Source/WWVegas/WW3D2/agg_def.h (100%) rename {GeneralsMD/Code => Core}/Libraries/Source/WWVegas/WW3D2/animatedsoundmgr.cpp (100%) rename {GeneralsMD/Code => Core}/Libraries/Source/WWVegas/WW3D2/animatedsoundmgr.h (100%) rename {Generals/Code => Core}/Libraries/Source/WWVegas/WW3D2/assetstatus.cpp (100%) rename {Generals/Code => Core}/Libraries/Source/WWVegas/WW3D2/assetstatus.h (100%) rename {GeneralsMD/Code => Core}/Libraries/Source/WWVegas/WW3D2/bitmaphandler.cpp (100%) rename {GeneralsMD/Code => Core}/Libraries/Source/WWVegas/WW3D2/bitmaphandler.h (100%) rename {GeneralsMD/Code => Core}/Libraries/Source/WWVegas/WW3D2/bwrender.cpp (100%) rename {GeneralsMD/Code => Core}/Libraries/Source/WWVegas/WW3D2/bwrender.h (100%) rename {GeneralsMD/Code => Core}/Libraries/Source/WWVegas/WW3D2/classid.h (100%) rename {GeneralsMD/Code => Core}/Libraries/Source/WWVegas/WW3D2/collect.cpp (100%) rename {GeneralsMD/Code => Core}/Libraries/Source/WWVegas/WW3D2/collect.h (100%) rename {GeneralsMD/Code => Core}/Libraries/Source/WWVegas/WW3D2/colorspace.h (100%) rename {GeneralsMD/Code => Core}/Libraries/Source/WWVegas/WW3D2/coltest.cpp (100%) rename {GeneralsMD/Code => Core}/Libraries/Source/WWVegas/WW3D2/coltest.h (100%) rename {GeneralsMD/Code => Core}/Libraries/Source/WWVegas/WW3D2/coltype.h (100%) rename {GeneralsMD/Code => Core}/Libraries/Source/WWVegas/WW3D2/composite.cpp (100%) rename {GeneralsMD/Code => Core}/Libraries/Source/WWVegas/WW3D2/composite.h (100%) rename {GeneralsMD/Code => Core}/Libraries/Source/WWVegas/WW3D2/decalsys.cpp (100%) rename {GeneralsMD/Code => Core}/Libraries/Source/WWVegas/WW3D2/decalsys.h (100%) rename {GeneralsMD/Code => Core}/Libraries/Source/WWVegas/WW3D2/distlod.cpp (100%) rename {GeneralsMD/Code => Core}/Libraries/Source/WWVegas/WW3D2/distlod.h (100%) rename {GeneralsMD/Code => Core}/Libraries/Source/WWVegas/WW3D2/dllist.h (100%) rename {GeneralsMD/Code => Core}/Libraries/Source/WWVegas/WW3D2/dx8list.h (100%) rename {GeneralsMD/Code => Core}/Libraries/Source/WWVegas/WW3D2/dx8polygonrenderer.cpp (100%) rename {GeneralsMD/Code => Core}/Libraries/Source/WWVegas/WW3D2/dx8polygonrenderer.h (100%) rename {GeneralsMD/Code => Core}/Libraries/Source/WWVegas/WW3D2/dx8webbrowser.cpp (100%) rename {GeneralsMD/Code => Core}/Libraries/Source/WWVegas/WW3D2/dx8webbrowser.h (100%) rename {GeneralsMD/Code => Core}/Libraries/Source/WWVegas/WW3D2/dynamesh.cpp (100%) rename {GeneralsMD/Code => Core}/Libraries/Source/WWVegas/WW3D2/dynamesh.h (100%) rename {GeneralsMD/Code => Core}/Libraries/Source/WWVegas/WW3D2/font3d.cpp (100%) rename {GeneralsMD/Code => Core}/Libraries/Source/WWVegas/WW3D2/font3d.h (100%) rename {GeneralsMD/Code => Core}/Libraries/Source/WWVegas/WW3D2/formconv.cpp (100%) rename {GeneralsMD/Code => Core}/Libraries/Source/WWVegas/WW3D2/formconv.h (100%) rename {GeneralsMD/Code => Core}/Libraries/Source/WWVegas/WW3D2/framgrab.h (100%) rename {GeneralsMD/Code => Core}/Libraries/Source/WWVegas/WW3D2/hanim.cpp (100%) rename {GeneralsMD/Code => Core}/Libraries/Source/WWVegas/WW3D2/hanim.h (100%) rename {GeneralsMD/Code => Core}/Libraries/Source/WWVegas/WW3D2/hcanim.cpp (100%) rename {GeneralsMD/Code => Core}/Libraries/Source/WWVegas/WW3D2/hcanim.h (100%) rename {GeneralsMD/Code => Core}/Libraries/Source/WWVegas/WW3D2/hmdldef.H (100%) rename {GeneralsMD/Code => Core}/Libraries/Source/WWVegas/WW3D2/hmdldef.cpp (100%) rename {GeneralsMD/Code => Core}/Libraries/Source/WWVegas/WW3D2/htree.cpp (100%) rename {GeneralsMD/Code => Core}/Libraries/Source/WWVegas/WW3D2/htree.h (100%) rename {GeneralsMD/Code => Core}/Libraries/Source/WWVegas/WW3D2/intersec.cpp (100%) rename {GeneralsMD/Code => Core}/Libraries/Source/WWVegas/WW3D2/intersec.h (100%) rename {GeneralsMD/Code => Core}/Libraries/Source/WWVegas/WW3D2/intersec.inl (100%) rename {GeneralsMD/Code => Core}/Libraries/Source/WWVegas/WW3D2/inttest.h (100%) rename {GeneralsMD/Code => Core}/Libraries/Source/WWVegas/WW3D2/layer.cpp (100%) rename {GeneralsMD/Code => Core}/Libraries/Source/WWVegas/WW3D2/layer.h (100%) rename {GeneralsMD/Code => Core}/Libraries/Source/WWVegas/WW3D2/line3d.cpp (100%) rename {GeneralsMD/Code => Core}/Libraries/Source/WWVegas/WW3D2/line3d.h (100%) rename {GeneralsMD/Code => Core}/Libraries/Source/WWVegas/WW3D2/matinfo.cpp (100%) rename {GeneralsMD/Code => Core}/Libraries/Source/WWVegas/WW3D2/matinfo.h (100%) rename {GeneralsMD/Code => Core}/Libraries/Source/WWVegas/WW3D2/meshdam.cpp (100%) rename {GeneralsMD/Code => Core}/Libraries/Source/WWVegas/WW3D2/meshdam.h (100%) rename {GeneralsMD/Code => Core}/Libraries/Source/WWVegas/WW3D2/metalmap.cpp (100%) rename {GeneralsMD/Code => Core}/Libraries/Source/WWVegas/WW3D2/metalmap.h (100%) rename {GeneralsMD/Code => Core}/Libraries/Source/WWVegas/WW3D2/missingtexture.cpp (100%) rename {GeneralsMD/Code => Core}/Libraries/Source/WWVegas/WW3D2/missingtexture.h (100%) rename {GeneralsMD/Code => Core}/Libraries/Source/WWVegas/WW3D2/pivot.cpp (100%) rename {GeneralsMD/Code => Core}/Libraries/Source/WWVegas/WW3D2/pivot.h (100%) rename {GeneralsMD/Code => Core}/Libraries/Source/WWVegas/WW3D2/pointgr.cpp (100%) rename {GeneralsMD/Code => Core}/Libraries/Source/WWVegas/WW3D2/pointgr.h (100%) rename {GeneralsMD/Code => Core}/Libraries/Source/WWVegas/WW3D2/polyinfo.cpp (100%) rename {GeneralsMD/Code => Core}/Libraries/Source/WWVegas/WW3D2/polyinfo.h (100%) rename {GeneralsMD/Code => Core}/Libraries/Source/WWVegas/WW3D2/predlod.cpp (100%) rename {GeneralsMD/Code => Core}/Libraries/Source/WWVegas/WW3D2/predlod.h (100%) rename {GeneralsMD/Code => Core}/Libraries/Source/WWVegas/WW3D2/prim_anim.cpp (100%) rename {GeneralsMD/Code => Core}/Libraries/Source/WWVegas/WW3D2/prim_anim.h (100%) rename {GeneralsMD/Code => Core}/Libraries/Source/WWVegas/WW3D2/projector.cpp (100%) rename {GeneralsMD/Code => Core}/Libraries/Source/WWVegas/WW3D2/projector.h (100%) rename {GeneralsMD/Code => Core}/Libraries/Source/WWVegas/WW3D2/proto.cpp (100%) rename {GeneralsMD/Code => Core}/Libraries/Source/WWVegas/WW3D2/proto.h (100%) rename {GeneralsMD/Code => Core}/Libraries/Source/WWVegas/WW3D2/proxy.h (100%) rename {GeneralsMD/Code => Core}/Libraries/Source/WWVegas/WW3D2/rddesc.h (100%) rename {GeneralsMD/Code => Core}/Libraries/Source/WWVegas/WW3D2/render2dsentence.cpp (100%) rename {GeneralsMD/Code => Core}/Libraries/Source/WWVegas/WW3D2/render2dsentence.h (100%) rename {GeneralsMD/Code => Core}/Libraries/Source/WWVegas/WW3D2/renderobjectrecycler.cpp (100%) rename {GeneralsMD/Code => Core}/Libraries/Source/WWVegas/WW3D2/renderobjectrecycler.h (100%) rename {GeneralsMD/Code => Core}/Libraries/Source/WWVegas/WW3D2/rendobj.cpp (100%) rename {GeneralsMD/Code => Core}/Libraries/Source/WWVegas/WW3D2/rendobj.h (100%) rename {GeneralsMD/Code => Core}/Libraries/Source/WWVegas/WW3D2/ringobj.cpp (100%) rename {GeneralsMD/Code => Core}/Libraries/Source/WWVegas/WW3D2/ringobj.h (100%) rename {GeneralsMD/Code => Core}/Libraries/Source/WWVegas/WW3D2/robjlist.h (100%) rename {GeneralsMD/Code => Core}/Libraries/Source/WWVegas/WW3D2/segline.cpp (100%) rename {GeneralsMD/Code => Core}/Libraries/Source/WWVegas/WW3D2/segline.h (100%) rename {GeneralsMD/Code => Core}/Libraries/Source/WWVegas/WW3D2/seglinerenderer.cpp (100%) rename {GeneralsMD/Code => Core}/Libraries/Source/WWVegas/WW3D2/seglinerenderer.h (100%) rename {GeneralsMD/Code => Core}/Libraries/Source/WWVegas/WW3D2/shattersystem.cpp (100%) rename {GeneralsMD/Code => Core}/Libraries/Source/WWVegas/WW3D2/shattersystem.h (100%) rename {GeneralsMD/Code => Core}/Libraries/Source/WWVegas/WW3D2/snapPts.h (100%) rename {GeneralsMD/Code => Core}/Libraries/Source/WWVegas/WW3D2/snappts.cpp (100%) rename {GeneralsMD/Code => Core}/Libraries/Source/WWVegas/WW3D2/soundlibrarybridge.h (100%) rename {GeneralsMD/Code => Core}/Libraries/Source/WWVegas/WW3D2/soundrobj.cpp (100%) rename {GeneralsMD/Code => Core}/Libraries/Source/WWVegas/WW3D2/soundrobj.h (100%) rename {GeneralsMD/Code => Core}/Libraries/Source/WWVegas/WW3D2/sphereobj.cpp (100%) rename {GeneralsMD/Code => Core}/Libraries/Source/WWVegas/WW3D2/sphereobj.h (100%) rename {GeneralsMD/Code => Core}/Libraries/Source/WWVegas/WW3D2/static_sort_list.cpp (100%) rename {GeneralsMD/Code => Core}/Libraries/Source/WWVegas/WW3D2/static_sort_list.h (100%) rename {GeneralsMD/Code => Core}/Libraries/Source/WWVegas/WW3D2/statistics.cpp (100%) rename {GeneralsMD/Code => Core}/Libraries/Source/WWVegas/WW3D2/statistics.h (100%) rename {GeneralsMD/Code => Core}/Libraries/Source/WWVegas/WW3D2/streak.cpp (100%) rename {GeneralsMD/Code => Core}/Libraries/Source/WWVegas/WW3D2/streak.h (100%) rename {GeneralsMD/Code => Core}/Libraries/Source/WWVegas/WW3D2/streakRender.cpp (100%) rename {GeneralsMD/Code => Core}/Libraries/Source/WWVegas/WW3D2/streakRender.h (100%) rename {GeneralsMD/Code => Core}/Libraries/Source/WWVegas/WW3D2/stripoptimizer.cpp (100%) rename {GeneralsMD/Code => Core}/Libraries/Source/WWVegas/WW3D2/stripoptimizer.h (100%) rename {GeneralsMD/Code => Core}/Libraries/Source/WWVegas/WW3D2/surfaceclass.cpp (100%) rename {GeneralsMD/Code => Core}/Libraries/Source/WWVegas/WW3D2/surfaceclass.h (100%) rename {GeneralsMD/Code => Core}/Libraries/Source/WWVegas/WW3D2/textdraw.cpp (100%) rename {GeneralsMD/Code => Core}/Libraries/Source/WWVegas/WW3D2/textdraw.h (100%) rename {GeneralsMD/Code => Core}/Libraries/Source/WWVegas/WW3D2/visrasterizer.cpp (100%) rename {GeneralsMD/Code => Core}/Libraries/Source/WWVegas/WW3D2/visrasterizer.h (100%) rename {GeneralsMD/Code => Core}/Libraries/Source/WWVegas/WW3D2/w3d_dep.cpp (100%) rename {GeneralsMD/Code => Core}/Libraries/Source/WWVegas/WW3D2/w3d_dep.h (100%) rename {GeneralsMD/Code => Core}/Libraries/Source/WWVegas/WW3D2/w3d_obsolete.h (100%) rename {GeneralsMD/Code => Core}/Libraries/Source/WWVegas/WW3D2/w3d_util.cpp (100%) rename {GeneralsMD/Code => Core}/Libraries/Source/WWVegas/WW3D2/w3d_util.h (100%) rename {GeneralsMD/Code => Core}/Libraries/Source/WWVegas/WW3D2/w3derr.h (100%) rename {GeneralsMD/Code => Core}/Libraries/Source/WWVegas/WW3D2/w3dexclusionlist.cpp (100%) rename {GeneralsMD/Code => Core}/Libraries/Source/WWVegas/WW3D2/w3dexclusionlist.h (100%) rename {GeneralsMD/Code => Core}/Libraries/Source/WWVegas/WW3D2/ww3dformat.cpp (100%) rename {GeneralsMD/Code => Core}/Libraries/Source/WWVegas/WW3D2/ww3dformat.h (100%) rename {GeneralsMD/Code => Core}/Libraries/Source/WWVegas/WW3D2/ww3dids.h (100%) rename {GeneralsMD/Code => Core}/Libraries/Source/WWVegas/WW3D2/ww3dtrig.h (100%) delete mode 100644 Generals/Code/Libraries/Source/WWVegas/WW3D2/FramGrab.cpp delete mode 100644 Generals/Code/Libraries/Source/WWVegas/WW3D2/aabtree.cpp delete mode 100644 Generals/Code/Libraries/Source/WWVegas/WW3D2/aabtree.h delete mode 100644 Generals/Code/Libraries/Source/WWVegas/WW3D2/agg_def.cpp delete mode 100644 Generals/Code/Libraries/Source/WWVegas/WW3D2/agg_def.h delete mode 100644 Generals/Code/Libraries/Source/WWVegas/WW3D2/animatedsoundmgr.cpp delete mode 100644 Generals/Code/Libraries/Source/WWVegas/WW3D2/animatedsoundmgr.h delete mode 100644 Generals/Code/Libraries/Source/WWVegas/WW3D2/bitmaphandler.cpp delete mode 100644 Generals/Code/Libraries/Source/WWVegas/WW3D2/bitmaphandler.h delete mode 100644 Generals/Code/Libraries/Source/WWVegas/WW3D2/bwrender.cpp delete mode 100644 Generals/Code/Libraries/Source/WWVegas/WW3D2/bwrender.h delete mode 100644 Generals/Code/Libraries/Source/WWVegas/WW3D2/classid.h delete mode 100644 Generals/Code/Libraries/Source/WWVegas/WW3D2/collect.cpp delete mode 100644 Generals/Code/Libraries/Source/WWVegas/WW3D2/collect.h delete mode 100644 Generals/Code/Libraries/Source/WWVegas/WW3D2/colorspace.h delete mode 100644 Generals/Code/Libraries/Source/WWVegas/WW3D2/coltest.cpp delete mode 100644 Generals/Code/Libraries/Source/WWVegas/WW3D2/coltest.h delete mode 100644 Generals/Code/Libraries/Source/WWVegas/WW3D2/coltype.h delete mode 100644 Generals/Code/Libraries/Source/WWVegas/WW3D2/composite.cpp delete mode 100644 Generals/Code/Libraries/Source/WWVegas/WW3D2/composite.h delete mode 100644 Generals/Code/Libraries/Source/WWVegas/WW3D2/decalsys.cpp delete mode 100644 Generals/Code/Libraries/Source/WWVegas/WW3D2/decalsys.h delete mode 100644 Generals/Code/Libraries/Source/WWVegas/WW3D2/distlod.cpp delete mode 100644 Generals/Code/Libraries/Source/WWVegas/WW3D2/distlod.h delete mode 100644 Generals/Code/Libraries/Source/WWVegas/WW3D2/dllist.h delete mode 100644 Generals/Code/Libraries/Source/WWVegas/WW3D2/dx8list.h delete mode 100644 Generals/Code/Libraries/Source/WWVegas/WW3D2/dx8polygonrenderer.cpp delete mode 100644 Generals/Code/Libraries/Source/WWVegas/WW3D2/dx8polygonrenderer.h delete mode 100644 Generals/Code/Libraries/Source/WWVegas/WW3D2/dx8webbrowser.cpp delete mode 100644 Generals/Code/Libraries/Source/WWVegas/WW3D2/dx8webbrowser.h delete mode 100644 Generals/Code/Libraries/Source/WWVegas/WW3D2/dynamesh.cpp delete mode 100644 Generals/Code/Libraries/Source/WWVegas/WW3D2/dynamesh.h delete mode 100644 Generals/Code/Libraries/Source/WWVegas/WW3D2/font3d.cpp delete mode 100644 Generals/Code/Libraries/Source/WWVegas/WW3D2/font3d.h delete mode 100644 Generals/Code/Libraries/Source/WWVegas/WW3D2/formconv.cpp delete mode 100644 Generals/Code/Libraries/Source/WWVegas/WW3D2/formconv.h delete mode 100644 Generals/Code/Libraries/Source/WWVegas/WW3D2/framgrab.h delete mode 100644 Generals/Code/Libraries/Source/WWVegas/WW3D2/hanim.cpp delete mode 100644 Generals/Code/Libraries/Source/WWVegas/WW3D2/hanim.h delete mode 100644 Generals/Code/Libraries/Source/WWVegas/WW3D2/hcanim.cpp delete mode 100644 Generals/Code/Libraries/Source/WWVegas/WW3D2/hcanim.h delete mode 100644 Generals/Code/Libraries/Source/WWVegas/WW3D2/hmdldef.H delete mode 100644 Generals/Code/Libraries/Source/WWVegas/WW3D2/hmdldef.cpp delete mode 100644 Generals/Code/Libraries/Source/WWVegas/WW3D2/htree.cpp delete mode 100644 Generals/Code/Libraries/Source/WWVegas/WW3D2/htree.h delete mode 100644 Generals/Code/Libraries/Source/WWVegas/WW3D2/intersec.cpp delete mode 100644 Generals/Code/Libraries/Source/WWVegas/WW3D2/intersec.h delete mode 100644 Generals/Code/Libraries/Source/WWVegas/WW3D2/intersec.inl delete mode 100644 Generals/Code/Libraries/Source/WWVegas/WW3D2/inttest.h delete mode 100644 Generals/Code/Libraries/Source/WWVegas/WW3D2/layer.cpp delete mode 100644 Generals/Code/Libraries/Source/WWVegas/WW3D2/layer.h delete mode 100644 Generals/Code/Libraries/Source/WWVegas/WW3D2/line3d.cpp delete mode 100644 Generals/Code/Libraries/Source/WWVegas/WW3D2/line3d.h delete mode 100644 Generals/Code/Libraries/Source/WWVegas/WW3D2/matinfo.cpp delete mode 100644 Generals/Code/Libraries/Source/WWVegas/WW3D2/matinfo.h delete mode 100644 Generals/Code/Libraries/Source/WWVegas/WW3D2/meshdam.cpp delete mode 100644 Generals/Code/Libraries/Source/WWVegas/WW3D2/meshdam.h delete mode 100644 Generals/Code/Libraries/Source/WWVegas/WW3D2/metalmap.cpp delete mode 100644 Generals/Code/Libraries/Source/WWVegas/WW3D2/metalmap.h delete mode 100644 Generals/Code/Libraries/Source/WWVegas/WW3D2/missingtexture.cpp delete mode 100644 Generals/Code/Libraries/Source/WWVegas/WW3D2/missingtexture.h delete mode 100644 Generals/Code/Libraries/Source/WWVegas/WW3D2/pivot.cpp delete mode 100644 Generals/Code/Libraries/Source/WWVegas/WW3D2/pivot.h delete mode 100644 Generals/Code/Libraries/Source/WWVegas/WW3D2/pointgr.cpp delete mode 100644 Generals/Code/Libraries/Source/WWVegas/WW3D2/pointgr.h delete mode 100644 Generals/Code/Libraries/Source/WWVegas/WW3D2/polyinfo.cpp delete mode 100644 Generals/Code/Libraries/Source/WWVegas/WW3D2/polyinfo.h delete mode 100644 Generals/Code/Libraries/Source/WWVegas/WW3D2/predlod.cpp delete mode 100644 Generals/Code/Libraries/Source/WWVegas/WW3D2/predlod.h delete mode 100644 Generals/Code/Libraries/Source/WWVegas/WW3D2/prim_anim.cpp delete mode 100644 Generals/Code/Libraries/Source/WWVegas/WW3D2/prim_anim.h delete mode 100644 Generals/Code/Libraries/Source/WWVegas/WW3D2/projector.cpp delete mode 100644 Generals/Code/Libraries/Source/WWVegas/WW3D2/projector.h delete mode 100644 Generals/Code/Libraries/Source/WWVegas/WW3D2/proto.cpp delete mode 100644 Generals/Code/Libraries/Source/WWVegas/WW3D2/proto.h delete mode 100644 Generals/Code/Libraries/Source/WWVegas/WW3D2/proxy.h delete mode 100644 Generals/Code/Libraries/Source/WWVegas/WW3D2/rddesc.h delete mode 100644 Generals/Code/Libraries/Source/WWVegas/WW3D2/render2dsentence.cpp delete mode 100644 Generals/Code/Libraries/Source/WWVegas/WW3D2/render2dsentence.h delete mode 100644 Generals/Code/Libraries/Source/WWVegas/WW3D2/renderobjectrecycler.cpp delete mode 100644 Generals/Code/Libraries/Source/WWVegas/WW3D2/renderobjectrecycler.h delete mode 100644 Generals/Code/Libraries/Source/WWVegas/WW3D2/rendobj.cpp delete mode 100644 Generals/Code/Libraries/Source/WWVegas/WW3D2/rendobj.h delete mode 100644 Generals/Code/Libraries/Source/WWVegas/WW3D2/ringobj.cpp delete mode 100644 Generals/Code/Libraries/Source/WWVegas/WW3D2/ringobj.h delete mode 100644 Generals/Code/Libraries/Source/WWVegas/WW3D2/robjlist.h delete mode 100644 Generals/Code/Libraries/Source/WWVegas/WW3D2/segline.cpp delete mode 100644 Generals/Code/Libraries/Source/WWVegas/WW3D2/segline.h delete mode 100644 Generals/Code/Libraries/Source/WWVegas/WW3D2/seglinerenderer.cpp delete mode 100644 Generals/Code/Libraries/Source/WWVegas/WW3D2/seglinerenderer.h delete mode 100644 Generals/Code/Libraries/Source/WWVegas/WW3D2/shattersystem.cpp delete mode 100644 Generals/Code/Libraries/Source/WWVegas/WW3D2/shattersystem.h delete mode 100644 Generals/Code/Libraries/Source/WWVegas/WW3D2/snapPts.h delete mode 100644 Generals/Code/Libraries/Source/WWVegas/WW3D2/snappts.cpp delete mode 100644 Generals/Code/Libraries/Source/WWVegas/WW3D2/soundlibrarybridge.h delete mode 100644 Generals/Code/Libraries/Source/WWVegas/WW3D2/soundrobj.cpp delete mode 100644 Generals/Code/Libraries/Source/WWVegas/WW3D2/soundrobj.h delete mode 100644 Generals/Code/Libraries/Source/WWVegas/WW3D2/sphereobj.cpp delete mode 100644 Generals/Code/Libraries/Source/WWVegas/WW3D2/sphereobj.h delete mode 100644 Generals/Code/Libraries/Source/WWVegas/WW3D2/static_sort_list.cpp delete mode 100644 Generals/Code/Libraries/Source/WWVegas/WW3D2/static_sort_list.h delete mode 100644 Generals/Code/Libraries/Source/WWVegas/WW3D2/statistics.cpp delete mode 100644 Generals/Code/Libraries/Source/WWVegas/WW3D2/statistics.h delete mode 100644 Generals/Code/Libraries/Source/WWVegas/WW3D2/streak.cpp delete mode 100644 Generals/Code/Libraries/Source/WWVegas/WW3D2/streak.h delete mode 100644 Generals/Code/Libraries/Source/WWVegas/WW3D2/streakRender.cpp delete mode 100644 Generals/Code/Libraries/Source/WWVegas/WW3D2/streakRender.h delete mode 100644 Generals/Code/Libraries/Source/WWVegas/WW3D2/stripoptimizer.cpp delete mode 100644 Generals/Code/Libraries/Source/WWVegas/WW3D2/stripoptimizer.h delete mode 100644 Generals/Code/Libraries/Source/WWVegas/WW3D2/surfaceclass.cpp delete mode 100644 Generals/Code/Libraries/Source/WWVegas/WW3D2/surfaceclass.h delete mode 100644 Generals/Code/Libraries/Source/WWVegas/WW3D2/textdraw.cpp delete mode 100644 Generals/Code/Libraries/Source/WWVegas/WW3D2/textdraw.h delete mode 100644 Generals/Code/Libraries/Source/WWVegas/WW3D2/visrasterizer.cpp delete mode 100644 Generals/Code/Libraries/Source/WWVegas/WW3D2/visrasterizer.h delete mode 100644 Generals/Code/Libraries/Source/WWVegas/WW3D2/w3d_dep.cpp delete mode 100644 Generals/Code/Libraries/Source/WWVegas/WW3D2/w3d_dep.h delete mode 100644 Generals/Code/Libraries/Source/WWVegas/WW3D2/w3d_obsolete.h delete mode 100644 Generals/Code/Libraries/Source/WWVegas/WW3D2/w3d_util.cpp delete mode 100644 Generals/Code/Libraries/Source/WWVegas/WW3D2/w3d_util.h delete mode 100644 Generals/Code/Libraries/Source/WWVegas/WW3D2/w3derr.h delete mode 100644 Generals/Code/Libraries/Source/WWVegas/WW3D2/w3dexclusionlist.cpp delete mode 100644 Generals/Code/Libraries/Source/WWVegas/WW3D2/w3dexclusionlist.h delete mode 100644 Generals/Code/Libraries/Source/WWVegas/WW3D2/ww3dformat.cpp delete mode 100644 Generals/Code/Libraries/Source/WWVegas/WW3D2/ww3dformat.h delete mode 100644 Generals/Code/Libraries/Source/WWVegas/WW3D2/ww3dids.h delete mode 100644 Generals/Code/Libraries/Source/WWVegas/WW3D2/ww3dtrig.h delete mode 100644 GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/DX8 Rationalizations.txt delete mode 100644 GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/DX8 Status.txt delete mode 100644 GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/DX8ToolModifications.txt delete mode 100644 GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/MAPPERS.TXT delete mode 100644 GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/RenderObjectGuide.txt delete mode 100644 GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/RequiredAssets/AddProjectorGradient.tga delete mode 100644 GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/RequiredAssets/Dazzle.INI delete mode 100644 GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/RequiredAssets/MultProjectorGradient.tga delete mode 100644 GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/RequiredAssets/ShatterAVel.tbl delete mode 100644 GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/RequiredAssets/ShatterPlanes0.w3d delete mode 100644 GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/RequiredAssets/ShatterVel.tbl delete mode 100644 GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/RequiredAssets/w3d_missing_texture.tga delete mode 100644 GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/State Management.txt delete mode 100644 GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/assetstatus.cpp delete mode 100644 GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/assetstatus.h diff --git a/Core/Libraries/Source/WWVegas/CMakeLists.txt b/Core/Libraries/Source/WWVegas/CMakeLists.txt index 60e58baa6ca..6c1a97bc6d9 100644 --- a/Core/Libraries/Source/WWVegas/CMakeLists.txt +++ b/Core/Libraries/Source/WWVegas/CMakeLists.txt @@ -16,7 +16,7 @@ target_link_libraries(core_wwcommon INTERFACE target_include_directories(core_wwcommon INTERFACE ${CMAKE_CURRENT_SOURCE_DIR} - # WW3D2 + WW3D2 WWAudio WWDebug # WWDownload # is not added because headers are included as "WWDownload/file.h" @@ -25,7 +25,7 @@ target_include_directories(core_wwcommon INTERFACE WWSaveLoad ) -# add_subdirectory(WW3D2) +add_subdirectory(WW3D2) add_subdirectory(WWAudio) add_subdirectory(WWDebug) add_subdirectory(WWDownload) @@ -39,7 +39,7 @@ add_library(core_wwvegas INTERFACE) target_include_directories(core_wwvegas INTERFACE ${CMAKE_CURRENT_SOURCE_DIR} - #WW3D2 + WW3D2 WWAudio WWDebug # WWDownload # is not added because headers are included as "WWDownload/file.h" diff --git a/Core/Libraries/Source/WWVegas/WW3D2/CMakeLists.txt b/Core/Libraries/Source/WWVegas/WW3D2/CMakeLists.txt new file mode 100644 index 00000000000..628746e29f8 --- /dev/null +++ b/Core/Libraries/Source/WWVegas/WW3D2/CMakeLists.txt @@ -0,0 +1,248 @@ +set(WW3D2_SRC + aabtree.cpp + aabtree.h + #aabtreebuilder.cpp + #aabtreebuilder.h + agg_def.cpp + agg_def.h + animatedsoundmgr.cpp + animatedsoundmgr.h + #animobj.cpp + #animobj.h + #assetmgr.cpp + #assetmgr.h + assetstatus.cpp + assetstatus.h + bitmaphandler.cpp + bitmaphandler.h + #bmp2d.cpp + #bmp2d.h + #boxrobj.cpp + #boxrobj.h + bwrender.cpp + bwrender.h + #camera.cpp + #camera.h + #classid.h # unused + collect.cpp + collect.h + colorspace.h + coltest.cpp + coltest.h + coltype.h + composite.cpp + composite.h + #dazzle.cpp + #dazzle.h + #ddsfile.cpp + #ddsfile.h + #decalmsh.cpp + #decalmsh.h + decalsys.cpp + decalsys.h + distlod.cpp + distlod.h + dllist.h + #dx8caps.cpp + #dx8caps.h + #dx8fvf.cpp + #dx8fvf.h + #dx8indexbuffer.cpp + #dx8indexbuffer.h + dx8list.h + dx8polygonrenderer.cpp + dx8polygonrenderer.h + #dx8renderer.cpp + #dx8renderer.h + #dx8rendererdebugger.cpp + #dx8rendererdebugger.h + #dx8texman.cpp + #dx8texman.h + #dx8vertexbuffer.cpp + #dx8vertexbuffer.h + dx8webbrowser.cpp + dx8webbrowser.h + #dx8wrapper.cpp + #dx8wrapper.h + dynamesh.cpp + dynamesh.h + font3d.cpp + font3d.h + formconv.cpp + formconv.h + FramGrab.cpp + framgrab.h + hanim.cpp + hanim.h + #hanimmgr.cpp + #hanimmgr.h + hcanim.cpp + hcanim.h + #hlod.cpp + #hlod.h + hmdldef.cpp + hmdldef.H + #hmorphanim.cpp + #hmorphanim.h + #hrawanim.cpp + #hrawanim.h + htree.cpp + htree.h + #htreemgr.cpp + #htreemgr.h + intersec.cpp + intersec.h + intersec.inl + inttest.h + layer.cpp + layer.h + #light.cpp + #light.h + #lightenvironment.cpp + #lightenvironment.h + line3d.cpp + line3d.h + #linegrp.cpp + #linegrp.h + #mapper.cpp + #mapper.h + matinfo.cpp + matinfo.h + #matpass.cpp + #matpass.h + #matrixmapper.cpp + #matrixmapper.h + #mesh.cpp + #mesh.h + #meshbuild.cpp + #meshbuild.h + meshdam.cpp + meshdam.h + #meshgeometry.cpp + #meshgeometry.h + #meshmatdesc.cpp + #meshmatdesc.h + #meshmdl.cpp + #meshmdl.h + #meshmdlio.cpp + metalmap.cpp + metalmap.h + missingtexture.cpp + missingtexture.h + #motchan.cpp + #motchan.h + #nullrobj.cpp + #nullrobj.h + #part_buf.cpp + #part_buf.h + #part_emt.cpp + #part_emt.h + #part_ldr.cpp + #part_ldr.h + pivot.cpp + pivot.h + pointgr.cpp + pointgr.h + polyinfo.cpp + polyinfo.h + predlod.cpp + predlod.h + prim_anim.cpp + prim_anim.h + projector.cpp + projector.h + proto.cpp + proto.h + proxy.h + rddesc.h + #render2d.cpp + #render2d.h + render2dsentence.cpp + render2dsentence.h + renderobjectrecycler.cpp + renderobjectrecycler.h + rendobj.cpp + rendobj.h + #rinfo.cpp + #rinfo.h + ringobj.cpp + ringobj.h + robjlist.h + #scene.cpp + #scene.h + segline.cpp + segline.h + seglinerenderer.cpp + seglinerenderer.h + #shader.cpp + #shader.h + shattersystem.cpp + shattersystem.h + #shdlib.h + snappts.cpp + snapPts.h + #sortingrenderer.cpp + #sortingrenderer.h + soundlibrarybridge.h + soundrobj.cpp + soundrobj.h + sphereobj.cpp + sphereobj.h + static_sort_list.cpp + static_sort_list.h + statistics.cpp + statistics.h + streak.cpp + streak.h + streakRender.cpp + streakRender.h + stripoptimizer.cpp + stripoptimizer.h + surfaceclass.cpp + surfaceclass.h + #texproject.cpp + #texproject.h + #textdraw.cpp # unused + textdraw.h + #texture.cpp + #texture.h + #texturefilter.cpp + #texturefilter.h + #textureloader.cpp + #textureloader.h + #texturethumbnail.cpp + #texturethumbnail.h + #vertmaterial.cpp + #vertmaterial.h + visrasterizer.cpp + visrasterizer.h + w3d_dep.cpp + w3d_dep.h + #w3d_file.h + w3d_obsolete.h + w3d_util.cpp + w3d_util.h + w3derr.h + w3dexclusionlist.cpp + w3dexclusionlist.h + #ww3d.cpp + #ww3d.h + ww3dformat.cpp + ww3dformat.h + ww3dids.h + ww3dtrig.h +) + +add_library(corei_ww3d2 INTERFACE) + +target_sources(corei_ww3d2 INTERFACE ${WW3D2_SRC}) + +if (NOT IS_VS6_BUILD) + target_link_libraries(corei_ww3d2 INTERFACE + comsuppw + ) +endif() + +target_link_libraries(corei_ww3d2 INTERFACE + core_browserengine +) diff --git a/Generals/Code/Libraries/Source/WWVegas/WW3D2/DX8 Rationalizations.txt b/Core/Libraries/Source/WWVegas/WW3D2/DX8 Rationalizations.txt similarity index 100% rename from Generals/Code/Libraries/Source/WWVegas/WW3D2/DX8 Rationalizations.txt rename to Core/Libraries/Source/WWVegas/WW3D2/DX8 Rationalizations.txt diff --git a/Generals/Code/Libraries/Source/WWVegas/WW3D2/DX8 Status.txt b/Core/Libraries/Source/WWVegas/WW3D2/DX8 Status.txt similarity index 100% rename from Generals/Code/Libraries/Source/WWVegas/WW3D2/DX8 Status.txt rename to Core/Libraries/Source/WWVegas/WW3D2/DX8 Status.txt diff --git a/Generals/Code/Libraries/Source/WWVegas/WW3D2/DX8ToolModifications.txt b/Core/Libraries/Source/WWVegas/WW3D2/DX8ToolModifications.txt similarity index 100% rename from Generals/Code/Libraries/Source/WWVegas/WW3D2/DX8ToolModifications.txt rename to Core/Libraries/Source/WWVegas/WW3D2/DX8ToolModifications.txt diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/FramGrab.cpp b/Core/Libraries/Source/WWVegas/WW3D2/FramGrab.cpp similarity index 100% rename from GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/FramGrab.cpp rename to Core/Libraries/Source/WWVegas/WW3D2/FramGrab.cpp diff --git a/Generals/Code/Libraries/Source/WWVegas/WW3D2/MAPPERS.TXT b/Core/Libraries/Source/WWVegas/WW3D2/MAPPERS.TXT similarity index 100% rename from Generals/Code/Libraries/Source/WWVegas/WW3D2/MAPPERS.TXT rename to Core/Libraries/Source/WWVegas/WW3D2/MAPPERS.TXT diff --git a/Generals/Code/Libraries/Source/WWVegas/WW3D2/RenderObjectGuide.txt b/Core/Libraries/Source/WWVegas/WW3D2/RenderObjectGuide.txt similarity index 100% rename from Generals/Code/Libraries/Source/WWVegas/WW3D2/RenderObjectGuide.txt rename to Core/Libraries/Source/WWVegas/WW3D2/RenderObjectGuide.txt diff --git a/Generals/Code/Libraries/Source/WWVegas/WW3D2/RequiredAssets/AddProjectorGradient.tga b/Core/Libraries/Source/WWVegas/WW3D2/RequiredAssets/AddProjectorGradient.tga similarity index 100% rename from Generals/Code/Libraries/Source/WWVegas/WW3D2/RequiredAssets/AddProjectorGradient.tga rename to Core/Libraries/Source/WWVegas/WW3D2/RequiredAssets/AddProjectorGradient.tga diff --git a/Generals/Code/Libraries/Source/WWVegas/WW3D2/RequiredAssets/Dazzle.INI b/Core/Libraries/Source/WWVegas/WW3D2/RequiredAssets/Dazzle.INI similarity index 100% rename from Generals/Code/Libraries/Source/WWVegas/WW3D2/RequiredAssets/Dazzle.INI rename to Core/Libraries/Source/WWVegas/WW3D2/RequiredAssets/Dazzle.INI diff --git a/Generals/Code/Libraries/Source/WWVegas/WW3D2/RequiredAssets/MultProjectorGradient.tga b/Core/Libraries/Source/WWVegas/WW3D2/RequiredAssets/MultProjectorGradient.tga similarity index 100% rename from Generals/Code/Libraries/Source/WWVegas/WW3D2/RequiredAssets/MultProjectorGradient.tga rename to Core/Libraries/Source/WWVegas/WW3D2/RequiredAssets/MultProjectorGradient.tga diff --git a/Generals/Code/Libraries/Source/WWVegas/WW3D2/RequiredAssets/ShatterAVel.tbl b/Core/Libraries/Source/WWVegas/WW3D2/RequiredAssets/ShatterAVel.tbl similarity index 100% rename from Generals/Code/Libraries/Source/WWVegas/WW3D2/RequiredAssets/ShatterAVel.tbl rename to Core/Libraries/Source/WWVegas/WW3D2/RequiredAssets/ShatterAVel.tbl diff --git a/Generals/Code/Libraries/Source/WWVegas/WW3D2/RequiredAssets/ShatterPlanes0.w3d b/Core/Libraries/Source/WWVegas/WW3D2/RequiredAssets/ShatterPlanes0.w3d similarity index 100% rename from Generals/Code/Libraries/Source/WWVegas/WW3D2/RequiredAssets/ShatterPlanes0.w3d rename to Core/Libraries/Source/WWVegas/WW3D2/RequiredAssets/ShatterPlanes0.w3d diff --git a/Generals/Code/Libraries/Source/WWVegas/WW3D2/RequiredAssets/ShatterVel.tbl b/Core/Libraries/Source/WWVegas/WW3D2/RequiredAssets/ShatterVel.tbl similarity index 100% rename from Generals/Code/Libraries/Source/WWVegas/WW3D2/RequiredAssets/ShatterVel.tbl rename to Core/Libraries/Source/WWVegas/WW3D2/RequiredAssets/ShatterVel.tbl diff --git a/Generals/Code/Libraries/Source/WWVegas/WW3D2/RequiredAssets/w3d_missing_texture.tga b/Core/Libraries/Source/WWVegas/WW3D2/RequiredAssets/w3d_missing_texture.tga similarity index 100% rename from Generals/Code/Libraries/Source/WWVegas/WW3D2/RequiredAssets/w3d_missing_texture.tga rename to Core/Libraries/Source/WWVegas/WW3D2/RequiredAssets/w3d_missing_texture.tga diff --git a/Generals/Code/Libraries/Source/WWVegas/WW3D2/State Management.txt b/Core/Libraries/Source/WWVegas/WW3D2/State Management.txt similarity index 100% rename from Generals/Code/Libraries/Source/WWVegas/WW3D2/State Management.txt rename to Core/Libraries/Source/WWVegas/WW3D2/State Management.txt diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/aabtree.cpp b/Core/Libraries/Source/WWVegas/WW3D2/aabtree.cpp similarity index 100% rename from GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/aabtree.cpp rename to Core/Libraries/Source/WWVegas/WW3D2/aabtree.cpp diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/aabtree.h b/Core/Libraries/Source/WWVegas/WW3D2/aabtree.h similarity index 100% rename from GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/aabtree.h rename to Core/Libraries/Source/WWVegas/WW3D2/aabtree.h diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/agg_def.cpp b/Core/Libraries/Source/WWVegas/WW3D2/agg_def.cpp similarity index 100% rename from GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/agg_def.cpp rename to Core/Libraries/Source/WWVegas/WW3D2/agg_def.cpp diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/agg_def.h b/Core/Libraries/Source/WWVegas/WW3D2/agg_def.h similarity index 100% rename from GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/agg_def.h rename to Core/Libraries/Source/WWVegas/WW3D2/agg_def.h diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/animatedsoundmgr.cpp b/Core/Libraries/Source/WWVegas/WW3D2/animatedsoundmgr.cpp similarity index 100% rename from GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/animatedsoundmgr.cpp rename to Core/Libraries/Source/WWVegas/WW3D2/animatedsoundmgr.cpp diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/animatedsoundmgr.h b/Core/Libraries/Source/WWVegas/WW3D2/animatedsoundmgr.h similarity index 100% rename from GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/animatedsoundmgr.h rename to Core/Libraries/Source/WWVegas/WW3D2/animatedsoundmgr.h diff --git a/Generals/Code/Libraries/Source/WWVegas/WW3D2/assetstatus.cpp b/Core/Libraries/Source/WWVegas/WW3D2/assetstatus.cpp similarity index 100% rename from Generals/Code/Libraries/Source/WWVegas/WW3D2/assetstatus.cpp rename to Core/Libraries/Source/WWVegas/WW3D2/assetstatus.cpp diff --git a/Generals/Code/Libraries/Source/WWVegas/WW3D2/assetstatus.h b/Core/Libraries/Source/WWVegas/WW3D2/assetstatus.h similarity index 100% rename from Generals/Code/Libraries/Source/WWVegas/WW3D2/assetstatus.h rename to Core/Libraries/Source/WWVegas/WW3D2/assetstatus.h diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/bitmaphandler.cpp b/Core/Libraries/Source/WWVegas/WW3D2/bitmaphandler.cpp similarity index 100% rename from GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/bitmaphandler.cpp rename to Core/Libraries/Source/WWVegas/WW3D2/bitmaphandler.cpp diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/bitmaphandler.h b/Core/Libraries/Source/WWVegas/WW3D2/bitmaphandler.h similarity index 100% rename from GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/bitmaphandler.h rename to Core/Libraries/Source/WWVegas/WW3D2/bitmaphandler.h diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/bwrender.cpp b/Core/Libraries/Source/WWVegas/WW3D2/bwrender.cpp similarity index 100% rename from GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/bwrender.cpp rename to Core/Libraries/Source/WWVegas/WW3D2/bwrender.cpp diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/bwrender.h b/Core/Libraries/Source/WWVegas/WW3D2/bwrender.h similarity index 100% rename from GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/bwrender.h rename to Core/Libraries/Source/WWVegas/WW3D2/bwrender.h diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/classid.h b/Core/Libraries/Source/WWVegas/WW3D2/classid.h similarity index 100% rename from GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/classid.h rename to Core/Libraries/Source/WWVegas/WW3D2/classid.h diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/collect.cpp b/Core/Libraries/Source/WWVegas/WW3D2/collect.cpp similarity index 100% rename from GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/collect.cpp rename to Core/Libraries/Source/WWVegas/WW3D2/collect.cpp diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/collect.h b/Core/Libraries/Source/WWVegas/WW3D2/collect.h similarity index 100% rename from GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/collect.h rename to Core/Libraries/Source/WWVegas/WW3D2/collect.h diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/colorspace.h b/Core/Libraries/Source/WWVegas/WW3D2/colorspace.h similarity index 100% rename from GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/colorspace.h rename to Core/Libraries/Source/WWVegas/WW3D2/colorspace.h diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/coltest.cpp b/Core/Libraries/Source/WWVegas/WW3D2/coltest.cpp similarity index 100% rename from GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/coltest.cpp rename to Core/Libraries/Source/WWVegas/WW3D2/coltest.cpp diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/coltest.h b/Core/Libraries/Source/WWVegas/WW3D2/coltest.h similarity index 100% rename from GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/coltest.h rename to Core/Libraries/Source/WWVegas/WW3D2/coltest.h diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/coltype.h b/Core/Libraries/Source/WWVegas/WW3D2/coltype.h similarity index 100% rename from GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/coltype.h rename to Core/Libraries/Source/WWVegas/WW3D2/coltype.h diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/composite.cpp b/Core/Libraries/Source/WWVegas/WW3D2/composite.cpp similarity index 100% rename from GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/composite.cpp rename to Core/Libraries/Source/WWVegas/WW3D2/composite.cpp diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/composite.h b/Core/Libraries/Source/WWVegas/WW3D2/composite.h similarity index 100% rename from GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/composite.h rename to Core/Libraries/Source/WWVegas/WW3D2/composite.h diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/decalsys.cpp b/Core/Libraries/Source/WWVegas/WW3D2/decalsys.cpp similarity index 100% rename from GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/decalsys.cpp rename to Core/Libraries/Source/WWVegas/WW3D2/decalsys.cpp diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/decalsys.h b/Core/Libraries/Source/WWVegas/WW3D2/decalsys.h similarity index 100% rename from GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/decalsys.h rename to Core/Libraries/Source/WWVegas/WW3D2/decalsys.h diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/distlod.cpp b/Core/Libraries/Source/WWVegas/WW3D2/distlod.cpp similarity index 100% rename from GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/distlod.cpp rename to Core/Libraries/Source/WWVegas/WW3D2/distlod.cpp diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/distlod.h b/Core/Libraries/Source/WWVegas/WW3D2/distlod.h similarity index 100% rename from GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/distlod.h rename to Core/Libraries/Source/WWVegas/WW3D2/distlod.h diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dllist.h b/Core/Libraries/Source/WWVegas/WW3D2/dllist.h similarity index 100% rename from GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dllist.h rename to Core/Libraries/Source/WWVegas/WW3D2/dllist.h diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dx8list.h b/Core/Libraries/Source/WWVegas/WW3D2/dx8list.h similarity index 100% rename from GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dx8list.h rename to Core/Libraries/Source/WWVegas/WW3D2/dx8list.h diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dx8polygonrenderer.cpp b/Core/Libraries/Source/WWVegas/WW3D2/dx8polygonrenderer.cpp similarity index 100% rename from GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dx8polygonrenderer.cpp rename to Core/Libraries/Source/WWVegas/WW3D2/dx8polygonrenderer.cpp diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dx8polygonrenderer.h b/Core/Libraries/Source/WWVegas/WW3D2/dx8polygonrenderer.h similarity index 100% rename from GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dx8polygonrenderer.h rename to Core/Libraries/Source/WWVegas/WW3D2/dx8polygonrenderer.h diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dx8webbrowser.cpp b/Core/Libraries/Source/WWVegas/WW3D2/dx8webbrowser.cpp similarity index 100% rename from GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dx8webbrowser.cpp rename to Core/Libraries/Source/WWVegas/WW3D2/dx8webbrowser.cpp diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dx8webbrowser.h b/Core/Libraries/Source/WWVegas/WW3D2/dx8webbrowser.h similarity index 100% rename from GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dx8webbrowser.h rename to Core/Libraries/Source/WWVegas/WW3D2/dx8webbrowser.h diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dynamesh.cpp b/Core/Libraries/Source/WWVegas/WW3D2/dynamesh.cpp similarity index 100% rename from GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dynamesh.cpp rename to Core/Libraries/Source/WWVegas/WW3D2/dynamesh.cpp diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dynamesh.h b/Core/Libraries/Source/WWVegas/WW3D2/dynamesh.h similarity index 100% rename from GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dynamesh.h rename to Core/Libraries/Source/WWVegas/WW3D2/dynamesh.h diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/font3d.cpp b/Core/Libraries/Source/WWVegas/WW3D2/font3d.cpp similarity index 100% rename from GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/font3d.cpp rename to Core/Libraries/Source/WWVegas/WW3D2/font3d.cpp diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/font3d.h b/Core/Libraries/Source/WWVegas/WW3D2/font3d.h similarity index 100% rename from GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/font3d.h rename to Core/Libraries/Source/WWVegas/WW3D2/font3d.h diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/formconv.cpp b/Core/Libraries/Source/WWVegas/WW3D2/formconv.cpp similarity index 100% rename from GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/formconv.cpp rename to Core/Libraries/Source/WWVegas/WW3D2/formconv.cpp diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/formconv.h b/Core/Libraries/Source/WWVegas/WW3D2/formconv.h similarity index 100% rename from GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/formconv.h rename to Core/Libraries/Source/WWVegas/WW3D2/formconv.h diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/framgrab.h b/Core/Libraries/Source/WWVegas/WW3D2/framgrab.h similarity index 100% rename from GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/framgrab.h rename to Core/Libraries/Source/WWVegas/WW3D2/framgrab.h diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/hanim.cpp b/Core/Libraries/Source/WWVegas/WW3D2/hanim.cpp similarity index 100% rename from GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/hanim.cpp rename to Core/Libraries/Source/WWVegas/WW3D2/hanim.cpp diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/hanim.h b/Core/Libraries/Source/WWVegas/WW3D2/hanim.h similarity index 100% rename from GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/hanim.h rename to Core/Libraries/Source/WWVegas/WW3D2/hanim.h diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/hcanim.cpp b/Core/Libraries/Source/WWVegas/WW3D2/hcanim.cpp similarity index 100% rename from GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/hcanim.cpp rename to Core/Libraries/Source/WWVegas/WW3D2/hcanim.cpp diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/hcanim.h b/Core/Libraries/Source/WWVegas/WW3D2/hcanim.h similarity index 100% rename from GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/hcanim.h rename to Core/Libraries/Source/WWVegas/WW3D2/hcanim.h diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/hmdldef.H b/Core/Libraries/Source/WWVegas/WW3D2/hmdldef.H similarity index 100% rename from GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/hmdldef.H rename to Core/Libraries/Source/WWVegas/WW3D2/hmdldef.H diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/hmdldef.cpp b/Core/Libraries/Source/WWVegas/WW3D2/hmdldef.cpp similarity index 100% rename from GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/hmdldef.cpp rename to Core/Libraries/Source/WWVegas/WW3D2/hmdldef.cpp diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/htree.cpp b/Core/Libraries/Source/WWVegas/WW3D2/htree.cpp similarity index 100% rename from GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/htree.cpp rename to Core/Libraries/Source/WWVegas/WW3D2/htree.cpp diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/htree.h b/Core/Libraries/Source/WWVegas/WW3D2/htree.h similarity index 100% rename from GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/htree.h rename to Core/Libraries/Source/WWVegas/WW3D2/htree.h diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/intersec.cpp b/Core/Libraries/Source/WWVegas/WW3D2/intersec.cpp similarity index 100% rename from GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/intersec.cpp rename to Core/Libraries/Source/WWVegas/WW3D2/intersec.cpp diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/intersec.h b/Core/Libraries/Source/WWVegas/WW3D2/intersec.h similarity index 100% rename from GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/intersec.h rename to Core/Libraries/Source/WWVegas/WW3D2/intersec.h diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/intersec.inl b/Core/Libraries/Source/WWVegas/WW3D2/intersec.inl similarity index 100% rename from GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/intersec.inl rename to Core/Libraries/Source/WWVegas/WW3D2/intersec.inl diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/inttest.h b/Core/Libraries/Source/WWVegas/WW3D2/inttest.h similarity index 100% rename from GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/inttest.h rename to Core/Libraries/Source/WWVegas/WW3D2/inttest.h diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/layer.cpp b/Core/Libraries/Source/WWVegas/WW3D2/layer.cpp similarity index 100% rename from GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/layer.cpp rename to Core/Libraries/Source/WWVegas/WW3D2/layer.cpp diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/layer.h b/Core/Libraries/Source/WWVegas/WW3D2/layer.h similarity index 100% rename from GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/layer.h rename to Core/Libraries/Source/WWVegas/WW3D2/layer.h diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/line3d.cpp b/Core/Libraries/Source/WWVegas/WW3D2/line3d.cpp similarity index 100% rename from GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/line3d.cpp rename to Core/Libraries/Source/WWVegas/WW3D2/line3d.cpp diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/line3d.h b/Core/Libraries/Source/WWVegas/WW3D2/line3d.h similarity index 100% rename from GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/line3d.h rename to Core/Libraries/Source/WWVegas/WW3D2/line3d.h diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/matinfo.cpp b/Core/Libraries/Source/WWVegas/WW3D2/matinfo.cpp similarity index 100% rename from GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/matinfo.cpp rename to Core/Libraries/Source/WWVegas/WW3D2/matinfo.cpp diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/matinfo.h b/Core/Libraries/Source/WWVegas/WW3D2/matinfo.h similarity index 100% rename from GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/matinfo.h rename to Core/Libraries/Source/WWVegas/WW3D2/matinfo.h diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/meshdam.cpp b/Core/Libraries/Source/WWVegas/WW3D2/meshdam.cpp similarity index 100% rename from GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/meshdam.cpp rename to Core/Libraries/Source/WWVegas/WW3D2/meshdam.cpp diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/meshdam.h b/Core/Libraries/Source/WWVegas/WW3D2/meshdam.h similarity index 100% rename from GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/meshdam.h rename to Core/Libraries/Source/WWVegas/WW3D2/meshdam.h diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/metalmap.cpp b/Core/Libraries/Source/WWVegas/WW3D2/metalmap.cpp similarity index 100% rename from GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/metalmap.cpp rename to Core/Libraries/Source/WWVegas/WW3D2/metalmap.cpp diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/metalmap.h b/Core/Libraries/Source/WWVegas/WW3D2/metalmap.h similarity index 100% rename from GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/metalmap.h rename to Core/Libraries/Source/WWVegas/WW3D2/metalmap.h diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/missingtexture.cpp b/Core/Libraries/Source/WWVegas/WW3D2/missingtexture.cpp similarity index 100% rename from GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/missingtexture.cpp rename to Core/Libraries/Source/WWVegas/WW3D2/missingtexture.cpp diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/missingtexture.h b/Core/Libraries/Source/WWVegas/WW3D2/missingtexture.h similarity index 100% rename from GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/missingtexture.h rename to Core/Libraries/Source/WWVegas/WW3D2/missingtexture.h diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/pivot.cpp b/Core/Libraries/Source/WWVegas/WW3D2/pivot.cpp similarity index 100% rename from GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/pivot.cpp rename to Core/Libraries/Source/WWVegas/WW3D2/pivot.cpp diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/pivot.h b/Core/Libraries/Source/WWVegas/WW3D2/pivot.h similarity index 100% rename from GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/pivot.h rename to Core/Libraries/Source/WWVegas/WW3D2/pivot.h diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/pointgr.cpp b/Core/Libraries/Source/WWVegas/WW3D2/pointgr.cpp similarity index 100% rename from GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/pointgr.cpp rename to Core/Libraries/Source/WWVegas/WW3D2/pointgr.cpp diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/pointgr.h b/Core/Libraries/Source/WWVegas/WW3D2/pointgr.h similarity index 100% rename from GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/pointgr.h rename to Core/Libraries/Source/WWVegas/WW3D2/pointgr.h diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/polyinfo.cpp b/Core/Libraries/Source/WWVegas/WW3D2/polyinfo.cpp similarity index 100% rename from GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/polyinfo.cpp rename to Core/Libraries/Source/WWVegas/WW3D2/polyinfo.cpp diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/polyinfo.h b/Core/Libraries/Source/WWVegas/WW3D2/polyinfo.h similarity index 100% rename from GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/polyinfo.h rename to Core/Libraries/Source/WWVegas/WW3D2/polyinfo.h diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/predlod.cpp b/Core/Libraries/Source/WWVegas/WW3D2/predlod.cpp similarity index 100% rename from GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/predlod.cpp rename to Core/Libraries/Source/WWVegas/WW3D2/predlod.cpp diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/predlod.h b/Core/Libraries/Source/WWVegas/WW3D2/predlod.h similarity index 100% rename from GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/predlod.h rename to Core/Libraries/Source/WWVegas/WW3D2/predlod.h diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/prim_anim.cpp b/Core/Libraries/Source/WWVegas/WW3D2/prim_anim.cpp similarity index 100% rename from GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/prim_anim.cpp rename to Core/Libraries/Source/WWVegas/WW3D2/prim_anim.cpp diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/prim_anim.h b/Core/Libraries/Source/WWVegas/WW3D2/prim_anim.h similarity index 100% rename from GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/prim_anim.h rename to Core/Libraries/Source/WWVegas/WW3D2/prim_anim.h diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/projector.cpp b/Core/Libraries/Source/WWVegas/WW3D2/projector.cpp similarity index 100% rename from GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/projector.cpp rename to Core/Libraries/Source/WWVegas/WW3D2/projector.cpp diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/projector.h b/Core/Libraries/Source/WWVegas/WW3D2/projector.h similarity index 100% rename from GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/projector.h rename to Core/Libraries/Source/WWVegas/WW3D2/projector.h diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/proto.cpp b/Core/Libraries/Source/WWVegas/WW3D2/proto.cpp similarity index 100% rename from GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/proto.cpp rename to Core/Libraries/Source/WWVegas/WW3D2/proto.cpp diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/proto.h b/Core/Libraries/Source/WWVegas/WW3D2/proto.h similarity index 100% rename from GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/proto.h rename to Core/Libraries/Source/WWVegas/WW3D2/proto.h diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/proxy.h b/Core/Libraries/Source/WWVegas/WW3D2/proxy.h similarity index 100% rename from GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/proxy.h rename to Core/Libraries/Source/WWVegas/WW3D2/proxy.h diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/rddesc.h b/Core/Libraries/Source/WWVegas/WW3D2/rddesc.h similarity index 100% rename from GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/rddesc.h rename to Core/Libraries/Source/WWVegas/WW3D2/rddesc.h diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/render2dsentence.cpp b/Core/Libraries/Source/WWVegas/WW3D2/render2dsentence.cpp similarity index 100% rename from GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/render2dsentence.cpp rename to Core/Libraries/Source/WWVegas/WW3D2/render2dsentence.cpp diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/render2dsentence.h b/Core/Libraries/Source/WWVegas/WW3D2/render2dsentence.h similarity index 100% rename from GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/render2dsentence.h rename to Core/Libraries/Source/WWVegas/WW3D2/render2dsentence.h diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/renderobjectrecycler.cpp b/Core/Libraries/Source/WWVegas/WW3D2/renderobjectrecycler.cpp similarity index 100% rename from GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/renderobjectrecycler.cpp rename to Core/Libraries/Source/WWVegas/WW3D2/renderobjectrecycler.cpp diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/renderobjectrecycler.h b/Core/Libraries/Source/WWVegas/WW3D2/renderobjectrecycler.h similarity index 100% rename from GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/renderobjectrecycler.h rename to Core/Libraries/Source/WWVegas/WW3D2/renderobjectrecycler.h diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/rendobj.cpp b/Core/Libraries/Source/WWVegas/WW3D2/rendobj.cpp similarity index 100% rename from GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/rendobj.cpp rename to Core/Libraries/Source/WWVegas/WW3D2/rendobj.cpp diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/rendobj.h b/Core/Libraries/Source/WWVegas/WW3D2/rendobj.h similarity index 100% rename from GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/rendobj.h rename to Core/Libraries/Source/WWVegas/WW3D2/rendobj.h diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/ringobj.cpp b/Core/Libraries/Source/WWVegas/WW3D2/ringobj.cpp similarity index 100% rename from GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/ringobj.cpp rename to Core/Libraries/Source/WWVegas/WW3D2/ringobj.cpp diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/ringobj.h b/Core/Libraries/Source/WWVegas/WW3D2/ringobj.h similarity index 100% rename from GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/ringobj.h rename to Core/Libraries/Source/WWVegas/WW3D2/ringobj.h diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/robjlist.h b/Core/Libraries/Source/WWVegas/WW3D2/robjlist.h similarity index 100% rename from GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/robjlist.h rename to Core/Libraries/Source/WWVegas/WW3D2/robjlist.h diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/segline.cpp b/Core/Libraries/Source/WWVegas/WW3D2/segline.cpp similarity index 100% rename from GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/segline.cpp rename to Core/Libraries/Source/WWVegas/WW3D2/segline.cpp diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/segline.h b/Core/Libraries/Source/WWVegas/WW3D2/segline.h similarity index 100% rename from GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/segline.h rename to Core/Libraries/Source/WWVegas/WW3D2/segline.h diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/seglinerenderer.cpp b/Core/Libraries/Source/WWVegas/WW3D2/seglinerenderer.cpp similarity index 100% rename from GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/seglinerenderer.cpp rename to Core/Libraries/Source/WWVegas/WW3D2/seglinerenderer.cpp diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/seglinerenderer.h b/Core/Libraries/Source/WWVegas/WW3D2/seglinerenderer.h similarity index 100% rename from GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/seglinerenderer.h rename to Core/Libraries/Source/WWVegas/WW3D2/seglinerenderer.h diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/shattersystem.cpp b/Core/Libraries/Source/WWVegas/WW3D2/shattersystem.cpp similarity index 100% rename from GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/shattersystem.cpp rename to Core/Libraries/Source/WWVegas/WW3D2/shattersystem.cpp diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/shattersystem.h b/Core/Libraries/Source/WWVegas/WW3D2/shattersystem.h similarity index 100% rename from GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/shattersystem.h rename to Core/Libraries/Source/WWVegas/WW3D2/shattersystem.h diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/snapPts.h b/Core/Libraries/Source/WWVegas/WW3D2/snapPts.h similarity index 100% rename from GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/snapPts.h rename to Core/Libraries/Source/WWVegas/WW3D2/snapPts.h diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/snappts.cpp b/Core/Libraries/Source/WWVegas/WW3D2/snappts.cpp similarity index 100% rename from GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/snappts.cpp rename to Core/Libraries/Source/WWVegas/WW3D2/snappts.cpp diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/soundlibrarybridge.h b/Core/Libraries/Source/WWVegas/WW3D2/soundlibrarybridge.h similarity index 100% rename from GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/soundlibrarybridge.h rename to Core/Libraries/Source/WWVegas/WW3D2/soundlibrarybridge.h diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/soundrobj.cpp b/Core/Libraries/Source/WWVegas/WW3D2/soundrobj.cpp similarity index 100% rename from GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/soundrobj.cpp rename to Core/Libraries/Source/WWVegas/WW3D2/soundrobj.cpp diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/soundrobj.h b/Core/Libraries/Source/WWVegas/WW3D2/soundrobj.h similarity index 100% rename from GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/soundrobj.h rename to Core/Libraries/Source/WWVegas/WW3D2/soundrobj.h diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/sphereobj.cpp b/Core/Libraries/Source/WWVegas/WW3D2/sphereobj.cpp similarity index 100% rename from GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/sphereobj.cpp rename to Core/Libraries/Source/WWVegas/WW3D2/sphereobj.cpp diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/sphereobj.h b/Core/Libraries/Source/WWVegas/WW3D2/sphereobj.h similarity index 100% rename from GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/sphereobj.h rename to Core/Libraries/Source/WWVegas/WW3D2/sphereobj.h diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/static_sort_list.cpp b/Core/Libraries/Source/WWVegas/WW3D2/static_sort_list.cpp similarity index 100% rename from GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/static_sort_list.cpp rename to Core/Libraries/Source/WWVegas/WW3D2/static_sort_list.cpp diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/static_sort_list.h b/Core/Libraries/Source/WWVegas/WW3D2/static_sort_list.h similarity index 100% rename from GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/static_sort_list.h rename to Core/Libraries/Source/WWVegas/WW3D2/static_sort_list.h diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/statistics.cpp b/Core/Libraries/Source/WWVegas/WW3D2/statistics.cpp similarity index 100% rename from GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/statistics.cpp rename to Core/Libraries/Source/WWVegas/WW3D2/statistics.cpp diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/statistics.h b/Core/Libraries/Source/WWVegas/WW3D2/statistics.h similarity index 100% rename from GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/statistics.h rename to Core/Libraries/Source/WWVegas/WW3D2/statistics.h diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/streak.cpp b/Core/Libraries/Source/WWVegas/WW3D2/streak.cpp similarity index 100% rename from GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/streak.cpp rename to Core/Libraries/Source/WWVegas/WW3D2/streak.cpp diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/streak.h b/Core/Libraries/Source/WWVegas/WW3D2/streak.h similarity index 100% rename from GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/streak.h rename to Core/Libraries/Source/WWVegas/WW3D2/streak.h diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/streakRender.cpp b/Core/Libraries/Source/WWVegas/WW3D2/streakRender.cpp similarity index 100% rename from GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/streakRender.cpp rename to Core/Libraries/Source/WWVegas/WW3D2/streakRender.cpp diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/streakRender.h b/Core/Libraries/Source/WWVegas/WW3D2/streakRender.h similarity index 100% rename from GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/streakRender.h rename to Core/Libraries/Source/WWVegas/WW3D2/streakRender.h diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/stripoptimizer.cpp b/Core/Libraries/Source/WWVegas/WW3D2/stripoptimizer.cpp similarity index 100% rename from GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/stripoptimizer.cpp rename to Core/Libraries/Source/WWVegas/WW3D2/stripoptimizer.cpp diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/stripoptimizer.h b/Core/Libraries/Source/WWVegas/WW3D2/stripoptimizer.h similarity index 100% rename from GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/stripoptimizer.h rename to Core/Libraries/Source/WWVegas/WW3D2/stripoptimizer.h diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/surfaceclass.cpp b/Core/Libraries/Source/WWVegas/WW3D2/surfaceclass.cpp similarity index 100% rename from GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/surfaceclass.cpp rename to Core/Libraries/Source/WWVegas/WW3D2/surfaceclass.cpp diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/surfaceclass.h b/Core/Libraries/Source/WWVegas/WW3D2/surfaceclass.h similarity index 100% rename from GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/surfaceclass.h rename to Core/Libraries/Source/WWVegas/WW3D2/surfaceclass.h diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/textdraw.cpp b/Core/Libraries/Source/WWVegas/WW3D2/textdraw.cpp similarity index 100% rename from GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/textdraw.cpp rename to Core/Libraries/Source/WWVegas/WW3D2/textdraw.cpp diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/textdraw.h b/Core/Libraries/Source/WWVegas/WW3D2/textdraw.h similarity index 100% rename from GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/textdraw.h rename to Core/Libraries/Source/WWVegas/WW3D2/textdraw.h diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/visrasterizer.cpp b/Core/Libraries/Source/WWVegas/WW3D2/visrasterizer.cpp similarity index 100% rename from GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/visrasterizer.cpp rename to Core/Libraries/Source/WWVegas/WW3D2/visrasterizer.cpp diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/visrasterizer.h b/Core/Libraries/Source/WWVegas/WW3D2/visrasterizer.h similarity index 100% rename from GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/visrasterizer.h rename to Core/Libraries/Source/WWVegas/WW3D2/visrasterizer.h diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/w3d_dep.cpp b/Core/Libraries/Source/WWVegas/WW3D2/w3d_dep.cpp similarity index 100% rename from GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/w3d_dep.cpp rename to Core/Libraries/Source/WWVegas/WW3D2/w3d_dep.cpp diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/w3d_dep.h b/Core/Libraries/Source/WWVegas/WW3D2/w3d_dep.h similarity index 100% rename from GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/w3d_dep.h rename to Core/Libraries/Source/WWVegas/WW3D2/w3d_dep.h diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/w3d_obsolete.h b/Core/Libraries/Source/WWVegas/WW3D2/w3d_obsolete.h similarity index 100% rename from GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/w3d_obsolete.h rename to Core/Libraries/Source/WWVegas/WW3D2/w3d_obsolete.h diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/w3d_util.cpp b/Core/Libraries/Source/WWVegas/WW3D2/w3d_util.cpp similarity index 100% rename from GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/w3d_util.cpp rename to Core/Libraries/Source/WWVegas/WW3D2/w3d_util.cpp diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/w3d_util.h b/Core/Libraries/Source/WWVegas/WW3D2/w3d_util.h similarity index 100% rename from GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/w3d_util.h rename to Core/Libraries/Source/WWVegas/WW3D2/w3d_util.h diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/w3derr.h b/Core/Libraries/Source/WWVegas/WW3D2/w3derr.h similarity index 100% rename from GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/w3derr.h rename to Core/Libraries/Source/WWVegas/WW3D2/w3derr.h diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/w3dexclusionlist.cpp b/Core/Libraries/Source/WWVegas/WW3D2/w3dexclusionlist.cpp similarity index 100% rename from GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/w3dexclusionlist.cpp rename to Core/Libraries/Source/WWVegas/WW3D2/w3dexclusionlist.cpp diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/w3dexclusionlist.h b/Core/Libraries/Source/WWVegas/WW3D2/w3dexclusionlist.h similarity index 100% rename from GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/w3dexclusionlist.h rename to Core/Libraries/Source/WWVegas/WW3D2/w3dexclusionlist.h diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/ww3dformat.cpp b/Core/Libraries/Source/WWVegas/WW3D2/ww3dformat.cpp similarity index 100% rename from GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/ww3dformat.cpp rename to Core/Libraries/Source/WWVegas/WW3D2/ww3dformat.cpp diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/ww3dformat.h b/Core/Libraries/Source/WWVegas/WW3D2/ww3dformat.h similarity index 100% rename from GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/ww3dformat.h rename to Core/Libraries/Source/WWVegas/WW3D2/ww3dformat.h diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/ww3dids.h b/Core/Libraries/Source/WWVegas/WW3D2/ww3dids.h similarity index 100% rename from GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/ww3dids.h rename to Core/Libraries/Source/WWVegas/WW3D2/ww3dids.h diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/ww3dtrig.h b/Core/Libraries/Source/WWVegas/WW3D2/ww3dtrig.h similarity index 100% rename from GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/ww3dtrig.h rename to Core/Libraries/Source/WWVegas/WW3D2/ww3dtrig.h diff --git a/Generals/Code/Libraries/Source/WWVegas/WW3D2/CMakeLists.txt b/Generals/Code/Libraries/Source/WWVegas/WW3D2/CMakeLists.txt index b6b311b9438..e4e14e3d9a8 100644 --- a/Generals/Code/Libraries/Source/WWVegas/WW3D2/CMakeLists.txt +++ b/Generals/Code/Libraries/Source/WWVegas/WW3D2/CMakeLists.txt @@ -1,109 +1,109 @@ set(WW3D2_SRC - aabtree.cpp - aabtree.h + #aabtree.cpp + #aabtree.h aabtreebuilder.cpp aabtreebuilder.h - agg_def.cpp - agg_def.h - animatedsoundmgr.cpp - animatedsoundmgr.h + #agg_def.cpp + #agg_def.h + #animatedsoundmgr.cpp + #animatedsoundmgr.h animobj.cpp animobj.h assetmgr.cpp assetmgr.h - assetstatus.cpp - assetstatus.h - bitmaphandler.cpp - bitmaphandler.h + #assetstatus.cpp + #assetstatus.h + #bitmaphandler.cpp + #bitmaphandler.h bmp2d.cpp bmp2d.h boxrobj.cpp boxrobj.h - bwrender.cpp - bwrender.h + #bwrender.cpp + #bwrender.h camera.cpp camera.h #classid.h - collect.cpp - collect.h - colorspace.h - coltest.cpp - coltest.h - coltype.h - composite.cpp - composite.h + #collect.cpp + #collect.h + #colorspace.h + #coltest.cpp + #coltest.h + #coltype.h + #composite.cpp + #composite.h dazzle.cpp dazzle.h ddsfile.cpp ddsfile.h decalmsh.cpp decalmsh.h - decalsys.cpp - decalsys.h - distlod.cpp - distlod.h - dllist.h + #decalsys.cpp + #decalsys.h + #distlod.cpp + #distlod.h + #dllist.h dx8caps.cpp dx8caps.h dx8fvf.cpp dx8fvf.h dx8indexbuffer.cpp dx8indexbuffer.h - dx8list.h - dx8polygonrenderer.cpp - dx8polygonrenderer.h + #dx8list.h + #dx8polygonrenderer.cpp + #dx8polygonrenderer.h dx8renderer.cpp dx8renderer.h dx8texman.cpp dx8texman.h dx8vertexbuffer.cpp dx8vertexbuffer.h - dx8webbrowser.cpp - dx8webbrowser.h + #dx8webbrowser.cpp + #dx8webbrowser.h dx8wrapper.cpp dx8wrapper.h - dynamesh.cpp - dynamesh.h - font3d.cpp - font3d.h - formconv.cpp - formconv.h - FramGrab.cpp - framgrab.h - hanim.cpp - hanim.h + #dynamesh.cpp + #dynamesh.h + #font3d.cpp + #font3d.h + #formconv.cpp + #formconv.h + #FramGrab.cpp + #framgrab.h + #hanim.cpp + #hanim.h hanimmgr.cpp hanimmgr.h - hcanim.cpp - hcanim.h + #hcanim.cpp + #hcanim.h hlod.cpp hlod.h - hmdldef.cpp - hmdldef.H + #hmdldef.cpp + #hmdldef.H hmorphanim.cpp hmorphanim.h hrawanim.cpp hrawanim.h - htree.cpp - htree.h + #htree.cpp + #htree.h htreemgr.cpp htreemgr.h - intersec.cpp - intersec.h - intersec.inl - inttest.h - layer.cpp - layer.h + #intersec.cpp + #intersec.h + #intersec.inl + #inttest.h + #layer.cpp + #layer.h light.cpp light.h lightenvironment.cpp lightenvironment.h - line3d.cpp - line3d.h + #line3d.cpp + #line3d.h mapper.cpp mapper.h - matinfo.cpp - matinfo.h + #matinfo.cpp + #matinfo.h matpass.cpp matpass.h matrixmapper.cpp @@ -112,8 +112,8 @@ set(WW3D2_SRC mesh.h meshbuild.cpp meshbuild.h - meshdam.cpp - meshdam.h + #meshdam.cpp + #meshdam.h meshgeometry.cpp meshgeometry.h meshmatdesc.cpp @@ -121,10 +121,10 @@ set(WW3D2_SRC meshmdl.cpp meshmdl.h meshmdlio.cpp - metalmap.cpp - metalmap.h - missingtexture.cpp - missingtexture.h + #metalmap.cpp + #metalmap.h + #missingtexture.cpp + #missingtexture.h motchan.cpp motchan.h nullrobj.cpp @@ -135,70 +135,70 @@ set(WW3D2_SRC part_emt.h part_ldr.cpp part_ldr.h - pivot.cpp - pivot.h - pointgr.cpp - pointgr.h - polyinfo.cpp - polyinfo.h - predlod.cpp - predlod.h - prim_anim.cpp - prim_anim.h - projector.cpp - projector.h - proto.cpp - proto.h - proxy.h - rddesc.h + #pivot.cpp + #pivot.h + #pointgr.cpp + #pointgr.h + #polyinfo.cpp + #polyinfo.h + #predlod.cpp + #predlod.h + #prim_anim.cpp + #prim_anim.h + #projector.cpp + #projector.h + #proto.cpp + #proto.h + #proxy.h + #rddesc.h render2d.cpp render2d.h - render2dsentence.cpp - render2dsentence.h - renderobjectrecycler.cpp - renderobjectrecycler.h - rendobj.cpp - rendobj.h + #render2dsentence.cpp + #render2dsentence.h + #renderobjectrecycler.cpp + #renderobjectrecycler.h + #rendobj.cpp + #rendobj.h rinfo.cpp rinfo.h - ringobj.cpp - ringobj.h - robjlist.h + #ringobj.cpp + #ringobj.h + #robjlist.h scene.cpp scene.h - segline.cpp - segline.h - seglinerenderer.cpp - seglinerenderer.h + #segline.cpp + #segline.h + #seglinerenderer.cpp + #seglinerenderer.h shader.cpp shader.h - shattersystem.cpp - shattersystem.h - snappts.cpp - snapPts.h + #shattersystem.cpp + #shattersystem.h + #snappts.cpp + #snapPts.h sortingrenderer.cpp sortingrenderer.h - soundlibrarybridge.h - soundrobj.cpp - soundrobj.h - sphereobj.cpp - sphereobj.h - static_sort_list.cpp - static_sort_list.h - statistics.cpp - statistics.h - streak.cpp - streak.h - streakRender.cpp - streakRender.h - stripoptimizer.cpp - stripoptimizer.h - surfaceclass.cpp - surfaceclass.h + #soundlibrarybridge.h + #soundrobj.cpp + #soundrobj.h + #sphereobj.cpp + #sphereobj.h + #static_sort_list.cpp + #static_sort_list.h + #statistics.cpp + #statistics.h + #streak.cpp + #streak.h + #streakRender.cpp + #streakRender.h + #stripoptimizer.cpp + #stripoptimizer.h + #surfaceclass.cpp + #surfaceclass.h texproject.cpp texproject.h #textdraw.cpp - textdraw.h + #textdraw.h texture.cpp texture.h texturefilter.cpp @@ -209,23 +209,23 @@ set(WW3D2_SRC texturethumbnail.h vertmaterial.cpp vertmaterial.h - visrasterizer.cpp - visrasterizer.h - w3d_dep.cpp - w3d_dep.h + #visrasterizer.cpp + #visrasterizer.h + #w3d_dep.cpp + #w3d_dep.h w3d_file.h - w3d_obsolete.h - w3d_util.cpp - w3d_util.h - w3derr.h - w3dexclusionlist.cpp - w3dexclusionlist.h + #w3d_obsolete.h + #w3d_util.cpp + #w3d_util.h + #w3derr.h + #w3dexclusionlist.cpp + #w3dexclusionlist.h ww3d.cpp ww3d.h - ww3dformat.cpp - ww3dformat.h - ww3dids.h - ww3dtrig.h + #ww3dformat.cpp + #ww3dformat.h + #ww3dids.h + #ww3dtrig.h ) add_library(g_ww3d2 STATIC) @@ -233,13 +233,7 @@ set_target_properties(g_ww3d2 PROPERTIES OUTPUT_NAME ww3d2) target_sources(g_ww3d2 PRIVATE ${WW3D2_SRC}) -if (NOT IS_VS6_BUILD) - target_link_libraries(g_ww3d2 PUBLIC - comsuppw - ) -endif() - target_link_libraries(g_ww3d2 PRIVATE - core_browserengine + corei_ww3d2 g_wwcommon ) diff --git a/Generals/Code/Libraries/Source/WWVegas/WW3D2/FramGrab.cpp b/Generals/Code/Libraries/Source/WWVegas/WW3D2/FramGrab.cpp deleted file mode 100644 index 89f0aeeb2e6..00000000000 --- a/Generals/Code/Libraries/Source/WWVegas/WW3D2/FramGrab.cpp +++ /dev/null @@ -1,191 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -// FramGrab.cpp: implementation of the FrameGrabClass class. -// -////////////////////////////////////////////////////////////////////// - -#include "framgrab.h" -#include -#include -//#include - -////////////////////////////////////////////////////////////////////// -// Construction/Destruction -////////////////////////////////////////////////////////////////////// - -FrameGrabClass::FrameGrabClass(const char *filename, MODE mode, int width, int height, int bitcount, float framerate) -{ - HRESULT hr; - - Mode = mode; - Filename = filename; - FrameRate = framerate; - Counter = 0; - - Stream = 0; - AVIFile = 0; - - if(Mode != AVI) return; - - AVIFileInit(); // opens AVIFile library - - // find the first free file with this prefix - int counter = 0; - int result; - char file[256]; - do { - sprintf(file, "%s%d.AVI", filename, counter++); - result = _access(file, 0); - } while(result != -1); - - // Create new AVI file using AVIFileOpen. - hr = AVIFileOpen(&AVIFile, file, OF_WRITE | OF_CREATE, NULL); - if (hr != 0) { - char buf[256]; - sprintf(buf, "Unable to open %s\n", Filename); - OutputDebugString(buf); - CleanupAVI(); - return; - } - - - // Create a stream using AVIFileCreateStream. - AVIStreamInfo.fccType = streamtypeVIDEO; - AVIStreamInfo.fccHandler = mmioFOURCC('M','S','V','C'); - AVIStreamInfo.dwFlags = 0; - AVIStreamInfo.dwCaps = 0; - AVIStreamInfo.wPriority = 0; - AVIStreamInfo.wLanguage = 0; - AVIStreamInfo.dwScale = 1; - AVIStreamInfo.dwRate = (int)FrameRate; - AVIStreamInfo.dwStart = 0; - AVIStreamInfo.dwLength = 0; - AVIStreamInfo.dwInitialFrames = 0; - AVIStreamInfo.dwSuggestedBufferSize = 0; - AVIStreamInfo.dwQuality = 0; - AVIStreamInfo.dwSampleSize = 0; - SetRect(&AVIStreamInfo.rcFrame, 0, 0, width, height); - AVIStreamInfo.dwEditCount = 0; - AVIStreamInfo.dwFormatChangeCount = 0; - sprintf(AVIStreamInfo.szName,"G"); - - hr = AVIFileCreateStream(AVIFile, &Stream, &AVIStreamInfo); - if (hr != 0) { - CleanupAVI(); - return; - } - - // Set format of new stream - BitmapInfoHeader.biWidth = width; - BitmapInfoHeader.biHeight = height; - BitmapInfoHeader.biBitCount = (unsigned short)bitcount; - BitmapInfoHeader.biSizeImage = ((((UINT)BitmapInfoHeader.biBitCount * BitmapInfoHeader.biWidth + 31) & ~31) / 8) * BitmapInfoHeader.biHeight; - BitmapInfoHeader.biSize = sizeof(BITMAPINFOHEADER); // size of structure - BitmapInfoHeader.biPlanes = 1; // must be set to 1 - BitmapInfoHeader.biCompression = BI_RGB; // uncompressed - BitmapInfoHeader.biXPelsPerMeter = 1; // not used - BitmapInfoHeader.biYPelsPerMeter = 1; // not used - BitmapInfoHeader.biClrUsed = 0; // all colors are used - BitmapInfoHeader.biClrImportant = 0; // all colors are important - - hr = AVIStreamSetFormat(Stream, 0, &BitmapInfoHeader, sizeof(BitmapInfoHeader)); - if (hr != 0) { - CleanupAVI(); - return; - } - - Bitmap = (long *) GlobalAllocPtr(GMEM_MOVEABLE, BitmapInfoHeader.biSizeImage); -} - -FrameGrabClass::~FrameGrabClass() -{ - if(Mode == AVI) { - CleanupAVI(); - } -} - -void FrameGrabClass::CleanupAVI() { - if(Bitmap != 0) { GlobalFreePtr(Bitmap); Bitmap = 0; } - if(Stream != 0) { AVIStreamRelease(Stream); Stream = 0; } - if(AVIFile != 0) { AVIFileRelease(AVIFile); AVIFile = 0; } - - AVIFileExit(); - Mode = RAW; -} - -void FrameGrabClass::GrabAVI(void *BitmapPointer) -{ - // CompressDIB(&bi, lpOld, &biNew, lpNew); - - // Save the compressed data using AVIStreamWrite. - HRESULT hr = AVIStreamWrite(Stream, Counter++, 1, BitmapPointer, BitmapInfoHeader.biSizeImage, AVIIF_KEYFRAME, NULL, NULL); - if(hr != 0) { - char buf[256]; - sprintf(buf, "avi write error %x/%d\n", hr, hr); - OutputDebugString(buf); - } -} - -void FrameGrabClass::GrabRawFrame(void * /*BitmapPointer*/) -{ - -} - - -void FrameGrabClass::ConvertGrab(void *BitmapPointer) -{ - ConvertFrame(BitmapPointer); - Grab( Bitmap ); -} - - -void FrameGrabClass::Grab(void *BitmapPointer) -{ - if(Mode == AVI) - GrabAVI(BitmapPointer); - else - GrabRawFrame(BitmapPointer); -} - - -void FrameGrabClass::ConvertFrame(void *BitmapPointer) -{ - - int width = BitmapInfoHeader.biWidth; - int height = BitmapInfoHeader.biHeight; - long *image = (long *) BitmapPointer; - - // copy the data, doing a vertical flip & byte re-ordering of the pixel longwords - int y = height; - while(y--) { - int x = width; - int yoffset = y * width; - int yoffset2 = (height - y) * width; - while(x--) { - long *source = &image[yoffset + x]; - long *dest = &Bitmap[yoffset2 + x]; - *dest = *source; - unsigned char *c = (unsigned char *) dest; - c[3] = c[0]; - c[0] = c[2]; - c[2] = c[3]; - c[3] = 0; - } - } -} diff --git a/Generals/Code/Libraries/Source/WWVegas/WW3D2/aabtree.cpp b/Generals/Code/Libraries/Source/WWVegas/WW3D2/aabtree.cpp deleted file mode 100644 index 8c25f4ba3a0..00000000000 --- a/Generals/Code/Libraries/Source/WWVegas/WW3D2/aabtree.cpp +++ /dev/null @@ -1,1236 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** 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 *** - *********************************************************************************************** - * * - * Project Name : WW3D * - * * - * $Archive:: /Commando/Code/ww3d2/aabtree.cpp $* - * * - * Author:: Greg Hjelstrom * - * * - * $Modtime:: 11/24/01 5:34p $* - * * - * $Revision:: 4 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * AABTreeClass::AABTreeClass -- Constructor * - * AABTreeClass::AABTreeClass -- Constructor * - * AABTreeClass::AABTreeClass -- copy constructor * - * AABTreeClass::~AABTreeClass -- Destructor * - * AABTreeClass::operator = -- assignment operator * - * AABTreeClass::Reset -- reset this tree, releases all allocated resources * - * AABTreeClass::Build_Tree_Recursive -- Initializes this tree from the given builder * - * AABTreeClass::Set_Mesh -- set the mesh pointer * - * AABTreeClass::Generate_APT -- Generate an active poly table for the mesh * - * AABTreeClass::Generate_OBBox_APT_Recursive -- recursively generate the apt * - * AABTreeClass::Cast_Ray_Recursive -- Internal implementation of Cast_Ray * - * AABTreeClass::Cast_Semi_Infinite_Axis_Aligned_Ray_Recursive -- Internal implementation * - * AABTreeClass::Cast_AABox_Recursive -- internal implementation of Cast_AABox * - * AABTreeClass::Cast_OBBox_Recursive -- Internal implementation of Cast_OBBox * - * AABTreeClass::Intersect_OBBox_Recursive -- internal implementation of Intersect_OBBox * - * AABTreeClass::Cast_Ray_To_Polys -- cast the ray to polys in the given node * - * AABTreeClass::Cast_Semi_Infinite_Axis_Aligned_Ray_To_Polys -- cast ray to polys in the nod* - * AABTreeClass::Cast_AABox_To_Polys -- cast aabox to polys in the given node * - * AABTreeClass::Cast_OBBox_To_Polys -- cast obbox to polys in the given node * - * AABTreeClass::Intersect_OBBox_With_Polys -- Test polys for intersection * - * AABTreeClass::Update_Bounding_Boxes_Recursive -- recompute the bounding boxes * - * AABTreeClass::Update_Min_Max -- updates min and max given a polygon index * - * AABTreeClass::Load_W3D -- Load a W3D description of an AABTree * - * AABTreeClass::Read_Poly_Indices -- load the polygon index array * - * AABTreeClass::Read_Nodes -- Load the node array * - * AABTreeClass::Generate_APT -- generate an apt from a box and viewdir * - * AABTreeClass::Generate_OBBox_APT_Recursive -- recurse, generate the apt for a box and vie * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - - -#include "aabtree.h" -#include "aabtreebuilder.h" -#include "wwdebug.h" -#include "tri.h" -#include "meshgeometry.h" -#include "coltest.h" -#include "inttest.h" -#include "colmathinlines.h" -#include "w3d_file.h" -#include "chunkio.h" - - - -/*********************************************************************************************** - * AABTreeClass::AABTreeClass -- Constructor * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - *=============================================================================================*/ -AABTreeClass::AABTreeClass(void) : - NodeCount(0), - Nodes(NULL), - PolyCount(0), - PolyIndices(NULL), - Mesh(NULL) -{ -} - -/*********************************************************************************************** - * AABTreeClass::AABTreeClass -- Constructor * - * * - * Builds an AABTree from the contents of an AABTreeBuilderClass. * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 6/19/98 GTH : Created. * - * 5/23/2000 gth : Created. * - *=============================================================================================*/ -AABTreeClass::AABTreeClass(AABTreeBuilderClass * builder) -{ - NodeCount = builder->Node_Count(); - Nodes = W3DNEWARRAY AABTreeClass::CullNodeStruct[NodeCount]; - - PolyCount = builder->Poly_Count(); - PolyIndices = W3DNEWARRAY uint32[PolyCount]; - - int curpolyindex = 0; - Build_Tree_Recursive(builder->Root,curpolyindex); -} - - -/*********************************************************************************************** - * AABTreeClass::AABTreeClass -- copy constructor * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 6/22/99 GTH : Created. * - *=============================================================================================*/ -AABTreeClass::AABTreeClass(const AABTreeClass & that) : - NodeCount(0), - Nodes(NULL), - PolyCount(0), - PolyIndices(0), - Mesh(NULL) -{ - *this = that; -} - -/*********************************************************************************************** - * AABTreeClass::~AABTreeClass -- Destructor * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 6/19/98 GTH : Created. * - *=============================================================================================*/ -AABTreeClass::~AABTreeClass(void) -{ - Reset(); -} - -/*********************************************************************************************** - * AABTreeClass::operator = -- assignment operator * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 6/22/99 GTH : Created. * - *=============================================================================================*/ -AABTreeClass & AABTreeClass::operator = (const AABTreeClass & that) -{ - Reset(); - - NodeCount = that.NodeCount; - if (NodeCount > 0) { - Nodes = W3DNEWARRAY CullNodeStruct[NodeCount]; - memcpy(Nodes,that.Nodes,NodeCount * sizeof(CullNodeStruct)); - } - - PolyCount = that.PolyCount; - if (PolyCount > 0) { - PolyIndices = W3DNEWARRAY uint32[PolyCount]; - memcpy(PolyIndices,that.PolyIndices,PolyCount * sizeof(uint32)); - } - - Mesh = that.Mesh; - - return *this; -} - - -/*********************************************************************************************** - * AABTreeClass::Reset -- reset this tree, releases all allocated resources * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 6/22/99 GTH : Created. * - *=============================================================================================*/ -void AABTreeClass::Reset(void) -{ - NodeCount = 0; - if (Nodes) { - delete[] Nodes; - Nodes = NULL; - } - PolyCount = 0; - if (PolyIndices) { - delete[] PolyIndices; - PolyIndices = NULL; - } - if (Mesh) { - Mesh = NULL; - } -} - -/*********************************************************************************************** - * AABTreeClass::Scale - uniform scale * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 6/17/02 Jani : Created. * - *=============================================================================================*/ -void AABTreeClass::Scale(float f) -{ - for (int i=0;iIndex]); - - newnode->Min = node->Min; - newnode->Max = node->Max; - - /* - ** If this is a non-leaf node, set up the child indices, otherwise set up the polygon indices - */ - if (node->Front != NULL) { - - WWASSERT(node->Back != NULL); // if we have one child, we better have both! - newnode->Set_Front_Child(node->Front->Index); - newnode->Set_Back_Child(node->Back->Index); - - } else { - - newnode->Set_Poly0(curpolyindex); - newnode->Set_Poly_Count(node->PolyCount); - - } - - /* - ** Copy the polygon indices for this node into our array - */ - for (int pcounter = 0; pcounter < node->PolyCount; pcounter++) { - PolyIndices[curpolyindex++] = node->PolyIndices[pcounter]; - } - - /* - ** Install the children - */ - if (node->Front) { - Build_Tree_Recursive(node->Front,curpolyindex); - } - if (node->Back) { - Build_Tree_Recursive(node->Back,curpolyindex); - } -} - - -/*********************************************************************************************** - * AABTreeClass::Set_Mesh -- set the mesh pointer * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 6/22/99 GTH : Created. * - *=============================================================================================*/ -void AABTreeClass::Set_Mesh(MeshGeometryClass * mesh) -{ - Mesh = mesh; -} - - -/*********************************************************************************************** - * AABTreeClass::Generate_APT -- Generate an active poly table for the mesh * - * * - * INPUT: * - * box - oriented box to cull the mesh against (in the mesh's coordinate system!!!) * - * apt - vector of ints to fill the apt into * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - *=============================================================================================*/ -void AABTreeClass::Generate_APT(const OBBoxClass & box,SimpleDynVecClass & apt) -{ - OBBoxAPTContextStruct context(box,apt); - Generate_OBBox_APT_Recursive(&(Nodes[0]),context); -} - - - -/*********************************************************************************************** - * AABTreeClass::Generate_OBBox_APT_Recursive -- recursively generate the apt * - * * - * INPUT: * - * node - current node in the recursion * - * context - structure containing the results/current state * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 1/25/00 gth : Created. * - *=============================================================================================*/ -void AABTreeClass::Generate_OBBox_APT_Recursive(CullNodeStruct * node,OBBoxAPTContextStruct & context) -{ - /* - ** Test the volume against the bounding volume of this node - ** If it is outside, stop descending the tree. - */ - AABoxClass nodebox; - nodebox.Init_Min_Max(node->Min,node->Max); // NOTE: too bad we have to compute the nodebox!!! - - if (!CollisionMath::Intersection_Test(context.Box,nodebox)) { - return; - } - - /* - ** If this is a leaf, test its polygons, otherwise recurse into the children - */ - if (node->Is_Leaf()) { - - int polycount = node->Get_Poly_Count(); - int poly0 = node->Get_Poly0(); - - if (polycount > 0) { - TriClass tri; - const Vector3 * loc = Mesh->Get_Vertex_Array(); - const TriIndex * polys = Mesh->Get_Polygon_Array(); -#if (!OPTIMIZE_PLANEEQ_RAM) - const Vector4 * norms = Mesh->Get_Plane_Array(); -#endif - for (int poly_counter=0; poly_counterGet_Front_Child()]),context); - Generate_OBBox_APT_Recursive(&(Nodes[node->Get_Back_Child()]),context); - } -} - - -/*********************************************************************************************** - * AABTreeClass::Generate_APT -- generate an apt from a box and viewdir * - * * - * Indices of the polys which intersect the box and are not backfacing to the given viewdir * - * will be added to the passed in apt. * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 5/10/2001 gth : Created. * - *=============================================================================================*/ -void AABTreeClass::Generate_APT -( - const OBBoxClass & box, - const Vector3 & viewdir, - SimpleDynVecClass & apt -) -{ - OBBoxRayAPTContextStruct context(box,viewdir,apt); - Generate_OBBox_APT_Recursive(&(Nodes[0]),context); -} - - -/*********************************************************************************************** - * AABTreeClass::Generate_OBBox_APT_Recursive -- recurse, generate the apt for a box and viewd * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 5/10/2001 gth : Created. * - *=============================================================================================*/ -void AABTreeClass::Generate_OBBox_APT_Recursive(CullNodeStruct * node, OBBoxRayAPTContextStruct & context) -{ - /* - ** Test the volume against the bounding volume of this node - ** If it is outside, stop descending the tree. - */ - AABoxClass nodebox; - nodebox.Init_Min_Max(node->Min,node->Max); // NOTE: too bad we have to compute the nodebox!!! - - if (!CollisionMath::Intersection_Test(context.Box,nodebox)) { - return; - } - - /* - ** If this is a leaf, test its polygons, otherwise recurse into the children - */ - if (node->Is_Leaf()) { - - int polycount = node->Get_Poly_Count(); - int poly0 = node->Get_Poly0(); - - if (polycount > 0) { - TriClass tri; - const Vector3 * loc = Mesh->Get_Vertex_Array(); - const TriIndex * polys = Mesh->Get_Polygon_Array(); -#if (!OPTIMIZE_PLANEEQ_RAM) - const Vector4 * norms = Mesh->Get_Plane_Array(); -#endif - - for (int poly_counter=0; poly_counterGet_Front_Child()]),context); - Generate_OBBox_APT_Recursive(&(Nodes[node->Get_Back_Child()]),context); - } -} - - -/*********************************************************************************************** - * AABTreeClass::Cast_Ray_Recursive -- Internal implementation of Cast_Ray * - * * - * INPUT: * - * raytest - contains all of the ray test information * - * node - current cull node being processed * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 6/19/98 GTH : Created. * - *=============================================================================================*/ -bool AABTreeClass::Cast_Ray_Recursive(CullNodeStruct * node,RayCollisionTestClass & raytest) -{ - /* - ** Cull the collision test against the bounding volume of this node - ** If it is culled, stop descending the tree. - */ - if (raytest.Cull(node->Min,node->Max)) { - return false; - } - - bool res = false; - if (node->Is_Leaf()) { - - return Cast_Ray_To_Polys(node,raytest); - - } else { - - res = res | Cast_Ray_Recursive(&(Nodes[node->Get_Front_Child()]),raytest); - res = res | Cast_Ray_Recursive(&(Nodes[node->Get_Back_Child()]),raytest); - - } - - return res; -} - - -/*********************************************************************************************** - * AABTreeClass::Cast_Semi_Infinite_Axis_Aligned_Ray_Recursive -- Internal implementation * - * * - * INPUT: * - * node - current cull node being processed * - * start_point - starting point * - * axis_r - the axis along which the ray is projected * - * axis_1, axis_2 - the other two axes * - * direction - 0 means the ray goes toward the negative axis, 1 means positive. * - * flags - reference bitfield for result flags (ray hit edge, start point embedded in tri, etc)* - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 8/30/00 NH : Created. * - *=============================================================================================*/ -int AABTreeClass::Cast_Semi_Infinite_Axis_Aligned_Ray_Recursive(CullNodeStruct * node, - const Vector3 & start_point, int axis_r, int axis_1, int axis_2, int direction, - unsigned char & flags) -{ - /* - ** Cull the ray against the bounding volume of this node - ** If it is culled, stop descending the tree. - ** We do two main tests: a 2D test against axis1 and axis2 to see if the starting point (and - ** hence the ray) falls within the 2D projection of the bbox, and a 1D test to see if the ray - ** is completely above or below the bbox. The second test checks (start > max) or (start < min) - ** depending on the direction of the ray - we do this in a branchless fashion by turning - ** (start < min) into (-start > -min). Then we can use tables to perform the correct check. - */ - static const float sign[2] = { -1.0f, 1.0f }; - float bounds[2], start[2]; - bounds[0] = -node->Min[axis_r]; - bounds[1] = node->Max[axis_r]; - start[0] = -start_point[axis_r]; - start[1] = start_point[axis_r]; - if ( start_point[axis_1] < node->Min[axis_1] || start_point[axis_2] < node->Min[axis_2] || - start_point[axis_1] > node->Max[axis_1] || start_point[axis_2] > node->Max[axis_2] || - start[direction] > bounds[direction] ) { - return 0; - } - - int count = 0; - if (node->Is_Leaf()) { - - return Cast_Semi_Infinite_Axis_Aligned_Ray_To_Polys(node, start_point, axis_r, axis_1, - axis_2, direction, flags); - - } else { - - count += Cast_Semi_Infinite_Axis_Aligned_Ray_Recursive(&(Nodes[node->Get_Front_Child()]), - start_point, axis_r, axis_1, axis_2, direction, flags); - count += Cast_Semi_Infinite_Axis_Aligned_Ray_Recursive(&(Nodes[node->Get_Back_Child()]), - start_point, axis_r, axis_1, axis_2, direction, flags); - - } - - return count; -} - - -/*********************************************************************************************** - * AABTreeClass::Cast_AABox_Recursive -- internal implementation of Cast_AABox * - * * - * INPUT: * - * boxtest - contains description of the collision operation to be performed * - * node - current cull node being processed * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 6/19/98 GTH : Created. * - *=============================================================================================*/ -bool AABTreeClass::Cast_AABox_Recursive(CullNodeStruct * node,AABoxCollisionTestClass & boxtest) -{ - /* - ** First, check the bounding box of the move against the bounding box - ** of this tree, if they don't intersect, bail out - */ - if (boxtest.Cull(node->Min,node->Max)) { - return false; - } - - bool res = false; - if (node->Is_Leaf()) { - - return Cast_AABox_To_Polys(node,boxtest); - - } else { - - res = res | Cast_AABox_Recursive(&(Nodes[node->Get_Front_Child()]),boxtest); - res = res | Cast_AABox_Recursive(&(Nodes[node->Get_Back_Child()]),boxtest); - - } - - return res; -} - - -/*********************************************************************************************** - * AABTreeClass::Cast_OBBox_Recursive -- Internal implementation of Cast_OBBox * - * * - * INPUT: * - * boxtest - contains description of the collision test to be performed * - * node - current cull node being processed * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 6/19/98 GTH : Created. * - *=============================================================================================*/ -bool AABTreeClass::Cast_OBBox_Recursive(CullNodeStruct * node,OBBoxCollisionTestClass & boxtest) -{ - /* - ** First, check the bounding box of the move against the bounding box - ** of this tree, if they don't intersect, bail out - */ - if (boxtest.Cull(node->Min,node->Max)) { - return false; - } - - bool res = false; - if (node->Is_Leaf()) { - - return Cast_OBBox_To_Polys(node,boxtest); - - } else { - - res = res | Cast_OBBox_Recursive(&(Nodes[node->Get_Front_Child()]),boxtest); - res = res | Cast_OBBox_Recursive(&(Nodes[node->Get_Back_Child()]),boxtest); - - } - - return res; -} - - -/*********************************************************************************************** - * AABTreeClass::Intersect_OBBox_Recursive -- internal implementation of Intersect_OBBox * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 1/20/00 gth : Created. * - *=============================================================================================*/ -bool AABTreeClass::Intersect_OBBox_Recursive(AABTreeClass::CullNodeStruct * node,OBBoxIntersectionTestClass & test) -{ - /* - ** Cull the collision test against the bounding volume of this node - ** If it is culled, stop descending the tree. - */ - if (test.Cull(node->Min,node->Max)) { - return false; - } - - bool res = false; - if (node->Is_Leaf()) { - - return Intersect_OBBox_With_Polys(node,test); - - } else { - - res = res | Intersect_OBBox_Recursive(&(Nodes[node->Get_Front_Child()]),test); - res = res | Intersect_OBBox_Recursive(&(Nodes[node->Get_Back_Child()]),test); - } - - return res; -} - -#ifdef RTS_DEBUG -#pragma optimize("", off) // We get an odd error when using optimized in the debug. -// All optimized seems to work. jba. -#endif -/*********************************************************************************************** - * AABTreeClass::Cast_Ray_To_Polys -- cast the ray to polys in the given node * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 6/19/98 GTH : Created. * - *=============================================================================================*/ -bool AABTreeClass::Cast_Ray_To_Polys(CullNodeStruct * node,RayCollisionTestClass & raytest) -{ - if (node->Get_Poly_Count() > 0) { - /* - ** Simply loop through the polys in this node, checking each for collision - */ - TriClass tri; - - const Vector3 * loc = Mesh->Get_Vertex_Array(); - const TriIndex * polyverts = Mesh->Get_Polygon_Array(); -#if (!OPTIMIZE_PLANEEQ_RAM) - const Vector4 * norms = Mesh->Get_Plane_Array(); -#endif - - int polyhit = -1; - int poly0 = node->Get_Poly0(); - int polycount = node->Get_Poly_Count(); - - for (int poly_counter=0; poly_counterStartBad) { - return true; - } - } - if (polyhit != -1) { - raytest.Result->SurfaceType = Mesh->Get_Poly_Surface_Type (polyhit); - return true; - } - } - return false; -} -#ifdef RTS_DEBUG -#pragma optimize("", on) -#endif - - -/*********************************************************************************************** - * AABTreeClass::Cast_Semi_Infinite_Axis_Aligned_Ray_To_Polys -- cast ray to polys in the node * - * * - * INPUT: * - * node - current cull node being processed * - * start_point - starting point * - * axis_r - the axis along which the ray is projected * - * axis_1, axis_2 - the other two axes * - * direction - 0 means the ray goes toward the negative axis, 1 means positive. * - * flags - reference bitfield for result flags (ray hit edge, start point embedded in tri, etc)* - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 8/30/00 NH : Created. * - *=============================================================================================*/ -int AABTreeClass::Cast_Semi_Infinite_Axis_Aligned_Ray_To_Polys(CullNodeStruct * node, - const Vector3 & start_point, int axis_r, int axis_1, int axis_2, int direction, - unsigned char & flags) -{ - int count = 0; - - if (node->Get_Poly_Count() > 0) { - - /* - ** Simply loop through the polys in this node, checking each for collision - */ - - const Vector3 * loc = Mesh->Get_Vertex_Array(); - const TriIndex * polyverts = Mesh->Get_Polygon_Array(); - const Vector4 * plane = Mesh->Get_Plane_Array(); - int poly0 = node->Get_Poly0(); - int polycount = node->Get_Poly_Count(); - - for (int poly_counter=0; poly_counter < polycount; poly_counter++) { - - int poly_index = PolyIndices[poly0 + poly_counter]; - - const Vector3 &v0 = loc[ polyverts[poly_index][0] ]; - const Vector3 &v1 = loc[ polyverts[poly_index][1] ]; - const Vector3 &v2 = loc[ polyverts[poly_index][2] ]; - const Vector4 &tri_plane = plane[poly_index]; - - // Since (int)true is defined as 1, and (int)false as 0: - count += (unsigned int)Cast_Semi_Infinite_Axis_Aligned_Ray_To_Triangle(v0, v1, v2, - tri_plane, start_point, axis_r, axis_1, axis_2, direction, flags); - } - } - - return count; -} - - -/*********************************************************************************************** - * AABTreeClass::Cast_AABox_To_Polys -- cast aabox to polys in the given node * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 6/19/98 GTH : Created. * - *=============================================================================================*/ -bool AABTreeClass::Cast_AABox_To_Polys(CullNodeStruct * node,AABoxCollisionTestClass & boxtest) -{ - if (node->Get_Poly_Count() > 0) { - /* - ** Simply loop through the polys in this node, checking each for collision - */ - TriClass tri; - - const Vector3 * loc = Mesh->Get_Vertex_Array(); - const TriIndex * polyverts = Mesh->Get_Polygon_Array(); -#if (!OPTIMIZE_PLANEEQ_RAM) - const Vector4 * norms = Mesh->Get_Plane_Array(); -#endif - - int polyhit = -1; - int poly0 = node->Get_Poly0(); - int polycount = node->Get_Poly_Count(); - - for (int poly_counter=0; poly_counterStartBad) { - return true; - } - } - if (polyhit != -1) { - boxtest.Result->SurfaceType = Mesh->Get_Poly_Surface_Type (polyhit); - return true; - } - } - return false; -} - - -/*********************************************************************************************** - * AABTreeClass::Cast_OBBox_To_Polys -- cast obbox to polys in the given node * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 6/19/98 GTH : Created. * - *=============================================================================================*/ -bool AABTreeClass::Cast_OBBox_To_Polys(CullNodeStruct * node,OBBoxCollisionTestClass & boxtest) -{ - int polycount = node->Get_Poly_Count(); - int poly0 = node->Get_Poly0(); - - if (polycount > 0) { - /* - ** Simply loop through the polys in this node, checking each for collision - */ - TriClass tri; - - const Vector3 * loc = Mesh->Get_Vertex_Array(); - const TriIndex * polyverts = Mesh->Get_Polygon_Array(); -#if (!OPTIMIZE_PLANEEQ_RAM) - const Vector4 * norms = Mesh->Get_Plane_Array(); -#endif - - int polyhit = -1; - - for (int poly_counter=0; poly_counterStartBad) { - return true; - } - } - if (polyhit != -1) { - boxtest.Result->SurfaceType = Mesh->Get_Poly_Surface_Type (polyhit); - return true; - } - } - return false; - -} - - -/*********************************************************************************************** - * AABTreeClass::Intersect_OBBox_With_Polys -- Test polys for intersection * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 1/20/00 gth : Created. * - *=============================================================================================*/ -bool AABTreeClass::Intersect_OBBox_With_Polys -( - CullNodeStruct * node, - OBBoxIntersectionTestClass & test -) -{ - int poly0 = node->Get_Poly0(); - int polycount = node->Get_Poly_Count(); - - if (polycount > 0) { - /* - ** Simply loop through the polys in this node, checking each for collision - */ - TriClass tri; - - const Vector3 * loc = Mesh->Get_Vertex_Array(); - const TriIndex * polyverts = Mesh->Get_Polygon_Array(); -#if (!OPTIMIZE_PLANEEQ_RAM) - const Vector4 * norms = Mesh->Get_Plane_Array(); -#endif - - for (int poly_counter=0; poly_counterMin.Set(100000.0f,100000.0f,100000.0f); - node->Max.Set(-100000.0f,-100000.0f,-100000.0f); - - /* - ** Recurse to the children first - */ - if (node->Is_Leaf() == false) { - - Update_Bounding_Boxes_Recursive(&(Nodes[node->Get_Front_Child()])); - Update_Bounding_Boxes_Recursive(&(Nodes[node->Get_Back_Child()])); - - /* - ** Bound our children - */ - int front = node->Get_Front_Child(); - int back = node->Get_Back_Child(); - - if (Nodes[front].Min.X < node->Min.X) node->Min.X = Nodes[front].Min.X; - if (Nodes[front].Max.X > node->Max.X) node->Max.X = Nodes[front].Max.X; - - if (Nodes[front].Min.Y < node->Min.Y) node->Min.Y = Nodes[front].Min.Y; - if (Nodes[front].Max.Y > node->Max.Y) node->Max.Y = Nodes[front].Max.Y; - - if (Nodes[front].Min.Z < node->Min.Z) node->Min.Z = Nodes[front].Min.Z; - if (Nodes[front].Max.Z > node->Max.Z) node->Max.Z = Nodes[front].Max.Z; - - if (Nodes[back].Min.X < node->Min.X) node->Min.X = Nodes[back].Min.X; - if (Nodes[back].Max.X > node->Max.X) node->Max.X = Nodes[back].Max.X; - - if (Nodes[back].Min.Y < node->Min.Y) node->Min.Y = Nodes[back].Min.Y; - if (Nodes[back].Max.Y > node->Max.Y) node->Max.Y = Nodes[back].Max.Y; - - if (Nodes[back].Min.Z < node->Min.Z) node->Min.Z = Nodes[back].Min.Z; - if (Nodes[back].Max.Z > node->Max.Z) node->Max.Z = Nodes[back].Max.Z; - - } else { - - /* - ** Bound our polygons - */ - int poly0 = node->Get_Poly0(); - int polycount = node->Get_Poly_Count(); - - for (int poly_index = 0; poly_index < polycount; poly_index++) { - int pi = PolyIndices[poly0 + poly_index]; - Update_Min_Max(pi,node->Min,node->Max ); - } - - } - - WWASSERT(node->Min.X != 100000.0f); - WWASSERT(node->Min.Y != 100000.0f); - WWASSERT(node->Min.Z != 100000.0f); - WWASSERT(node->Max.X != -100000.0f); - WWASSERT(node->Max.Y != -100000.0f); - WWASSERT(node->Max.Z != -100000.0f); -} - - -/*********************************************************************************************** - * AABTreeClass::Update_Min_Max -- updates min and max given a polygon index * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 6/22/99 GTH : Created. * - *=============================================================================================*/ -void AABTreeClass::Update_Min_Max(int poly_index,Vector3 & min,Vector3 & max) -{ - for (int vert_index = 0; vert_index < 3; vert_index++) { - - const TriIndex * polyverts = Mesh->Get_Polygon_Array() + poly_index; - const Vector3 * point = Mesh->Get_Vertex_Array() + (*polyverts)[vert_index]; - - if (point->X < min.X) min.X = point->X; - if (point->Y < min.Y) min.Y = point->Y; - if (point->Z < min.Z) min.Z = point->Z; - - if (point->X > max.X) max.X = point->X; - if (point->Y > max.Y) max.Y = point->Y; - if (point->Z > max.Z) max.Z = point->Z; - } -} - - -/*********************************************************************************************** - * AABTreeClass::Load_W3D -- Load a W3D description of an AABTree * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 5/22/2000 gth : Created. * - *=============================================================================================*/ -void AABTreeClass::Load_W3D(ChunkLoadClass & cload) -{ - Reset(); - - W3dMeshAABTreeHeader header; - cload.Open_Chunk(); - WWASSERT(cload.Cur_Chunk_ID() == W3D_CHUNK_AABTREE_HEADER); - cload.Read(&header,sizeof(header)); - cload.Close_Chunk(); - - NodeCount = header.NodeCount; - PolyCount = header.PolyCount; - Nodes = W3DNEWARRAY CullNodeStruct[NodeCount]; - PolyIndices = W3DNEWARRAY uint32[PolyCount]; - - while (cload.Open_Chunk()) { - switch (cload.Cur_Chunk_ID()) - { - case W3D_CHUNK_AABTREE_POLYINDICES: - Read_Poly_Indices(cload); - break; - - case W3D_CHUNK_AABTREE_NODES: - Read_Nodes(cload); - break; - } - cload.Close_Chunk(); - } -} - - -/*********************************************************************************************** - * AABTreeClass::Read_Poly_Indices -- load the polygon index array * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 5/22/2000 gth : Created. * - *=============================================================================================*/ -void AABTreeClass::Read_Poly_Indices(ChunkLoadClass & cload) -{ - cload.Read(PolyIndices,sizeof(uint32) * PolyCount); -} - - -/*********************************************************************************************** - * AABTreeClass::Read_Nodes -- Load the node array * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 5/22/2000 gth : Created. * - *=============================================================================================*/ -void AABTreeClass::Read_Nodes(ChunkLoadClass & cload) -{ - W3dMeshAABTreeNode w3dnode; - - for (int i=0; i. -*/ - -/*********************************************************************************************** - *** 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 *** - *********************************************************************************************** - * * - * Project Name : WW3D * - * * - * $Archive:: /Commando/Code/ww3d2/aabtree.h $* - * * - * Org Author:: Greg Hjelstrom * - * * - * Author:: Kenny Mitchell * - * * - * $Modtime:: 6/26/02 2:58p $* - * * - * $Revision:: 4 $* - * * - *---------------------------------------------------------------------------------------------* - * 06/26/02 KM Integrating shader system - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#if defined(_MSC_VER) -#pragma once -#endif - -#ifndef AABTREE_H -#define AABTREE_H - -#include "always.h" -#include "refcount.h" -#include "simplevec.h" -#include "vector3.h" -#include "Vector3i.h" -#include "aaplane.h" -#include "bittype.h" -#include "colmath.h" -#include "wwdebug.h" -#include "aabtreebuilder.h" -#include "obbox.h" -#include -#include - - -class MeshClass; -class CameraClass; -class RayCollisionTestClass; -class AABoxCollisionTestClass; -class OBBoxCollisionTestClass; -class OBBoxIntersectionTestClass; -class ChunkLoadClass; -class ChunkSaveClass; -class MeshGeometryClass; -class OBBoxClass; -class ChunkLoadClass; - -struct BoxRayAPTContextStruct; - -#define AABTREE_LEAF_FLAG 0x80000000 - - -/* -** AABTreeClass -** This class encapsulates an Axis-Aligned Bounding Box Tree for a mesh. This tree -** can be used to perform hierarchical culling for collision detection. Note that -** this class is constructed using the AABTreeBuilderClass; these two classes are -** very tightly coupled. Pretty much the only code which needs to know about the AABTreeClass -** is in MeshGeometryClass. I moved these out into a separate file just to reduce the -** size of meshmdl.cpp. -*/ -class AABTreeClass : public W3DMPO, public RefCountClass -{ - W3DMPO_GLUE(AABTreeClass) -public: - - AABTreeClass(void); - AABTreeClass(AABTreeBuilderClass * builder); - AABTreeClass(const AABTreeClass & that); - ~AABTreeClass(void); - - void Load_W3D(ChunkLoadClass & cload); - - // Uniformly scale the AABTree - void Scale(float scale); - - int Get_Node_Count(void) { return NodeCount; } - int Get_Poly_Count(void) { return PolyCount; } - int Compute_Ram_Size(void); - void Generate_APT(const OBBoxClass & box,SimpleDynVecClass & apt); - void Generate_APT(const OBBoxClass & box,const Vector3 & viewdir,SimpleDynVecClass & apt); - - bool Cast_Ray(RayCollisionTestClass & raytest); - int Cast_Semi_Infinite_Axis_Aligned_Ray(const Vector3 & start_point, - int axis_dir, unsigned char & flags); - bool Cast_AABox(AABoxCollisionTestClass & boxtest); - bool Cast_OBBox(OBBoxCollisionTestClass & boxtest); - bool Intersect_OBBox(OBBoxIntersectionTestClass & boxtest); - - void Set_Mesh(MeshGeometryClass * mesh); - -private: - - AABTreeClass & operator = (const AABTreeClass & that); - - void Read_Poly_Indices(ChunkLoadClass & cload); - void Read_Nodes(ChunkLoadClass & cload); - - void Build_Tree_Recursive(AABTreeBuilderClass::CullNodeStruct * node,int &curpolyindex); - void Reset(void); - void Update_Bounding_Boxes(void); - void Update_Min_Max(int index,Vector3 & min,Vector3 & max); - - /* - ** CullNodeStruct - the culling tree is built out of an array of these structures - ** They contain the extents of an axis-aligned box, indices to children nodes, - ** and indices into the polygon array - ** (05/22/2000 gth - changed this structure to support either child nodes -or- - ** a polygon array but not both at the same time. Also switched to 32bit indices - ** so that the code doesn't become useless as quickly ) - */ - struct CullNodeStruct - { - Vector3 Min; - Vector3 Max; - - uint32 FrontOrPoly0; - uint32 BackOrPolyCount; - - // accessors - inline bool Is_Leaf(void); - - inline int Get_Back_Child(void); // returns index of back child (only call for non-LEAFs!!!) - inline int Get_Front_Child(void); // returns index of front child (only call for non-LEAFs!!!) - inline int Get_Poly0(void); // returns index of first polygon (only call on LEAFs) - inline int Get_Poly_Count(void); // returns polygon count (only call on LEAFs) - - // initialization - inline void Set_Front_Child(uint32 index); - inline void Set_Back_Child(uint32 index); - inline void Set_Poly0(uint32 index); - inline void Set_Poly_Count(uint32 count); - }; - - /* - ** OBBoxAPTContextStruct - this is a temporary datastructure used in building - ** an APT by culling the mesh to an oriented bounding box. - */ - struct OBBoxAPTContextStruct - { - OBBoxAPTContextStruct(const OBBoxClass & box,SimpleDynVecClass & apt) : - Box(box), APT(apt) - { } - - OBBoxClass Box; - SimpleDynVecClass & APT; - }; - - /** - ** OBBoxRayAPTContextStruct - temporary datastructure used in building an APT - ** by culling the mesh to a oriented box and eliminating backfaces to a ray. - */ - struct OBBoxRayAPTContextStruct - { - OBBoxRayAPTContextStruct(const OBBoxClass & box,const Vector3 & viewdir,SimpleDynVecClass & apt) : - Box(box), - ViewVector(viewdir), - APT(apt) - { } - - OBBoxClass Box; - Vector3 ViewVector; - SimpleDynVecClass & APT; - }; - - void Generate_OBBox_APT_Recursive(CullNodeStruct * node,OBBoxAPTContextStruct & context); - void Generate_OBBox_APT_Recursive(CullNodeStruct * node, OBBoxRayAPTContextStruct & context); - - bool Cast_Ray_Recursive(CullNodeStruct * node,RayCollisionTestClass & raytest); - int Cast_Semi_Infinite_Axis_Aligned_Ray_Recursive(CullNodeStruct * node, const Vector3 & start_point, - int axis_r, int axis_1, int axis_2, int direction, unsigned char & flags); - bool Cast_AABox_Recursive(CullNodeStruct * node,AABoxCollisionTestClass & boxtest); - bool Cast_OBBox_Recursive(CullNodeStruct * node,OBBoxCollisionTestClass & boxtest); - bool Intersect_OBBox_Recursive(CullNodeStruct * node,OBBoxIntersectionTestClass & boxtest); - - bool Cast_Ray_To_Polys(CullNodeStruct * node,RayCollisionTestClass & raytest); - int Cast_Semi_Infinite_Axis_Aligned_Ray_To_Polys(CullNodeStruct * node, const Vector3 & start_point, - int axis_r, int axis_1, int axis_2, int direction, unsigned char & flags); - bool Cast_AABox_To_Polys(CullNodeStruct * node,AABoxCollisionTestClass & boxtest); - bool Cast_OBBox_To_Polys(CullNodeStruct * node,OBBoxCollisionTestClass & boxtest); - bool Intersect_OBBox_With_Polys(CullNodeStruct * node,OBBoxIntersectionTestClass & boxtest); - - void Update_Bounding_Boxes_Recursive(CullNodeStruct * node); - - int NodeCount; // number of nodes in the tree - CullNodeStruct * Nodes; // array of nodes - int PolyCount; // number of polygons in the parent mesh (and the number of indexes in our array) - uint32 * PolyIndices; // linear array of polygon indices, nodes index into this array - MeshGeometryClass * Mesh; // pointer to the parent mesh (non-ref-counted; we are a member of this mesh) - - friend class MeshClass; - friend class MeshGeometryClass; - friend class AuxMeshDataClass; - friend class AABTreeBuilderClass; - -}; - -inline int AABTreeClass::Compute_Ram_Size(void) -{ - return NodeCount * sizeof(CullNodeStruct) + - PolyCount * sizeof(int) + - sizeof(AABTreeClass); -} - -inline bool AABTreeClass::Cast_Ray(RayCollisionTestClass & raytest) -{ - WWASSERT(Nodes != NULL); - return Cast_Ray_Recursive(&(Nodes[0]),raytest); -} - -inline int AABTreeClass::Cast_Semi_Infinite_Axis_Aligned_Ray(const Vector3 & start_point, - int axis_dir, unsigned char & flags) -{ - // These tables translate between the axis_dir representation (which is an integer in which 0 - // indicates a ray along the positive x axis, 1 along the negative x axis, 2 the positive y - // axis, 3 negative y axis, 4 positive z axis, 5 negative z axis) and a four-integer - // representation (axis_r is the axis number - 0, 1 or 2 - of the axis along which the ray is - // cast; axis_1 and axis_2 are the axis numbers of the other two axes; direction is 0 for - // negative and 1 for positive direction of the ray). - static const int axis_r[6] = { 0, 0, 1, 1, 2, 2 }; - static const int axis_1[6] = { 1, 1, 2, 2, 0, 0 }; - static const int axis_2[6] = { 2, 2, 0, 0, 1, 1 }; - static const int direction[6] = { 1, 0, 1, 0, 1, 0 }; - WWASSERT(Nodes != NULL); - WWASSERT(axis_dir >= 0); - WWASSERT(axis_dir < 6); - - // The functions called after this point will 'or' bits into this variable, so it needs to - // be initialized here to TRI_RAYCAST_FLAG_NONE. - flags = TRI_RAYCAST_FLAG_NONE; - - return Cast_Semi_Infinite_Axis_Aligned_Ray_Recursive(&(Nodes[0]), start_point, - axis_r[axis_dir], axis_1[axis_dir], axis_2[axis_dir], direction[axis_dir], flags); -} - -inline bool AABTreeClass::Cast_AABox(AABoxCollisionTestClass & boxtest) -{ - WWASSERT(Nodes != NULL); - return Cast_AABox_Recursive(&(Nodes[0]),boxtest); -} - -inline bool AABTreeClass::Cast_OBBox(OBBoxCollisionTestClass & boxtest) -{ - WWASSERT(Nodes != NULL); - return Cast_OBBox_Recursive(&(Nodes[0]),boxtest); -} - -inline bool AABTreeClass::Intersect_OBBox(OBBoxIntersectionTestClass & boxtest) -{ - WWASSERT(Nodes != NULL); - return Intersect_OBBox_Recursive(&(Nodes[0]),boxtest); -} - -inline void AABTreeClass::Update_Bounding_Boxes(void) -{ - WWASSERT(Nodes != NULL); - Update_Bounding_Boxes_Recursive(&(Nodes[0])); -} - - -/*********************************************************************************************** - - AABTreeClass::CullNodeStruct implementation - - These nodes can be either leaf nodes or non-leaf nodes. If they are leaf nodes, they - will contain an index to their first polygon index and a polygon count. If they are - non-leafs they will contain indices to their front and back children. Since I'm re-using - the same variables for the child indices and the polygon indices, you have to call - the Is_Leaf function then only call the appropriate functions. The flag indicating whether - this node is a leaf is stored in the MSB of the FrontOrPoly0 variable. It will always - be stripped off by these accessor functions - -***********************************************************************************************/ - -inline bool AABTreeClass::CullNodeStruct::Is_Leaf(void) -{ - return ((FrontOrPoly0 & AABTREE_LEAF_FLAG) != 0); -} - -inline int AABTreeClass::CullNodeStruct::Get_Front_Child(void) -{ - WWASSERT(!Is_Leaf()); - return FrontOrPoly0; // we shouldn't be calling this on a leaf and the leaf bit should be zero... -} - -inline int AABTreeClass::CullNodeStruct::Get_Back_Child(void) -{ - WWASSERT(!Is_Leaf()); - return BackOrPolyCount; -} - -inline int AABTreeClass::CullNodeStruct::Get_Poly0(void) -{ - WWASSERT(Is_Leaf()); - return (FrontOrPoly0 & ~AABTREE_LEAF_FLAG); -} - -inline int AABTreeClass::CullNodeStruct::Get_Poly_Count(void) -{ - WWASSERT(Is_Leaf()); - return BackOrPolyCount; -} - -inline void AABTreeClass::CullNodeStruct::Set_Front_Child(uint32 index) -{ - WWASSERT(index < 0x7FFFFFFF); - FrontOrPoly0 = index; -} - -inline void AABTreeClass::CullNodeStruct::Set_Back_Child(uint32 index) -{ - WWASSERT(index < 0x7FFFFFFF); - BackOrPolyCount = index; -} - -inline void AABTreeClass::CullNodeStruct::Set_Poly0(uint32 index) -{ - WWASSERT(index < 0x7FFFFFFF); - FrontOrPoly0 = (index | AABTREE_LEAF_FLAG); -} - -inline void AABTreeClass::CullNodeStruct::Set_Poly_Count(uint32 count) -{ - WWASSERT(count < 0x7FFFFFFF); - BackOrPolyCount = count; -} - -#endif diff --git a/Generals/Code/Libraries/Source/WWVegas/WW3D2/agg_def.cpp b/Generals/Code/Libraries/Source/WWVegas/WW3D2/agg_def.cpp deleted file mode 100644 index 4275e31188e..00000000000 --- a/Generals/Code/Libraries/Source/WWVegas/WW3D2/agg_def.cpp +++ /dev/null @@ -1,894 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** 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 *** - *********************************************************************************************** - * * - * Project Name : WW3D * - * * - * $Archive:: /Commando/Code/ww3d2/agg_def.cpp $* - * * - * Author:: Patrick Smith - * * - * $Modtime:: 4/05/01 10:21a $* - * * - * $Revision:: 5 $* - * * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - - -#include "agg_def.h" -#include "htree.h" -#include "w3derr.h" -#include "chunkio.h" -#include "wwdebug.h" -#include "assetmgr.h" -#include "matinfo.h" -#include "texture.h" -#include "wwstring.h" - -#include - - -/////////////////////////////////////////////////////////////////////////////////// -// -// Local constants -// -const char * const EMPTY_STRING = ""; - - -/////////////////////////////////////////////////////////////////////////////////// -// -// Global variable initialization -// -AggregateLoaderClass _AggregateLoader; - - -/////////////////////////////////////////////////////////////////////////////////// -// -// AggregateDefClass -// -AggregateDefClass::AggregateDefClass (void) - : m_pName (NULL) -{ - // Set our member data to default settings - ::memset (&m_Info, 0, sizeof (m_Info)); - ::memset (&m_MiscInfo, 0, sizeof (m_MiscInfo)); - m_MiscInfo.OriginalClassID = RenderObjClass::CLASSID_HLOD; - return ; -} - - -/////////////////////////////////////////////////////////////////////////////////// -// -// AggregateDefClass -// -AggregateDefClass::AggregateDefClass (const AggregateDefClass &src) - : m_pName (NULL) -{ - // Set our member data to default settings - ::memset (&m_Info, 0, sizeof (m_Info)); - ::memset (&m_MiscInfo, 0, sizeof (m_MiscInfo)); - m_MiscInfo.OriginalClassID = RenderObjClass::CLASSID_HLOD; - - // Invoke the assignment operator - (*this) = src; - return ; -} - - -/////////////////////////////////////////////////////////////////////////////////// -// -// AggregateDefClass -// -AggregateDefClass::AggregateDefClass (RenderObjClass &base_model) - : m_pName (NULL) -{ - // Set our member data to default settings - ::memset (&m_Info, 0, sizeof (m_Info)); - ::memset (&m_MiscInfo, 0, sizeof (m_MiscInfo)); - m_MiscInfo.OriginalClassID = RenderObjClass::CLASSID_HLOD; - - Initialize (base_model); - return ; -} - - -/////////////////////////////////////////////////////////////////////////////////// -// -// ~AggregateDefClass -// -AggregateDefClass::~AggregateDefClass (void) -{ - // Free the name buffer if necessary - if (m_pName != NULL) { - - // free() is used because the buffer was allocated with ::_strdup(). - ::free (m_pName); - m_pName = NULL; - } - - Free_Subobject_List (); - return ; -} - - -/////////////////////////////////////////////////////////////////////////////////// -// -// operator= -// -const AggregateDefClass & -AggregateDefClass::operator= (const AggregateDefClass &src) -{ - int index; - - // Free the name buffer if necessary - if (m_pName != NULL) { - ::free (m_pName); - m_pName = NULL; - } - - // Start with a fresh set of data - Free_Subobject_List (); - - // Copy the src object's name and info struct - Set_Name (src.Get_Name ()); - ::memcpy (&m_Info, &src.m_Info, sizeof (m_Info)); - ::memcpy (&m_MiscInfo, &src.m_MiscInfo, sizeof (m_MiscInfo)); - m_Version = src.m_Version; - - // Loop through all the entries in the src object's subobj list - for (index = 0; index < src.m_SubobjectList.Count (); index ++) { - W3dAggregateSubobjectStruct *pinfo = src.m_SubobjectList[index]; - if (pinfo != NULL) { - - // Copy the src object's info for this subobj - W3dAggregateSubobjectStruct *new_info = W3DNEW W3dAggregateSubobjectStruct; - ::memcpy (new_info, pinfo, sizeof (W3dAggregateSubobjectStruct)); - - // Add this subobj to our list - m_SubobjectList.Add (new_info); - } - } - - // Return a reference to ourselves - return *this; -} - - -/////////////////////////////////////////////////////////////////////////////////// -// -// Free_Subobject_List -// -void -AggregateDefClass::Free_Subobject_List (void) -{ - // Delete all the stucture pointers contained in the subobject list - for (int index = 0; index < m_SubobjectList.Count (); index ++) { - W3dAggregateSubobjectStruct *pinfo = m_SubobjectList[index]; - if (pinfo) { - delete pinfo; - } - } - - // Reset the lists contents - m_SubobjectList.Delete_All (); - return ; -} - - -/////////////////////////////////////////////////////////////////////////////////// -// -// Create -// -RenderObjClass * -AggregateDefClass::Create (void) -{ - // Attempt to create an instance of the hierarchy - RenderObjClass *pmodel = Create_Render_Object (m_Info.BaseModelName); - if (pmodel != NULL) { - - // Perform the aggregation - Attach_Subobjects (*pmodel); - - // Let the new object know what its new name and base name are. - pmodel->Set_Name (m_pName); - pmodel->Set_Base_Model_Name (m_Info.BaseModelName); - pmodel->Set_Sub_Objects_Match_LOD ((m_MiscInfo.Flags & W3D_AGGREGATE_FORCE_SUB_OBJ_LOD) == W3D_AGGREGATE_FORCE_SUB_OBJ_LOD); - - } else { - WWDEBUG_SAY (("Unable to load aggregate %s.\r\n", m_Info.BaseModelName)); - } - - // Return a pointer to the new aggregate - return pmodel; -} - - -/////////////////////////////////////////////////////////////////////////////////// -// -// Find_Subobject -// -RenderObjClass * -AggregateDefClass::Find_Subobject -( - RenderObjClass &model, - const char mesh_path[MESH_PATH_ENTRIES][MESH_PATH_ENTRY_LEN], - const char bone_path[MESH_PATH_ENTRIES][MESH_PATH_ENTRY_LEN] -) -{ - RenderObjClass *parent_model = &model; - parent_model->Add_Ref (); - - // Loop through all the models in our "path" until we've either failed - // or found the exact mesh we were looking for... - for (int index = 1; - (mesh_path[index][0] != 0) && (parent_model != NULL); - index ++) { - - // Look one level deeper into the subobject chain... - RenderObjClass *sub_obj = NULL; - if (bone_path[index][0] == 0) { - sub_obj = parent_model->Get_Sub_Object_By_Name (mesh_path[index]); - } else { - - int bone_index = parent_model->Get_Bone_Index (bone_path[index]); - int subobj_count = parent_model->Get_Num_Sub_Objects_On_Bone (bone_index); - - // Loop through all the subobjects on this bone - for (int subobj_index = 0; (subobj_index < subobj_count) && (sub_obj == NULL); subobj_index ++) { - - // Is this the subobject we were looking for? - RenderObjClass *ptemp_obj = parent_model->Get_Sub_Object_On_Bone (subobj_index, bone_index); - if (::lstrcmpi (ptemp_obj->Get_Name (), mesh_path[index]) == 0) { - sub_obj = ptemp_obj; - } else { - REF_PTR_RELEASE (ptemp_obj); - } - } - } - - REF_PTR_RELEASE (parent_model); - - // The parent for the next iteration is the subobject on this one. - parent_model = sub_obj; - } - - // Return a pointer to the subobject - return parent_model; -} - - -/////////////////////////////////////////////////////////////////////////////////// -// -// Attach_Subobjects -// -void -AggregateDefClass::Attach_Subobjects (RenderObjClass &base_model) -{ - // Now loop through all the subobjects and attach them to the appropriate bone - for (int index = 0; index < m_SubobjectList.Count (); index ++) { - W3dAggregateSubobjectStruct *psubobj_info = m_SubobjectList[index]; - if (psubobj_info != NULL) { - - // Now create this subobject and attach it to its bone. - RenderObjClass *prender_obj = Create_Render_Object (psubobj_info->SubobjectName); - if (prender_obj != NULL) { - - // Attach this object to the requested bone - if (base_model.Add_Sub_Object_To_Bone (prender_obj, psubobj_info->BoneName) == false) { - WWDEBUG_SAY (("Unable to attach %s to %s.\r\n", psubobj_info->SubobjectName, psubobj_info->BoneName)); - } - - // Release our hold on this pointer - prender_obj->Release_Ref (); - } else { - WWDEBUG_SAY (("Unable to load aggregate subobject %s.\r\n", psubobj_info->SubobjectName)); - } - } - } - - return ; -} - - -/////////////////////////////////////////////////////////////////////////////////// -// -// Create_Render_Object -// -RenderObjClass * -AggregateDefClass::Create_Render_Object (const char *passet_name) -{ - // Assume failure - RenderObjClass *prender_obj = NULL; - - // Attempt to get an instance of the render object from the asset manager - prender_obj = WW3DAssetManager::Get_Instance()->Create_Render_Obj (passet_name); - - // If we couldn't find the render object in the asset manager, then attempt to - // load it from file - if ((prender_obj == NULL) && - Load_Assets (passet_name)) { - - // It should be in the asset manager now, so attempt to get it again. - prender_obj = WW3DAssetManager::Get_Instance()->Create_Render_Obj (passet_name); - } - - // Return a pointer to the render object - return prender_obj; -} - - -/////////////////////////////////////////////////////////////////////////////////// -// -// Load_Assets -// -bool -AggregateDefClass::Load_Assets (const char *passet_name) -{ - // Assume failure - bool retval = false; - - // Param OK? - if (passet_name != NULL) { - - // Determine what the current working directory is - char path[MAX_PATH]; - ::GetCurrentDirectory (sizeof (path), path); - - // Ensure the path is directory delimited - if (path[::lstrlen(path)-1] != '\\') { - ::lstrcat (path, "\\"); - } - - // Assume the filename is simply the "asset name" + the w3d extension - ::lstrcat (path, passet_name); - ::lstrcat (path, ".w3d"); - - // If the file exists, then load it into the asset manager. - if (::GetFileAttributes (path) != 0xFFFFFFFF) { - retval = WW3DAssetManager::Get_Instance()->Load_3D_Assets (path); - } - } - - // Return the true/false result code - return retval; -} - - -/////////////////////////////////////////////////////////////////////////////////// -// -// Initialize -// -void -AggregateDefClass::Initialize (RenderObjClass &base_model) -{ - // Start with fresh lists - Free_Subobject_List (); - - // Determine what the render objects original name was. - const char *orig_model_name = base_model.Get_Base_Model_Name (); - orig_model_name = (orig_model_name == NULL) ? base_model.Get_Name () : orig_model_name; - - // Record information about this base model - ::lstrcpy (m_Info.BaseModelName, orig_model_name); - m_Info.SubobjectCount = 0; - m_MiscInfo.OriginalClassID = base_model.Class_ID (); - m_MiscInfo.Flags = 0; - m_MiscInfo.Flags |= base_model.Is_Sub_Objects_Match_LOD_Enabled () ? W3D_AGGREGATE_FORCE_SUB_OBJ_LOD : 0; - - - // Pass the aggregate name along - Set_Name (base_model.Get_Name ()); - - // Create a new instance of the model which we can use - // to compare with the supplied model and determine - // which 'bones-models' and textures are new. - RenderObjClass *pvanilla_model = (RenderObjClass *)Create_Render_Object (orig_model_name); - - // Build lists of changes from the delta between the original model and the provided one - Build_Subobject_List (*pvanilla_model, base_model); - - // Release the model if necessary - REF_PTR_RELEASE (pvanilla_model); - return ; -} - - - -/////////////////////////////////////////////////////////////////////////////////// -// -// Build_Subobject_List -// -void -AggregateDefClass::Build_Subobject_List -( - RenderObjClass &original_model, - RenderObjClass &model -) -{ - int index; - - // Loop through all the bones in this render obj - int bone_count = model.Get_Num_Bones (); - for (int bone_index = 0; bone_index < bone_count; bone_index ++) { - const char *pbone_name = model.Get_Bone_Name (bone_index); - - // Build a list of nodes that are contained in the vanilla model - DynamicVectorClass orig_node_list; - for (index = 0; - index < original_model.Get_Num_Sub_Objects_On_Bone (bone_index); - index ++) { - RenderObjClass *psubobj = original_model.Get_Sub_Object_On_Bone (index, bone_index); - if (psubobj != NULL) { - orig_node_list.Add (psubobj); - } - } - - // Build a list of nodes that are contained in this bone - DynamicVectorClass node_list; - for (index = 0; - index < model.Get_Num_Sub_Objects_On_Bone (bone_index); - index ++) { - RenderObjClass *psubobj = model.Get_Sub_Object_On_Bone (index, bone_index); - if (psubobj != NULL) { - node_list.Add (psubobj); - } - } - - int node_count = node_list.Count (); - if (node_count > 0) { - - // Loop through the subobjects and add each one to our internal list - W3dAggregateSubobjectStruct subobj_info = { 0 }; - for (int node_index = 0; node_index < node_count; node_index ++) { - RenderObjClass *psubobject = node_list[node_index]; - WWASSERT (psubobject != NULL); - - // Is this subobject new? (i.e. not in a 'vanilla' instance?) - const char *prototype_name = psubobject->Get_Name (); - if (psubobject != NULL && - (Is_Object_In_List (prototype_name, orig_node_list) == false)) { - - // Add this subobject to our list - ::lstrcpy (subobj_info.SubobjectName, prototype_name); - ::lstrcpy (subobj_info.BoneName, pbone_name); - Add_Subobject (subobj_info); - m_Info.SubobjectCount ++; - - // Attach this render object to the 'original' model (this is done - // so we can do texture compares later) - RenderObjClass *prender_obj = WW3DAssetManager::Get_Instance ()->Create_Render_Obj (prototype_name); - ((RenderObjClass &)original_model).Add_Sub_Object_To_Bone (prender_obj, pbone_name); - REF_PTR_RELEASE (prender_obj); - } - } - } - - // Free our hold on the render objs in the original node list - for (index = 0; index < orig_node_list.Count (); index ++) { - REF_PTR_RELEASE (orig_node_list[index]); - } - orig_node_list.Delete_All (); - - // Free our hold on the render objs in the node list - for (index = 0; index < node_list.Count (); index ++) { - REF_PTR_RELEASE (node_list[index]); - } - node_list.Delete_All (); - } - - return ; -} - - -/////////////////////////////////////////////////////////////////////////////////// -// -// Is_Object_In_List -// -bool -AggregateDefClass::Is_Object_In_List -( - const char *passet_name, - DynamicVectorClass &node_list -) -{ - // Assume failure - bool retval = false; - - // Loop through the nodes in the list until we've found the one - // were are looking for. - for (int node_index = 0; (node_index < node_list.Count ()) && (retval == false); node_index ++) { - RenderObjClass *prender_obj = node_list[node_index]; - - // Is this the render object we were looking for? - if (prender_obj != NULL && - ::lstrcmpi (prender_obj->Get_Name (), passet_name) == 0) { - retval = true; - } - } - - // Return the true/false result code - return retval; -} - - -/////////////////////////////////////////////////////////////////////////////////// -// -// Load -// -WW3DErrorType -AggregateDefClass::Load_W3D (ChunkLoadClass &chunk_load) -{ - W3dTextureReplacerHeaderStruct header = { 0 }; - - - while (chunk_load.Open_Chunk()) { - - WW3DErrorType error = WW3D_ERROR_OK; - - switch (chunk_load.Cur_Chunk_ID()) { - - case W3D_CHUNK_AGGREGATE_HEADER: - error = Read_Header(chunk_load); - break; - - case W3D_CHUNK_AGGREGATE_INFO: - error = Read_Info(chunk_load); - break; - - case W3D_CHUNK_TEXTURE_REPLACER_INFO: - if (chunk_load.Read (&header, sizeof (header)) == sizeof (header)) { - if (header.ReplacedTexturesCount > 0) { - WWDEBUG_SAY(("Obsolete texture replacement chunk encountered in aggregate: %s\r\n",m_pName)); - } - } - break; - - case W3D_CHUNK_AGGREGATE_CLASS_INFO: - error = Read_Class_Info(chunk_load); - break; - - default: - - // Unknown chunk. - break; - } - chunk_load.Close_Chunk(); - if (error != WW3D_ERROR_OK) return (error); - } - - return WW3D_ERROR_OK; -} - - -/////////////////////////////////////////////////////////////////////////////////// -// -// Read_Header -// -WW3DErrorType -AggregateDefClass::Read_Header (ChunkLoadClass &chunk_load) -{ - // Assume error - WW3DErrorType ret_val = WW3D_ERROR_LOAD_FAILED; - - // Is this the header chunk? - W3dAggregateHeaderStruct header = { 0 }; - if (chunk_load.Read (&header, sizeof (header)) == sizeof (header)) { - - // Copy the name from the header structure - m_pName = ::_strdup (header.Name); - m_Version = header.Version; - - // Success! - ret_val = WW3D_ERROR_OK; - } - - // Return the WW3D_ERROR_TYPE return code - return ret_val; -} - - -/////////////////////////////////////////////////////////////////////////////////// -// -// Read_Info -// -WW3DErrorType -AggregateDefClass::Read_Info (ChunkLoadClass &chunk_load) -{ - // Assume error - WW3DErrorType ret_val = WW3D_ERROR_LOAD_FAILED; - - // Read the chunk straight into our member structure - ::memset (&m_Info, 0, sizeof (m_Info)); - if (chunk_load.Read (&m_Info, sizeof (m_Info)) == sizeof (m_Info)) { - - // Success! - ret_val = WW3D_ERROR_OK; - - // Read all the subobjects from the file - for (UINT isubobject = 0; - (isubobject < m_Info.SubobjectCount) && (ret_val == WW3D_ERROR_OK); - isubobject ++) { - - // Read this subobject's definition from the file - ret_val = Read_Subobject (chunk_load); - } - } - - // Return the WW3D_ERROR_TYPE return code - return ret_val; -} - - -/////////////////////////////////////////////////////////////////////////////////// -// -// Read_Subobject -// -WW3DErrorType -AggregateDefClass::Read_Subobject (ChunkLoadClass &chunk_load) -{ - // Assume error - WW3DErrorType ret_val = WW3D_ERROR_LOAD_FAILED; - - // Read the subobject information from the file - W3dAggregateSubobjectStruct subobj_info = { 0 }; - if (chunk_load.Read (&subobj_info, sizeof (subobj_info)) == sizeof (subobj_info)) { - - // Add this subobject to our list - Add_Subobject (subobj_info); - - // Success! - ret_val = WW3D_ERROR_OK; - } - - // Return the WW3D_ERROR_TYPE return code - return ret_val; -} - - -/////////////////////////////////////////////////////////////////////////////////// -// -// Add_Subobject -// -void -AggregateDefClass::Add_Subobject (const W3dAggregateSubobjectStruct &subobj_info) -{ - // Create a new structure and copy the contents of the src - W3dAggregateSubobjectStruct *pnew_entry = W3DNEW W3dAggregateSubobjectStruct; - ::lstrcpy (pnew_entry->SubobjectName, subobj_info.SubobjectName); - ::lstrcpy (pnew_entry->BoneName, subobj_info.BoneName); - - // Add this new entry to the list - m_SubobjectList.Add (pnew_entry); - return ; -} - - -/////////////////////////////////////////////////////////////////////////////////// -// -// Read_Class_Info -// -WW3DErrorType -AggregateDefClass::Read_Class_Info (ChunkLoadClass &chunk_load) -{ - // Assume error - WW3DErrorType ret_val = WW3D_ERROR_LOAD_FAILED; - - // Read the chunk straight into our header structure - ::memset (&m_MiscInfo, 0, sizeof (m_MiscInfo)); - if (chunk_load.Read (&m_MiscInfo, sizeof (m_MiscInfo)) == sizeof (m_MiscInfo)) { - - // Success! - ret_val = WW3D_ERROR_OK; - } - - // Return the WW3D_ERROR_TYPE return code - return ret_val; -} - - -////////////////////////////////////////////////////////////////////////////////// -// -// Save -// -WW3DErrorType -AggregateDefClass::Save_W3D (ChunkSaveClass &chunk_save) -{ - // Assume error - WW3DErrorType ret_val = WW3D_ERROR_SAVE_FAILED; - - // Begin a chunk that identifies an aggregate - if (chunk_save.Begin_Chunk (W3D_CHUNK_AGGREGATE) == TRUE) { - - // Attempt to save the different sections of the aggregate definition - if ((Save_Header (chunk_save) == WW3D_ERROR_OK) && - (Save_Info (chunk_save) == WW3D_ERROR_OK) && - (Save_Class_Info (chunk_save) == WW3D_ERROR_OK)) { - - // Success! - ret_val = WW3D_ERROR_OK; - } - - // Close the aggregate chunk - chunk_save.End_Chunk (); - } - - // Return the WW3D_ERROR_TYPE return code - return ret_val; -} - - -/////////////////////////////////////////////////////////////////////////////////// -// -// Save_Header -// -WW3DErrorType -AggregateDefClass::Save_Header (ChunkSaveClass &chunk_save) -{ - // Assume error - WW3DErrorType ret_val = WW3D_ERROR_SAVE_FAILED; - - // Begin a chunk that identifies the aggregate - if (chunk_save.Begin_Chunk (W3D_CHUNK_AGGREGATE_HEADER) == TRUE) { - - // Fill the header structure - W3dAggregateHeaderStruct header = { 0 }; - header.Version = W3D_CURRENT_AGGREGATE_VERSION; - ::lstrcpyn (header.Name, m_pName, sizeof (header.Name)); - header.Name[sizeof (header.Name) - 1] = 0; - - // Write the header out to the chunk - if (chunk_save.Write (&header, sizeof (header)) == sizeof (header)) { - // Success! - ret_val = WW3D_ERROR_OK; - } - - // End the header chunk - chunk_save.End_Chunk (); - } - - // Return the WW3D_ERROR_TYPE return code - return ret_val; -} - - -/////////////////////////////////////////////////////////////////////////////////// -// -// Save_Info -// -WW3DErrorType -AggregateDefClass::Save_Info (ChunkSaveClass &chunk_save) -{ - // Assume error - WW3DErrorType ret_val = WW3D_ERROR_SAVE_FAILED; - - // Begin a chunk that identifies the aggregate settings - if (chunk_save.Begin_Chunk (W3D_CHUNK_AGGREGATE_INFO) == TRUE) { - - // Write the settings structure out to the chunk - if (chunk_save.Write (&m_Info, sizeof (m_Info)) == sizeof (m_Info)) { - // Success! - ret_val = WW3D_ERROR_OK; - - // Write all the subobjects to the file - for (int isubobject = 0; - (isubobject < m_SubobjectList.Count ()) && (ret_val == WW3D_ERROR_OK); - isubobject ++) { - - // Write this object to the file - ret_val = Save_Subobject (chunk_save, m_SubobjectList[isubobject]); - } - } - - // End the settings chunk - chunk_save.End_Chunk (); - } - - // Return the WW3D_ERROR_TYPE return code - return ret_val; -} - - -/////////////////////////////////////////////////////////////////////////////////// -// -// Save_Subobject -// -WW3DErrorType -AggregateDefClass::Save_Subobject -( - ChunkSaveClass &chunk_save, - W3dAggregateSubobjectStruct *psubobject -) -{ - // Assume error - WW3DErrorType ret_val = WW3D_ERROR_SAVE_FAILED; - - // Write the subobj structure out to the chunk - if (chunk_save.Write (psubobject, sizeof (W3dAggregateSubobjectStruct)) == sizeof (W3dAggregateSubobjectStruct)) { - - // Success! - ret_val = WW3D_ERROR_OK; - } - - // Return the WW3D_ERROR_TYPE return code - return ret_val; -} - - -///////////////////////////////////////////////////////////////////////////////// -// -// Save_Class_Info -// -WW3DErrorType -AggregateDefClass::Save_Class_Info (ChunkSaveClass &chunk_save) -{ - // Assume error - WW3DErrorType ret_val = WW3D_ERROR_SAVE_FAILED; - - // Begin a chunk that identifies the texture replacer header - if (chunk_save.Begin_Chunk (W3D_CHUNK_AGGREGATE_CLASS_INFO) == TRUE) { - - // Write the class information structure out to the chunk - if (chunk_save.Write (&m_MiscInfo, sizeof (m_MiscInfo)) == sizeof (m_MiscInfo)) { - - // Success! - ret_val = WW3D_ERROR_OK; - } - - // End the class info chunk - chunk_save.End_Chunk (); - } - - // Return the WW3D_ERROR_TYPE return code - return ret_val; -} - - -/////////////////////////////////////////////////////////////////////////////////// -// -// Load -// -PrototypeClass * -AggregateLoaderClass::Load_W3D (ChunkLoadClass &chunk_load) -{ - // Assume failure - AggregatePrototypeClass *pprototype = NULL; - - // Create a definition object - AggregateDefClass *pdefinition = W3DNEW AggregateDefClass; - if (pdefinition != NULL) { - - // Ask the definition object to load the aggregate data - if (pdefinition->Load_W3D (chunk_load) != WW3D_ERROR_OK) { - - // Error! Free the definition - delete pdefinition; - pdefinition = NULL; - } else { - - // Success! Create a prototype from the definition - pprototype = W3DNEW AggregatePrototypeClass (pdefinition); - } - } - - // Return a pointer to the prototype - return pprototype; -} - diff --git a/Generals/Code/Libraries/Source/WWVegas/WW3D2/agg_def.h b/Generals/Code/Libraries/Source/WWVegas/WW3D2/agg_def.h deleted file mode 100644 index 55f2bc3dd86..00000000000 --- a/Generals/Code/Libraries/Source/WWVegas/WW3D2/agg_def.h +++ /dev/null @@ -1,259 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** 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 *** - *********************************************************************************************** - * * - * Project Name : WW3D * - * * - * $Archive:: /Commando/Code/ww3d2/agg_def.h $* - * * - * Author:: Patrick Smith * - * * - * $Modtime:: 4/05/01 9:52a $* - * * - * $Revision:: 2 $* - * * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - - -#if defined(_MSC_VER) -#pragma once -#endif - -#ifndef AGGREGATE_DEF_H -#define AGGREGATE_DEF_H - -#include "proto.h" -#include "rendobj.h" -#include "w3d_file.h" -#include "w3derr.h" -#include "Vector.H" -#include "bittype.h" -#include - -#ifdef _UNIX -#include "osdep.h" -#endif - - -// Forward declarations -class ChunkLoadClass; -class ChunkSaveClass; -class IndirectTextureClass; - - -/////////////////////////////////////////////////////////////////////////////////// -// -// Macros -// -#ifndef SAFE_FREE -#define SAFE_FREE(pointer) \ -{ \ - if (pointer) { \ - ::free (pointer); \ - pointer = 0; \ - } \ -} - -#endif //SAFE_FREE - - -////////////////////////////////////////////////////////////////////////////////// -// -// AggregateDefClass -// -// Description of an aggregate object. Used by the asset manager -// to construct aggregates. An 'aggregate' is simply a 'shell' that -// contains references to a hierarchy model and subobjects to attach to its bones. -// -class AggregateDefClass -{ - public: - - /////////////////////////////////////////////////////////// - // - // Public constructors/destructors - // - AggregateDefClass (void); - AggregateDefClass (RenderObjClass &base_model); - AggregateDefClass (const AggregateDefClass &src); - virtual ~AggregateDefClass (void); - - - /////////////////////////////////////////////////////////// - // - // Public operators - // - const AggregateDefClass &operator= (const AggregateDefClass &src); - - /////////////////////////////////////////////////////////// - // - // Public methods - // - virtual WW3DErrorType Load_W3D (ChunkLoadClass &chunk_load); - virtual WW3DErrorType Save_W3D (ChunkSaveClass &chunk_save); - const char * Get_Name (void) const { return m_pName; } - void Set_Name (const char *pname) { SAFE_FREE (m_pName); m_pName = ::_strdup (pname); } - RenderObjClass * Create (void); - AggregateDefClass * Clone (void) const { return W3DNEW AggregateDefClass (*this); } - - // - // Public accessors - // - ULONG Class_ID (void) const { return m_MiscInfo.OriginalClassID; } - - // - // Initialization - // - void Initialize (RenderObjClass &base_model); - - protected: - - /////////////////////////////////////////////////////////// - // - // Protected data types - // - typedef struct _TEXTURE_INFO - { - W3dTextureReplacerStruct names; - IndirectTextureClass * pnew_texture; - - bool operator == (_TEXTURE_INFO &src) { return false; } - bool operator != (_TEXTURE_INFO &src) { return true; } - } TEXTURE_INFO; - - - /////////////////////////////////////////////////////////// - // - // Protected methods - // - - // - // Loading methods - // - virtual WW3DErrorType Read_Header (ChunkLoadClass &chunk_load); - virtual WW3DErrorType Read_Info (ChunkLoadClass &chunk_load); - virtual WW3DErrorType Read_Subobject (ChunkLoadClass &chunk_load); - virtual WW3DErrorType Read_Class_Info (ChunkLoadClass &chunk_load); - - // - // Saving methods - // - virtual WW3DErrorType Save_Header (ChunkSaveClass &chunk_save); - virtual WW3DErrorType Save_Info (ChunkSaveClass &chunk_save); - virtual WW3DErrorType Save_Subobject (ChunkSaveClass &chunk_save, W3dAggregateSubobjectStruct *psubobject); - virtual WW3DErrorType Save_Class_Info (ChunkSaveClass &chunk_save); - - // - // Creation methods - // - virtual void Attach_Subobjects (RenderObjClass &base_model); - - // - // Search methods - // - virtual RenderObjClass * Find_Subobject (RenderObjClass &model, const char mesh_path[MESH_PATH_ENTRIES][MESH_PATH_ENTRY_LEN], const char bone_path[MESH_PATH_ENTRIES][MESH_PATH_ENTRY_LEN]); - - // - // Misc. methods - // - virtual void Free_Subobject_List (void); - virtual void Add_Subobject (const W3dAggregateSubobjectStruct &subobj_info); - virtual bool Load_Assets (const char *asset_name); - virtual RenderObjClass *Create_Render_Object (const char *passet_name); - virtual bool Is_Object_In_List (const char *passet_name, DynamicVectorClass &node_list); - - virtual void Build_Subobject_List (RenderObjClass &original_model, RenderObjClass &model); - - - private: - - /////////////////////////////////////////////////////////// - // - // Private member data - // - DWORD m_Version; - DynamicVectorClass m_SubobjectList; - W3dAggregateInfoStruct m_Info; - W3dAggregateMiscInfo m_MiscInfo; - char * m_pName; -}; - - -/////////////////////////////////////////////////////////////////////////////////// -// -// AggregatePrototypeClass -// -class AggregatePrototypeClass : public W3DMPO, public PrototypeClass -{ - W3DMPO_GLUE(AggregatePrototypeClass) - public: - - /////////////////////////////////////////////////////////// - // - // Public constructors/destructors - // - AggregatePrototypeClass (AggregateDefClass *pdef) { m_pDefinition = pdef; } - - /////////////////////////////////////////////////////////// - // - // Public methods - // - virtual const char * Get_Name(void) const { return m_pDefinition->Get_Name (); } - virtual int Get_Class_ID(void) const { return m_pDefinition->Class_ID (); } - virtual RenderObjClass * Create (void) { return m_pDefinition->Create (); } - virtual void DeleteSelf() { delete this; } - virtual AggregateDefClass * Get_Definition (void) const { return m_pDefinition; } - virtual void Set_Definition (AggregateDefClass *pdef) { m_pDefinition = pdef; } - - protected: - virtual ~AggregatePrototypeClass (void) { delete m_pDefinition; } - - private: - - /////////////////////////////////////////////////////////// - // - // Private member data - // - AggregateDefClass * m_pDefinition; -}; - - -/////////////////////////////////////////////////////////////////////////////////// -// -// AggregateLoaderClass -// -class AggregateLoaderClass : public PrototypeLoaderClass -{ - public: - - virtual int Chunk_Type (void) { return W3D_CHUNK_AGGREGATE; } - virtual PrototypeClass * Load_W3D (ChunkLoadClass &chunk_load); -}; - - -/////////////////////////////////////////////////////////////////////////////////// -// -// Global variables -// -extern AggregateLoaderClass _AggregateLoader; - - -#endif //__AGGREGATE_DEF_H diff --git a/Generals/Code/Libraries/Source/WWVegas/WW3D2/animatedsoundmgr.cpp b/Generals/Code/Libraries/Source/WWVegas/WW3D2/animatedsoundmgr.cpp deleted file mode 100644 index 019a755a890..00000000000 --- a/Generals/Code/Libraries/Source/WWVegas/WW3D2/animatedsoundmgr.cpp +++ /dev/null @@ -1,566 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** 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 *** - *********************************************************************************************** - * * - * Project Name : ww3d2 * - * * - * $Archive:: /Commando/Code/ww3d2/animatedsoundmgr.cpp $* - * * - * Author:: Patrick Smith * - * * - * $Modtime:: 12/13/01 6:05p $* - * * - * $Revision:: 2 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -// -// MBL Update for CNC3 INCURSION - 10.23.2002 - Expanded param handling, Added STOP command -// - -#include // stricmp() -#include "animatedsoundmgr.h" -#include "INI.H" -#include "inisup.h" -#include "ffactory.h" -#include "WWFILE.H" -#include -#include "definition.h" -#include "definitionmgr.h" -#include "definitionclassids.h" -#include "WWAudio.h" -#include "AudibleSound.h" -#include "htree.h" -#include "hanim.h" -#include "soundlibrarybridge.h" - -#include "wwdebug.h" - -////////////////////////////////////////////////////////////////////// -// Static member initialization -////////////////////////////////////////////////////////////////////// -HashTemplateClass AnimatedSoundMgrClass::AnimationNameHash; -DynamicVectorClass AnimatedSoundMgrClass::AnimSoundLists; -SoundLibraryBridgeClass* AnimatedSoundMgrClass::SoundLibrary = NULL; - -////////////////////////////////////////////////////////////////////// -// Local inlines -////////////////////////////////////////////////////////////////////// -static WWINLINE INIClass * -Get_INI (const char *filename) -{ - INIClass *ini = NULL; - - // - // Get the file from our filefactory - // - FileClass *file = _TheFileFactory->Get_File (filename); - if (file) { - - // - // Create the INI object - // - if (file->Is_Available ()) { - ini = new INIClass (*file); - } - - // - // Close the file - // - _TheFileFactory->Return_File (file); - } - - return ini; -} - -static int -Build_List_From_String -( - const char * buffer, - const char * delimiter, - StringClass ** string_list -) -{ - int count = 0; - - WWASSERT (buffer != NULL); - WWASSERT (delimiter != NULL); - WWASSERT (string_list != NULL); - if ((buffer != NULL) && - (delimiter != NULL) && - (string_list != NULL)) - { - int delim_len = ::strlen (delimiter); - - // - // Determine how many entries there will be in the list - // - const char *entry = buffer; - for (; - (entry != NULL) && (entry[1] != 0); - entry = ::strstr (entry, delimiter)) - { - - // - // Move past the current delimiter (if necessary) - // - if ((::strnicmp (entry, delimiter, delim_len) == 0) && (count > 0)) { - entry += delim_len; - } - - // Increment the count of entries - count ++; - } - - if (count > 0) { - - // - // Allocate enough StringClass objects to hold all the strings in the list - // - (*string_list) = new StringClass[count]; - - // - // Parse the string and pull out its entries. - // - count = 0; - for (entry = buffer; - (entry != NULL) && (entry[1] != 0); - entry = ::strstr (entry, delimiter)) - { - - // - // Move past the current delimiter (if necessary) - // - if ((::strnicmp (entry, delimiter, delim_len) == 0) && (count > 0)) { - entry += delim_len; - } - - // - // Copy this entry into its own string - // - StringClass entry_string = entry; - char *delim_start = ::strstr (entry_string.Peek_Buffer(), delimiter); - if (delim_start != NULL) { - delim_start[0] = 0; - } - - // - // Add this entry to our list - // - if ((entry_string.Get_Length () > 0) || (count == 0)) { - (*string_list)[count++] = entry_string; - } - } - - } else if (delim_len > 0) { - count = 1; - (*string_list) = new StringClass[count]; - (*string_list)[0] = buffer; - } - - } - - // - // Return the number of entries in our list - // - return count; -} - - -static bool -Is_In_Param_List -( - StringClass *param_list, - int param_count, - const char *param_to_check -) -{ - // - // Check incoming parameters - // - WWASSERT( param_list != NULL ); - if ( param_list == NULL ) - { - return( false ); - } - WWASSERT( param_count >= 2 ); - if ( param_count < 2 ) - { - return( false ); - } - WWASSERT( param_to_check != NULL ); - if ( param_to_check == NULL ) - { - return( false ); - } - - // - // Note: params 0 & 1 are fixed to frame and name... - // - for ( int param_index = 2; param_index < param_count; param_index ++ ) - { - { - StringClass string = param_list[ param_index ]; - - // OutputDebugString( "MBL: Comparing " ); - // OutputDebugString( string.Peek_Buffer() ); - // OutputDebugString( " with " ); - // OutputDebugString( param_to_check ); - // OutputDebugString( "\n" ); - - // if ( stricmp( string.Peek_Buffer(), param_to_check ) == 0 ) // Breaks with whitespaces - if ( strstr( string.Peek_Buffer(), param_to_check ) != 0 ) - { - return( true ); - } - } - } - - return( false ); -} - -////////////////////////////////////////////////////////////////////// -// -// Initialize -// -////////////////////////////////////////////////////////////////////// -void -AnimatedSoundMgrClass::Initialize (const char *ini_filename) -{ - // - // Don't re-initialize... - // - if (AnimSoundLists.Count () > 0) { - return ; - } - - const char *DEFAULT_INI_FILENAME = "w3danimsound.ini"; - - // - // Determine which filename to use - // - const char *filename_to_use = ini_filename; - if (filename_to_use == NULL) { - filename_to_use = DEFAULT_INI_FILENAME; - } - - // - // Get the INI file which contains the data for this viewer - // - INIClass *ini_file = ::Get_INI (filename_to_use); - if (ini_file != NULL) { - - // - // Loop over all the sections in the INI - // - List §ion_list = ini_file->Get_Section_List (); - for ( INISection *section = section_list.First (); - section != NULL && section->Is_Valid (); - section = section->Next_Valid ()) - { - // - // Get the animation name from the section name - // - StringClass animation_name = section->Section; - ::strupr (animation_name.Peek_Buffer ()); - - // OutputDebugString( "MBL Section / animation: " ); - // OutputDebugString( animation_name.Peek_Buffer() ); - // OutputDebugString( "\n" ); - - // - // Allocate a sound list - // - ANIM_SOUND_LIST *sound_list = new ANIM_SOUND_LIST; - - // - // Loop over all the entries in this section - // - int entry_count = ini_file->Entry_Count (section->Section); - - for (int entry_index = 0; entry_index < entry_count; entry_index ++) { - StringClass value; - - // - // Get the data associated with this entry - // - const char *entry_name = ini_file->Get_Entry (section->Section, entry_index); - - // OutputDebugString( " MBL Entry name: " ); - // OutputDebugString( entry_name ); - // OutputDebugString( "\n" ); - - if (strcmp(entry_name, "BoneName") == 0) { - ini_file->Get_String (value, section->Section, entry_name); - sound_list->BoneName = value; - - // OutputDebugString( " MBL (BoneName) entry line value: " ); - // OutputDebugString( value.Peek_Buffer() ); - // OutputDebugString( "\n" ); - - } else { - ini_file->Get_String (value, section->Section, entry_name); - - // OutputDebugString( " MBL (not BoneName) entry line value: " ); - // OutputDebugString( value.Peek_Buffer() ); - // OutputDebugString( "\n" ); - - // - // Extract the parameters from the section - // - int len = value.Get_Length (); - StringClass definition_name (len + 1, true); - int action_frame = 0; - - // - // Separate the parameters into an easy-to-handle data structure - // - StringClass *param_list = NULL; - int param_count = ::Build_List_From_String (value, ",", ¶m_list); - - // if ((param_count >= 2) && (param_count <= 3)) - { - action_frame = ::atoi (param_list[0]); - definition_name = param_list[1]; - definition_name.Trim (); - - // - // Tie the relevant information together and store it - // in the list of sounds for this animation - // - ANIM_SOUND_INFO* sound_info = new ANIM_SOUND_INFO; - sound_info->Frame = action_frame; - sound_info->SoundName = definition_name; - - // - // "2D" check - // - // if ((param_count == 3) && (atoi(param_list[2]) == 2)) { - // sound_info->Is2D = true; - // } - // - sound_info->Is2D = false; - if ( Is_In_Param_List( param_list, param_count, "2D" ) ) - { - sound_info->Is2D = true; - } - - // - // "STOP" check - // - sound_info->IsStop = false; - if ( Is_In_Param_List( param_list, param_count, "STOP" ) ) - { - sound_info->IsStop = true; - } - - sound_list->Add_Sound_Info (sound_info); - delete [] param_list; - } - } - } - - if (sound_list->List.Count () != 0) { - - // - // Add this sound list to our hash-table and vector-array - // - AnimationNameHash.Insert (animation_name, sound_list); - AnimSoundLists.Add (sound_list); - - } else { - //WWDEBUG_SAY (("AnimatedSoundMgrClass::Initialize -- No sounds added for %d!\n", animation_name.Peek_Buffer ())); - delete sound_list; - } - } - - delete ini_file; - } - - return ; -} - - -////////////////////////////////////////////////////////////////////// -// -// Shutdown -// -////////////////////////////////////////////////////////////////////// -void -AnimatedSoundMgrClass::Shutdown (void) -{ - // - // Reset the animation name hash - // - AnimationNameHash.Remove_All (); - - // - // Free each of the sound objects - // - for (int index = 0; index < AnimSoundLists.Count (); index ++) { - /* - ANIM_SOUND_LIST* list = AnimSoundLists[index]; - for (int i = 0; i < list->Count(); i++) { - delete (*list)[i]; - } - */ - delete AnimSoundLists[index]; - } - - AnimSoundLists.Delete_All (); - return ; -} - - -////////////////////////////////////////////////////////////////////// -// -// Does_Animation_Have_Embedded_Sounds -// -////////////////////////////////////////////////////////////////////// -const char* -AnimatedSoundMgrClass::Get_Embedded_Sound_Name (HAnimClass *anim) -{ - if (anim == NULL) { - return NULL; - } - ANIM_SOUND_LIST* list = Find_Sound_List (anim); - if (list == NULL) { - return NULL; - } - - return list->BoneName.Peek_Buffer(); -} - - - -////////////////////////////////////////////////////////////////////// -// -// Find_Sound_List -// -////////////////////////////////////////////////////////////////////// -AnimatedSoundMgrClass::ANIM_SOUND_LIST * -AnimatedSoundMgrClass::Find_Sound_List (HAnimClass *anim) -{ - // - // Build the full name of the animation - // - StringClass full_name (0, true); - full_name = anim->Get_Name (); - - // - // Make the name uppercase - // - ::strupr (full_name.Peek_Buffer ()); - - // - // Lookup the sound list for this animation - // - ANIM_SOUND_LIST *retval = AnimationNameHash.Get (full_name); - return retval; -} - - -////////////////////////////////////////////////////////////////////// -// -// Trigger_Sound -// -////////////////////////////////////////////////////////////////////// -float -AnimatedSoundMgrClass::Trigger_Sound -( - HAnimClass * anim, - float old_frame, - float new_frame, - const Matrix3D & tm -) -{ - if ((SoundLibrary == NULL) || (anim == NULL)) { - return old_frame; - } - - float retval = old_frame; - -#ifndef W3D_MAX4 - // - // Lookup the sound list for this animation - // - ANIM_SOUND_LIST *sound_list = Find_Sound_List (anim); - if (sound_list != NULL) { - - for (int index = 0; index < sound_list->List.Count (); index ++) { - int frame = sound_list->List[index]->Frame; - - // - // Is the animation passing the frame we need? - // - if ((old_frame < frame) && (new_frame >= frame)) { - - // - // Don't trigger the sound if its skipped too far past... - // - //if (WWMath::Fabs (new_frame - old_frame) < 3.0F) { - - // - // Stop the audio? - // - if (sound_list->List[index]->IsStop == true) - { - // - // Stop the audio - // - SoundLibrary->Stop_Playing_Audio( sound_list->List[index]->SoundName.Peek_Buffer() ); - } - else - { - // - // Play the audio - // - if (sound_list->List[index]->Is2D == true) - { - SoundLibrary->Play_2D_Audio(sound_list->List[index]->SoundName.Peek_Buffer()); - } - else - { - SoundLibrary->Play_3D_Audio(sound_list->List[index]->SoundName.Peek_Buffer(), tm); - } - } - - //WWDEBUG_SAY (("Triggering Sound %d %s\n", GetTickCount (), sound_list->List[index]->SoundName)); - - retval = frame; - - //} - } - - } - - //retval = true; - } -#endif - - return retval; -} - -void AnimatedSoundMgrClass::Set_Sound_Library(SoundLibraryBridgeClass* library) -{ - SoundLibrary = library; -} diff --git a/Generals/Code/Libraries/Source/WWVegas/WW3D2/animatedsoundmgr.h b/Generals/Code/Libraries/Source/WWVegas/WW3D2/animatedsoundmgr.h deleted file mode 100644 index 4627227d38e..00000000000 --- a/Generals/Code/Libraries/Source/WWVegas/WW3D2/animatedsoundmgr.h +++ /dev/null @@ -1,136 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** 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 *** - *********************************************************************************************** - * * - * Project Name : ww3d2 * - * * - * $Archive:: /Commando/Code/ww3d2/animatedsoundmgr.h $* - * * - * Author:: Patrick Smith * - * * - * $Modtime:: 12/13/01 6:05p $* - * * - * $Revision:: 2 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -// -// MBL Update for CNC3 INCURSION - 10.23.2002 - Expanded param handling, Added STOP command -// - -#if defined(_MSC_VER) -#pragma once -#endif - -#ifndef __ANIMATEDSOUNDMGR_H -#define __ANIMATEDSOUNDMGR_H - -#include "simplevec.h" -#include "Vector.H" -#include "hashtemplate.h" - - -////////////////////////////////////////////////////////////////////// -// Forward declarations -////////////////////////////////////////////////////////////////////// -class HTreeClass; -class HAnimClass; -class Matrix3D; -class SoundLibraryBridgeClass; - -////////////////////////////////////////////////////////////////////// -// -// AnimatedSoundMgrClass -// -////////////////////////////////////////////////////////////////////// -class AnimatedSoundMgrClass -{ -public: - - /////////////////////////////////////////////////////////////////// - // Public methods - /////////////////////////////////////////////////////////////////// - - // - // Initialization and shutdown - // - static void Initialize (const char *ini_filename = NULL); - static void Shutdown (void); - - // - // Sound playback - // - static const char* Get_Embedded_Sound_Name (HAnimClass *anim); - static float Trigger_Sound (HAnimClass *anim, float old_frame, float new_frame, const Matrix3D &tm); - - // Bridges E&B code with WW3D. - static void Set_Sound_Library(SoundLibraryBridgeClass* library); - -private: - - /////////////////////////////////////////////////////////////////// - // Private data types - /////////////////////////////////////////////////////////////////// - struct AnimSoundInfo - { - AnimSoundInfo() : Frame(0), SoundName(), Is2D(false), IsStop(false) {} - int Frame; - StringClass SoundName; - bool Is2D; - bool IsStop; - }; - - typedef AnimSoundInfo ANIM_SOUND_INFO; - - struct AnimSoundList - { - AnimSoundList() : List(), BoneName("root") {} - ~AnimSoundList() - { - for (int i = 0; i < List.Count(); i++) { - delete List[i]; - } - } - void Add_Sound_Info(ANIM_SOUND_INFO* info) {List.Add(info);} - - SimpleDynVecClass List; - StringClass BoneName; - }; - - typedef AnimSoundList ANIM_SOUND_LIST; - - /////////////////////////////////////////////////////////////////// - // Private member data - /////////////////////////////////////////////////////////////////// - static HashTemplateClass AnimationNameHash; - static DynamicVectorClass AnimSoundLists; - - static SoundLibraryBridgeClass* SoundLibrary; - - /////////////////////////////////////////////////////////////////// - // Private methods - /////////////////////////////////////////////////////////////////// - static ANIM_SOUND_LIST * Find_Sound_List (HAnimClass *anim); -}; - - -#endif //__ANIMATEDSOUNDMGR_H diff --git a/Generals/Code/Libraries/Source/WWVegas/WW3D2/bitmaphandler.cpp b/Generals/Code/Libraries/Source/WWVegas/WW3D2/bitmaphandler.cpp deleted file mode 100644 index f64bc8300e2..00000000000 --- a/Generals/Code/Libraries/Source/WWVegas/WW3D2/bitmaphandler.cpp +++ /dev/null @@ -1,448 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -#include "bitmaphandler.h" -#include "wwdebug.h" -#include "colorspace.h" - -void Bitmap_Assert(bool condition) -{ - WWASSERT(condition); -} - -void BitmapHandlerClass::Create_Mipmap_B8G8R8A8( - unsigned char* dest_surface, - unsigned dest_surface_pitch, - unsigned char* src_surface, - unsigned src_surface_pitch, - unsigned width, - unsigned height) -{ - unsigned src_pitch=src_surface_pitch/4; - for (unsigned y=0;y1 ) ? 63 : 127; - - switch(dest_surface_format) { - case WW3D_FORMAT_U8V8: - *dest_ptr++ = (unsigned char)iDu; - *dest_ptr++ = (unsigned char)iDv; - break; - - case WW3D_FORMAT_L6V5U5: - *(unsigned short*)dest_ptr = (unsigned short)( ( (iDu>>3) & 0x1f ) << 0 ); - *(unsigned short*)dest_ptr |= (unsigned short)( ( (iDv>>3) & 0x1f ) << 5 ); - *(unsigned short*)dest_ptr |= (unsigned short)( ( ( uL>>2) & 0x3f ) << 10 ); - dest_ptr += 2; - break; - - case WW3D_FORMAT_X8L8V8U8: - *dest_ptr++ = (unsigned char)iDu; - *dest_ptr++ = (unsigned char)iDv; - *dest_ptr++ = (unsigned char)uL; - *dest_ptr++ = (unsigned char)0L; - break; - - default: - WWASSERT(0); // Unknown bumpmap format - break; - } - - // Move one pixel to the left (src is 32-bpp) - src_ptr_mid+=src_bpp; - src_ptr_prev_line+=src_bpp; - src_ptr_next_line+=src_bpp; - } - } - return; - } - - bool has_hsv_shift = hsv_shift[0]!=0.0f || hsv_shift[1]!=0.0f || hsv_shift[2]!=0.0f; - if (src_surface_format==dest_surface_format && (src_surface_format==WW3D_FORMAT_A8R8G8B8 || src_surface_format==WW3D_FORMAT_X8R8G8B8)) { - // One-to-one copy or scaling? - dest_surface_pitch/=4; - src_surface_pitch/=4; - if (dest_surface_width==src_surface_width && dest_surface_height==src_surface_height) { - // Generate the next mip level while copying the current surface? - if (generate_mip_level) { - if (dest_surface_width==1) { - unsigned b8g8r8a8=*(unsigned*)src_surface; - if (has_hsv_shift) Recolor(b8g8r8a8,hsv_shift); - *(unsigned*)dest_surface=b8g8r8a8; - } - else { - for (unsigned y=0;y. -*/ - -#if defined(_MSC_VER) -#pragma once -#endif - -#ifndef BITMAPHANDLER_H -#define BITMAPHANDLER_H - -#include "always.h" -#include "ww3dformat.h" -#include "vector3.h" -#include "colorspace.h" - -void Bitmap_Assert(bool condition); - -class BitmapHandlerClass -{ -public: - // Read pixel at given address - WWINLINE static void Read_B8G8R8A8( - unsigned char* argb, - const unsigned char* src_ptr, - WW3DFormat src_format, - const unsigned char* palette, - unsigned palette_bpp); - - // Read pixel at given address - WWINLINE static void Read_B8G8R8A8( - unsigned& argb, - const unsigned char* src_ptr, - WW3DFormat src_format, - const unsigned char* palette, - unsigned palette_bpp); - - // Read pixel from surface - WWINLINE static void Read_B8G8R8A8( - unsigned& argb, - const unsigned char* src_ptr, - WW3DFormat src_format, - int x, - int y, - int width, - int height, - const unsigned char* palette, - unsigned palette_bpp); - - WWINLINE static void Write_B8G8R8A8( - unsigned char* dest_ptr, - WW3DFormat dest_format, - const unsigned char* argb); - - WWINLINE static void Write_B8G8R8A8( - unsigned char* dest_ptr, - WW3DFormat dest_format, - const unsigned& argb); - - WWINLINE static void Copy_Pixel( - unsigned char* dest_ptr, - WW3DFormat dest_format, - const unsigned char* src_ptr, - WW3DFormat src_format, - const unsigned char* palette, - unsigned palette_bpp); - - WWINLINE static void Copy_Pixel( - unsigned char* dest_ptr, - WW3DFormat dest_format, - const unsigned char* src_ptr, - WW3DFormat src_format, - const unsigned char* palette, - unsigned palette_bpp, - const Vector3& hsv_shift); - - WWINLINE static unsigned Combine_A8R8G8B8( - unsigned bgra1, - unsigned bgra2, - unsigned bgra3, - unsigned bgra4); - - static void Create_Mipmap_B8G8R8A8( - unsigned char* dest_surface, - unsigned dest_surface_pitch, - unsigned char* src_surface, - unsigned src_surface_pitch, - unsigned width, - unsigned height); - - static void Copy_Image_Generate_Mipmap( - unsigned width, - unsigned height, - unsigned char* dest_surface, - unsigned dest_pitch, - WW3DFormat dest_format, - unsigned char* src_surface, - unsigned src_pitch, - WW3DFormat src_format, - unsigned char* mip_surface, - unsigned mip_pitch, - const Vector3& hsv_shift=Vector3(0.0f,0.0f,0.0f)); - - static void Copy_Image( - unsigned char* dest_surface, - unsigned dest_surface_width, - unsigned dest_surface_height, - unsigned dest_surface_pitch, - WW3DFormat dest_surface_format, - unsigned char* src_surface, - unsigned src_surface_width, - unsigned src_surface_height, - unsigned src_surface_pitch, - WW3DFormat src_surface_format, - const unsigned char* src_palette, - unsigned src_palette_bpp, - bool generate_mip_level, - const Vector3& hsv_shift=Vector3(0.0f,0.0f,0.0f)); - -}; - -// ---------------------------------------------------------------------------- -// -// Read color value of given type in BGRA (D3D) byte order. Regarless -// of the source format the color value is converted to 32-bit format. -// -// ---------------------------------------------------------------------------- - -WWINLINE void BitmapHandlerClass::Read_B8G8R8A8( - unsigned char* argb, - const unsigned char* src_ptr, - WW3DFormat src_format, - const unsigned char* palette, - unsigned palette_bpp) -{ - switch (src_format) { - case WW3D_FORMAT_A8R8G8B8: - case WW3D_FORMAT_X8R8G8B8: - *(unsigned*)argb=*(unsigned*)src_ptr; - break; - case WW3D_FORMAT_R8G8B8: - *argb++=src_ptr[0]; - *argb++=src_ptr[1]; - *argb++=src_ptr[2]; - *argb++=0xff; - break; - case WW3D_FORMAT_A4R4G4B4: - { - unsigned short tmp; - tmp=*(unsigned short*)src_ptr; - *argb++=((tmp&0x000f)<<4); - *argb++=((tmp&0x00f0)); - *argb++=((tmp&0x0f00)>>4); - *argb++=((tmp&0xf000)>>8); - } - break; - case WW3D_FORMAT_A1R5G5B5: - { - unsigned short tmp; - tmp=*(unsigned short*)src_ptr; - argb[3]=tmp&0x8000 ? 0xff : 0x0; - argb[2]=(tmp>>7)&0xf8; - argb[1]=(tmp>>2)&0xf8; - argb[0]=(tmp<<3)&0xf8; - } - break; - case WW3D_FORMAT_R5G6B5: - { - unsigned short tmp; - tmp=*(unsigned short*)src_ptr; - argb[3]=0xff; - argb[2]=(tmp>>8)&0xf8; - argb[1]=(tmp>>3)&0xfc; - argb[0]=(tmp<<3)&0xf8; - } - break; - case WW3D_FORMAT_R3G3B2: - { - unsigned char tmp=*src_ptr; - argb[3]=0xff; - argb[2]=tmp&0xe0; - argb[1]=(tmp<<3)&0xe0; - argb[0]=(tmp<<6)&0xc0; - } - break; - case WW3D_FORMAT_L8: - { - unsigned char tmp=*src_ptr++; - *argb++=tmp; - *argb++=tmp; - *argb++=tmp; - *argb++=0xff; - } - break; - case WW3D_FORMAT_A8: - { - *argb++=0; - *argb++=0; - *argb++=0; - *argb++=*src_ptr++; - } - break; - case WW3D_FORMAT_P8: - { - unsigned char index=*src_ptr++; - switch (palette_bpp) { - case 4: - *argb++=palette[palette_bpp*index+3]; - *argb++=palette[palette_bpp*index+2]; - *argb++=palette[palette_bpp*index+1]; - *argb++=palette[palette_bpp*index+0]; - break; - case 3: - *argb++=palette[palette_bpp*index+2]; - *argb++=palette[palette_bpp*index+1]; - *argb++=palette[palette_bpp*index+0]; - *argb++=0xff; - break; - case 2: - case 1: - default: - Bitmap_Assert(0); - break; - } - } - break; - case WW3D_FORMAT_DXT1: - case WW3D_FORMAT_DXT2: - case WW3D_FORMAT_DXT3: - case WW3D_FORMAT_DXT4: - case WW3D_FORMAT_DXT5: - default: Bitmap_Assert(0); break; - } -} - -WWINLINE void BitmapHandlerClass::Read_B8G8R8A8( - unsigned& argb, - const unsigned char* src_ptr, - WW3DFormat src_format, - const unsigned char* palette, - unsigned palette_bpp) -{ - Read_B8G8R8A8((unsigned char*)&argb,src_ptr,src_format,palette,palette_bpp); -} - -// Read pixel from surface -WWINLINE void BitmapHandlerClass::Read_B8G8R8A8( - unsigned& argb, - const unsigned char* src_ptr, - WW3DFormat src_format, - int x, - int y, - int width, - int height, - const unsigned char* palette, - unsigned palette_bpp) -{ - if (x<0 || y<0 || x>=width || y>=height) { - argb=0; - return; - } - - unsigned bpp=Get_Bytes_Per_Pixel(src_format); - Read_B8G8R8A8( - argb, - src_ptr+bpp*x+width*bpp*y, - src_format, - palette, - palette_bpp); -} - - -// ---------------------------------------------------------------------------- -// -// Write color value of given type in BGRA (D3D) byte order. The source value -// is always 32 bit and it is converted to defined destination format. -// -// ---------------------------------------------------------------------------- - -WWINLINE void BitmapHandlerClass::Write_B8G8R8A8( - unsigned char* dest_ptr, - WW3DFormat dest_format, - const unsigned char* argb) -{ - switch (dest_format) { - case WW3D_FORMAT_A8R8G8B8: - case WW3D_FORMAT_X8R8G8B8: - *(unsigned*)dest_ptr=*(unsigned*)argb; - break; - case WW3D_FORMAT_R8G8B8: - *dest_ptr++=*argb++; - *dest_ptr++=*argb++; - *dest_ptr++=*argb++; - break; - case WW3D_FORMAT_A4R4G4B4: - { - unsigned short tmp; - tmp=((argb[3])&0xf0)<<8; - tmp|=((argb[2])&0xf0)<<4; - tmp|=((argb[1])&0xf0); - tmp|=((argb[0])&0xf0)>>4; - *(unsigned short*)dest_ptr=tmp; - } - break; - case WW3D_FORMAT_A1R5G5B5: - { - unsigned short tmp; - tmp=argb[3] ? 0x8000 : 0x0; - tmp|=((argb[2])&0xf8)<<7; - tmp|=((argb[1])&0xf8)<<2; - tmp|=((argb[0])&0xf8)>>3; - *(unsigned short*)dest_ptr=tmp; - } - break; - case WW3D_FORMAT_R5G6B5: - { - unsigned short tmp; - tmp=((argb[2])&0xf8)<<8; - tmp|=((argb[1])&0xfc)<<3; - tmp|=((argb[0])&0xf8)>>3; - *(unsigned short*)dest_ptr=tmp; - } - break; - case WW3D_FORMAT_R3G3B2: - { - unsigned char tmp; - tmp=((argb[2])&0xe0); - tmp|=((argb[1])&0xe0)>>3; - tmp|=((argb[0])&0xc0)>>6; - *(unsigned short*)dest_ptr=tmp; - } - break; - case WW3D_FORMAT_L8: - { - // CIE Req. 709: Y709 = 0.2125R + 0.7154G + 0.0721B - unsigned char tmp = (unsigned char) ( ( - ((unsigned int)argb[0] * (unsigned int)0x1275) + // 0.0721B - ((unsigned int)argb[1] * (unsigned int)0xB725) + // 0.7154G (rounded up so FF, FF, FF becomes FF) - ((unsigned int)argb[2] * (unsigned int)0x3666) // 0.2125R - ) >> 16); - *dest_ptr++=tmp; - } - break; - case WW3D_FORMAT_A8: - { - *dest_ptr++=*argb++; - } - break; - case WW3D_FORMAT_DXT1: - case WW3D_FORMAT_DXT2: - case WW3D_FORMAT_DXT3: - case WW3D_FORMAT_DXT4: - case WW3D_FORMAT_DXT5: - case WW3D_FORMAT_P8: // Paletted destination not supported - default: Bitmap_Assert(0); break; - } -} - -WWINLINE void BitmapHandlerClass::Write_B8G8R8A8( - unsigned char* dest_ptr, - WW3DFormat dest_format, - const unsigned& argb) -{ - Write_B8G8R8A8(dest_ptr,dest_format,(unsigned char*)&argb); -} - -// ---------------------------------------------------------------------------- -// -// Copy pixel. Perform color space conversion if needed. The source and -// destination are always D3D-style BGRA. -// -// ---------------------------------------------------------------------------- - -WWINLINE void BitmapHandlerClass::Copy_Pixel( - unsigned char* dest_ptr, - WW3DFormat dest_format, - const unsigned char* src_ptr, - WW3DFormat src_format, - const unsigned char* palette, - unsigned palette_bpp) -{ - // Color space conversion needed? - - if (dest_format==src_format) { - switch (dest_format) { - case WW3D_FORMAT_A8R8G8B8: - case WW3D_FORMAT_X8R8G8B8: - *(unsigned*)dest_ptr=*(unsigned*)src_ptr; - break; - case WW3D_FORMAT_R8G8B8: - *dest_ptr++=src_ptr[0]; - *dest_ptr++=src_ptr[1]; - *dest_ptr++=src_ptr[2]; - break; - case WW3D_FORMAT_A4R4G4B4: - { - unsigned short tmp=*(unsigned short*)src_ptr; - *(unsigned short*)dest_ptr=((tmp&0x000f)<<12)|((tmp&0x00f0)<<4)|((tmp&0x0f00)>>4)|((tmp&0xf000)>>12); - } - break; - case WW3D_FORMAT_A1R5G5B5: - { - unsigned short tmp=*(unsigned short*)src_ptr; - *(unsigned short*)dest_ptr=((tmp&0x001f)<<11)|((tmp&0x03e0)<<1)|((tmp&0x7c00)>>9)|((tmp&0x8000)>>15); - } - break; - case WW3D_FORMAT_R5G6B5: - { - unsigned short tmp=*(unsigned short*)src_ptr; - *(unsigned short*)dest_ptr=((tmp&0x001f)<<11)|(tmp&0x07e0)|((tmp&0xf800)>>11); - } - break; - case WW3D_FORMAT_R3G3B2: - case WW3D_FORMAT_L8: - case WW3D_FORMAT_A8: *dest_ptr++=*src_ptr++; - break; - case WW3D_FORMAT_P8: // Paletted destinations not supported - default: Bitmap_Assert(0); break; - } - } - else { - unsigned b8g8r8a8; - Read_B8G8R8A8(b8g8r8a8,src_ptr,src_format,palette,palette_bpp); - Write_B8G8R8A8(dest_ptr,dest_format,b8g8r8a8); - } -} - -// ---------------------------------------------------------------------------- -// -// Copy pixel with HSV shift. The source and destination are always D3D-style BGRA. -// -// ---------------------------------------------------------------------------- - -WWINLINE void BitmapHandlerClass::Copy_Pixel( - unsigned char* dest_ptr, - WW3DFormat dest_format, - const unsigned char* src_ptr, - WW3DFormat src_format, - const unsigned char* palette, - unsigned palette_bpp, - const Vector3& hsv_shift) -{ - unsigned b8g8r8a8; - Read_B8G8R8A8(b8g8r8a8,src_ptr,src_format,palette,palette_bpp); - Recolor(b8g8r8a8,hsv_shift); - Write_B8G8R8A8(dest_ptr,dest_format,b8g8r8a8); -} - -WWINLINE unsigned BitmapHandlerClass::Combine_A8R8G8B8( - unsigned bgra1, - unsigned bgra2, - unsigned bgra3, - unsigned bgra4) -{ - bgra1&=0xfcfcfcfc; - bgra2&=0xfcfcfcfc; - bgra3&=0xfcfcfcfc; - bgra4&=0xfcfcfcfc; - bgra1>>=2; - bgra2>>=2; - bgra3>>=2; - bgra4>>=2; - bgra1+=bgra2; - bgra3+=bgra4; - bgra1+=bgra3; - return bgra1; -} - - -#endif diff --git a/Generals/Code/Libraries/Source/WWVegas/WW3D2/bwrender.cpp b/Generals/Code/Libraries/Source/WWVegas/WW3D2/bwrender.cpp deleted file mode 100644 index 75fcf1ffe02..00000000000 --- a/Generals/Code/Libraries/Source/WWVegas/WW3D2/bwrender.cpp +++ /dev/null @@ -1,242 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** 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 *** - *********************************************************************************************** - * * - * Project Name : ww3d2 * - * * - * $Archive:: /Commando/Code/ww3d2/bwrender.cpp $* - * * - * Original Author:: Jani Penttinen * - * * - * $Author:: Greg_h $* - * * - * $Modtime:: 4/04/01 10:14a $* - * * - * $Revision:: 2 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - - -#include "bwrender.h" -#include "vp.h" -#include - - -BWRenderClass::Buffer::Buffer(unsigned char* buffer_, int scale_) - : - buffer(buffer_), - scale(scale_), - minv(3), - maxv(scale_-3) -{ -} - -BWRenderClass::Buffer::~Buffer() -{ -} - -void BWRenderClass::Buffer::Set_H_Line(int start_x, int end_x, int y) -{ - if (y=maxv || end_x=maxv) return; - if (start_x=maxv) end_x=maxv-1; - unsigned char* ptr=buffer+scale*y+start_x; - int w=end_x-start_x; - if (w) { - ::memset(ptr,0x00,w); - -/* // Blurring (test) - *(ptr-1)&=0x80; - *(ptr-2)&=0xc0; - *(ptr+w)&=0x80; - *(ptr+w+1)&=0xc0; - for (int a=0;a(vertices), - half_scale, - half_scale, - count*2); -} - -// -------------------------------------------------------------------- - -static inline bool Cull( - const Vector2& c1, - const Vector2& c2, - const Vector2& c3) -{ - float x1=c2[0]-c1[0]; - float y1=c2[1]-c1[1]; - float x2=c3[0]-c1[0]; - float y2=c3[1]-c1[1]; - float r=x1*y2-x2*y1; - if (r<0) return false; - return true; -} - -void BWRenderClass::Render_Triangle_Strip(const unsigned long* indices,int index_count) -{ - index_count-=2; - bool b=false; - for (int n=0;nx_step_2) { - float t=x_step_1; - x_step_1=x_step_2; - x_step_2=t; - } - - while (ycnt>0) { - pixel_buffer.Set_H_Line(WWMath::Float_To_Long(x_left),WWMath::Float_To_Long(x_right),y); - - x_left+=x_step_1; - x_right+=x_step_2; - ycnt--; - y++; - } - } - else { - if (xcf[0]0) { - pixel_buffer.Set_H_Line(WWMath::Float_To_Long(x_left),WWMath::Float_To_Long(x_right),y); - x_left+=x_step_1; - x_right+=x_step_2; - ycnt--; - y++; - } - } - -} - diff --git a/Generals/Code/Libraries/Source/WWVegas/WW3D2/bwrender.h b/Generals/Code/Libraries/Source/WWVegas/WW3D2/bwrender.h deleted file mode 100644 index a281b7c7f10..00000000000 --- a/Generals/Code/Libraries/Source/WWVegas/WW3D2/bwrender.h +++ /dev/null @@ -1,96 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** 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 *** - *********************************************************************************************** - * * - * Project Name : ww3d2 * - * * - * $Archive:: /Commando/Code/ww3d2/bwrender.h $* - * * - * Original Author:: Jani Penttinen * - * * - * $Author:: Greg_h $* - * * - * $Modtime:: 4/04/01 10:36a $* - * * - * $Revision:: 2 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#if defined(_MSC_VER) -#pragma once -#endif - -#ifndef BWRENDER_H -#define BWRENDER_H - - -#include "always.h" -#include "vector2.h" -#include "vector3.h" -#include "Vector3i.h" - -/** -** BWRenderClass -** This class implements a simple black-and-white triangle rasterizer which -** can be used to generate shadow textures. It is faster than a general purpose -** software renderer due to the fact that no z-buffering or sorting is needed and -** texturing isn't supported. -** (gth) 04/02/2001 - I'm going to add render-to-texture code to Renegade so this -** class may be obsolete. -*/ -class BWRenderClass -{ - // Internal pixel buffer used by the triangle renderer - // The buffer is not allocated or freed by this class. - class Buffer - { - unsigned char* buffer; - int scale; - int minv; - int maxv; - public: - Buffer(unsigned char* buffer, int scale); - ~Buffer(); - - void Set_H_Line(int start_x, int end_x, int y); - void Fill(unsigned char c); - inline int Scale() const { return scale; } - } pixel_buffer; - - Vector2* vertices; - - void Render_Preprocessed_Triangle(Vector3& xcf,Vector3i& yci); - -public: - BWRenderClass(unsigned char* buffer, int scale); - ~BWRenderClass(); - - void Fill(unsigned char c); - void Set_Vertex_Locations(Vector2* vertices,int count); // Warning! Contents are modified! - void Render_Triangles(const unsigned long* indices,int index_count); - void Render_Triangle_Strip(const unsigned long* indices,int index_count); -}; - - -#endif //BWRENDER_H - diff --git a/Generals/Code/Libraries/Source/WWVegas/WW3D2/classid.h b/Generals/Code/Libraries/Source/WWVegas/WW3D2/classid.h deleted file mode 100644 index 11e87ddcd42..00000000000 --- a/Generals/Code/Libraries/Source/WWVegas/WW3D2/classid.h +++ /dev/null @@ -1,65 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*************************************************************************** - *** 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 *** - *************************************************************************** - * * - * Project Name : Commando * - * * - * $Archive:: /Commando/Code/ww3d2/classid.h $* - * * - * $Author:: Jani_p $* - * * - * $Modtime:: 3/29/01 1:13a $* - * * - * $Revision:: 2 $* - * * - *-------------------------------------------------------------------------*/ - - -#if defined(_MSC_VER) -#pragma once -#endif - -#ifndef CLASSID_H -#define CLASSID_H - -#include "always.h" - -/* -** enum of all the WW3D class IDs. -*/ -enum -{ - ID_INDIRECT_TEXTURE_CLASS = 0x10000, // IndirectTextureClass "texture.h" - ID_VARIABLE_TEXTURE_CLASS, // VariableTextureClass "texture.h" - ID_FILE_LIST_TEXTURE_CLASS, // FileListTextureClass "texture.h" - ID_RESIZEABLE_TEXTURE_INSTANCE_CLASS, // ResizeableTextureInstanceClass "texture.h" - ID_ANIM_TEXTURE_INSTANCE_CLASS, // AnimTextureInstanceClass "texture.h" - ID_MANUAL_ANIM_TEXTURE_INSTANCE_CLASS, // ManualAnimTextureInstanceClass "texture.h" - ID_TIME_ANIM_TEXTURE_INSTANCE_CLASS, // TimeAnimTextureInstanceClass "texture.h" - ID_POINT_GROUP_CLASS, // PointGroupClass "pointgr.h" - ID_MESH_MODEL_CLASS, // MeshModelClass "mesh.cpp" - ID_CACHED_TEXTURE_FILE_CLASS, // CachedTextureFileClass "assetmgr.cpp" - ID_STREAMING_TEXTURE_CLASS, // StreamingTextureClass "texture.h" - ID_STREAMING_TEXTURE_INSTANCE_CLASS, // StreamingTextureInstanceClass "texture.h" -}; - - -#endif diff --git a/Generals/Code/Libraries/Source/WWVegas/WW3D2/collect.cpp b/Generals/Code/Libraries/Source/WWVegas/WW3D2/collect.cpp deleted file mode 100644 index 619fcb371ac..00000000000 --- a/Generals/Code/Libraries/Source/WWVegas/WW3D2/collect.cpp +++ /dev/null @@ -1,1109 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** 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 *** - *********************************************************************************************** - * * - * Project Name : WW3D * - * * - * $Archive:: /Commando/Code/ww3d2/collect.cpp $* - * * - * Author:: Greg Hjelstrom * - * * - * $Modtime:: 1/08/01 10:04a $* - * * - * $Revision:: 1 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * CollectionClass::CollectionClass -- default constructor for collection render object * - * CollectionClass::CollectionClass -- constructor for collection render object * - * CollectionClass::CollectionClass -- copy constructor * - * CollectionClass::CollectionClass -- assignment operator * - * CollectionClass::~CollectionClass -- destructor * - * CollectionClass::Clone -- virtual copy constructor * - * CollectionClass::Free -- releases all assets in use by this collection * - * CollectionClass::Class_ID -- returns class id for collection render objects * - * CollectionClass::Get_Num_Polys -- returns the number of polygons in this collection * - * CollectionClass::Render -- render this collection * - * CollectionClass::Special_Render -- passes the special render call to all sub-objects * - * CollectionClass::Set_Transform -- set the transform for this collection * - * CollectionClass::Set_Position -- set the position for this collection * - * CollectionClass::Get_Num_Sub_Objects -- returns the number of sub objects * - * CollectionClass::Get_Sub_Object -- returns a pointer to the desired sub object * - * CollectionClass::Add_Sub_Object -- adds another object into this collection * - * CollectionClass::Remove_Sub_Object -- removes a sub object from this collection * - * CollectionClass::Cast_Ray -- passes the ray test to each sub object * - * CollectionClass::Cast_AABox -- passes the axis-aligned box test to each sub object * - * CollectionClass::Cast_OBBox -- passes the oriented box test to each sub object * - * CollectionClass::Intersect_AABox -- test for intersection with an AABox * - * CollectionClass::Intersect_OBBox -- test for intersection with an OBBox * - * CollectionClass::Get_Obj_Space_Bounding_Sphere -- returns the object space bounding spher * - * CollectionClass::Get_Obj_Space_Bounding_Box -- returns the object-space bounding box * - * CollectionClass::Snap_Point_Count -- returns the number of snap points in this collecion * - * CollectionClass::Get_Snap_Point -- return the desired snap point * - * CollectionClass::Scale -- scale the objects in this collection * - * CollectionClass::Scale -- scale the objects in this collection * - * CollectionClass::Update_Obj_Space_Bounding_Volumes -- recomputes the object space boundin * - * CollectionClass::Update_Sub_Object_Transforms -- recomputes all sub object transforms * - * CollectionLoaderClass::Load -- reads a collection from a w3d file * - * CollectionDefClass::CollectionDefClass -- constructor * - * CollectionDefClass::~CollectionDefClass -- destructor for collection definition * - * CollectionDefClass::Free -- releases assets in use by a collection definition * - * CollectionDefClass::Get_Name -- returns name of the collection * - * CollectionDefClass::Load -- loads a collection definition from a w3d file * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - - -#include "collect.h" -#include "chunkio.h" -#include "camera.h" -#include "wwdebug.h" -#include "snapPts.h" -#include "assetmgr.h" -#include "ww3d.h" -#include "w3derr.h" -//#include "sr.hpp" - - -CollectionLoaderClass _CollectionLoader; - -/* -** CollectionDefClass. This is the "blueprint" for a collection object -** The asset manager will store these until someone actually asks it to -** create an instance of the collection object -*/ -class CollectionDefClass -{ -public: - - CollectionDefClass(void); - ~CollectionDefClass(void); - - const char * Get_Name(void) const; - WW3DErrorType Load(ChunkLoadClass & cload); - -protected: - - void Free(void); - - char Name[W3D_NAME_LEN]; - DynamicVectorClass ObjectNames; - SnapPointsClass * SnapPoints; - - DynamicVectorClass ProxyList; - - friend class CollectionClass; -}; - - -/* -** CollectionPrototypeClass this is the render object prototype for -** Collections. -*/ -class CollectionPrototypeClass : public W3DMPO, public PrototypeClass -{ - W3DMPO_GLUE(CollectionPrototypeClass) -public: - CollectionPrototypeClass(CollectionDefClass * def) { ColDef = def; WWASSERT(ColDef); } - - virtual const char * Get_Name(void) const { return ColDef->Get_Name(); } - virtual int Get_Class_ID(void) const { return RenderObjClass::CLASSID_COLLECTION; } - virtual RenderObjClass * Create(void) { return NEW_REF( CollectionClass, (*ColDef)); } - virtual void DeleteSelf() { delete this; } - - CollectionDefClass * ColDef; - -protected: - virtual ~CollectionPrototypeClass(void) { delete ColDef; } -}; - - -/*********************************************************************************************** - * CollectionClass::CollectionClass -- default constructor for collection render object * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 23/8/00 GTH : Created. * - *=============================================================================================*/ -CollectionClass::CollectionClass(void) : - SnapPoints(NULL) -{ - Update_Obj_Space_Bounding_Volumes(); -} - - -/*********************************************************************************************** - * CollectionClass::CollectionClass -- constructor for collection render object * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 12/8/98 GTH : Created. * - *=============================================================================================*/ -CollectionClass::CollectionClass(const CollectionDefClass & def) : - SubObjects(def.ObjectNames.Count()), - SnapPoints(NULL) -{ - // Set our name - Set_Name (def.Get_Name ()); - - // create the sub objects - SubObjects.Resize(def.ObjectNames.Count()); - for (int i=0; iCreate_Render_Obj(def.ObjectNames[i])); - SubObjects[i]->Set_Container(this); - } - - // Copy the list of placeholder objects from the definition - ProxyList = def.ProxyList; - - // grab ahold of the snap points. - SnapPoints = def.SnapPoints; - if (SnapPoints) SnapPoints->Add_Ref(); - - // set up our collision typeas the union of all of our sub-objects - Update_Sub_Object_Bits(); - - // update the object bounding volumes - Update_Obj_Space_Bounding_Volumes(); -} - - -/*********************************************************************************************** - * CollectionClass::CollectionClass -- copy constructor * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 12/8/98 GTH : Created. * - *=============================================================================================*/ -CollectionClass::CollectionClass(const CollectionClass & src) : - CompositeRenderObjClass(src), - SubObjects(src.SubObjects.Count()), - SnapPoints(NULL) -{ - *this = src; -} - - -/*********************************************************************************************** - * CollectionClass::CollectionClass -- assignment operator * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 12/8/98 GTH : Created. * - *=============================================================================================*/ -CollectionClass & CollectionClass::operator = (const CollectionClass & that) -{ - if (this != &that) { - Free(); - CompositeRenderObjClass::operator = (that); - - SubObjects.Resize(that.SubObjects.Count()); - for (int i=0; iClone()); - SubObjects[i]->Set_Container(this); - } - - // Copy the list of placeholder objects from the definition - ProxyList = that.ProxyList; - - SnapPoints = that.SnapPoints; - if (SnapPoints) SnapPoints->Add_Ref(); - - Update_Sub_Object_Bits(); - Update_Obj_Space_Bounding_Volumes(); - } - return * this; -} - - -/*********************************************************************************************** - * CollectionClass::~CollectionClass -- destructor * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 12/8/98 GTH : Created. * - *=============================================================================================*/ -CollectionClass::~CollectionClass(void) -{ - Free(); -} - - -/*********************************************************************************************** - * CollectionClass::Clone -- virtual copy constructor * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 12/8/98 GTH : Created. * - *=============================================================================================*/ -RenderObjClass * CollectionClass::Clone(void) const -{ - return NEW_REF( CollectionClass, (*this)); -} - - -/*********************************************************************************************** - * CollectionClass::Free -- releases all assets in use by this collection * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 12/8/98 GTH : Created. * - *=============================================================================================*/ -void CollectionClass::Free(void) -{ - for (int i=0; iSet_Container(NULL); - SubObjects[i]->Release_Ref(); - SubObjects[i] = NULL; - } - SubObjects.Delete_All(); - ProxyList.Delete_All (); - - REF_PTR_RELEASE(SnapPoints); -} - - -/*********************************************************************************************** - * CollectionClass::Class_ID -- returns class id for collection render objects * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 12/8/98 GTH : Created. * - *=============================================================================================*/ -int CollectionClass::Class_ID(void) const -{ - return RenderObjClass::CLASSID_COLLECTION; -} - - -/*********************************************************************************************** - * CollectionClass::Get_Num_Polys -- returns the number of polygons in this collection * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 12/8/98 GTH : Created. * - *=============================================================================================*/ -int CollectionClass::Get_Num_Polys(void) const -{ - int pcount = 0; - for (int i=0; iGet_Num_Polys(); - } - return pcount; -} - - -/*********************************************************************************************** - * CollectionClass::Render -- render this collection * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 12/8/98 GTH : Created. * - *=============================================================================================*/ -void CollectionClass::Render(RenderInfoClass & rinfo) -{ - if (Is_Not_Hidden_At_All() == false) { - return; - } - - if (Are_Sub_Object_Transforms_Dirty()) { - Update_Sub_Object_Transforms(); - } - - for (int i=0; iRender(rinfo); - } -} - - -/*********************************************************************************************** - * CollectionClass::Special_Render -- passes the special render call to all sub-objects * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 3/2/99 GTH : Created. * - *=============================================================================================*/ -void CollectionClass::Special_Render(SpecialRenderInfoClass & rinfo) -{ - if (Is_Not_Hidden_At_All() == false) { - return; - } - - if (Are_Sub_Object_Transforms_Dirty()) { - Update_Sub_Object_Transforms(); - } - - for (int i=0; iSpecial_Render(rinfo); - } -} - -/*********************************************************************************************** - * CollectionClass::Set_Transform -- set the transform for this collection * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 12/8/98 GTH : Created. * - *=============================================================================================*/ -void CollectionClass::Set_Transform(const Matrix3D &m) -{ - RenderObjClass::Set_Transform(m); - Set_Sub_Object_Transforms_Dirty(true); -} - - -/*********************************************************************************************** - * CollectionClass::Set_Position -- set the position for this collection * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 12/8/98 GTH : Created. * - *=============================================================================================*/ -void CollectionClass::Set_Position(const Vector3 &v) -{ - RenderObjClass::Set_Position(v); - Set_Sub_Object_Transforms_Dirty(true); -} - - -/*********************************************************************************************** - * CollectionClass::Get_Num_Sub_Objects -- returns the number of sub objects * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 12/8/98 GTH : Created. * - *=============================================================================================*/ -int CollectionClass::Get_Num_Sub_Objects(void) const -{ - return SubObjects.Count(); -} - - -/*********************************************************************************************** - * CollectionClass::Get_Sub_Object -- returns a pointer to the desired sub object * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 12/8/98 GTH : Created. * - *=============================================================================================*/ -RenderObjClass * CollectionClass::Get_Sub_Object(int index) const -{ - if (SubObjects[index]) { - SubObjects[index]->Add_Ref(); - } - return SubObjects[index]; -} - - -/*********************************************************************************************** - * CollectionClass::Add_Sub_Object -- adds another object into this collection * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 12/8/98 GTH : Created. * - *=============================================================================================*/ -int CollectionClass::Add_Sub_Object(RenderObjClass * subobj) -{ - WWASSERT(subobj); - subobj->Add_Ref(); - subobj->Set_Container(this); - subobj->Set_Transform(Transform); - int res = SubObjects.Add(subobj); - Update_Sub_Object_Bits(); - Update_Obj_Space_Bounding_Volumes(); - if (Is_In_Scene()) { - subobj->Notify_Added(Scene); - } - return res; -} - - -/*********************************************************************************************** - * CollectionClass::Remove_Sub_Object -- removes a sub object from this collection * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 12/8/98 GTH : Created. * - *=============================================================================================*/ -int CollectionClass::Remove_Sub_Object(RenderObjClass * robj) -{ - if (robj == NULL) return 0; - - int res = 0; - - Matrix3D tm = Get_Transform(); - - for (int i=0; iNotify_Removed(Scene); - } - SubObjects[i]->Set_Container(NULL); - SubObjects[i]->Set_Transform(tm); - SubObjects[i]->Release_Ref(); - res = SubObjects.Delete(i); - break; - } - } - - if (res != 0) { - Update_Sub_Object_Bits(); - Update_Obj_Space_Bounding_Volumes(); - } - - return res; -} - - -/*********************************************************************************************** - * CollectionClass::Cast_Ray -- passes the ray test to each sub object * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 12/8/98 GTH : Created. * - *=============================================================================================*/ -bool CollectionClass::Cast_Ray(RayCollisionTestClass & raytest) -{ - bool res = false; - for (int i=0; iCast_Ray(raytest); - } - return res; -} - - -/*********************************************************************************************** - * CollectionClass::Cast_AABox -- passes the axis-aligned box test to each sub object * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 12/8/98 GTH : Created. * - *=============================================================================================*/ -bool CollectionClass::Cast_AABox(AABoxCollisionTestClass & boxtest) -{ - bool res = false; - for (int i=0; iCast_AABox(boxtest); - } - return res; -} - - -/*********************************************************************************************** - * CollectionClass::Cast_OBBox -- passes the oriented box test to each sub object * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 12/8/98 GTH : Created. * - *=============================================================================================*/ -bool CollectionClass::Cast_OBBox(OBBoxCollisionTestClass & boxtest) -{ - bool res = false; - for (int i=0; iCast_OBBox(boxtest); - } - return res; -} - - -/*********************************************************************************************** - * CollectionClass::Intersect_AABox -- test for intersection with an AABox * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 1/19/00 gth : Created. * - *=============================================================================================*/ -bool CollectionClass::Intersect_AABox(AABoxIntersectionTestClass & boxtest) -{ - bool res = false; - for (int i=0; iIntersect_AABox(boxtest); - } - return res; -} - - -/*********************************************************************************************** - * CollectionClass::Intersect_OBBox -- test for intersection with an OBBox * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 1/19/00 gth : Created. * - *=============================================================================================*/ -bool CollectionClass::Intersect_OBBox(OBBoxIntersectionTestClass & boxtest) -{ - bool res = false; - for (int i=0; iIntersect_OBBox(boxtest); - } - return res; -} - -/*********************************************************************************************** - * CollectionClass::Get_Obj_Space_Bounding_Sphere -- returns the object space bounding sphere. * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 12/8/98 GTH : Created. * - *=============================================================================================*/ -void CollectionClass::Get_Obj_Space_Bounding_Sphere(SphereClass & sphere) const -{ - sphere = BoundSphere; -} - - -/*********************************************************************************************** - * CollectionClass::Get_Obj_Space_Bounding_Box -- returns the object-space bounding box * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 12/8/98 GTH : Created. * - *=============================================================================================*/ -void CollectionClass::Get_Obj_Space_Bounding_Box(AABoxClass & box) const -{ - box = BoundBox; -} - - -/*********************************************************************************************** - * CollectionClass::Snap_Point_Count -- returns the number of snap points in this collecion * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 12/8/98 GTH : Created. * - *=============================================================================================*/ -int CollectionClass::Snap_Point_Count(void) -{ - if (SnapPoints) { - return SnapPoints->Count(); - } else { - return 0; - } -} - - -/*********************************************************************************************** - * CollectionClass::Get_Snap_Point -- return the desired snap point * - * * - * This function will set the passed vector to be equal to the object space coordinates of * - * the desired snap point. * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 12/8/98 GTH : Created. * - *=============================================================================================*/ -void CollectionClass::Get_Snap_Point(int index,Vector3 * set) -{ - WWASSERT(set != NULL); - if (SnapPoints) { - *set = (*SnapPoints)[index]; - } else { - set->X = set->Y = set->Z = 0; - } -} - - -/*********************************************************************************************** - * CollectionClass::Scale -- scale the objects in this collection * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 12/8/98 GTH : Created. * - *=============================================================================================*/ -void CollectionClass::Scale(float scale) -{ - for (int i=0; iScale(scale); - } -} - - -/*********************************************************************************************** - * CollectionClass::Scale -- scale the objects in this collection * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 12/8/98 GTH : Created. * - *=============================================================================================*/ -void CollectionClass::Scale(float scalex, float scaley, float scalez) -{ - for (int i=0; iScale(scalex,scaley,scalez); - } -} - - -/*********************************************************************************************** - * CollectionClass::Update_Obj_Space_Bounding_Volumes -- recomputes the object space bounding * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 12/8/98 GTH : Created. * - *=============================================================================================*/ -void CollectionClass::Update_Obj_Space_Bounding_Volumes(void) -{ - int i; - if (SubObjects.Count() <= 0) { - BoundSphere = SphereClass(Vector3(0,0,0),0); - BoundBox.Center.Set(0,0,0); - BoundBox.Extent.Set(0,0,0); - return; - } - - Matrix3D tm = Get_Transform(); - Set_Transform(Matrix3D(1)); - - // loop through all sub-objects, combining their bounding spheres. - BoundSphere = SubObjects[0]->Get_Bounding_Sphere(); - for (i=1; i < SubObjects.Count(); i++) { - BoundSphere.Add_Sphere(SubObjects[i]->Get_Bounding_Sphere()); - } - - // loop through the sub-objects, computing a box in the root coordinate - // system which bounds all of the meshes. Note that we've set the - // root coordinate system to identity for this. - MinMaxAABoxClass box(Vector3(FLT_MAX,FLT_MAX,FLT_MAX),Vector3(-FLT_MAX,-FLT_MAX,-FLT_MAX)); - - for (i=0; i < SubObjects.Count(); i++) { - box.Add_Box(SubObjects[i]->Get_Bounding_Box()); - } - - BoundBox.Init(box); - - Invalidate_Cached_Bounding_Volumes(); - - // Now update the object space bounding volumes of this object's container: - RenderObjClass *container = Get_Container(); - if (container) container->Update_Obj_Space_Bounding_Volumes(); - - Set_Transform(tm); -} - - -/*********************************************************************************************** - * CollectionClass::Update_Sub_Object_Transforms -- recomputes all sub object transforms * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 12/8/98 GTH : Created. * - *=============================================================================================*/ -void CollectionClass::Update_Sub_Object_Transforms(void) -{ - RenderObjClass::Update_Sub_Object_Transforms(); - for (int i=0; iSet_Transform(Transform); - SubObjects[i]->Update_Sub_Object_Transforms(); - } - Set_Sub_Object_Transforms_Dirty(false); -} - - -/*********************************************************************************************** - * CollectionClass::Get_Placeholder -- Returns information about a placeholder object. - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 4/28/99 PDS : Created. * - *=============================================================================================*/ -bool CollectionClass::Get_Proxy (int index, ProxyClass &proxy) const -{ - bool retval = false; - - if (index >= 0 && index < ProxyList.Count ()) { - - // - // Return the proxy information to the caller - // - proxy = ProxyList[index]; - retval = true; - } - - return retval; -} - - -/*********************************************************************************************** - * CollectionClass::Get_Proxy_Count -- Returns the count of proxy objects in the collection. - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 4/28/99 PDS : Created. * - *=============================================================================================*/ -int CollectionClass::Get_Proxy_Count (void) const -{ - return ProxyList.Count (); -} - - -/*********************************************************************************************** - * CollectionDefClass::CollectionDefClass -- constructor * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 12/8/98 GTH : Created. * - *=============================================================================================*/ -CollectionDefClass::CollectionDefClass(void) -{ - SnapPoints = NULL; -} - - -/*********************************************************************************************** - * CollectionDefClass::~CollectionDefClass -- destructor for collection definition * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 12/8/98 GTH : Created. * - *=============================================================================================*/ -CollectionDefClass::~CollectionDefClass(void) -{ - Free(); -} - - -/*********************************************************************************************** - * CollectionDefClass::Free -- releases assets in use by a collection definition * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 12/8/98 GTH : Created. * - *=============================================================================================*/ -void CollectionDefClass::Free(void) -{ - for (int i=0; i 0); - char * name = W3DNEWARRAY char [cload.Cur_Chunk_Length()]; - cload.Read(name,cload.Cur_Chunk_Length()); - ObjectNames.Add(name); - break; - } - - case W3D_CHUNK_PLACEHOLDER: - { - // Read the placeholder information from the chunk - WWASSERT(cload.Cur_Chunk_Length() > 0); - W3dPlaceholderStruct info; - cload.Read(&info, sizeof (info)); - - // Read the placeholder name from the chunk - char *name = W3DNEWARRAY char[info.name_len + 1]; - cload.Read(name, info.name_len); - name[info.name_len] = 0; - - // Create a matrix from the data in the chunk - Matrix3D transform (info.transform[0][0], info.transform[1][0], info.transform[2][0], info.transform[3][0], - info.transform[0][1], info.transform[1][1], info.transform[2][1], info.transform[3][1], - info.transform[0][2], info.transform[1][2], info.transform[2][2], info.transform[3][2]); - - // Add this placeholder to our list - ProxyList.Add (ProxyClass (name, transform)); - - // Free the name array - delete [] name; - break; - } - - case W3D_CHUNK_POINTS: - SnapPoints = NEW_REF(SnapPointsClass, ()); - SnapPoints->Load_W3D(cload); - break; - } - - cload.Close_Chunk(); - } - - return WW3D_ERROR_OK; - -Error: - - return WW3D_ERROR_LOAD_FAILED; -} - -/*********************************************************************************************** - * CollectionLoaderClass::Load -- reads a collection from a w3d file * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 12/8/98 GTH : Created. * - *=============================================================================================*/ -PrototypeClass * CollectionLoaderClass::Load_W3D(ChunkLoadClass & cload) -{ - CollectionDefClass * def = W3DNEW CollectionDefClass; - - if (def == NULL) { - return NULL; - } - - if (def->Load(cload) != WW3D_ERROR_OK) { - - // load failed, delete the model and return an error - delete def; - return NULL; - - } else { - - // ok, accept this model! - CollectionPrototypeClass * proto = W3DNEW CollectionPrototypeClass(def); - return proto; - - } -} - - - diff --git a/Generals/Code/Libraries/Source/WWVegas/WW3D2/collect.h b/Generals/Code/Libraries/Source/WWVegas/WW3D2/collect.h deleted file mode 100644 index 57d3fe87f11..00000000000 --- a/Generals/Code/Libraries/Source/WWVegas/WW3D2/collect.h +++ /dev/null @@ -1,149 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** 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 *** - *********************************************************************************************** - * * - * Project Name : WW3D * - * * - * $Archive:: /Commando/Code/ww3d2/collect.h $* - * * - * Author:: Greg Hjelstrom * - * * - * $Modtime:: 1/08/01 10:04a $* - * * - * $Revision:: 1 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#if defined(_MSC_VER) -#pragma once -#endif - -#ifndef COLLECT_H -#define COLLECT_H - -#include "rendobj.h" -#include "composite.h" -#include "Vector.H" -#include "proto.h" -#include "w3d_file.h" -#include "wwstring.h" -#include "proxy.h" - -class CollectionDefClass; -class SnapPointsClass; - - -/* -** CollectionClass -** This is a render object which contains a collection of render objects. -*/ -class CollectionClass : public CompositeRenderObjClass -{ -public: - - CollectionClass(void); - CollectionClass(const CollectionDefClass & def); - CollectionClass(const CollectionClass & src); - CollectionClass & operator = (const CollectionClass &); - virtual ~CollectionClass(void); - virtual RenderObjClass * Clone(void) const; - - virtual int Class_ID(void) const; - virtual int Get_Num_Polys(void) const; - - ///////////////////////////////////////////////////////////////////////////// - // Proxy interface - ///////////////////////////////////////////////////////////////////////////// - virtual int Get_Proxy_Count (void) const; - virtual bool Get_Proxy (int index, ProxyClass &proxy) const; - - ///////////////////////////////////////////////////////////////////////////// - // Render Object Interface - Rendering - ///////////////////////////////////////////////////////////////////////////// - virtual void Render(RenderInfoClass & rinfo); - virtual void Special_Render(SpecialRenderInfoClass & rinfo); - - ///////////////////////////////////////////////////////////////////////////// - // Render Object Interface - "Scene Graph" - ///////////////////////////////////////////////////////////////////////////// - virtual void Set_Transform(const Matrix3D &m); - virtual void Set_Position(const Vector3 &v); - virtual int Get_Num_Sub_Objects(void) const; - virtual RenderObjClass * Get_Sub_Object(int index) const; - virtual int Add_Sub_Object(RenderObjClass * subobj); - virtual int Remove_Sub_Object(RenderObjClass * robj); - - ///////////////////////////////////////////////////////////////////////////// - // Render Object Interface - Collision Detection, Ray Tracing - ///////////////////////////////////////////////////////////////////////////// - virtual bool Cast_Ray(RayCollisionTestClass & raytest); - virtual bool Cast_AABox(AABoxCollisionTestClass & boxtest); - virtual bool Cast_OBBox(OBBoxCollisionTestClass & boxtest); - virtual bool Intersect_AABox(AABoxIntersectionTestClass & boxtest); - virtual bool Intersect_OBBox(OBBoxIntersectionTestClass & boxtest); - - ///////////////////////////////////////////////////////////////////////////// - // Render Object Interface - Bounding Volumes - ///////////////////////////////////////////////////////////////////////////// - virtual void Get_Obj_Space_Bounding_Sphere(SphereClass & sphere) const; - virtual void Get_Obj_Space_Bounding_Box(AABoxClass & box) const; - - - ///////////////////////////////////////////////////////////////////////////// - // Render Object Interface - Attributes, Options, Properties, etc - ///////////////////////////////////////////////////////////////////////////// - virtual int Snap_Point_Count(void); - virtual void Get_Snap_Point(int index,Vector3 * set); - virtual void Scale(float scale); - virtual void Scale(float scalex, float scaley, float scalez); - virtual void Update_Obj_Space_Bounding_Volumes(void); - -protected: - - void Free(void); - void Update_Sub_Object_Transforms(void); - - DynamicVectorClass ProxyList; - DynamicVectorClass SubObjects; - SnapPointsClass * SnapPoints; - - SphereClass BoundSphere; - AABoxClass BoundBox; -}; - - -/* -** CollectionLoaderClass -** Loader for collection objects -*/ -class CollectionLoaderClass : public PrototypeLoaderClass -{ -public: - - virtual int Chunk_Type(void) { return W3D_CHUNK_COLLECTION; } - virtual PrototypeClass * Load_W3D(ChunkLoadClass & cload); -}; - -extern CollectionLoaderClass _CollectionLoader; - -#endif diff --git a/Generals/Code/Libraries/Source/WWVegas/WW3D2/colorspace.h b/Generals/Code/Libraries/Source/WWVegas/WW3D2/colorspace.h deleted file mode 100644 index 65b960e1622..00000000000 --- a/Generals/Code/Libraries/Source/WWVegas/WW3D2/colorspace.h +++ /dev/null @@ -1,161 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** 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 *** - *********************************************************************************************** - * * - * Project Name : Colorspace * - * * - * $Archive:: $* - * * - * Original Author:: Hector Yee * - * * - * $Author:: $* - * * - * $Modtime:: $* - * * - * $Revision:: $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#if defined(_MSC_VER) -#pragma once -#endif - -#ifndef COLORSPACE_H -#define COLORSPACE_H - -#include "dx8wrapper.h" -#include - -void RGB_To_HSV(Vector3 &hsv,const Vector3 &rgb); -void HSV_To_RGB(Vector3 &rgb, const Vector3 &hsv); -void Recolor(Vector3 &rgb, const Vector3 &hsv_shift); - -//--------------------------------------------------------------------- -// Color Conversions -//--------------------------------------------------------------------- - -inline void RGB_To_HSV(Vector3 &hsv,const Vector3 &rgb) -// modified from Foley et al. page 592 -// converts rgb[0..1] to h [0,360), s and v in [0,1] -// negative h values are to signify undefined -{ - float max=WWMath::Max(rgb.X,rgb.Y); - max=WWMath::Max(max,rgb.Z); - float min=WWMath::Min(rgb.X,rgb.Y); - min=WWMath::Min(min,rgb.Z); - - // value - hsv.Z=max; - - // saturation - hsv.Y=(max!=0.0f)?((max-min)/max):0.0f; - if (hsv.Y==0.0f) hsv.X=-1.0f; - else - { - float delta=max-min; - if (rgb.X==max) - hsv.X=(rgb.Y-rgb.Z)/delta; - else if (rgb.Y==max) - hsv.X=2.0f+ (rgb.Z-rgb.X)/delta; - else if (rgb.Z==max) - hsv.X=4.0f+ (rgb.X-rgb.Y)/delta; - hsv.X*=60.0f; - if (hsv.X<0.0f) hsv.X+=360.0f; - } -} - -inline void HSV_To_RGB(Vector3 &rgb, const Vector3 &hsv) -{ - float h=hsv.X; - float s=hsv.Y; - float v=hsv.Z; - - if (hsv.Y==0.0f) { - rgb.Set(v,v,v); - } else { - float f,p,q,t; - - int i; - - if (h==360.0f) h=0.0f; - - h/=60.0f; - i=WWMath::Floor(h); - f=h-i; - p=v*(1.0f-s); - q=v*(1.0f-(s*f)); - t=v*(1.0f-(s*(1.0f-f))); - switch (i) { - case 0: - rgb.Set(v,t,p); - break; - case 1: - rgb.Set(q,v,p); - break; - case 2: - rgb.Set(p,v,t); - break; - case 3: - rgb.Set(p,q,v); - break; - case 4: - rgb.Set(t,p,v); - break; - case 5: - rgb.Set(v,p,q); - break; - } - } -} - -inline void Recolor(Vector3 &rgb, const Vector3 &hsv_shift) -{ - Vector3 hsv; - RGB_To_HSV(hsv,rgb); - - // If the Hue has the "undefined flag" (a negative value), this means that the color is pure - // monochrome. In this case do not shift the hue (it is undefined) or the saturation (it is 0 - // so it cannot be decreased, and increasing it would cause the undefined hue to actually - // become visible). In this case, we only modify the value. - if (hsv.X<0.0f) hsv+=Vector3(0.0f,0.0f,hsv_shift.Z); - else hsv+=hsv_shift; - - // angular mod - if (hsv.X<0.0f) hsv.X+=360.0f; - if (hsv.X>360.0f) hsv.X-=360.0f; - // clamp saturation and value - hsv.Y=WWMath::Clamp(hsv.Y,0.0f,1.0f); - hsv.Z=WWMath::Clamp(hsv.Z,0.0f,1.0f); - HSV_To_RGB(rgb,hsv); -} - -inline void Recolor(unsigned& rgba, const Vector3 &hsv_shift) -{ - Vector4 rgba_v = DX8Wrapper::Convert_Color(rgba); - Recolor((Vector3&)rgba_v, hsv_shift); - rgba = DX8Wrapper::Convert_Color(rgba_v); -} - - -#endif - diff --git a/Generals/Code/Libraries/Source/WWVegas/WW3D2/coltest.cpp b/Generals/Code/Libraries/Source/WWVegas/WW3D2/coltest.cpp deleted file mode 100644 index 3282c89e2e1..00000000000 --- a/Generals/Code/Libraries/Source/WWVegas/WW3D2/coltest.cpp +++ /dev/null @@ -1,375 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** 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 *** - *********************************************************************************************** - * * - * Project Name : WW3D * - * * - * $Archive:: /Commando/Code/ww3d2/coltest.cpp $* - * * - * Author:: Greg Hjelstrom * - * * - * $Modtime:: 5/07/01 10:26a $* - * * - * $Revision:: 2 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - - -#include "coltest.h" - - -AABoxCollisionTestClass::AABoxCollisionTestClass(const AABoxCollisionTestClass & that) : - CollisionTestClass(that), - Box(that.Box), - Move(that.Move), - SweepMin(that.SweepMin), - SweepMax(that.SweepMax) -{ -} - -AABoxCollisionTestClass::AABoxCollisionTestClass(const AABoxClass & aabox,const Vector3 & move,CastResultStruct * res,int collision_type) : - CollisionTestClass(res,collision_type), - Box(aabox), - Move(move) -{ - SweepMin = Box.Center - Box.Extent; - SweepMax = Box.Center + Box.Extent; - - Vector3 endmin = Box.Center + move - Box.Extent; - Vector3 endmax = Box.Center + move + Box.Extent; - - if (endmax.X > SweepMax.X) SweepMax.X = endmax.X; - if (endmax.Y > SweepMax.Y) SweepMax.Y = endmax.Y; - if (endmax.Z > SweepMax.Z) SweepMax.Z = endmax.Z; - - if (endmin.X < SweepMin.X) SweepMin.X = endmin.X; - if (endmin.Y < SweepMin.Y) SweepMin.Y = endmin.Y; - if (endmin.Z < SweepMin.Z) SweepMin.Z = endmin.Z; -} - - -bool AABoxCollisionTestClass::Cull(const AABoxClass & box) -{ -// const float MOVE_THRESHOLD = 2.0f; -// if (WWMath::Fabs(Move.X) + WWMath::Fabs(Move.Y) + WWMath::Fabs(Move.Z) > MOVE_THRESHOLD) { -// CastResultStruct res; -// return !Box.Cast_To_Box(Move,box,&res); -// } else { - Vector3 min_corner; - Vector3 max_corner; - Vector3::Subtract(box.Center,box.Extent,&min_corner); - Vector3::Add(box.Center,box.Extent,&max_corner); - - if ((SweepMin.X > max_corner.X) || (SweepMax.X < min_corner.X)) { - return true; - } - - if ((SweepMin.Y > max_corner.Y) || (SweepMax.Y < min_corner.Y)) { - return true; - } - - if ((SweepMin.Z > max_corner.Z) || (SweepMax.Z < min_corner.Z)) { - return true; - } - return false; -// } -} - - -void AABoxCollisionTestClass::Rotate(ROTATION_TYPE rotation) -{ - -#ifndef NDEBUG - - int i; - Matrix3D tm(1); - switch(rotation) { - case ROTATE_NONE: - break; - case ROTATE_Z90: - tm = Matrix3D::RotateZ90; - break; - case ROTATE_Z180: - tm = Matrix3D::RotateZ180; - break; - case ROTATE_Z270: - tm = Matrix3D::RotateZ270; - break; - } - -#ifdef ALLOW_TEMPORARIES - Vector3 realcenter = tm * Box.Center; -#else - Vector3 realcenter; - tm.mulVector3(Box.Center, realcenter); -#endif - - Vector3 pts[8]; - Vector3 & min = SweepMin; - Vector3 & max = SweepMax; - - pts[0].Set(min.X,min.Y,min.Z); - pts[1].Set(min.X,max.Y,min.Z); - pts[2].Set(max.X,max.Y,min.Z); - pts[3].Set(max.X,min.Y,min.Z); - - pts[4].Set(min.X,min.Y,max.Z); - pts[5].Set(min.X,max.Y,max.Z); - pts[6].Set(max.X,max.Y,max.Z); - pts[7].Set(max.X,min.Y,max.Z); - -// for (i=0; i<8; i++) { -// pts[i] = tm * pts[i]; -// } - tm.mulVector3Array(pts, 8); - - Vector3 realmin = pts[0]; - Vector3 realmax = pts[0]; - - for (i=1; i<8; i++) { - if (realmin.X >= pts[i].X) realmin.X = pts[i].X; - if (realmin.Y >= pts[i].Y) realmin.Y = pts[i].Y; - if (realmin.Z >= pts[i].Z) realmin.Z = pts[i].Z; - - if (realmax.X <= pts[i].X) realmax.X = pts[i].X; - if (realmax.Y <= pts[i].Y) realmax.Y = pts[i].Y; - if (realmax.Z <= pts[i].Z) realmax.Z = pts[i].Z; - } - - -#endif - - - // rotate the test by the desired rotation about the Z axis, special cased for - // 90 degree rotations about Z. arbitrary rotations cause the axis aligned - // box to not be aligned any more :-) - float tmp,minx,miny,maxx,maxy; - switch(rotation) { - case ROTATE_NONE: - break; - - case ROTATE_Z90: - // rotate the center point and the move vector - tmp = Box.Center.X; Box.Center.X = -Box.Center.Y; Box.Center.Y = tmp; - tmp = Move.X; Move.X = -Move.Y; Move.Y = tmp; - - // swap x and y for the extent - tmp = Box.Extent.X; Box.Extent.X = Box.Extent.Y; Box.Extent.Y = tmp; - - // update sweep bounding box - minx = SweepMin.X; miny = SweepMin.Y; maxx = SweepMax.X; maxy = SweepMax.Y; - SweepMin.X = -maxy; - SweepMin.Y = minx; - SweepMax.X = -miny; - SweepMax.Y = maxx; - break; - - case ROTATE_Z180: - // rotate center and move vector - Box.Center.X = -Box.Center.X; - Box.Center.Y = -Box.Center.Y; - Move.X = -Move.X; - Move.Y = -Move.Y; - - // update min/max boxes - minx = SweepMin.X; miny = SweepMin.Y; maxx = SweepMax.X; maxy = SweepMax.Y; - SweepMin.X = -maxx; - SweepMin.Y = -maxy; - SweepMax.X = -minx; - SweepMax.Y = -miny; - break; - - case ROTATE_Z270: - // rotate center and move. - tmp = Box.Center.X; Box.Center.X = Box.Center.Y; Box.Center.Y = -tmp; - tmp = Move.X; Move.X = Move.Y; Move.Y = -tmp; - - // update extent (x and y axis swap) - tmp = Box.Extent.X; Box.Extent.X = Box.Extent.Y; Box.Extent.Y = tmp; - - // update min/max boxes - minx = SweepMin.X; miny = SweepMin.Y; maxx = SweepMax.X; maxy = SweepMax.Y; - SweepMin.X = miny; - SweepMin.Y = -maxx; - SweepMax.X = maxy; - SweepMax.Y = -minx; - break; - } - -#ifndef NDEBUG - - assert((Box.Center - realcenter).Length() < 0.001f); - assert((SweepMin - realmin).Length() < 0.001f); - assert((SweepMax - realmax).Length() < 0.001f); - -#endif -} - - -void AABoxCollisionTestClass::Transform(const Matrix3D & tm) -{ - // NOTE: this function will expand the box to enclose the rotated - // form of the original box. In practice, this function was only - // implemented to double-check the results of the Translate and Rotate - // functions. - int i; - Vector3 tmpcenter = Box.Center; - Vector3 tmpextent = Box.Extent; - tm.Transform_Center_Extent_AABox(tmpcenter,tmpextent,&Box.Center,&Box.Extent); - - Move = tm.Rotate_Vector(Move); - - Vector3 pts[8]; - Vector3 & min = SweepMin; - Vector3 & max = SweepMax; - - pts[0].Set(min.X,min.Y,min.Z); - pts[1].Set(min.X,max.Y,min.Z); - pts[2].Set(max.X,max.Y,min.Z); - pts[3].Set(max.X,min.Y,min.Z); - - pts[4].Set(min.X,min.Y,max.Z); - pts[5].Set(min.X,max.Y,max.Z); - pts[6].Set(max.X,max.Y,max.Z); - pts[7].Set(max.X,min.Y,max.Z); - -// for (i=0; i<8; i++) { -// pts[i] = tm * pts[i]; -// } - tm.mulVector3Array(pts, 8); - - Vector3 realmin = pts[0]; - Vector3 realmax = pts[0]; - - for (i=1; i<8; i++) { - if (realmin.X >= pts[i].X) realmin.X = pts[i].X; - if (realmin.Y >= pts[i].Y) realmin.Y = pts[i].Y; - if (realmin.Z >= pts[i].Z) realmin.Z = pts[i].Z; - - if (realmax.X <= pts[i].X) realmax.X = pts[i].X; - if (realmax.Y <= pts[i].Y) realmax.Y = pts[i].Y; - if (realmax.Z <= pts[i].Z) realmax.Z = pts[i].Z; - } - - SweepMin = realmin; - SweepMax = realmax; -} - - - -OBBoxCollisionTestClass::OBBoxCollisionTestClass -( - const OBBoxClass & obbox, - const Vector3 & move, - CastResultStruct * res, - int type -) : - CollisionTestClass(res,type), - Box(obbox), - Move(move) -{ - Vector3 max_extent; - max_extent.X = WWMath::Fabs(Box.Basis[0][0] * Box.Extent.X) + - WWMath::Fabs(Box.Basis[0][1] * Box.Extent.Y) + - WWMath::Fabs(Box.Basis[0][2] * Box.Extent.Z) + 0.01f; - - max_extent.Y = WWMath::Fabs(Box.Basis[1][0] * Box.Extent.X) + - WWMath::Fabs(Box.Basis[1][1] * Box.Extent.Y) + - WWMath::Fabs(Box.Basis[1][2] * Box.Extent.Z) + 0.01f; - - max_extent.Z = WWMath::Fabs(Box.Basis[2][0] * Box.Extent.X) + - WWMath::Fabs(Box.Basis[2][1] * Box.Extent.Y) + - WWMath::Fabs(Box.Basis[2][2] * Box.Extent.Z) + 0.01f; - - SweepMin = Box.Center - max_extent; - SweepMax = Box.Center + max_extent; - - Vector3 endmin = Box.Center + move - max_extent; - Vector3 endmax = Box.Center + move + max_extent; - - if (endmax.X > SweepMax.X) SweepMax.X = endmax.X; - if (endmax.Y > SweepMax.Y) SweepMax.Y = endmax.Y; - if (endmax.Z > SweepMax.Z) SweepMax.Z = endmax.Z; - - if (endmin.X < SweepMin.X) SweepMin.X = endmin.X; - if (endmin.Y < SweepMin.Y) SweepMin.Y = endmin.Y; - if (endmin.Z < SweepMin.Z) SweepMin.Z = endmin.Z; -} - -OBBoxCollisionTestClass::OBBoxCollisionTestClass(const OBBoxCollisionTestClass & that) : - CollisionTestClass(that), - Box(that.Box), - Move(that.Move), - SweepMin(that.SweepMin), - SweepMax(that.SweepMax) -{ -} - -OBBoxCollisionTestClass::OBBoxCollisionTestClass -( - const OBBoxCollisionTestClass & that, - const Matrix3D & tm -) : - CollisionTestClass(that) -{ - tm.Transform_Min_Max_AABox(that.SweepMin,that.SweepMax,&SweepMin,&SweepMax); - Matrix3D::Rotate_Vector(tm,that.Move,&Move); - OBBoxClass::Transform(tm,that.Box,&Box); -} - -OBBoxCollisionTestClass::OBBoxCollisionTestClass -( - const AABoxCollisionTestClass & that, - const Matrix3D & tm -) : - CollisionTestClass(that) -{ - tm.Transform_Min_Max_AABox(that.SweepMin,that.SweepMax,&SweepMin,&SweepMax); - Matrix3D::Rotate_Vector(tm,that.Move,&Move); - Matrix3D::Transform_Vector(tm,that.Box.Center,&(Box.Center)); - Box.Extent = that.Box.Extent; - Box.Basis = tm; // copies the 3x3 rotation portion of the transform -} - - -bool OBBoxCollisionTestClass::Cull(const AABoxClass & box) -{ - Vector3 min_corner; - Vector3 max_corner; - Vector3::Subtract(box.Center,box.Extent,&min_corner); - Vector3::Add(box.Center,box.Extent,&max_corner); - - if ((SweepMin.X > max_corner.X) || (SweepMax.X < min_corner.X)) { - return true; - } - - if ((SweepMin.Y > max_corner.Y) || (SweepMax.Y < min_corner.Y)) { - return true; - } - - if ((SweepMin.Z > max_corner.Z) || (SweepMax.Z < min_corner.Z)) { - return true; - } - return false; -} - diff --git a/Generals/Code/Libraries/Source/WWVegas/WW3D2/coltest.h b/Generals/Code/Libraries/Source/WWVegas/WW3D2/coltest.h deleted file mode 100644 index f406ecbb086..00000000000 --- a/Generals/Code/Libraries/Source/WWVegas/WW3D2/coltest.h +++ /dev/null @@ -1,317 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** 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 *** - *********************************************************************************************** - * * - * Project Name : WW3D * - * * - * $Archive:: /VSS_Sync/ww3d2/coltest.h $* - * * - * Org Author:: Greg Hjelstrom * - * * - * Author : Kenny Mitchell * - * * - * $Modtime:: 07/01/02 12:45p $* - * * - * $Revision:: 5 $* - * * - * 07/01/02 KM Coltype enum change to avoid MAX conflicts * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - - -#if defined(_MSC_VER) -#pragma once -#endif - -#ifndef COLTEST_H -#define COLTEST_H - -#include "always.h" -#include "castres.h" -#include "lineseg.h" -#include "aabox.h" -#include "obbox.h" -#include "tri.h" -#include "colmath.h" -#include "coltype.h" - -class RenderObjClass; - - -///////////////////////////////////////////////////////////////////////////////////////////////////////////// -// CollisionTestClass -// -// Each type of collision test will have an associated class which -// ties together all of the information necessary for the test. -// These classes also provide a perfect place to add any information -// which can be pre-calculated. -// -// The base class: CollisionTestClass simply contains a pointer to -// the user's CastResultStruct which will contain the results of -// the collision test. I store a pointer to a result structure -// because in some cases, new CollisionTestClasses are created in -// the process of checking (e.g. if the test needs to be transformed -// into another coordinate system) and I did not want to be -// constantly copying the result structure around. So, the user -// must allocate a result structure (usually on the stack) and keep it -// until the CollisionTestClass is discarded. -// -// Every CollisionTestClass should have the following functions: -// -// bool Cull(const Vector3 & min,const Vector3 & max); -// bool Cull(const AABoxClass & box); -// bool Cast_To_Triangle(const TriClass & tri); -// -// These are not virtual because I don't want to pay the price of virtual function -// calls at the point in the code where these are used. It may be possible to -// write template functions if we use these exact function prototpyes for all -// collision test classes though. -// -// -///////////////////////////////////////////////////////////////////////////////////////////////////////////// -class CollisionTestClass -{ -public: - CollisionTestClass(CastResultStruct * res,int collision_type); - CollisionTestClass(const CollisionTestClass & that); - -public: - CastResultStruct * Result; - int CollisionType; - RenderObjClass * CollidedRenderObj; -}; - - -inline CollisionTestClass::CollisionTestClass(CastResultStruct * res,int collision_type) : - Result(res), - CollisionType(collision_type), - CollidedRenderObj(NULL) -{ -} - -inline CollisionTestClass::CollisionTestClass(const CollisionTestClass & that) : - Result(that.Result), - CollisionType(that.CollisionType), - CollidedRenderObj(that.CollidedRenderObj) -{ -} - - -///////////////////////////////////////////////////////////////////////////////////////////////////////////// -// RayCollisionTestClass -// -// Contains a linesegment to be tested and of course the inherited -// pointer to a CollisionStruct for the result -// -///////////////////////////////////////////////////////////////////////////////////////////////////////////// -class RayCollisionTestClass : public CollisionTestClass -{ -public: - - RayCollisionTestClass(const LineSegClass & ray,CastResultStruct * res,int collision_type = COLL_TYPE_0,bool check_translucent=false, bool check_hidden=false); - RayCollisionTestClass(const RayCollisionTestClass & raytest,const Matrix3D & tm); - - bool Cull(const Vector3 & min,const Vector3 & max); - bool Cull(const AABoxClass & box); - bool Cast_To_Triangle(const TriClass & tri); - -public: - - LineSegClass Ray; - bool CheckTranslucent; - bool CheckHidden; - -private: - - // not implemented - RayCollisionTestClass(const RayCollisionTestClass &); - RayCollisionTestClass & operator = (const RayCollisionTestClass &); - -}; - - -inline RayCollisionTestClass::RayCollisionTestClass(const LineSegClass & ray,CastResultStruct * res,int collision_type,bool check_translucent, bool check_hidden) : - CollisionTestClass(res,collision_type), - Ray(ray), - CheckTranslucent(check_translucent), - CheckHidden(check_hidden) -{ -} - -inline RayCollisionTestClass::RayCollisionTestClass(const RayCollisionTestClass & raytest,const Matrix3D & tm) : - CollisionTestClass(raytest), - Ray(raytest.Ray,tm), - CheckTranslucent(raytest.CheckTranslucent), - CheckHidden(raytest.CheckHidden) -{ -} - -inline bool RayCollisionTestClass::Cull(const Vector3 & min,const Vector3 & max) -{ - return (CollisionMath::Overlap_Test(min,max,Ray) == CollisionMath::POS); -} - -inline bool RayCollisionTestClass::Cull(const AABoxClass & box) -{ - return (CollisionMath::Overlap_Test(box,Ray) == CollisionMath::POS); -} - -inline bool RayCollisionTestClass::Cast_To_Triangle(const TriClass & tri) -{ - return CollisionMath::Collide(Ray,tri,Result); -} - - -///////////////////////////////////////////////////////////////////////////////////////////////////////////// -// AABoxCollisionTestClass -// -// Contains an Axis Aligned Box and a movement vector to be tested -// for collision. Also adds Min and Max vectors both for the initial -// box and for the volume swept out by the box. -// -///////////////////////////////////////////////////////////////////////////////////////////////////////////// -class AABoxCollisionTestClass : public CollisionTestClass -{ -public: - - AABoxCollisionTestClass(const AABoxClass & aabox,const Vector3 & move,CastResultStruct * res,int collision_type = COLL_TYPE_0); - AABoxCollisionTestClass(const AABoxCollisionTestClass & that); - - enum ROTATION_TYPE - { - ROTATE_NONE = 0, - ROTATE_Z90, - ROTATE_Z180, - ROTATE_Z270 - }; - - bool Cull(const Vector3 & min,const Vector3 & max); - bool Cull(const AABoxClass & box); - bool Cast_To_Triangle(const TriClass & tri); - - void Translate(const Vector3 & translation); - void Rotate(ROTATION_TYPE rotation); - void Transform(const Matrix3D & tm); - -public: - - AABoxClass Box; - Vector3 Move; - - Vector3 SweepMin; - Vector3 SweepMax; - -private: - - // not implemented - AABoxCollisionTestClass & operator = (const AABoxCollisionTestClass &); - -}; - - -inline void AABoxCollisionTestClass::Translate(const Vector3 & translation) -{ - // translate the test by the desired translation vector - Box.Center += translation; - SweepMin += translation; - SweepMax += translation; -} - -inline bool AABoxCollisionTestClass::Cull(const Vector3 & min,const Vector3 & max) -{ - if ((SweepMin.X > max.X) || (SweepMax.X < min.X)) { - return true; - } - - if ((SweepMin.Y > max.Y) || (SweepMax.Y < min.Y)) { - return true; - } - - if ((SweepMin.Z > max.Z) || (SweepMax.Z < min.Z)) { - return true; - } - return false; -} - -inline bool AABoxCollisionTestClass::Cast_To_Triangle(const TriClass & tri) -{ - return CollisionMath::Collide(Box,Move,tri,Result); -} - - -///////////////////////////////////////////////////////////////////////////////////////////////////////////// -// OBBoxCollisionTestClass -// -// Contains an Oriented Bounding Box and a movement vector to be tested -// for collision. Also adds Min and Max vectors (axis aligned box) -// both for the initial box and for the volume swept out by the box. -// -///////////////////////////////////////////////////////////////////////////////////////////////////////////// -class OBBoxCollisionTestClass : public CollisionTestClass -{ -public: - - OBBoxCollisionTestClass(const OBBoxClass & obbox,const Vector3 & move,CastResultStruct * res,int type = COLL_TYPE_0); - OBBoxCollisionTestClass(const OBBoxCollisionTestClass & that); - OBBoxCollisionTestClass(const OBBoxCollisionTestClass & that,const Matrix3D & tm); - OBBoxCollisionTestClass(const AABoxCollisionTestClass & that,const Matrix3D & tm); - - bool Cull(const Vector3 & min,const Vector3 & max); - bool Cull(const AABoxClass & box); - bool Cast_To_Triangle(const TriClass & tri); - -public: - - OBBoxClass Box; - Vector3 Move; - Vector3 SweepMin; - Vector3 SweepMax; - -private: - // not implemented - OBBoxCollisionTestClass & operator = (const OBBoxCollisionTestClass &); -}; - - -inline bool OBBoxCollisionTestClass::Cull(const Vector3 & min,const Vector3 & max) -{ - if ((SweepMin.X > max.X) || (SweepMax.X < min.X)) { - return true; - } - - if ((SweepMin.Y > max.Y) || (SweepMax.Y < min.Y)) { - return true; - } - - if ((SweepMin.Z > max.Z) || (SweepMax.Z < min.Z)) { - return true; - } - return false; -} - -inline bool OBBoxCollisionTestClass::Cast_To_Triangle(const TriClass & tri) -{ - return CollisionMath::Collide(Box,Move,tri,Vector3(0,0,0),Result); -} - - -#endif diff --git a/Generals/Code/Libraries/Source/WWVegas/WW3D2/coltype.h b/Generals/Code/Libraries/Source/WWVegas/WW3D2/coltype.h deleted file mode 100644 index 4047f469d0f..00000000000 --- a/Generals/Code/Libraries/Source/WWVegas/WW3D2/coltype.h +++ /dev/null @@ -1,94 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** 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 *** - *********************************************************************************************** - * * - * Project Name : WW3D * - * * - * $Archive:: /Commando/Code/ww3d2/coltype.h $* - * * - * Original Author:: Greg Hjelstrom * - * * - * Author : Kenny Mitchell * - * * - * $Modtime:: 07/01/02 12:45p $* - * * - * $Revision:: 2 $* - * * - * 07/01/02 KM Coltype enum change to avoid MAX conflicts * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - - -#if defined(_MSC_VER) -#pragma once -#endif - - -#ifndef COLTYPE_H -#define COLTYPE_H - - -///////////////////////////////////////////////////////////////////////////////////////////////////////////// -// -// Collision 'Types' -// -// This enum defines the collision type bit-field that is used in render object -// collision detection. -// -// The collision type field in a collision or intersection test is used as a -// low-level collision mask. It will be 'AND'ed with the collision type of -// the render object and will ignore the object unless the result is -// non-zero. In Commando, we use this to implement separate collision -// representations for "physical" collisions versus "projectile" -// collisions. I.e. we use a very simple mesh for the character's -// physical collision and a more complex set of meshes for checking whether -// a bullet hits a person. This masking system is not meant to be a general -// "collision grouping" system. You should use a higher level system for doing -// things like making bullets ignore each other, etc. -// -// One more wrinkle to the system: The collision type in the render obj -// will always have the LSB set (COLL_TYPE_ALL) so that you can always -// do queries against every piece of geometry in a render obj if desired. -// -///////////////////////////////////////////////////////////////////////////////////////////////////////////// -enum -{ - COLL_TYPE_ALL = 0x01, // perform this test against *EVERYTHING* - COLL_TYPE_0 = 0x02, // perform this test against type 0 collision objects - COLL_TYPE_1 = 0x04, // perform this test against type 1 collision objects - COLL_TYPE_2 = 0x08, - COLL_TYPE_3 = 0x10, - COLL_TYPE_4 = 0x20, - COLL_TYPE_5 = 0x40, - COLL_TYPE_6 = 0x80, - - COLL_TYPE_PHYSICAL = COLL_TYPE_0, // physics collisions - COLL_TYPE_PROJECTILE = COLL_TYPE_1, // projectile collisions - COLL_TYPE_VIS = COLL_TYPE_2, // "vis node" detection - COLL_TYPE_CAMERA = COLL_TYPE_3, // camera collision (99% should match physical setting) - COLL_TYPE_VEHICLE = COLL_TYPE_4, // vehicles will collide with physical and this. -}; - - - -#endif - diff --git a/Generals/Code/Libraries/Source/WWVegas/WW3D2/composite.cpp b/Generals/Code/Libraries/Source/WWVegas/WW3D2/composite.cpp deleted file mode 100644 index f07e78cdfaf..00000000000 --- a/Generals/Code/Libraries/Source/WWVegas/WW3D2/composite.cpp +++ /dev/null @@ -1,561 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** 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 *** - *********************************************************************************************** - * * - * Project Name : WW3D * - * * - * $Archive:: /Commando/Code/ww3d2/composite.cpp $* - * * - * Author:: Greg Hjelstrom * - * * - * $Modtime:: 11/27/01 12:45a $* - * * - * $Revision:: 6 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * CompositeRenderObjClass::CompositeRenderObjClass -- Constructor * - * CompositeRenderObjClass::CompositeRenderObjClass -- copy constructor * - * CompositeRenderObjClass::~CompositeRenderObjClass -- Destructor * - * CompositeRenderObjClass::operator -- assignment operator * - * CompositeRenderObjClass::Restart -- Recursively call Restart on all sub-objects * - * CompositeRenderObjClass::Get_Name -- returns the name of this render object * - * CompositeRenderObjClass::Set_Name -- sets the name of this render object * - * CompositeRenderObjClass::Set_Base_Model_Name -- sets the "base-model-name" * - * CompositeRenderObjClass::Get_Num_Polys -- returns the number of polys * - * CompositeRenderObjClass::Notify_Added -- notify all sub-objects that they were added * - * CompositeRenderObjClass::Notify_Removed -- notifies all subobjs they were removed from th * - * CompositeRenderObjClass::Cast_Ray -- cast a ray against this object * - * CompositeRenderObjClass::Cast_AABox -- cast a swept AABox against this object * - * CompositeRenderObjClass::Cast_OBBox -- cast a swept OBBox against this object * - * CompositeRenderObjClass::Intersect_AABox -- intersect this object with an AABox * - * CompositeRenderObjClass::Intersect_OBBox -- intersect this object with an OBBox * - * CompositeRenderObjClass::Create_Decal -- create a decal on this object * - * CompositeRenderObjClass::Delete_Decal -- remove a logical decal from this object * - * CompositeRenderObjClass::Update_Obj_Space_Bounding_Volumes -- updates the object-space BV * - * CompositeRenderObjClass::Set_User_Data -- set the userdata pointer * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - - -#include "composite.h" -#include "wwdebug.h" -#include -#include - - -/*********************************************************************************************** - * CompositeRenderObjClass::CompositeRenderObjClass -- Constructor * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - *=============================================================================================*/ -CompositeRenderObjClass::CompositeRenderObjClass(void) -{ -} - - -/*********************************************************************************************** - * CompositeRenderObjClass::CompositeRenderObjClass -- copy constructor * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 1/26/00 gth : Created. * - *=============================================================================================*/ -CompositeRenderObjClass::CompositeRenderObjClass(const CompositeRenderObjClass & that) -{ - Set_Name(that.Get_Name()); - Set_Base_Model_Name(that.Get_Base_Model_Name()); -} - - -/*********************************************************************************************** - * CompositeRenderObjClass::~CompositeRenderObjClass -- Destructor * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 1/26/00 gth : Created. * - *=============================================================================================*/ -CompositeRenderObjClass::~CompositeRenderObjClass(void) -{ -} - - -/*********************************************************************************************** - * CompositeRenderObjClass::operator -- assignment operator * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 1/26/00 gth : Created. * - *=============================================================================================*/ -CompositeRenderObjClass & CompositeRenderObjClass::operator = (const CompositeRenderObjClass & that) -{ - Set_Name(that.Get_Name()); - Set_Base_Model_Name(that.Get_Base_Model_Name()); - return *this; -} - - -/*********************************************************************************************** - * CompositeRenderObjClass::Restart -- Recursively call Restart on all sub-objects * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 5/30/2001 gth : Created. * - *=============================================================================================*/ -void CompositeRenderObjClass::Restart(void) -{ - for (int ni = 0; ni < Get_Num_Sub_Objects(); ni++) { - RenderObjClass * robj = Get_Sub_Object(ni); - WWASSERT(robj); - robj->Restart(); - robj->Release_Ref(); - } -} - -/*********************************************************************************************** - * CompositeRenderObjClass::Get_Name -- returns the name of this render object * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 1/26/00 gth : Created. * - *=============================================================================================*/ -const char * CompositeRenderObjClass::Get_Name(void) const -{ - return Name; -} - - -/*********************************************************************************************** - * CompositeRenderObjClass::Set_Name -- sets the name of this render object * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 1/26/00 gth : Created. * - *=============================================================================================*/ -void CompositeRenderObjClass::Set_Name(const char * name) -{ - Name=name; -} - - -/*********************************************************************************************** - * CompositeRenderObjClass::Set_Base_Model_Name -- sets the "base-model-name" * - * * - * The base-model-name was needed by the aggregate code. Ask Patrick Smith about it :-) * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 1/26/00 gth : Created. * - *=============================================================================================*/ -void CompositeRenderObjClass::Set_Base_Model_Name(const char *name) -{ - // NULL is a legal value for BaseModelName. Unfortunately, - // StringClass::operator= does not modify the string when - // assigning NULL, so we explicitly handle that case here. - if (name != 0) { - BaseModelName = name; - } else { - BaseModelName = ""; - } -} - - -/*********************************************************************************************** - * CompositeRenderObjClass::Get_Num_Polys -- returns the number of polys * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 1/26/00 gth : Created. * - *=============================================================================================*/ -int CompositeRenderObjClass::Get_Num_Polys(void) const -{ - int count = 0; - for (int ni = 0; ni < Get_Num_Sub_Objects(); ni++) { - RenderObjClass * robj = Get_Sub_Object(ni); - WWASSERT(robj); - count += robj->Get_Num_Polys(); - robj->Release_Ref(); - } - return count; -} - - -/*********************************************************************************************** - * CompositeRenderObjClass::Notify_Added -- notify all sub-objects that they were added * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 1/26/00 gth : Created. * - *=============================================================================================*/ -void CompositeRenderObjClass::Notify_Added(SceneClass * scene) -{ - RenderObjClass::Notify_Added(scene); - for (int ni = 0; ni < Get_Num_Sub_Objects(); ni++) { - RenderObjClass * robj = Get_Sub_Object(ni); - WWASSERT(robj); - robj->Notify_Added(scene); - robj->Release_Ref(); - } -} - - -/*********************************************************************************************** - * CompositeRenderObjClass::Notify_Removed -- notifies all subobjs they were removed from the * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 1/26/00 gth : Created. * - *=============================================================================================*/ -void CompositeRenderObjClass::Notify_Removed(SceneClass * scene) -{ - for (int ni = 0; ni < Get_Num_Sub_Objects(); ni++) { - RenderObjClass * robj = Get_Sub_Object(ni); - WWASSERT(robj); - robj->Notify_Removed(scene); - robj->Release_Ref(); - } - RenderObjClass::Notify_Removed(scene); -} - - -/*********************************************************************************************** - * CompositeRenderObjClass::Cast_Ray -- cast a ray against this object * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 1/26/00 gth : Created. * - *=============================================================================================*/ -bool CompositeRenderObjClass::Cast_Ray(RayCollisionTestClass & raytest) -{ - bool res = false; - for (int i=0; iCast_Ray(raytest); - robj->Release_Ref(); - } - return res; -} - - -/*********************************************************************************************** - * CompositeRenderObjClass::Cast_AABox -- cast a swept AABox against this object * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 1/26/00 gth : Created. * - *=============================================================================================*/ -bool CompositeRenderObjClass::Cast_AABox(AABoxCollisionTestClass & boxtest) -{ - bool res = false; - for (int i=0; iCast_AABox(boxtest); - robj->Release_Ref(); - } - return res; -} - - -/*********************************************************************************************** - * CompositeRenderObjClass::Cast_OBBox -- cast a swept OBBox against this object * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 1/26/00 gth : Created. * - *=============================================================================================*/ -bool CompositeRenderObjClass::Cast_OBBox(OBBoxCollisionTestClass & boxtest) -{ - bool res = false; - for (int i=0; iCast_OBBox(boxtest); - robj->Release_Ref(); - } - return res; -} - - -/*********************************************************************************************** - * CompositeRenderObjClass::Intersect_AABox -- intersect this object with an AABox * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 1/26/00 gth : Created. * - *=============================================================================================*/ -bool CompositeRenderObjClass::Intersect_AABox(AABoxIntersectionTestClass & boxtest) -{ - bool res = false; - for (int i=0; iIntersect_AABox(boxtest); - robj->Release_Ref(); - } - return res; -} - - -/*********************************************************************************************** - * CompositeRenderObjClass::Intersect_OBBox -- intersect this object with an OBBox * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 1/26/00 gth : Created. * - *=============================================================================================*/ -bool CompositeRenderObjClass::Intersect_OBBox(OBBoxIntersectionTestClass & boxtest) -{ - bool res = false; - for (int i=0; iIntersect_OBBox(boxtest); - robj->Release_Ref(); - } - return res; -} - - -/*********************************************************************************************** - * CompositeRenderObjClass::Create_Decal -- create a decal on this object * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 1/26/00 gth : Created. * - *=============================================================================================*/ -void CompositeRenderObjClass::Create_Decal(DecalGeneratorClass * generator) -{ - for (int i=0; iCreate_Decal(generator); - robj->Release_Ref(); - } -} - - -/*********************************************************************************************** - * CompositeRenderObjClass::Delete_Decal -- remove a logical decal from this object * - * * - * This internally removes all decals with the given ID. The ID comes from the generator * - * which was used to create the decals. * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 1/26/00 gth : Created. * - *=============================================================================================*/ -void CompositeRenderObjClass::Delete_Decal(uint32 decal_id) -{ - for (int i=0; iDelete_Decal(decal_id); - robj->Release_Ref(); - } -} - - -/*********************************************************************************************** - * CompositeRenderObjClass::Update_Obj_Space_Bounding_Volumes -- updates the object-space BVs * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 1/26/00 gth : Created. * - *=============================================================================================*/ -void CompositeRenderObjClass::Update_Obj_Space_Bounding_Volumes(void) -{ - int i; - RenderObjClass * robj = NULL; - - // if we don't have any sub objects, just set default bounds - if (Get_Num_Sub_Objects() <= 0) { - ObjSphere.Init(Vector3(0,0,0),0); - ObjBox.Center.Set(0,0,0); - ObjBox.Extent.Set(0,0,0); - return; - } - - - AABoxClass obj_aabox; - MinMaxAABoxClass box; - SphereClass sphere; - - // loop through all sub-objects, combining their object-space bounding spheres and boxes. - robj = Get_Sub_Object(0); - WWASSERT(robj); - robj->Get_Obj_Space_Bounding_Sphere(ObjSphere); - robj->Get_Obj_Space_Bounding_Box(obj_aabox); - robj->Release_Ref(); - box.Init(obj_aabox); - - for (i=1; iGet_Obj_Space_Bounding_Sphere(sphere); - robj->Get_Obj_Space_Bounding_Box(obj_aabox); - - ObjSphere.Add_Sphere(sphere); - box.Add_Box(obj_aabox); - - robj->Release_Ref(); - } - - ObjBox.Init(box); - - Invalidate_Cached_Bounding_Volumes(); - - // Now update the object space bounding volumes of this object's container: - RenderObjClass *container = Get_Container(); - if (container) container->Update_Obj_Space_Bounding_Volumes(); -} - -/*********************************************************************************************** - * CompositeRenderObjClass::Set_User_Data -- set the userdata * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 1/26/00 gth : Created. * - *=============================================================================================*/ -void CompositeRenderObjClass::Set_User_Data(void *value, bool recursive) -{ - RenderObjClass::Set_User_Data(value); - if (recursive) { - for (int i=0; iSet_User_Data(value,recursive); - robj->Release_Ref(); - } - } -} - -const char * CompositeRenderObjClass::Get_Base_Model_Name (void) const -{ - if (BaseModelName.Is_Empty()) { - return NULL; - } - - return BaseModelName; -} \ No newline at end of file diff --git a/Generals/Code/Libraries/Source/WWVegas/WW3D2/composite.h b/Generals/Code/Libraries/Source/WWVegas/WW3D2/composite.h deleted file mode 100644 index 007f01706a4..00000000000 --- a/Generals/Code/Libraries/Source/WWVegas/WW3D2/composite.h +++ /dev/null @@ -1,99 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** 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 *** - *********************************************************************************************** - * * - * Project Name : WW3D * - * * - * $Archive:: /Commando/Code/ww3d2/composite.h $* - * * - * Author:: Greg Hjelstrom * - * * - * $Modtime:: 11/25/01 12:25p $* - * * - * $Revision:: 5 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - - -#if defined(_MSC_VER) -#pragma once -#endif - -#ifndef COMPOSITE_H -#define COMPOSITE_H - -#include "rendobj.h" -#include "wwstring.h" - -/* -** CompositeRenderObjClass -** The sole purpose of this class is to encapsulate some of the chores that all -** "composite" (contain sub objects) render objects have to do. Typically all -** of the functions are implemented through the existing sub-object interface -** so there is still no assumption on how you store/organize your sub-objects. -*/ -class CompositeRenderObjClass : public RenderObjClass -{ -public: - - CompositeRenderObjClass(void); - CompositeRenderObjClass(const CompositeRenderObjClass & that); - virtual ~CompositeRenderObjClass(void); - CompositeRenderObjClass & operator = (const CompositeRenderObjClass & that); - - virtual void Restart(void); - - virtual const char * Get_Name(void) const; - virtual void Set_Name(const char * name); - virtual const char * Get_Base_Model_Name (void) const; - virtual void Set_Base_Model_Name (const char *name); - virtual int Get_Num_Polys(void) const; - virtual void Notify_Added(SceneClass * scene); - virtual void Notify_Removed(SceneClass * scene); - - virtual bool Cast_Ray(RayCollisionTestClass & raytest); - virtual bool Cast_AABox(AABoxCollisionTestClass & boxtest); - virtual bool Cast_OBBox(OBBoxCollisionTestClass & boxtest); - virtual bool Intersect_AABox(AABoxIntersectionTestClass & boxtest); - virtual bool Intersect_OBBox(OBBoxIntersectionTestClass & boxtest); - - virtual void Create_Decal(DecalGeneratorClass * generator); - virtual void Delete_Decal(uint32 decal_id); - - virtual void Get_Obj_Space_Bounding_Sphere(SphereClass & sphere) const { sphere = ObjSphere; } - virtual void Get_Obj_Space_Bounding_Box(AABoxClass & box) const { box = ObjBox; } - virtual void Update_Obj_Space_Bounding_Volumes(void); - - virtual void Set_User_Data(void *value, bool recursive = false); - -protected: - - StringClass Name; // name of the render object - StringClass BaseModelName; // name of the original render obj (before aggregation) - SphereClass ObjSphere; // object-space bounding sphere - AABoxClass ObjBox; // object-space bounding box -}; - - - -#endif \ No newline at end of file diff --git a/Generals/Code/Libraries/Source/WWVegas/WW3D2/decalsys.cpp b/Generals/Code/Libraries/Source/WWVegas/WW3D2/decalsys.cpp deleted file mode 100644 index 581b388e902..00000000000 --- a/Generals/Code/Libraries/Source/WWVegas/WW3D2/decalsys.cpp +++ /dev/null @@ -1,489 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** 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 *** - *********************************************************************************************** - * * - * Project Name : WW3D * - * * - * $Archive:: /Commando/Code/ww3d2/decalsys.cpp $* - * * - * Original Author:: Greg Hjelstrom * - * * - * $Author:: Kenny Mitchell * - * * - * $Modtime:: 06/26/02 4:04p $* - * * - * $Revision:: 8 $* - * * - * 06/26/02 KM Matrix name change to avoid MAX conflicts * - *---------------------------------------------------------------------------------------------* - * Functions: * - * DecalSystemClass::DecalSystemClass -- Constructor * - * DecalSystemClass::~DecalSystemClass -- Destructor * - * DecalSystemClass::Lock_Decal_Generator -- returns a DecalGenerator * - * DecalSystemClass::Unlock_Decal_Generator -- Destroys the decal generator * - * DecalSystemClass::Generate_Unique_Global_Decal_Id -- Generates a unique id for a decal * - * DecalGeneratorClass::DecalGeneratorClass -- Constructor * - * DecalGeneratorClass::~DecalGeneratorClass -- Destructor * - * DecalGeneratorClass::Add_Mesh -- Meshes that generate a decal should add themselves * - * DecalGeneratorClass::Get_Mesh_List -- returns the list of meshes * - * DecalGeneratorClass::Set_Mesh_Transform -- sets the current mesh coordinate system * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#include "decalsys.h" -#include "rendobj.h" -#include "mesh.h" -#include "decalmsh.h" -#include "matrixmapper.h" -#include "texture.h" - - -uint32 DecalSystemClass::DecalIDGenerator = 0; - - -/* -** DecalSystemClass Implementation -*/ - -/*********************************************************************************************** - * DecalSystemClass::DecalSystemClass -- Constructor * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - *=============================================================================================*/ -DecalSystemClass::DecalSystemClass(void) -{ -} - - -/*********************************************************************************************** - * DecalSystemClass::~DecalSystemClass -- Destructor * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - *=============================================================================================*/ -DecalSystemClass::~DecalSystemClass(void) -{ -} - - -/*********************************************************************************************** - * DecalSystemClass::Lock_Decal_Generator -- returns a DecalGenerator * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 1/26/00 gth : Created. * - *=============================================================================================*/ -DecalGeneratorClass * DecalSystemClass::Lock_Decal_Generator(void) -{ - DecalGeneratorClass * gen = W3DNEW DecalGeneratorClass(Generate_Decal_Id(), this); - return gen; -} - - -/*********************************************************************************************** - * DecalSystemClass::Unlock_Decal_Generator -- Destroys the decal generator * - * * - * Derived classes may take a record of the results of the generator here. Then they can * - * put a cap on the total number of decals in the system or whatever... * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 1/26/00 gth : Created. * - *=============================================================================================*/ -void DecalSystemClass::Unlock_Decal_Generator(DecalGeneratorClass * generator) -{ - delete generator; -} - - -/*********************************************************************************************** - * DecalSystemClass::Generate_Unique_Global_Decal_Id -- Generates a unique id for a decal * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * Hopefully you won't use more than 4 billion decals at one time... * - * * - * HISTORY: * - * 1/26/00 gth : Created. * - *=============================================================================================*/ -uint32 DecalSystemClass::Generate_Unique_Global_Decal_Id(void) -{ - return DecalIDGenerator++; -} - - -/* -** DecalGeneratorClass Implementation -*/ - -/*********************************************************************************************** - * DecalGeneratorClass::DecalGeneratorClass -- Constructor * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 1/26/00 gth : Created. * - *=============================================================================================*/ -DecalGeneratorClass::DecalGeneratorClass(uint32 id,DecalSystemClass * system) : - DecalID(id), - System(system), - BackfaceVal(0.0f), - ApplyToTranslucentMeshes(false), - Material(NULL) -{ - Material = NEW_REF(MaterialPassClass,()); - - WWASSERT(System != NULL); - WWASSERT(Material != NULL); -} - - -/*********************************************************************************************** - * DecalGeneratorClass::~DecalGeneratorClass -- Destructor * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 1/26/00 gth : Created. * - *=============================================================================================*/ -DecalGeneratorClass::~DecalGeneratorClass(void) -{ - REF_PTR_RELEASE(Material); -} - - -/*********************************************************************************************** - * DecalGeneratorClass::Add_Mesh -- Meshes that generate a decal should add themselves * - * * - * This adds a mesh to the internal list. All meshes that actually add a decal should add * - * themselves to this list so that the DecalSystem can keep track of them. * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 1/26/00 gth : Created. * - *=============================================================================================*/ -void DecalGeneratorClass::Add_Mesh(RenderObjClass * mesh) -{ - WWASSERT(mesh->Class_ID() == RenderObjClass::CLASSID_MESH); - MeshList.Add(mesh); -} - - -/*********************************************************************************************** - * DecalGeneratorClass::Get_Mesh_List -- returns the list of meshes * - * * - * This is the list of meshes which generated decals for this "logical decal" * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 1/26/00 gth : Created. * - *=============================================================================================*/ -NonRefRenderObjListClass & DecalGeneratorClass::Get_Mesh_List(void) -{ - return MeshList; -} - - -/*********************************************************************************************** - * DecalGeneratorClass::Set_Mesh_Transform -- sets the current mesh coordinate system * - * * - * The coordinate system of the mesh is needed in order to compute texture coordinates for * - * the decal polygons. * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 1/26/00 gth : Created. * - *=============================================================================================*/ -void DecalGeneratorClass::Set_Mesh_Transform(const Matrix3D & mesh_transform) -{ - /* - ** Mobj-texture = Projection * Mwrld-texture * Mobj-wrld - */ - Matrix3D world_to_texture; - Matrix3D tmp; - Matrix4x4 mesh_to_texture; - - Transform.Get_Orthogonal_Inverse(world_to_texture); - Matrix3D::Multiply(world_to_texture,mesh_transform,&tmp); - Matrix4x4::Multiply(Projection,tmp,&mesh_to_texture); - - /* - ** Plug the matrix and texture size into the mapper - */ - if (WW3D::Is_Texturing_Enabled()) { - float texsize = 64.0f; - TextureClass * tex = Material->Peek_Texture(); - WWASSERT(tex != NULL); - if (tex) { -// SurfaceClass::SurfaceDescription surface_desc; -// tex->Get_Level_Description(surface_desc); -// texsize = surface_desc.Width; - texsize = tex->Get_Width(); - } - - Mapper->Set_Texture_Transform(mesh_to_texture,texsize); - } -} - - -/* -** MultiFixedPoolDecalSystemClass implementation -*/ - -MultiFixedPoolDecalSystemClass::MultiFixedPoolDecalSystemClass(uint32 num_pools, const uint32 *pool_sizes) : - Pools(0), - PoolCount(num_pools), - Generator_PoolID(0), - Generator_SlotID(0) -{ - if (PoolCount) - { - WWASSERT(pool_sizes); - Pools = W3DNEWARRAY LogicalDecalPoolClass [PoolCount]; - } - for (uint32 i = 0; i < PoolCount; i++) { - assert(pool_sizes[i]); - Pools[i].Initialize(pool_sizes[i]); - } -} - -MultiFixedPoolDecalSystemClass::MultiFixedPoolDecalSystemClass(const MultiFixedPoolDecalSystemClass & that) : - Pools(0), - PoolCount(that.PoolCount), - Generator_PoolID(that.Generator_PoolID), - Generator_SlotID(that.Generator_SlotID) -{ - uint32 i; - - // Allocate arrays (we dont' copy array contents because those are mesh-specific and will be - // filled when the state is set anyway) - if (PoolCount) Pools = W3DNEWARRAY LogicalDecalPoolClass [PoolCount]; - for (i = 0; i < PoolCount; i++) { - Pools[i].Initialize(that.Pools[i].Size); - } -} - -MultiFixedPoolDecalSystemClass::~MultiFixedPoolDecalSystemClass(void) -{ - if (Pools) { - delete [] Pools; - Pools = 0; - } -} - -// This clears the slot in addition to locking the generator, thus preventing any decal id -// collisions (since any decal previously in that slot will have the same id as the new one). -DecalGeneratorClass * MultiFixedPoolDecalSystemClass::Lock_Decal_Generator(void) -{ - Clear_Decal_Slot(Generator_PoolID, Generator_SlotID); - return DecalSystemClass::Lock_Decal_Generator(); -} - -// This will register the decal in the system in the appropriate pool and slot (determined by -// the generator's pool and slot ids), removing any decal which may have been there before. -void MultiFixedPoolDecalSystemClass::Unlock_Decal_Generator(DecalGeneratorClass * generator) -{ - find_logical_decal(generator->Get_Decal_ID()).Set(generator); - DecalSystemClass::Unlock_Decal_Generator(generator); -} - -// This notifies the system that a mesh which has decals on it was destroyed - therefore we -// need to remove the mesh from our list to avoid dangling pointers. -void MultiFixedPoolDecalSystemClass::Decal_Mesh_Destroyed(uint32 decal_id,DecalMeshClass * mesh) -{ - // We must remove this mesh from all lists where it is present. The method is: for each - // decal id present in the decal mesh, find the logical decal and remove the decal mesh from - // its list. - assert(mesh); - MeshClass *parent = mesh->Peek_Parent(); - find_logical_decal(decal_id).MeshList.Remove(parent); -} - -// Not part of the DecalSystemClass interface - this function removes any decal currently in -// the given slot in the given pool. -void MultiFixedPoolDecalSystemClass::Clear_Decal_Slot(uint32 pool_id, uint32 slot_id) -{ - find_logical_decal(pool_id, slot_id).Clear(encode_decal_id(pool_id, slot_id)); -} - -// This one removes all decals in a given pool. -void MultiFixedPoolDecalSystemClass::Clear_Pool(uint32 pool_id) -{ - LogicalDecalPoolClass & pool = Pools[pool_id]; - uint32 pool_size = pool.Size; - for (uint32 slot_id = 0; slot_id < pool_size; slot_id++) { - pool.Array[slot_id].Clear(encode_decal_id(pool_id, slot_id)); - } -} - -// And this one removes all decals in the system. -void MultiFixedPoolDecalSystemClass::Clear_All_Decals(void) -{ - for (uint32 pool_id = 0; pool_id < PoolCount; pool_id++) { - LogicalDecalPoolClass & pool = Pools[pool_id]; - uint32 pool_size = pool.Size; - for (uint32 slot_id = 0; slot_id < pool_size; slot_id++) { - pool.Array[slot_id].Clear(encode_decal_id(pool_id, slot_id)); - } - } -} - -// Get a reference to the logical decal at the given pool and slot id (performs range checking) -MultiFixedPoolDecalSystemClass::LogicalDecalClass & MultiFixedPoolDecalSystemClass::find_logical_decal(uint32 pool_id, uint32 slot_id) -{ - assert(pool_id < PoolCount); - pool_id = MIN(pool_id, PoolCount); - LogicalDecalPoolClass & pool = Pools[pool_id]; - assert(slot_id < pool.Size); - slot_id = MIN(slot_id, pool.Size); - return pool.Array[slot_id]; -} - -// Get a reference to the logical decal with the given decal id -MultiFixedPoolDecalSystemClass::LogicalDecalClass & MultiFixedPoolDecalSystemClass::find_logical_decal(uint32 decal_id) -{ - uint32 pool_id, slot_id; - decode_decal_id(decal_id, pool_id, slot_id); - return find_logical_decal(pool_id, slot_id); -} - - -/* -** MultiFixedPoolDecalSystemClass::LogicalDecalClass implementation -*/ - -MultiFixedPoolDecalSystemClass::LogicalDecalClass::LogicalDecalClass(void) -{ -} - -MultiFixedPoolDecalSystemClass::LogicalDecalClass::~LogicalDecalClass(void) -{ - // We don't need to do anything here since the mesh list will get removed automatically and - // the decals themselves don't neccessarily need to be removed because the logical decal is. - // (we don't hold references to the meshes in the mesh list) -} - -// Sets the logical decal to the one specified by the given generator (clearing any existing -// decal information) -void MultiFixedPoolDecalSystemClass::LogicalDecalClass::Set(DecalGeneratorClass * generator) -{ - Clear(generator->Get_Decal_ID()); - - /* - ** Copy the generators' mesh list into our mesh list - */ - NonRefRenderObjListIterator gen_mesh_it(&(generator->Get_Mesh_List())); - for (gen_mesh_it.First(); !gen_mesh_it.Is_Done(); gen_mesh_it.Next()) { - MeshList.Add(gen_mesh_it.Get_Obj()); - } -} - -// Just clears any existing logical decal information, leaving the decal empty. -void MultiFixedPoolDecalSystemClass::LogicalDecalClass::Clear(uint32 decal_id) -{ - // Remove the decal with this ID from all meshes where it appears - NonRefRenderObjListIterator it(&MeshList); - for (it.First(); !it.Is_Done(); it.Next()) { - it.Get_Obj()->Delete_Decal(decal_id); - } - - // Delete list - while (!MeshList.Is_Empty()) { - MeshList.Remove_Head(); - } -} - - -/* -** MultiFixedPoolDecalSystemClass::LogicalDecalPoolClass implementation -*/ - -MultiFixedPoolDecalSystemClass::LogicalDecalPoolClass::LogicalDecalPoolClass(void) : - Array(0), - Size(0) -{ -} - -MultiFixedPoolDecalSystemClass::LogicalDecalPoolClass::~LogicalDecalPoolClass(void) -{ - if (Array) { - delete [] Array; - Array = 0; - } -} - -void MultiFixedPoolDecalSystemClass::LogicalDecalPoolClass::Initialize(uint32 size) -{ - if (Array) { - delete [] Array; - Array = 0; - } - - Size = size; - assert(Size); - Array = W3DNEWARRAY LogicalDecalClass[Size]; -} diff --git a/Generals/Code/Libraries/Source/WWVegas/WW3D2/decalsys.h b/Generals/Code/Libraries/Source/WWVegas/WW3D2/decalsys.h deleted file mode 100644 index 80e9c4fd364..00000000000 --- a/Generals/Code/Libraries/Source/WWVegas/WW3D2/decalsys.h +++ /dev/null @@ -1,308 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** 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 *** - *********************************************************************************************** - * * - * Project Name : WW3D * - * * - * $Archive:: /Commando/Code/ww3d2/decalsys.h $* - * * - * Original Author:: Greg Hjelstrom * - * * - * $Author:: Greg_h $* - * * - * $Modtime:: 6/29/01 11:30a $* - * * - * $Revision:: 6 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#if defined(_MSC_VER) -#pragma once -#endif - -#ifndef DECALSYS_H -#define DECALSYS_H - -#include "always.h" -#include "matrix3d.h" -#include "matrix4.h" -#include "obbox.h" -#include "robjlist.h" -#include "matpass.h" -#include "projector.h" - -class DecalGeneratorClass; -class DecalMeshClass; - -/** -** DecalSystemClass -** This is a class that manages creation and destruction of decals in the system. It is -** meant to be over-ridden for game-specific behaviors. -** -** Sample Code: -** 1 - Create the generator. The system gives it a unique id and gives you a clean decal generator -** -** DecalGeneratorClass * gen = DecalSystem->Lock_Decal_Generator(); -** gen->Set_Transform(tm); -** gen->Set_Projection(proj_tm); -** gen->Set_Bounds(OBBox); -** -** 2 - Apply the generator to any objects that you want it to affect. It wont do anything if it -** does not overlap any polygons in those objects -** -** Scene->Collect_Objects(gen->Get_Bounding_Box(),objectlist); -** for (iterator.First(objectlist); !iterator.Is_Done(); iterator.Next()) { -** iterator.Peek_Object()->Create_Decal(gen); -** } -** -** 3 - Release the generator back to the system. At this point, the system may record which meshes -** actually generated extra decal polygons for future removal. All of this information will be -** tied together with the unique 'decal ID' that was assigned to the generator. -** -** DecalSystem->Unlock_Decal_Generator(gen); -** -*/ -class DecalSystemClass -{ -public: - DecalSystemClass(void); - virtual ~DecalSystemClass(void); - - /* - ** Create and release DecalGenerators. Note that this is the point at which the - ** decal system can track "logical" decals. The generator will keep an internal list - ** of all of the render objects which generated decals which you should copy if you - ** want to track them (e.g. if you want to cap the maximum number of active decals and - ** kill the old ones...) - */ - virtual DecalGeneratorClass * Lock_Decal_Generator(void); - virtual void Unlock_Decal_Generator(DecalGeneratorClass * generator); - - /* - ** When a decal-mesh is destroyed, it must inform the DecalSystem. Otherwise, systems - ** which track decals can get dangling pointers. - */ - virtual void Decal_Mesh_Destroyed(uint32 decal_id,DecalMeshClass * mesh) { } - -protected: - - /* - ** This generates the decal ID when a generator is created. This decal system reroutes this - ** to Generate_Unique_Global_Decal_Id(), but other decal systems may use a different method. - */ - virtual uint32 Generate_Decal_Id(void) { return Generate_Unique_Global_Decal_Id(); } - - /* - ** Unique ID generation for decals. Not all decal systems have to use - ** this method of generating ids. Some may wish to assign the id as the - ** array index of the logical id or use some other aritrary method. - */ - static uint32 Generate_Unique_Global_Decal_Id(void); - - static uint32 DecalIDGenerator; -}; - - -/** -** DecalGeneratorClass -** This class encapsulates the information needed to generate a decal. It also tracks -** what meshes actually used it to generate new decal polygons. -*/ -class DecalGeneratorClass : public ProjectorClass -{ -public: - - /* - ** All meshes that actually generate decal polygons should register themselves in the - ** list. Then when the decal generation is finished, this list can be copied so that - ** we can come back to those meshes and remove the decals if we want to. - */ - void Add_Mesh(RenderObjClass * mesh); - NonRefRenderObjListClass & Get_Mesh_List(void); - - /* - ** Decal generator parameters. - ** see ProjectorClass for control over the coordinate system, projection, etc - */ - uint32 Get_Decal_ID(void) { return DecalID; } - DecalSystemClass * Peek_Decal_System(void) { return System; } - - /* - ** Backface rejection thresh-hold. The dot-product between the projection vector and - ** the normal of each polygon is taken, if the result is greater than this value the polygon - ** is accepted into the decal. Set it to -1 if you want to accept all polygons. - */ - void Set_Backface_Threshhold(float val) { BackfaceVal = val; } - float Get_Backface_Threshhold(void) { return BackfaceVal; } - - /* - ** Normally, decals are not generated on translucent meshes. This is due to the "floating - ** decals" that you can get on things like trees. The user can override this behavior - ** through the following interface. - */ - void Apply_To_Translucent_Meshes(bool onoff) { ApplyToTranslucentMeshes = onoff; } - bool Is_Applied_To_Translucent_Meshes(void) { return ApplyToTranslucentMeshes; } - - /* - ** Material parameters: just grab a pointer the material pass and modify it. - ** Remember to release your ref to it when you are done. - */ - MaterialPassClass * Get_Material(void) { WWASSERT(Material != NULL); Material->Add_Ref(); return Material; } - - /* - ** Decal generation support. Call Set_Mesh_Transform for the mesh you want to add - ** a decal to. Then for each vertex, you can call 'Compute_Texture_Coordinate' - */ - void Set_Mesh_Transform(const Matrix3D & tm); - -protected: - - DecalGeneratorClass(uint32 id,DecalSystemClass * system); - ~DecalGeneratorClass(void); - - /* - ** Logical Decal ID, DecalSystem that this generator is tied to - */ - DecalSystemClass * System; - uint32 DecalID; // unique ID generated by the DecalSystem - - /* - ** Backface Threshhold, Translucent mesh decal enable - */ - float BackfaceVal; - bool ApplyToTranslucentMeshes; - - /* - ** Material settings - */ - MaterialPassClass * Material; // material settings for the decal - - /* - ** Results, list of the meshes which actually generated decal polygons for this logical decal. - */ - NonRefRenderObjListClass MeshList; - - friend class DecalSystemClass; -}; - - -/** -** MultiFixedPoolDecalSystemClass: This is for decal systems which use several fixed-size decal -** pools (If more than one pool is used, it is usually to have separate pools for several -** different classes of decals). Note that here the decal IDs are a combination of the pool and -** slot ids. (decal ids only have to be unique within a given decal system) -*/ - -class MultiFixedPoolDecalSystemClass : public DecalSystemClass -{ - -public: - - MultiFixedPoolDecalSystemClass(uint32 num_pools, const uint32 *pool_sizes); - MultiFixedPoolDecalSystemClass(const MultiFixedPoolDecalSystemClass & that); - virtual ~MultiFixedPoolDecalSystemClass(void); - - // This clears the slot in addition to locking the generator, thus preventing any decal id - // collisions (since any decal previously in that slot will have the same id as the new one). - virtual DecalGeneratorClass * Lock_Decal_Generator(void); - - // This will register the decal in the system in the appropriate pool and slot (determined by - // the generator's pool and slot ids), removing any decal which may have been there before. - virtual void Unlock_Decal_Generator(DecalGeneratorClass * generator); - - // This notifies the system that a mesh which has decals on it was destroyed - therefore we - // need to remove the mesh from our list to avoid dangling pointers. - virtual void Decal_Mesh_Destroyed(uint32 id,DecalMeshClass * mesh); - - // Not part of the DecalSystemClass interface - this function removes any decal currently in - // the given slot in the given pool. - void Clear_Decal_Slot(uint32 pool_id, uint32 slot_id); - - // This one removes all decals in a given pool. - void Clear_Pool(uint32 pool_id); - - // And this one removes all decals in the system. - void Clear_All_Decals(void); - -protected: - - /* - ** This generates the decal ID when a generator is created. This decal system generates the - ** decal ID from a pool ID and slot ID which are part of the state of the system so someone - ** can set them before calling Lock_Decal_Generator() (which is where this function is called). - ** We do it this way to avoid needing to override Lock_Decal_Generator(). - */ - virtual uint32 Generate_Decal_Id(void) { return encode_decal_id(Generator_PoolID, Generator_SlotID); } - uint32 Generator_PoolID; // These should be set before calling Lock_Decal_Generator() - uint32 Generator_SlotID; // These should be set before calling Lock_Decal_Generator() - - class LogicalDecalClass; - - // Get a reference to the logical decal at the given pool and slot id (performs range chacking) - LogicalDecalClass & find_logical_decal(uint32 pool_id, uint32 slot_id); - - // Get a reference to the logical decal with the given decal id - LogicalDecalClass & find_logical_decal(uint32 decal_id); - - // The decal ids are formed so that the upper 16 bits are equal to the pool id and the lower - // 16 bits are equal to the slot id. - static uint32 encode_decal_id(uint32 pool_id, uint32 slot_id) { return (slot_id & 0xFFFF) | (pool_id << 16); } - static void decode_decal_id(uint32 decal_id, uint32 & pool_id, uint32 & slot_id) { slot_id = decal_id & 0xFFFF; pool_id = decal_id >> 16; } - - // A class to store the meshes to which the decal has been applied (so that they can be removed when needed) - class LogicalDecalClass - { - public: - LogicalDecalClass(void); - ~LogicalDecalClass(void); - - void Set(DecalGeneratorClass * generator); - - // Just clears any existing logical decal information, leaving the decal empty. - void Clear(uint32 decal_id); - - NonRefRenderObjListClass MeshList; - }; - - class LogicalDecalPoolClass - { - public: - LogicalDecalPoolClass(void); - ~LogicalDecalPoolClass(void); - - void Initialize(uint32 size); - - LogicalDecalClass * Array; - uint32 Size; - }; - - LogicalDecalPoolClass * Pools; - uint32 PoolCount; - -}; - - - - -#endif //DECALSYS_H - diff --git a/Generals/Code/Libraries/Source/WWVegas/WW3D2/distlod.cpp b/Generals/Code/Libraries/Source/WWVegas/WW3D2/distlod.cpp deleted file mode 100644 index 2f096ea2c6e..00000000000 --- a/Generals/Code/Libraries/Source/WWVegas/WW3D2/distlod.cpp +++ /dev/null @@ -1,1166 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** 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 *** - *********************************************************************************************** - * * - * Project Name : WW3D * - * * - * $Archive:: /Commando/Code/ww3d2/distlod.cpp $* - * * - * Author:: Greg Hjelstrom * - * * - * $Modtime:: 2/06/01 3:21p $* - * * - * $Revision:: 3 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * DistLODDefClass -- default constructor for DistLODDefClass * - * DistLODDefClass::DistLODDefClass -- manual constructor for DistLODDefClass * - * DistLODDefClass::~DistLODDefClass -- destructor for DistLODDefClass * - * DistLODDefClass::Free -- releases all memory in use by this object * - * DistLODDefClass::Load -- initialize this object from a W3D file * - * DistLODDefClass::read_header -- read the header from a W3D file * - * DistLODDefClass::read_node -- read a model node description from a W3D file * - * DistLODClass::DistLODClass -- constructor * - * DistLODClass::DistLODClass -- copy constructor * - * DistLODClass::~DistLODClass -- destructor * - * DistLODClass::Free -- releases memory in use * - * DistLODClass::Get_Name -- returns the name of this LOD object * - * DistLODClass::Get_Num_Polys -- returns the number of polys in this model * - * DistLODClass::Render -- Render this LOD. * - * DistLODClass::Special_Render -- custom render function * - * DistLODCLass::Get_Num_Sub_Objects -- returns the number of subobjects (levels of detail) * - * DistLODClass::Get_Sub_Object -- returns pointer to the specified sub-object (LOD) * - * DistLODCLass::Set_Transform -- sets the transform for this model * - * DistLODClass::Set_Position -- set the position of this object * - * DistLODClass::Set_Animation -- set the animation state of this model * - * DistLODClass::Set_Animation -- set the animation state of this model * - * DistLODClass::Set_Animation -- set the animation state to a blend of two anims * - * DistLODClass::Set_Animation -- set the animation state to a combination of anims * - * DistLODClass::Get_Num_Bones -- returns the number of bones * - * DistLODClass::Get_Bone_Name -- returns the name of the specified bone * - * DistLODClass::Get_Bone_Index -- returns the index of the given bone (if found) * - * DistLODClass::Get_Bone_Transform -- returns the transform of the given bone * - * DistLODClass::Get_Bone_Transform -- returns the transform of the given bone * - * DistLODClass::Capture_Bone -- take control of a bone * - * DistLODClass::Release_Bone -- release control of a bone * - * DistLODClass::Is_Bone_Captured -- check whether the given bone is captured * - * DistLODClass::Control_Bone -- set the transform for a captured bone * - * DistLODClass::Cast_Ray -- cast a ray against this model * - * DistLODClass::Cast_AABox -- perform an AABox cast against this model * - * DistLODClass::Cast_OBBox -- perform an OBBox cast against this model * - * DistLODCLass::Get_Num_Snap_Points -- returns number of snap points in this model * - * DistLODClass::Get_Snap_Point -- returns the i'th snap point * - * DistLODCLass::Scale -- scale this model; passes on to each LOD * - * DistLODClass::Scale -- scale this model; passes on to each LOD * - * DistLODClass::Update_LOD -- adjusts the current LOD based on the distance * - * DistLODClass::Increment_Lod -- moves to a higher detail LOD * - * DistLODClass::Decrement_Lod -- moves to a lower detail LOD * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - - -#include "distlod.h" -#include "nstrdup.h" -#include "ww3d.h" -#include "assetmgr.h" -#include "camera.h" -#include "w3derr.h" -#include "wwdebug.h" -#include "chunkio.h" -#include "hlod.h" -#include "rinfo.h" -#include "coltest.h" -#include "inttest.h" - -/* -** Loader Instance -*/ -DistLODLoaderClass _DistLODLoader; - - -RenderObjClass * DistLODPrototypeClass::Create(void) -{ - DistLODClass * dist = NEW_REF( DistLODClass , ( *Definition ) ); - - // Have to pull each LOD out of the DistLOD, create a copy of the name - // and destroy the DistLOD so that the models are "containerless". Also - // invert the order of the models in the DistLOD - char * name = nstrdup(dist->Get_Name()); - WWASSERT(name != NULL); - - int count = dist->Get_Num_Sub_Objects(); - RenderObjClass ** robj = W3DNEWARRAY RenderObjClass * [count]; - int i=0; - for (; iGet_Sub_Object(i); - WWASSERT(robj[count - 1 - i] != NULL); - } - dist->Release_Ref(); - - WWDEBUG_SAY(("OBSOLETE Dist-LOD model found! Please re-export %s!\r\n",name)); - HLodClass * hlod = NEW_REF(HLodClass , (name,robj,count)); - - // Now, release the temporary refs and memory for the name - for (i=0; iRelease_Ref(); - } - free(name); - - return hlod; -} - -/* -** The Prototype Loader -*/ -PrototypeClass *DistLODLoaderClass::Load_W3D( ChunkLoadClass &cload ) -{ - DistLODDefClass * pCDistLODClass = W3DNEW DistLODDefClass; - - if (pCDistLODClass == NULL) - { - return NULL; - } - - if (pCDistLODClass->Load_W3D(cload) != WW3D_ERROR_OK) - { - // load failed, delete the model and return an error - delete pCDistLODClass; - return NULL; - - } else { - - // ok, accept this model! - DistLODPrototypeClass *pCLODProto = W3DNEW DistLODPrototypeClass (pCDistLODClass); - return pCLODProto; - } -} - - -/*********************************************************************************************** - * DistLODDefClass -- default constructor for DistLODDefClass * - * * - * DistLODDefClass is a "blueprint" for constructing a DistLODClass * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - *=============================================================================================*/ -DistLODDefClass::DistLODDefClass(void) : - Name(NULL), - LodCount(0), - Lods(NULL) -{ -} - - -/*********************************************************************************************** - * DistLODDefClass::DistLODDefClass -- manual constructor for DistLODDefClass * - * * - * This constructor allows you to create a DistLODDef Manually (and then use it to create * - * the desired DistLODClass). The array of DistLODModelDefStructs which you pass in will * - * only be read from so you are responsible for the memory used by them. * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 7/15/98 GTH : Created. * - *=============================================================================================*/ -DistLODDefClass::DistLODDefClass(const char * name,int lodcount,DistLODNodeDefStruct * modeldefs) : - Name(NULL), - LodCount(0), - Lods(NULL) -{ - assert(name != NULL); - Name = nstrdup(name); - - LodCount = lodcount; - Lods = W3DNEWARRAY DistLODNodeDefStruct[LodCount]; - for (int i=0; iCreate_Render_Obj(def.Lods[i].Name); - assert(Lods[i].Model != NULL); - Lods[i].Model->Set_Container(this); - - // copy the distances - Lods[i].ResUpDist = def.Lods[i].ResUpDist; - Lods[i].ResDownDist = def.Lods[i].ResDownDist; - } - - Update_Sub_Object_Bits(); - Update_Obj_Space_Bounding_Volumes(); -} - - -/*********************************************************************************************** - * DistLODClass::DistLODClass -- copy constructor * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 3/3/99 GTH : Created. * - *=============================================================================================*/ -DistLODClass::DistLODClass(const DistLODClass & that) : - CompositeRenderObjClass( that ) -{ - LodCount = that.LodCount; - CurLod = VpPushLod = that.CurLod; - - Lods = W3DNEWARRAY LODNodeClass[LodCount]; - for (int i=0; iClone(); - assert(Lods[i].Model != NULL); - Lods[i].Model->Set_Container(this); - - // copy the distances - Lods[i].ResUpDist = that.Lods[i].ResUpDist; - Lods[i].ResDownDist = that.Lods[i].ResDownDist; - } - Update_Obj_Space_Bounding_Volumes(); -} - - -/*********************************************************************************************** - * DistLODClass::~DistLODClass -- destructor * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 3/3/99 GTH : Created. * - *=============================================================================================*/ -DistLODClass::~DistLODClass(void) -{ - Free(); -} - - -/*********************************************************************************************** - * DistLODClass::Free -- releases memory in use * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 3/3/99 GTH : Created. * - *=============================================================================================*/ -void DistLODClass::Free(void) -{ - if (Lods != NULL) { - for (int i=0; iSet_Container(NULL); - Lods[i].Model->Release_Ref(); - Lods[i].Model = NULL; - } - } - delete[] Lods; - Lods = NULL; - } - CurLod = 0; - LodCount = 0; -} - - -/*********************************************************************************************** - * DistLODClass::Get_Num_Polys -- returns the number of polys in this model * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * returns the number of polys in the *current* lod. * - * * - * HISTORY: * - * 3/3/99 GTH : Created. * - *=============================================================================================*/ -int DistLODClass::Get_Num_Polys(void) const -{ - return Lods[CurLod].Model->Get_Num_Polys(); -} - - -/*********************************************************************************************** - * DistLODClass::Render -- Render this LOD. * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 3/3/99 GTH : Created. * - *=============================================================================================*/ -void DistLODClass::Render(RenderInfoClass & rinfo) -{ - if (Is_Not_Hidden_At_All() == false) { - return; - } - - Update_Lod(rinfo.Camera); - Lods[CurLod].Model->Render(rinfo); -} - - -/*********************************************************************************************** - * DistLODClass::Special_Render -- custom render function * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 3/3/99 GTH : Created. * - *=============================================================================================*/ -void DistLODClass::Special_Render(SpecialRenderInfoClass & rinfo) -{ - Update_Lod(rinfo.Camera); - Lods[CurLod].Model->Special_Render(rinfo); -} - - -/*********************************************************************************************** - * DistLODCLass::Get_Num_Sub_Objects -- returns the number of subobjects (levels of detail) * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 3/1/99 GTH : Created. * - *=============================================================================================*/ -int DistLODClass::Get_Num_Sub_Objects(void) const -{ - return LodCount; -} - - -/*********************************************************************************************** - * DistLODClass::Get_Sub_Object -- returns pointer to the specified sub-object (LOD) * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 3/1/99 GTH : Created. * - *=============================================================================================*/ -RenderObjClass * DistLODClass::Get_Sub_Object(int index) const -{ - assert(index >= 0); - assert(index < LodCount); - - if (Lods[index].Model == NULL) { - return NULL; - } else { - Lods[index].Model->Add_Ref(); - return Lods[index].Model; - } -} - -int DistLODClass::Add_Sub_Object_To_Bone(RenderObjClass * subobj,int bone_index) -{ - // NOTE: this is broken code, a render object cannot have two containers... - if (subobj->Class_ID() == CLASSID_DISTLOD) { - // Add each lod of the sub object to a cooresponding model of mine - DistLODClass * sub_lod_obj = (DistLODClass *)subobj; - for (int i=0; i< LodCount; i++) { - Lods[i].Model->Add_Sub_Object_To_Bone( sub_lod_obj->Lods[ MIN( i, sub_lod_obj->LodCount-1 ) ].Model, bone_index); - } - } else { - Lods[0].Model->Add_Sub_Object_To_Bone( subobj, bone_index); - } - return 0; -} - - -/*********************************************************************************************** - * DistLODCLass::Set_Transform -- sets the transform for this model * - * * - * sets the transform in all LODs. * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 3/3/99 GTH : Created. * - *=============================================================================================*/ -void DistLODClass::Set_Transform(const Matrix3D &m) -{ - RenderObjClass::Set_Transform(m); - for (int i=0; iSet_Transform(m); - } -} - - -/*********************************************************************************************** - * DistLODClass::Set_Position -- set the position of this object * - * * - * sets the position of all lods * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 3/3/99 GTH : Created. * - *=============================================================================================*/ -void DistLODClass::Set_Position(const Vector3 &v) -{ - RenderObjClass::Set_Position(v); - for (int i=0; iSet_Position(v); - } -} - - -/*********************************************************************************************** - * DistLODClass::Set_Animation -- set the animation state of this model * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 3/3/99 GTH : Created. * - *=============================================================================================*/ -void DistLODClass::Set_Animation( void ) -{ - for (int i=0; iSet_Animation(); - } -} - - -/*********************************************************************************************** - * DistLODClass::Set_Animation -- set the animation state of this model * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 3/3/99 GTH : Created. * - *=============================================================================================*/ -void DistLODClass::Set_Animation( HAnimClass * motion,float frame,int mode) -{ - for (int i=0; iSet_Animation(motion,frame,mode); - } -} - - -/*********************************************************************************************** - * DistLODClass::Set_Animation -- set the animation state to a blend of two anims * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 3/3/99 GTH : Created. * - *=============================================================================================*/ -void DistLODClass::Set_Animation( HAnimClass * motion0,float frame0,HAnimClass * motion1,float frame1,float percentage) -{ - for (int i=0; iSet_Animation(motion0,frame0,motion1,frame1,percentage); - } -} - - -/*********************************************************************************************** - * DistLODClass::Set_Animation -- set the animation state to a combination of anims * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 3/3/99 GTH : Created. * - *=============================================================================================*/ -void DistLODClass::Set_Animation( HAnimComboClass * anim_combo) -{ - for (int i=0; iSet_Animation( anim_combo); - } -} - - -/*********************************************************************************************** - * DistLODClass::Peek_Animation * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 12/8/98 GTH : Created. * - *=============================================================================================*/ -HAnimClass * DistLODClass::Peek_Animation( void ) -{ - return Lods[0].Model->Peek_Animation(); -} - - -/*********************************************************************************************** - * DistLODClass::Get_Num_Bones -- returns the number of bones * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 3/3/99 GTH : Created. * - *=============================================================================================*/ -int DistLODClass::Get_Num_Bones(void) -{ - return Lods[0].Model->Get_Num_Bones(); -} - - -/*********************************************************************************************** - * DistLODClass::Get_Bone_Name -- returns the name of the specified bone * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 3/3/99 GTH : Created. * - *=============================================================================================*/ -const char * DistLODClass::Get_Bone_Name(int bone_index) -{ - return Lods[0].Model->Get_Bone_Name(bone_index); -} - - -/*********************************************************************************************** - * DistLODClass::Get_Bone_Index -- returns the index of the given bone (if found) * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 3/3/99 GTH : Created. * - *=============================================================================================*/ -int DistLODClass::Get_Bone_Index(const char * bonename) -{ - // Highest LOD is used since lowest may be a Null3DObjClass. - return Lods[0].Model->Get_Bone_Index(bonename); -} - - -/*********************************************************************************************** - * DistLODClass::Get_Bone_Transform -- returns the transform of the given bone * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 3/3/99 GTH : Created. * - *=============================================================================================*/ -const Matrix3D & DistLODClass::Get_Bone_Transform(const char * bonename) -{ - // Highest LOD is used since lowest may be a Null3DObjClass. - return Lods[0].Model->Get_Bone_Transform(bonename); -} - - -/*********************************************************************************************** - * DistLODClass::Get_Bone_Transform -- returns the transform of the given bone * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 3/3/99 GTH : Created. * - *=============================================================================================*/ -const Matrix3D & DistLODClass::Get_Bone_Transform(int boneindex) -{ - // Highest LOD is used since lowest may be a Null3DObjClass. - return Lods[0].Model->Get_Bone_Transform(boneindex); -} - - -/*********************************************************************************************** - * DistLODClass::Capture_Bone -- take control of a bone * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 3/3/99 GTH : Created. * - *=============================================================================================*/ -void DistLODClass::Capture_Bone(int bindex) -{ - for (int i=0; iCapture_Bone(bindex); - } -} - - -/*********************************************************************************************** - * DistLODClass::Release_Bone -- release control of a bone * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 3/3/99 GTH : Created. * - *=============================================================================================*/ -void DistLODClass::Release_Bone(int bindex) -{ - for (int i=0; iRelease_Bone(bindex); - } -} - - -/*********************************************************************************************** - * DistLODClass::Is_Bone_Captured -- check whether the given bone is captured * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 3/3/99 GTH : Created. * - *=============================================================================================*/ -bool DistLODClass::Is_Bone_Captured(int bindex) const -{ - // Highest LOD is used since lowest may be a Null3DObjClass. - return Lods[0].Model->Is_Bone_Captured(bindex); -} - - -/*********************************************************************************************** - * DistLODClass::Control_Bone -- set the transform for a captured bone * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 3/3/99 GTH : Created. * - *=============================================================================================*/ -void DistLODClass::Control_Bone(int bindex,const Matrix3D & tm,bool world_space_translation) -{ - for (int i=0; iControl_Bone(bindex,tm,world_space_translation); - } -} - -/*********************************************************************************************** - * DistLODClass::Cast_Ray -- cast a ray against this model * - * * - * casts the ray against the top-level LOD * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 3/3/99 GTH : Created. * - *=============================================================================================*/ -bool DistLODClass::Cast_Ray(RayCollisionTestClass & raytest) -{ - if (raytest.CollisionType & Get_Collision_Type()) { - return Lods[HIGHEST_LOD].Model->Cast_Ray(raytest); - } else { - return false; - } -} - - -/*********************************************************************************************** - * DistLODClass::Cast_AABox -- perform an AABox cast against this model * - * * - * tests against the top-level LOD * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 3/3/99 GTH : Created. * - *=============================================================================================*/ -bool DistLODClass::Cast_AABox(AABoxCollisionTestClass & boxtest) -{ - if (boxtest.CollisionType & Get_Collision_Type()) { - return Lods[HIGHEST_LOD].Model->Cast_AABox(boxtest); - } else { - return false; - } -} - - -/*********************************************************************************************** - * DistLODClass::Cast_OBBox -- perform an OBBox cast against this model * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 3/1/99 GTH : Created. * - *=============================================================================================*/ -bool DistLODClass::Cast_OBBox(OBBoxCollisionTestClass & boxtest) -{ - if (boxtest.CollisionType & Get_Collision_Type()) { - return Lods[HIGHEST_LOD].Model->Cast_OBBox(boxtest); - } else { - return false; - } -} - - -/*********************************************************************************************** - * DistLODCLass::Get_Num_Snap_Points -- returns number of snap points in this model * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 3/1/99 GTH : Created. * - *=============================================================================================*/ -int DistLODClass::Get_Num_Snap_Points(void) -{ - return Lods[0].Model->Get_Num_Snap_Points(); -} - - -/*********************************************************************************************** - * DistLODClass::Get_Snap_Point -- returns the i'th snap point * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 3/1/99 GTH : Created. * - *=============================================================================================*/ -void DistLODClass::Get_Snap_Point(int index,Vector3 * set) -{ - Lods[0].Model->Get_Snap_Point(index,set); -} - - -/*********************************************************************************************** - * DistLODCLass::Scale -- scale this model; passes on to each LOD * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 3/1/99 GTH : Created. * - *=============================================================================================*/ -void DistLODClass::Scale(float scale) -{ - for (int i=0; iScale(scale); - } -} - - -/*********************************************************************************************** - * DistLODClass::Scale -- scale this model; passes on to each LOD * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 3/1/99 GTH : Created. * - *=============================================================================================*/ -void DistLODClass::Scale(float scalex, float scaley, float scalez) -{ - for (int i=0; iScale(scalex,scaley,scalez); - } -} - - -/*********************************************************************************************** - * DistLODClass::Update_LOD -- adjusts the current LOD based on the distance * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 3/1/99 GTH : Created. * - *=============================================================================================*/ -void DistLODClass::Update_Lod(const CameraClass & camera) -{ - // evaluate the distance from the camera and select an LOD based on it. - float dist = ( - camera.Get_Position() - - Lods[CurLod].Model->Get_Bounding_Sphere().Center - ).Quick_Length(); - - if (dist < Lods[CurLod].ResUpDist) { - Increment_Lod(); - } else if (dist > Lods[CurLod].ResDownDist) { - Decrement_Lod(); - } -} - - -/*********************************************************************************************** - * DistLODClass::Increment_Lod -- moves to a higher detail LOD * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 3/1/99 GTH : Created. * - *=============================================================================================*/ -void DistLODClass::Increment_Lod(void) -{ - // TODO: change the order in which models are stored - if (CurLod > 0) { - if (Is_In_Scene()) { - Lods[CurLod].Model->Notify_Removed(Scene); - } - CurLod--; - if (Is_In_Scene()) { - Lods[CurLod].Model->Notify_Added(Scene); - } - } -} - - -/*********************************************************************************************** - * DistLODClass::Decrement_Lod -- moves to a lower detail LOD * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 3/1/99 GTH : Created. * - *=============================================================================================*/ -void DistLODClass::Decrement_Lod(void) -{ - if (CurLod < LodCount - 1) { - if (Is_In_Scene()) { - Lods[CurLod].Model->Notify_Removed(Scene); - } - CurLod++; - if (Is_In_Scene()) { - Lods[CurLod].Model->Notify_Added(Scene); - } - } -} - - diff --git a/Generals/Code/Libraries/Source/WWVegas/WW3D2/distlod.h b/Generals/Code/Libraries/Source/WWVegas/WW3D2/distlod.h deleted file mode 100644 index a17240aa547..00000000000 --- a/Generals/Code/Libraries/Source/WWVegas/WW3D2/distlod.h +++ /dev/null @@ -1,246 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** 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 *** - *********************************************************************************************** - * * - * Project Name : WW3D * - * * - * $Archive:: /Commando/Code/ww3d2/distlod.h $* - * * - * Author:: Greg Hjelstrom * - * * - * $Modtime:: 1/25/01 2:46p $* - * * - * $Revision:: 2 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - - -#if defined(_MSC_VER) -#pragma once -#endif - -#ifndef DISTLOD_H -#define DISTLOD_H - -#include "proto.h" -#include "rendobj.h" -#include "composite.h" -#include "w3derr.h" - -class ChunkLoadClass; -struct DistLODNodeDefStruct; -class DistLODDefClass; - - -/* -** DistLODClass -** Distance based LOD switching. This is a simple LOD object which switches models -** based on the pre-set distances. Note that the models are stored in order of -** descending resolution; i.e. the highest res model will be in index 0. -** Most functions in this class simply pass the call on to all of the LODs. -** -** When the level of detail is changed, the LOD which was being used must be -** notified that it is being removed from the scene and the new LOD must be -** notified that it is being added. This allows us to correctly handle lights -** and particle emitters in LODs... -*/ -class DistLODClass : public CompositeRenderObjClass -{ -public: - - DistLODClass(const DistLODDefClass & desc); - DistLODClass(const DistLODClass & that); - virtual ~DistLODClass(void); - virtual RenderObjClass * Clone(void) const { return W3DNEW DistLODClass(*this); } - virtual int Class_ID(void) const { return CLASSID_DISTLOD; } - virtual int Get_Num_Polys(void) const; - - ///////////////////////////////////////////////////////////////////////////// - // Render Object Interface - Rendering - ///////////////////////////////////////////////////////////////////////////// - virtual void Render(RenderInfoClass & rinfo); - virtual void Special_Render(SpecialRenderInfoClass & rinfo); - - ///////////////////////////////////////////////////////////////////////////// - // Render Object Interface - "Scene Graph" - // Access each LOD individually through Get_Sub_Object. - ///////////////////////////////////////////////////////////////////////////// - virtual void Set_Transform(const Matrix3D &m); - virtual void Set_Position(const Vector3 &v); - - virtual int Get_Num_Sub_Objects(void) const; - virtual RenderObjClass * Get_Sub_Object(int index) const; - - virtual int Add_Sub_Object_To_Bone(RenderObjClass * subobj,int bone_index); - - ///////////////////////////////////////////////////////////////////////////// - // Render Object Interface - Hierarchical Animation - // Here again, these functions are passed on to all LODs. Each LOD is - // assumed to use the same HTree (or have no HTree, this is so that LODs are - // animation-compatible) so the bone query functions simply pass to the top - // LOD. - ///////////////////////////////////////////////////////////////////////////// - virtual void Set_Animation( void ); - virtual void Set_Animation( HAnimClass * motion, float frame, int anim_mode = ANIM_MODE_MANUAL); - virtual void Set_Animation( HAnimClass * motion0,float frame0,HAnimClass * motion1,float frame1,float percentage); - virtual void Set_Animation( HAnimComboClass * anim_combo); - virtual HAnimClass * Peek_Animation( void ); - virtual int Get_Num_Bones(void); - virtual const char * Get_Bone_Name(int bone_index); - virtual int Get_Bone_Index(const char * bonename); - virtual const Matrix3D & Get_Bone_Transform(const char * bonename); - virtual const Matrix3D & Get_Bone_Transform(int boneindex); - virtual void Capture_Bone(int bindex); - virtual void Release_Bone(int bindex); - virtual bool Is_Bone_Captured(int bindex) const; - virtual void Control_Bone(int bindex,const Matrix3D & tm,bool world_space_translation = false); - - ///////////////////////////////////////////////////////////////////////////// - // Render Object Interface - Collision Detection, Ray Tracing - // Collision tests are performed on the top-level LOD. - ///////////////////////////////////////////////////////////////////////////// - virtual bool Cast_Ray(RayCollisionTestClass & raytest); - virtual bool Cast_AABox(AABoxCollisionTestClass & boxtest); - virtual bool Cast_OBBox(OBBoxCollisionTestClass & boxtest); - - ///////////////////////////////////////////////////////////////////////////// - // Render Object Interface - Attributes, Options, Properties, etc - ///////////////////////////////////////////////////////////////////////////// - virtual int Get_Num_Snap_Points(void); - virtual void Get_Snap_Point(int index,Vector3 * set); - virtual void Scale(float scale); - virtual void Scale(float scalex, float scaley, float scalez); - - ///////////////////////////////////////////////////////////////////////////// - // DistLOD Interface - ///////////////////////////////////////////////////////////////////////////// - virtual float Get_Switch_Up_Dist(int index) const { return Lods[index].ResUpDist; } - virtual float Get_Switch_Down_Dist(int index) const { return Lods[index].ResDownDist; } - virtual void Set_Switch_Up_Dist(int index, float dist) { Lods[index].ResUpDist = dist; } - virtual void Set_Switch_Down_Dist(int index, float dist) { Lods[index].ResDownDist = dist; } - -private: - - enum { HIGHEST_LOD = 0 }; - - void Free(void); - void Update_Lod(const CameraClass & camera); - void Increment_Lod(void); - void Decrement_Lod(void); - - struct LODNodeClass - { - RenderObjClass * Model; - float ResUpDist; - float ResDownDist; - }; - - int LodCount; // how many models are in this LOD object - int CurLod; // which model is currently used for rendering - int VpPushLod; // which model was used for the vp->push (in CurLod changes before the pop) - LODNodeClass * Lods; // one LODNodeClass for each level -}; - - -/* -** Loaders for DistLODClass -*/ -class DistLODLoaderClass : public PrototypeLoaderClass -{ -public: - - virtual int Chunk_Type (void) { return W3D_CHUNK_LODMODEL; } - virtual PrototypeClass * Load_W3D(ChunkLoadClass & cload); -}; - -/* -** DistLODModelDefStruct -** Describes a single model in a Distance-Based LOD Object -*/ -struct DistLODNodeDefStruct -{ - DistLODNodeDefStruct(void) : Name(NULL),ResDownDist(0.0f),ResUpDist(0.0f) {} - - char * Name; - float ResDownDist; - float ResUpDist; -}; - -/* -** DistLODDefClass -** Description of a Distance-Based LOD Object. These are similar -** to the HModelDef's that are used by the asset manager to construct -** HModels. -*/ -class DistLODDefClass -{ -public: - - DistLODDefClass(void); - DistLODDefClass(const char * name,int lodcount,DistLODNodeDefStruct * lods); - ~DistLODDefClass(void); - - WW3DErrorType Load_W3D(ChunkLoadClass & cload); - const char * Get_Name(void) const { return Name; } - -private: - - char * Name; - - int LodCount; - DistLODNodeDefStruct * Lods; - - void Free(void); - bool read_header(ChunkLoadClass & cload); - bool read_node(ChunkLoadClass & cload,DistLODNodeDefStruct * node); - - friend class DistLODClass; -}; - -/* -** Prototype for Dist-LOD objects -*/ -class DistLODPrototypeClass : public W3DMPO, public PrototypeClass -{ - W3DMPO_GLUE(DistLODPrototypeClass) -public: - DistLODPrototypeClass( DistLODDefClass *def ) { Definition = def; } - - virtual const char * Get_Name(void) const { return Definition->Get_Name(); } - virtual int Get_Class_ID(void) const { return RenderObjClass::CLASSID_DISTLOD; } - virtual RenderObjClass * Create(void); - virtual void DeleteSelf() { delete this; } - -protected: - virtual ~DistLODPrototypeClass(void) { delete Definition; } - -private: - DistLODDefClass * Definition; -}; - -/* -** Instance of the loaders which the asset manager install -*/ -extern DistLODLoaderClass _DistLODLoader; - -#endif \ No newline at end of file diff --git a/Generals/Code/Libraries/Source/WWVegas/WW3D2/dllist.h b/Generals/Code/Libraries/Source/WWVegas/WW3D2/dllist.h deleted file mode 100644 index 2748c17c25d..00000000000 --- a/Generals/Code/Libraries/Source/WWVegas/WW3D2/dllist.h +++ /dev/null @@ -1,211 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** 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 *** - *********************************************************************************************** - * * - * Project Name : ww3d * - * * - * $Archive:: /Commando/Code/ww3d2/dllist.h $* - * * - * Original Author:: Jani Penttinen * - * * - * $Author:: Jani_p $* - * * - * $Modtime:: 3/21/01 6:18p $* - * * - * $Revision:: 11 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#if defined(_MSC_VER) -#pragma once -#endif - -#ifndef DLLIST_H -#define DLLIST_H - - -template class DLNodeClass; - -template -class DLListClass -{ - friend DLNodeClass; - DLNodeClass* head; - DLNodeClass* tail; - -public: - DLListClass() : head(0), tail(0) {} - virtual ~DLListClass() { } - - void Add_Head(DLNodeClass* node); - void Remove_Head(); - void Add_Tail(DLNodeClass* node); - void Remove_Tail(); - - T* Head() { return static_cast(head); } - T* Tail() { return static_cast(tail); } - const T* Const_Head() const { return static_cast(head); } - const T* Const_Tail() const { return static_cast(tail); } -}; - -// Destroy-list will call delete for all nodes when the list is destructed. Note that the class doesn't work -// with undeclared pointer types (destructor has to be known). -template -class DLDestroyListClass : public DLListClass -{ - using DLListClass::Head; - -public: - virtual ~DLDestroyListClass() - { - while (T* t=Head()) { - delete t; - } - } -}; - -template -class DLNodeClass : public W3DMPO -{ - // nope, this is an ABC - //W3DMPO_GLUE(DLNodeClass) - - friend DLListClass; - DLNodeClass* succ; - DLNodeClass* pred; - DLListClass* list; -public: - DLNodeClass() : succ(0), pred(0), list(0) {} - ~DLNodeClass() { Remove(); } - - void Insert_Before(DLNodeClass* n) - { - list=n->list; - succ=n; - pred=n->pred; - if (n->pred) n->pred->succ=this; - n->pred=this; - - if (list->head==n) { - list->head=this; - } - } - - void Insert_After(DLNodeClass* n) - { - list=n->list; - pred=n; - succ=n->succ; - if (n->succ) n->succ->pred=this; - n->succ=this; - - if (list->tail==n) { - list->tail=this; - } - } - - void Remove() - { - if (!list) return; - if (list->Head()==this) { - DLListClass* tmp_list=list; - list=0; - tmp_list->Remove_Head(); - return; - } - if (list->Tail()==this) { - DLListClass* tmp_list=list; - list=0; - tmp_list->Remove_Tail(); - return; - } - if (succ) succ->pred=pred; - if (pred) pred->succ=succ; - list=0; - } - - - T* Succ() { return static_cast(succ); } - T* Pred() { return static_cast(pred); } - const T* Const_Succ() const { return static_cast(succ); } - const T* Const_Pred() const { return static_cast(pred); } - - DLListClass* List() { return list; } -}; - - -template -inline void DLListClass::Add_Head(DLNodeClass* n) -{ - n->list=this; - if (head) { - n->Insert_Before(head); - head=n; - } - else { - tail=n; - head=n; - n->succ=0; - n->pred=0; - } -} - -template -inline void DLListClass::Add_Tail(DLNodeClass* n) -{ - n->list=this; - if (tail) { - n->Insert_After(tail); - tail=n; - } - else { - tail=n; - head=n; - n->succ=0; - n->pred=0; - } -} - -template -inline void DLListClass::Remove_Head() -{ - if (!head) return; - DLNodeClass* n=head; - head=head->Succ(); - if (!head) tail=head; - else head->pred=0; - n->Remove(); -} - -template -inline void DLListClass::Remove_Tail() -{ - if (!tail) return; - DLNodeClass* n=tail; - tail=tail->Pred(); - if (!tail) head=tail; - else tail->succ=0; - n->Remove(); -} - -#endif //DLLIST_H diff --git a/Generals/Code/Libraries/Source/WWVegas/WW3D2/dx8list.h b/Generals/Code/Libraries/Source/WWVegas/WW3D2/dx8list.h deleted file mode 100644 index 3cab7260356..00000000000 --- a/Generals/Code/Libraries/Source/WWVegas/WW3D2/dx8list.h +++ /dev/null @@ -1,74 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** 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 *** - *********************************************************************************************** - * * - * Project Name : ww3d * - * * - * $Archive:: /Commando/Code/ww3d2/dx8list.h $* - * * - * Original Author:: Greg Hjelstrom * - * * - * Author : Kenny Mitchell * - * * - * $Modtime:: 06/27/02 1:27p $* - * * - * $Revision:: 5 $* - * * - * 06/27/02 KM Texture class abstraction * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - - -#if defined(_MSC_VER) -#pragma once -#endif - -#ifndef DX8LIST_H -#define DX8LIST_H - -#include "always.h" -#include "multilist.h" - - -/* -** Here we're just typedefing some multi-lists so we don't have to write the -** long template names. -*/ -class DX8TextureCategoryClass; -typedef MultiListClass TextureCategoryList; -typedef MultiListIterator TextureCategoryListIterator; - -class DX8FVFCategoryContainer; -typedef MultiListClass FVFCategoryList; -typedef MultiListIterator FVFCategoryListIterator; - -class DX8PolygonRendererClass; -typedef MultiListClass DX8PolygonRendererList; -typedef MultiListIterator DX8PolygonRendererListIterator; - -class TextureTrackerClass; -typedef MultiListClass TextureTrackerList; -typedef MultiListIterator TextureTrackerListIterator; - - -#endif //DX8LIST_H - diff --git a/Generals/Code/Libraries/Source/WWVegas/WW3D2/dx8polygonrenderer.cpp b/Generals/Code/Libraries/Source/WWVegas/WW3D2/dx8polygonrenderer.cpp deleted file mode 100644 index 7fed7750167..00000000000 --- a/Generals/Code/Libraries/Source/WWVegas/WW3D2/dx8polygonrenderer.cpp +++ /dev/null @@ -1,115 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** 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 *** - *********************************************************************************************** - * * - * Project Name : ww3d * - * * - * $Archive:: /Commando/Code/ww3d2/dx8polygonrenderer.cpp $* - * * - * Original Author:: Greg Hjelstrom * - * * - * $Author:: Jani_p $* - * * - * $Modtime:: 8/22/01 6:54p $* - * * - * $Revision:: 11 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - - - -#include "dx8polygonrenderer.h" -#include "dx8renderer.h" - - -// ---------------------------------------------------------------------------- - -DX8PolygonRendererClass::DX8PolygonRendererClass( - unsigned index_count_, - MeshModelClass* mmc_, - DX8TextureCategoryClass* tex_cat, - unsigned vertex_offset_, - unsigned index_offset_, - bool strip_, - unsigned pass_) - : - mmc(mmc_), - texture_category(tex_cat), - index_offset(index_offset_), - vertex_offset(vertex_offset_), - min_vertex_index(0), - vertex_index_range(0), - index_count(index_count_), - strip(strip_), - pass(pass_) -{ - WWASSERT(index_count); - mmc->PolygonRendererList.Add_Tail(this); -} - -DX8PolygonRendererClass::DX8PolygonRendererClass(const DX8PolygonRendererClass& src,MeshModelClass* mmc_) - : - mmc(mmc_), - texture_category(src.texture_category), - index_offset(src.index_offset), - vertex_offset(src.vertex_offset), - min_vertex_index(src.min_vertex_index), - vertex_index_range(src.vertex_index_range), - index_count(src.index_count), - strip(src.strip), - pass(src.pass) -{ - mmc->PolygonRendererList.Add_Tail(this); -} - -DX8PolygonRendererClass::~DX8PolygonRendererClass() -{ - if (texture_category) texture_category->Remove_Polygon_Renderer(this); -} - -// ---------------------------------------------------------------------------- - -void DX8PolygonRendererClass::Log() -{ - StringClass work(true); - - work.Format(" %8d %8d %6d %6d %6d %s\n", - index_count, - index_count/3, - index_offset, - min_vertex_index, - vertex_index_range, - mmc->Get_Name()); - -/* work.Format( - " Index count: %d (%d polys) i_offset: %d min_vi: %d vi_range: %d ident: %d (%s)\n", - index_count, - index_count/3, - index_offset, - min_vertex_index, - vertex_index_range, - mmc->ident, - mmc->Get_Name()); -*/ WWDEBUG_SAY((work)); -} - diff --git a/Generals/Code/Libraries/Source/WWVegas/WW3D2/dx8polygonrenderer.h b/Generals/Code/Libraries/Source/WWVegas/WW3D2/dx8polygonrenderer.h deleted file mode 100644 index 10200285fc1..00000000000 --- a/Generals/Code/Libraries/Source/WWVegas/WW3D2/dx8polygonrenderer.h +++ /dev/null @@ -1,161 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** 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 *** - *********************************************************************************************** - * * - * Project Name : ww3d * - * * - * $Archive:: /Commando/Code/ww3d2/dx8polygonrenderer.h $* - * * - * Original Author:: Greg Hjelstrom * - * * - * $Author:: Jani_p $* - * * - * $Modtime:: 7/12/01 6:38p $* - * * - * $Revision:: 22 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - - -#if defined(_MSC_VER) -#pragma once -#endif - -#ifndef DX8_POLYGON_RENDERER_H -#define DX8_POLYGON_RENDERER_H - - -#include "always.h" -#include "meshmdl.h" -#include "dx8list.h" -#include "sortingrenderer.h" -#include "mesh.h" -#include "dx8wrapper.h" - -class DX8PolygonRendererClass; -class DX8TextureCategoryClass; - - -/** -** DX8PolygonRendererClass -** This is a record of a batch/range of polygons to be rendered. These hang off of the DX8TextureCategoryClass's -** and are rendered after the system installs a vertex buffer and textures in the DX8 wrapper. -*/ -class DX8PolygonRendererClass : public MultiListObjectClass -{ - MeshModelClass * mmc; - DX8TextureCategoryClass * texture_category; - unsigned index_offset; // absolute index of index 0 for our parent mesh - unsigned vertex_offset; // absolute index of vertex 0 for our parent mesh - unsigned index_count; // number of indices - unsigned min_vertex_index; // relative index of the first vertex our polys reference - unsigned vertex_index_range; // range to the last vertex our polys reference - bool strip; // is this a strip? - unsigned pass; // rendering pass - -public: - DX8PolygonRendererClass( - unsigned index_count, - MeshModelClass* mmc_, - DX8TextureCategoryClass* tex_cat, - unsigned vertex_offset, - unsigned index_offset, - bool strip, - unsigned pass); - DX8PolygonRendererClass(const DX8PolygonRendererClass& src,MeshModelClass* mmc_); - ~DX8PolygonRendererClass(); - - void Render(/*const Matrix3D & tm,*/int base_vertex_offset); - void Render_Sorted(/*const Matrix3D & tm,*/int base_vertex_offset,const SphereClass & bounding_sphere); - void Set_Vertex_Index_Range(unsigned min_vertex_index_,unsigned vertex_index_range_); - - unsigned Get_Vertex_Offset(void) { return vertex_offset; } - unsigned Get_Index_Offset(void) { return index_offset; } - inline unsigned Get_Pass(void) { return pass; } - - MeshModelClass* Get_Mesh_Model_Class() { return mmc; } - DX8TextureCategoryClass* Get_Texture_Category() { return texture_category; } - void Set_Texture_Category(DX8TextureCategoryClass* tc) { texture_category=tc; } - - void Log(); -}; - -// ---------------------------------------------------------------------------- - -inline void DX8PolygonRendererClass::Set_Vertex_Index_Range(unsigned min_vertex_index_,unsigned vertex_index_range_) -{ -// WWDEBUG_SAY(("Set_Vertex_Index_Range - min: %d, range: %d\n",min_vertex_index_,vertex_index_range_)); -// if (vertex_index_range_>30000) { -// int a=0; -// a++; -// } - min_vertex_index=min_vertex_index_; - vertex_index_range=vertex_index_range_; -} - -// ---------------------------------------------------------------------------- - -inline void DX8PolygonRendererClass::Render(/*const Matrix3D & tm,*/int base_vertex_offset) -{ -// DX8Wrapper::Set_Transform(D3DTS_WORLD,tm); -// SNAPSHOT_SAY(("Set_Transform\n")); - SNAPSHOT_SAY(("Set_Index_Buffer_Index_Offset(%d)\n",base_vertex_offset)); - - DX8Wrapper::Set_Index_Buffer_Index_Offset(base_vertex_offset); - if (strip) { - SNAPSHOT_SAY(("Draw_Strip(%d,%d,%d,%d)\n",index_offset,index_count-2,min_vertex_index,vertex_index_range)); - DX8Wrapper::Draw_Strip( - index_offset, - index_count-2, - min_vertex_index, - vertex_index_range); - } - else { - SNAPSHOT_SAY(("Draw_Triangles(%d,%d,%d,%d)\n",index_offset,index_count-2,min_vertex_index,vertex_index_range)); - DX8Wrapper::Draw_Triangles( - index_offset, - index_count/3, - min_vertex_index, - vertex_index_range); - } -} - -inline void DX8PolygonRendererClass::Render_Sorted(/*const Matrix3D & tm,*/int base_vertex_offset,const SphereClass & bounding_sphere) -{ - WWASSERT(!strip); // Strips can't be sorted for now -// DX8Wrapper::Set_Transform(D3DTS_WORLD,tm); -// SNAPSHOT_SAY(("Set_Transform\n")); - SNAPSHOT_SAY(("Set_Index_Buffer_Index_Offset(%d)\n",base_vertex_offset)); - SNAPSHOT_SAY(("Insert_Sorting_Triangles(%d,%d,%d,%d)\n",index_offset,index_count-2,min_vertex_index,vertex_index_range)); - - DX8Wrapper::Set_Index_Buffer_Index_Offset(base_vertex_offset); - SortingRendererClass::Insert_Triangles( - bounding_sphere, - index_offset, - index_count/3, - min_vertex_index, - vertex_index_range); - -} - -#endif \ No newline at end of file diff --git a/Generals/Code/Libraries/Source/WWVegas/WW3D2/dx8webbrowser.cpp b/Generals/Code/Libraries/Source/WWVegas/WW3D2/dx8webbrowser.cpp deleted file mode 100644 index f806904303d..00000000000 --- a/Generals/Code/Libraries/Source/WWVegas/WW3D2/dx8webbrowser.cpp +++ /dev/null @@ -1,260 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -//****************************************************************************************** -// -// Earth And Beyond -// Copyright (c) 2002 Electronic Arts , Inc. - Westwood Studios -// -// File Name : dx8webbrowser.cpp -// Description : Implementation of D3D Embedded Browser wrapper. -// Author : Darren Schueller -// Date of Creation : 6/4/2002 -// -//****************************************************************************************** -// $Header: $ -//****************************************************************************************** - -#include "dx8webbrowser.h" -#include "ww3d.h" -#include "dx8wrapper.h" - -#if ENABLE_EMBEDDED_BROWSER - -#if defined(_MSC_VER) && _MSC_VER < 1300 - -// Import the Browser Type Library -// BGC, the path for the dll file is pretty odd, no? -// I'll leave it like this till I can figure out a -// better way. -#import "../../../../../Run/BrowserEngine.dll" no_namespace - -#else - -#include -#include - -#include "EABrowserEngine/BrowserEngine.h" - -typedef _com_ptr_t<_com_IIID> IFEBrowserEngine2Ptr; - -#endif - -static IFEBrowserEngine2Ptr pBrowser = 0; - -HWND DX8WebBrowser::hWnd = 0; - -bool DX8WebBrowser::Initialize( const char* badpageurl, - const char* loadingpageurl, - const char* mousefilename, - const char* mousebusyfilename) -{ - if(pBrowser == 0) - { - // Initialize COM - CoInitialize(0); - - // Create an instance of the browser control - HRESULT hr = pBrowser.CreateInstance(__uuidof(FEBrowserEngine2)); - - if(hr == REGDB_E_CLASSNOTREG) - { - HMODULE lib = ::LoadLibrary("BrowserEngine.DLL"); - if(lib) - { - FARPROC proc = ::GetProcAddress(lib,"DllRegisterServer"); - if(proc) - { - proc(); - // Create an instance of the browser control - hr = pBrowser.CreateInstance(__uuidof(FEBrowserEngine2)); - } - FreeLibrary(lib); - } - } - - // Initialize the browser. - if(hr == S_OK) - { - hWnd = (HWND)WW3D::Get_Window(); - pBrowser->Initialize(reinterpret_cast(DX8Wrapper::_Get_D3D_Device8())); - - if(badpageurl) - pBrowser->put_BadPageURL(_bstr_t(badpageurl)); - - if(loadingpageurl) - pBrowser->put_LoadingPageURL(_bstr_t(loadingpageurl)); - - if(mousefilename) - pBrowser->put_MouseFileName(_bstr_t(mousefilename)); - - if(mousebusyfilename) - pBrowser->put_MouseBusyFileName(_bstr_t(mousebusyfilename)); - } - else - { - pBrowser = 0; - return false; - } - } - - return true; -} - -void DX8WebBrowser::Shutdown() -{ - if(pBrowser) - { - // Shutdown the browser - pBrowser->Shutdown(); - - // Release the smart pointer. - pBrowser = 0; - - hWnd = 0; - - // Shut down COM - CoUninitialize(); - } -} - - -// ****************************************************************************************** -// * Function Name: DX8WebBrowser::Update -// ****************************************************************************************** -// * Description: Updates the browser image surfaces by copying the bits from the browser -// * DCs to the D3D Image surfaces. -// * -// * Return Type: -// * -// * Argument: void -// * -// ****************************************************************************************** -void DX8WebBrowser::Update(void) -{ - if(pBrowser) pBrowser->D3DUpdate(); -}; - - -// ****************************************************************************************** -// * Function Name: DX8WebBrowser::Render -// ****************************************************************************************** -// * Description: Draws all browsers to the back buffer. -// * -// * Return Type: -// * -// * Argument: int backbufferindex -// * -// ****************************************************************************************** -void DX8WebBrowser::Render(int backbufferindex) -{ - if(pBrowser) pBrowser->D3DRender(backbufferindex); -}; - -// ****************************************************************************************** -// * Function Name: DX8WebBrowser::CreateBrowser -// ****************************************************************************************** -// * Description: Creates a browser window. -// * -// * Return Type: -// * -// * Argument: const char* browsername - This is a "name" used to identify the -// * browser instance. Multiple browsers can -// * be created, and are referenced using this name. -// * Argument: const char* url - The url to display. -// * Argument: int x - The position and size of the browser (in pixels) -// * Argument: int y -// * Argument: int w -// * Argument: int h -// * Argument: int updateticks - When non-zero, this forces the browser image to get updated -// * at the specified rate (number of milliseconds) regardless -// * of paint messages. When this is zero (the default) the browser -// * image is only updated whenever a paint message is received. -// * -// ****************************************************************************************** -void DX8WebBrowser::CreateBrowser(const char* browsername, const char* url, int x, int y, int w, int h, int updateticks, LONG options, LPDISPATCH gamedispatch) -{ - WWDEBUG_SAY(("DX8WebBrowser::CreateBrowser - Creating browser with the name %s, url = %s, (x, y, w, h) = (%d, %d, %d, %d), update ticks = %d\n", browsername, url, x, y, h, w, updateticks)); - if(pBrowser) - { - _bstr_t brsname(browsername); - pBrowser->CreateBrowser(brsname, _bstr_t(url), reinterpret_cast(hWnd), x, y, w, h, options, gamedispatch); - pBrowser->SetUpdateRate(brsname, updateticks); - } -} - - -// ****************************************************************************************** -// * Function Name: DX8WebBrowser::DestroyBrowser -// ****************************************************************************************** -// * Description: Destroys the specified browser. This closes the window and releases -// * the browser instance. -// * -// * Return Type: -// * -// * Argument: const char* browsername - The name of the browser to destroy. -// * -// ****************************************************************************************** -void DX8WebBrowser::DestroyBrowser(const char* browsername) -{ - WWDEBUG_SAY(("DX8WebBrowser::DestroyBrowser - destroying browser %s\n", browsername)); - if(pBrowser) - pBrowser->DestroyBrowser(_bstr_t(browsername)); -} - - -// ****************************************************************************************** -// * Function Name: DX8WebBrowser::Is_Browser_Open -// ****************************************************************************************** -// * Description: This function checks to see if a browser of the specified name exists and -// * is currently open. -// * -// * Return Type: -// * -// * Argument: const char* browsername - The name of the browser to test. -// * -// ****************************************************************************************** -bool DX8WebBrowser::Is_Browser_Open(const char* browsername) -{ - if(pBrowser == 0) return false; -#if defined(_MSC_VER) && _MSC_VER < 1300 - return (pBrowser->IsOpen(_bstr_t(browsername)) != 0); -#else - long isOpen; - return (pBrowser->IsOpen(_bstr_t(browsername), &isOpen) != 0); -#endif -} - -// ****************************************************************************************** -// * Function Name: DX8WebBrowser::Navigate -// ****************************************************************************************** -// * Description: This function causes the browser to navigate to the specified page. -// * -// * Return Type: -// * -// * Argument: const char* browsername - The name of the browser to test. -// * const char* url - The url to navigate to. -// * -// ****************************************************************************************** -void DX8WebBrowser::Navigate(const char* browsername, const char* url) -{ - if(pBrowser == 0) return; - pBrowser->Navigate(_bstr_t(browsername),_bstr_t(url)); -} - -#endif \ No newline at end of file diff --git a/Generals/Code/Libraries/Source/WWVegas/WW3D2/dx8webbrowser.h b/Generals/Code/Libraries/Source/WWVegas/WW3D2/dx8webbrowser.h deleted file mode 100644 index 82d68c35d71..00000000000 --- a/Generals/Code/Libraries/Source/WWVegas/WW3D2/dx8webbrowser.h +++ /dev/null @@ -1,93 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -//****************************************************************************************** -// -// Earth And Beyond -// Copyright (c) 2002 Electronic Arts , Inc. - Westwood Studios -// -// File Name : dx8webbrowser.h -// Description : Implementation of D3D Embedded Browser Wrapper -// Author : Darren Schueller -// Date of Creation : 6/4/2002 -// -//****************************************************************************************** -// $Header: $ -//****************************************************************************************** - -#ifndef DX8_WEBBROWSER_H -#define DX8_WEBBROWSER_H - -#include -#include "d3d8.h" - -// *********************************** -// Set this to 0 to remove all embedded browser code. -// -#define ENABLE_EMBEDDED_BROWSER 1 -// -// *********************************** - -#if ENABLE_EMBEDDED_BROWSER - -// These options must match the browser option bits defined in the BrowserEngine code. -// Look in febrowserengine.h -#define BROWSEROPTION_SCROLLBARS 0x0001 -#define BROWSEROPTION_3DBORDER 0x0002 - -struct IDirect3DDevice8; - -/** -** DX8WebBrowser -** -** DX8 interface wrapper class. This encapsulates the BrowserEngine interface. -*/ -class DX8WebBrowser -{ -public: - - static bool Initialize( const char* badpageurl = 0, - const char* loadingpageurl = 0, - const char* mousefilename = 0, - const char* mousebusyfilename = 0); //Initialize the Embedded Browser - - static void Shutdown(void); // Shutdown the embedded browser. Will close any open browsers. - - static void Update(void); // Copies all browser contexts to D3D Image surfaces. - static void Render(int backbufferindex); //Draws all browsers to the backbuffer. - - // Creates a browser with the specified name - static void CreateBrowser(const char* browsername, const char* url, int x, int y, int w, int h, int updateticks = 0, LONG options = BROWSEROPTION_SCROLLBARS | BROWSEROPTION_3DBORDER, LPDISPATCH gamedispatch = 0); - - // Destroys the browser with the specified name - static void DestroyBrowser(const char* browsername); - - // Returns true if a browser with the specified name is open. - static bool Is_Browser_Open(const char* browsername); - - // Navigates the specified browser to the specified page. - static void Navigate(const char* browsername, const char* url); - -private: - // The window handle of the application. This is initialized by Initialize(). - static HWND hWnd; -}; - -#endif - -#endif \ No newline at end of file diff --git a/Generals/Code/Libraries/Source/WWVegas/WW3D2/dynamesh.cpp b/Generals/Code/Libraries/Source/WWVegas/WW3D2/dynamesh.cpp deleted file mode 100644 index 8cecd495f2d..00000000000 --- a/Generals/Code/Libraries/Source/WWVegas/WW3D2/dynamesh.cpp +++ /dev/null @@ -1,835 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*************************************************************************** - *** 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 *** - *************************************************************************** - * * - * Project Name : Commando * - * * - * $Archive:: /Commando/Code/ww3d2/dynamesh.cpp $* - * * - * $Author:: Greg_h $* - * * - * $Modtime:: 12/03/01 4:50p $* - * * - * $Revision:: 25 $* - * * - *-------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#include "dynamesh.h" -#include "dx8vertexbuffer.h" -#include "dx8indexbuffer.h" -#include "dx8wrapper.h" -#include "sortingrenderer.h" -#include "rinfo.h" -#include "camera.h" -#include "dx8fvf.h" - - - -/* -** DynamicMeshModel implementation -*/ - -DynamicMeshModel::DynamicMeshModel(unsigned int max_polys, unsigned int max_verts) : - MeshGeometryClass(), - DynamicMeshPNum(0), - DynamicMeshVNum(0), - MatDesc(NULL), - MatInfo(NULL) -{ - MatInfo = NEW_REF(MaterialInfoClass, ()); - - MatDesc = W3DNEW MeshMatDescClass; - MatDesc->Set_Polygon_Count(max_polys); - MatDesc->Set_Vertex_Count(max_verts); - - Reset_Geometry(max_polys, max_verts); -} - -DynamicMeshModel::DynamicMeshModel(unsigned int max_polys, unsigned int max_verts, MaterialInfoClass *mat_info) : - MeshGeometryClass(), - DynamicMeshPNum(0), - DynamicMeshVNum(0), - MatDesc(NULL), - MatInfo(NULL) -{ - MatInfo = mat_info; - MatInfo->Add_Ref(); - - MatDesc = W3DNEW MeshMatDescClass; - MatDesc->Set_Polygon_Count(max_polys); - MatDesc->Set_Vertex_Count(max_verts); - - Reset_Geometry(max_polys, max_verts); -} - -DynamicMeshModel::DynamicMeshModel(const DynamicMeshModel &src) : - MeshGeometryClass(src), - DynamicMeshPNum(src.DynamicMeshPNum), - DynamicMeshVNum(src.DynamicMeshVNum), - MatDesc(NULL), - MatInfo(NULL) -{ - // Copy the material info structure. - MatInfo = NEW_REF(MaterialInfoClass, (*(src.MatInfo))); - - - // [SKB: Feb 21 2002 @ 11:47pm] : - // Moved before the remapping cause I don't like referencing null. - MatDesc = W3DNEW MeshMatDescClass; - - // remap! - MaterialRemapperClass remapper(src.MatInfo, MatInfo); - remapper.Remap_Mesh(src.MatDesc, MatDesc); -} - -DynamicMeshModel::~DynamicMeshModel(void) -{ - if (MatDesc) { - delete MatDesc; - MatDesc = NULL; - } - REF_PTR_RELEASE(MatInfo); -} - -void DynamicMeshModel::Compute_Plane_Equations(void) -{ - // Make sure the arrays are allocated before we do this - get_vert_normals(); - Vector4 * planes = get_planes(true); - - // Set the poly and vertex counts to the dynamic counts, call the base class function, then - // set them back. - int old_poly_count = PolyCount; - int old_vert_count = VertexCount; - PolyCount = DynamicMeshPNum; - VertexCount = DynamicMeshVNum; - - MeshGeometryClass::Compute_Plane_Equations(planes); - - PolyCount = old_poly_count; - VertexCount = old_vert_count; -} - -void DynamicMeshModel::Compute_Vertex_Normals(void) -{ - // Make sure the arrays are allocated before we do this - Vector3 * vnorms = get_vert_normals(); - get_planes(true); - - // Set the poly and vertex counts to the dynamic counts, call the base class function, then - // set them back. - int old_poly_count = PolyCount; - int old_vert_count = VertexCount; - PolyCount = DynamicMeshPNum; - VertexCount = DynamicMeshVNum; - - MeshGeometryClass::Compute_Vertex_Normals(vnorms); - - PolyCount = old_poly_count; - VertexCount = old_vert_count; -} - -void DynamicMeshModel::Compute_Bounds(Vector3 * verts) -{ - // Set the poly and vertex counts to the dynamic counts, call the base class function, then - // set them back. - int old_poly_count = PolyCount; - int old_vert_count = VertexCount; - PolyCount = DynamicMeshPNum; - VertexCount = DynamicMeshVNum; - - MeshGeometryClass::Compute_Bounds(verts); - - PolyCount = old_poly_count; - VertexCount = old_vert_count; -} - -void DynamicMeshModel::Reset(void) -{ - Set_Counts(0, 0); - int polycount = Get_Polygon_Count(); - int vertcount = Get_Vertex_Count(); - Reset_Geometry(polycount, vertcount); - MatDesc->Reset(polycount, vertcount, 1); - REF_PTR_RELEASE(MatInfo); - MatInfo = NEW_REF(MaterialInfoClass, ()); -} - -void DynamicMeshModel::Render(RenderInfoClass & rinfo) -{ - // Process texture reductions: -// MatInfo->Process_Texture_Reduction(); - - unsigned buffer_type=(Get_Flag(MeshGeometryClass::SORT)&& WW3D::Is_Sorting_Enabled()) ? BUFFER_TYPE_DYNAMIC_SORTING : BUFFER_TYPE_DYNAMIC_DX8; - - /* - ** Write the vertex data to the vertex buffer. We assume the FVF contains positions, normals, - ** one texture channel, and the diffuse color channel (color0). If it does not contain all - ** these components, the code will fail. - */ - DynamicVBAccessClass dynamic_vb(buffer_type,dynamic_fvf_type,DynamicMeshVNum); - const FVFInfoClass &fvf_info = dynamic_vb.FVF_Info(); - - { // scope for lock - - DynamicVBAccessClass::WriteLockClass lock(&dynamic_vb); - unsigned char *vertices = (unsigned char*)lock.Get_Formatted_Vertex_Array(); - const Vector3 *locs = Get_Vertex_Array(); - const Vector3 *normals = Get_Vertex_Normal_Array(); - const Vector2 *uvs = MatDesc->Get_UV_Array_By_Index(0, false); - const Vector2 *uv1s = MatDesc->Get_UV_Array_By_Index(1, false); - const unsigned *colors = MatDesc->Get_Color_Array(0, false); - const static Vector3 default_normal(0.0f, 0.0f, 0.0f); - const static Vector2 default_uv(0.0f, 0.0f); - const unsigned int default_color = 0xFFFFFFFF; - for (int i=0; i < DynamicMeshVNum; i++) - { - *(Vector3 *)(vertices + fvf_info.Get_Location_Offset()) = locs[i]; - *(Vector3 *)(vertices + fvf_info.Get_Normal_Offset()) = normals[i]; - if (uvs) { - *(Vector2 *)(vertices + fvf_info.Get_Tex_Offset(0)) = uvs[i]; - } else { - *(Vector2 *)(vertices + fvf_info.Get_Tex_Offset(0)) = default_uv; - } - if (uv1s) { - *(Vector2 *)(vertices + fvf_info.Get_Tex_Offset(1)) = uv1s[i]; - } else { - *(Vector2 *)(vertices + fvf_info.Get_Tex_Offset(1)) = default_uv; - } - - if (colors) { - *(unsigned int *)(vertices + fvf_info.Get_Diffuse_Offset()) = colors[i]; - } else { - *(unsigned int *)(vertices + fvf_info.Get_Diffuse_Offset()) = default_color; - } - vertices += fvf_info.Get_FVF_Size(); - } - - } // end scope for lock - - /* - ** Write index data to index buffers - */ - DynamicIBAccessClass dynamic_ib(buffer_type,DynamicMeshPNum * 3); - const TriIndex *tris = Get_Polygon_Array(); - - { // scope for lock - - DynamicIBAccessClass::WriteLockClass lock(&dynamic_ib); - unsigned short * indices = lock.Get_Index_Array(); - for (int i=0; i < DynamicMeshPNum; i++) - { - indices[i*3 + 0] = (unsigned short)tris[i][0]; - indices[i*3 + 1] = (unsigned short)tris[i][1]; - indices[i*3 + 2] = (unsigned short)tris[i][2]; - } - - } // end scope for lock - - /* - ** Set vertex and index buffers - */ - DX8Wrapper::Set_Vertex_Buffer(dynamic_vb); - DX8Wrapper::Set_Index_Buffer(dynamic_ib,0); - - /* - ** Draw dynamesh, one pass at a time - */ - unsigned int pass_count = Get_Pass_Count(); - for (unsigned int pass = 0; pass < pass_count; pass++) { - - /* - ** Set current render states (texture, vertex material, shader). Scan triangles until one - ** of these changes, and then draw. - */ - - // The vertex index range used - unsigned short min_vert_idx = DynamicMeshVNum - 1; - unsigned short max_vert_idx = 0; - unsigned short start_tri_idx = 0; - unsigned short cur_tri_idx = 0; - - bool done = false; - bool texture_changed = false; - bool texture1_changed = false; - bool material_changed = false; - bool shader_changed = false; - - TextureClass **texture_array0 = NULL; - TexBufferClass * tex_buf = MatDesc->Get_Texture_Array(pass, 0, false); - if (tex_buf) { - texture_array0 = tex_buf->Get_Array(); - } else { - texture_array0 = NULL; - } - - TextureClass **texture_array1 = NULL; - TexBufferClass * tex_buf1 = MatDesc->Get_Texture_Array(pass, 1, false); - if (tex_buf1) { - texture_array1 = tex_buf1->Get_Array(); - } else { - texture_array1 = NULL; - } - - VertexMaterialClass **material_array = NULL; - MatBufferClass * mat_buf = MatDesc->Get_Material_Array(pass, false); - if (mat_buf) { - material_array = mat_buf->Get_Array(); - } else { - material_array = NULL; - } - ShaderClass *shader_array = MatDesc->Get_Shader_Array(pass, false); - - // Set the DX8 state to the first triangle's state - if (texture_array0) { - DX8Wrapper::Set_Texture(0,texture_array0[0]); - } else { - DX8Wrapper::Set_Texture(0,MatDesc->Peek_Single_Texture(pass, 0)); - } - - if (texture_array1) { - DX8Wrapper::Set_Texture(1,texture_array1[0]); - } else { - DX8Wrapper::Set_Texture(1,MatDesc->Peek_Single_Texture(pass, 1)); - } - - if (material_array) { - DX8Wrapper::Set_Material(material_array[tris[0].I]); - } else { - DX8Wrapper::Set_Material(MatDesc->Peek_Single_Material(pass)); - } - if (shader_array) { - DX8Wrapper::Set_Shader(shader_array[0]); - } else { - DX8Wrapper::Set_Shader(MatDesc->Get_Single_Shader(pass)); - } - - SphereClass sphere(Vector3(0.0f,0.0f,0.0f),0.0f); - Get_Bounding_Sphere(&sphere); - - // If no texture, shader or material arrays for this pass just draw and go to next pass - if (!texture_array0 && !texture_array1 && !material_array && !shader_array) { - if (buffer_type==BUFFER_TYPE_DYNAMIC_SORTING) { - SortingRendererClass::Insert_Triangles(sphere,0, DynamicMeshPNum, 0, DynamicMeshVNum); - } - else { - DX8Wrapper::Draw_Triangles(0, DynamicMeshPNum, 0, DynamicMeshVNum); - } - continue; - } - - while (!done) { - - // Add vertex indices of tri[cur_tri_idx] to min_vert_idx, max_vert_idx - const TriIndex &tri = tris[cur_tri_idx]; - unsigned short min_idx = (unsigned short)MIN(MIN(tri.I, tri.J), tri.K); - unsigned short max_idx = (unsigned short)MAX(MAX(tri.I, tri.J), tri.K); - min_vert_idx = MIN(min_vert_idx, min_idx); - max_vert_idx = MAX(max_vert_idx, max_idx); - - // Check the next triangle to see if the current run has ended. - unsigned short next_tri_idx = cur_tri_idx + 1; - done = next_tri_idx >= DynamicMeshPNum; - if (done) { - texture_changed = false; - texture1_changed = false; - material_changed = false; - shader_changed = false; - } else { - texture_changed = texture_array0 && texture_array0[cur_tri_idx] != texture_array0[next_tri_idx]; - texture1_changed = texture_array1 && texture_array1[cur_tri_idx] != texture_array1[next_tri_idx]; - material_changed = material_array && material_array[tris[cur_tri_idx].I] != material_array[tris[next_tri_idx].I]; - shader_changed = shader_array && shader_array[cur_tri_idx] != shader_array[next_tri_idx]; - } - - // If run ends (mesh ends or state changes) draw, reset indices, set state for next run. - if (done || texture_changed || material_changed || shader_changed) { - if (buffer_type==BUFFER_TYPE_DYNAMIC_SORTING) { - SortingRendererClass::Insert_Triangles( - sphere, - (start_tri_idx * 3), - (1 + cur_tri_idx - start_tri_idx), - min_vert_idx, - 1 + max_vert_idx - min_vert_idx); - } - else { - DX8Wrapper::Draw_Triangles( - (start_tri_idx * 3), - (1 + cur_tri_idx - start_tri_idx), - min_vert_idx, - 1 + max_vert_idx - min_vert_idx); - } - start_tri_idx = next_tri_idx; - min_vert_idx = DynamicMeshVNum - 1; - max_vert_idx = 0; - if (texture_changed) DX8Wrapper::Set_Texture(0,texture_array0[next_tri_idx]); - if (texture1_changed) DX8Wrapper::Set_Texture(1,texture_array1[next_tri_idx]); - if (material_changed) DX8Wrapper::Set_Material(material_array[tris[next_tri_idx].I]); - if (shader_changed) DX8Wrapper::Set_Shader(shader_array[next_tri_idx]); - } - - cur_tri_idx = next_tri_idx; - - } // while (!done) - - } // for (pass) - -} - -void DynamicMeshModel::Initialize_Texture_Array(int pass, int stage, TextureClass *texture) -{ - TexBufferClass * texlist = MatDesc->Get_Texture_Array(pass, 0, true); - for (int lp = 0; lp < PolyCount; lp++) { - texlist->Set_Element(lp, texture); - } -} - -void DynamicMeshModel::Initialize_Material_Array(int pass, VertexMaterialClass *vmat) -{ - MatBufferClass * vertmatlist = MatDesc->Get_Material_Array(pass, true); - for (int lp = 0; lp < VertexCount; lp++) { - vertmatlist->Set_Element(lp, vmat); - } -} - -void DynamicMeshClass::Render(RenderInfoClass & rinfo) -{ - if (Is_Not_Hidden_At_All() == false) return; - - // test for an empty mesh.. - if (PolyCount == 0 ) return; - - // If static sort lists are enabled and this mesh has a sort level, put it on the list instead - // of rendering it. - - if (WW3D::Are_Static_Sort_Lists_Enabled() && SortLevel != SORT_LEVEL_NONE) { - - WW3D::Add_To_Static_Sort_List(this, SortLevel); - - } else { - - const FrustumClass & frustum = rinfo.Camera.Get_Frustum(); - - if (CollisionMath::Overlap_Test(frustum, Get_Bounding_Box()) != CollisionMath::OUTSIDE) { - DX8Wrapper::Set_Transform(D3DTS_WORLD, Transform); - Model->Render(rinfo); - } - } -} - -bool DynamicMeshClass::End_Vertex() -{ - // check that we have room for a new vertex - WWASSERT(VertCount < Model->Get_Vertex_Count()); - - // if we are a multi-material object record the material - int pass = Get_Pass_Count(); - while (pass--) { - if (MultiVertexMaterial[pass]) { - VertexMaterialClass *mat = Peek_Material_Info()->Get_Vertex_Material(VertexMaterialIdx[pass]); - Model->Set_Material(VertCount, mat, pass); - REF_PTR_RELEASE(mat); - } - - } - - // if we are multi colored, record the color - for (int color_array_index = 0; color_array_index < MAX_COLOR_ARRAYS; color_array_index++) { - if (MultiVertexColor[color_array_index]) { -// Vector4 * color = &((Model->Get_Color_Array(color_array_index))[VertCount]); -// color->X = CurVertexColor[color_array_index].X; -// color->Y = CurVertexColor[color_array_index].Y; -// color->Z = CurVertexColor[color_array_index].Z; -// color->W = CurVertexColor[color_array_index].W; - unsigned * color = &((Model->Get_Color_Array(color_array_index))[VertCount]); - *color=DX8Wrapper::Convert_Color_Clamp(CurVertexColor[color_array_index]); - } - } - - // mark this vertex as being complete - VertCount++; - TriVertexCount++; - - // if we have 3 or more vertices, add a new poly - if (TriVertexCount >= 3) { - - // check that we have room for a new poly - WWASSERT(PolyCount < Model->Get_Polygon_Count()); - - // set vertex indices - TriIndex *poly = &(Model->Get_Non_Const_Polygon_Array())[PolyCount]; - if (TriMode == TRI_MODE_STRIPS) { - (*poly)[0] = VertCount-3; - (*poly)[1] = VertCount-2; - (*poly)[2] = VertCount-1; - - // for every other tri, reverse vertex order - if (Flip_Face()) { - (*poly)[1] = VertCount-1; - (*poly)[2] = VertCount-2; - } - } else { - (*poly)[0] = FanVertex; - (*poly)[1] = VertCount-2; - (*poly)[2] = VertCount-1; - } - - // check each pass - int pass = Get_Pass_Count(); - while (pass--) { - - // If we are multi texture - if (MultiTexture[pass]) { - TextureClass *tex = Peek_Material_Info()->Get_Texture(TextureIdx[pass]); - Model->Set_Texture(PolyCount, tex, pass); - REF_PTR_RELEASE(tex); - } - } - - // increase the count and record that we have a new material - PolyCount++; - Model->Set_Counts(PolyCount, VertCount); - } - return true; -} - -/****************************************************************** -** -** DynamicMeshClass -** -*******************************************************************/ -DynamicMeshClass::DynamicMeshClass(int max_poly, int max_vert) : - Model(NULL), - PolyCount(0), - VertCount(0), - TriVertexCount(0), - FanVertex(0), - TriMode(TRI_MODE_STRIPS), - SortLevel(SORT_LEVEL_NONE) -{ - int pass = MAX_PASSES; - while (pass--) { - MultiTexture[pass] = false; - TextureIdx[pass] = -1; - - MultiVertexMaterial[pass] = false; - VertexMaterialIdx[pass] = -1; - } - - for (int color_array_index = 0; color_array_index < MAX_COLOR_ARRAYS; color_array_index++) { - MultiVertexColor[color_array_index] = false; - CurVertexColor[color_array_index].Set(1.0f, 1.0f, 1.0f, 1.0f); - } - - Model = NEW_REF(DynamicMeshModel, (max_poly, max_vert)); -} - -DynamicMeshClass::DynamicMeshClass(int max_poly, int max_vert, MaterialInfoClass *mat_info) : - Model(NULL), - PolyCount(0), - VertCount(0), - TriVertexCount(0), - FanVertex(0), - TriMode(TRI_MODE_STRIPS), - SortLevel(SORT_LEVEL_NONE) -{ - int pass = MAX_PASSES; - while (pass--) { - MultiTexture[pass] = false; - TextureIdx[pass] = -1; - - MultiVertexMaterial[pass] = false; - VertexMaterialIdx[pass] = -1; - } - - for (int color_array_index = 0; color_array_index < MAX_COLOR_ARRAYS; color_array_index++) { - MultiVertexColor[color_array_index] = false; - CurVertexColor[color_array_index].Set(1.0f, 1.0f, 1.0f, 1.0f); - } - - Model = NEW_REF(DynamicMeshModel, (max_poly, max_vert, mat_info)); -} - -DynamicMeshClass::DynamicMeshClass(const DynamicMeshClass & src) : - RenderObjClass(src), - Model(NULL), - PolyCount(src.PolyCount), - VertCount(src.VertCount), - TriVertexCount(src.TriVertexCount), - FanVertex(src.FanVertex), - TriMode(src.TriMode), - SortLevel(src.SortLevel) -{ - int pass = MAX_PASSES; - while (pass--) { - MultiTexture[pass] = src.MultiTexture[pass]; - TextureIdx[pass] = src.TextureIdx[pass]; - - MultiVertexMaterial[pass] = src.MultiVertexMaterial[pass]; - VertexMaterialIdx[pass] = src.VertexMaterialIdx[pass]; - - MultiVertexColor[pass] = src.MultiVertexColor[pass]; - CurVertexColor[pass] = src.CurVertexColor[pass]; - } - - for (int color_array_index = 0; color_array_index < MAX_COLOR_ARRAYS; color_array_index++) { - MultiVertexColor[color_array_index] = src.MultiVertexColor[color_array_index]; - CurVertexColor[color_array_index] = src.CurVertexColor[color_array_index]; - } - - Model = NEW_REF(DynamicMeshModel, (*(src.Model))); -} - -void DynamicMeshClass::Resize(int max_polys, int max_verts) -{ - Reset(); - - REF_PTR_RELEASE(Model); - Model = NEW_REF(DynamicMeshModel, (max_polys, max_verts)); - - // reset all the texture & vertex material indices - int pass = MAX_PASSES; - while (pass--) { - TextureIdx[pass] = -1; - VertexMaterialIdx[pass] = -1; - MultiVertexMaterial[pass] = false; - } -} - -DynamicMeshClass::~DynamicMeshClass() -{ - REF_PTR_RELEASE(Model); -} - -RenderObjClass * DynamicMeshClass::Clone(void) const -{ - return NEW_REF(DynamicMeshClass, (*this)); -} - -void DynamicMeshClass::Location(float x, float y, float z) -{ - Vector3 * loc = Model->Get_Vertex_Array(); - assert(loc); - - loc[VertCount].X = x; - loc[VertCount].Y = y; - loc[VertCount].Z = z; -} - -/* -** For moving a vertex after the DynaMesh has already been created. -*/ -void DynamicMeshClass::Move_Vertex(int index, float x, float y, float z) -{ - Vector3 * loc = Model->Get_Vertex_Array(); - assert(loc); - loc[index][0] = x; - loc[index][1] = y; - loc[index][2] = z; -} - -/* -** Get a vertex value. -*/ -void DynamicMeshClass::Get_Vertex(int index, float &x, float &y, float &z) -{ - Vector3 * loc = Model->Get_Vertex_Array(); - assert(loc); - x = loc[index][0]; - y = loc[index][1]; - z = loc[index][2]; -} - - -/* -** Offset the entire mesh -*/ -void DynamicMeshClass::Translate_Vertices(const Vector3 & offset) -{ - Vector3 * loc = Model->Get_Vertex_Array(); - assert(loc); - for (int i=0; i < Get_Num_Vertices(); i++) { - loc[i].X += offset.X; - loc[i].Y += offset.Y; - loc[i].Z += offset.Z; - } - - Set_Dirty_Bounds(); - Set_Dirty_Planes(); -} - -int DynamicMeshClass::Set_Vertex_Material(int idx, int pass) -{ - assert(idx < Peek_Material_Info()->Vertex_Material_Count()); - VertexMaterialIdx[pass] = idx; - if (!MultiVertexMaterial[pass]) { - // WWASSERT( VertexMaterialIdx[pass] == 0); - VertexMaterialClass *mat = Peek_Material_Info()->Get_Vertex_Material(VertexMaterialIdx[pass]); - Model->Set_Single_Material(mat, pass); - mat->Release_Ref(); - } - return VertexMaterialIdx[pass]; -} - -int DynamicMeshClass::Set_Vertex_Material(VertexMaterialClass *material, bool dont_search, int pass) -{ - // Check if same as the last vertex material - if (Peek_Material_Info()->Vertex_Material_Count() && (VertexMaterialIdx[pass] != -1) && Peek_Material_Info()->Peek_Vertex_Material(VertexMaterialIdx[pass]) == material) { - return VertexMaterialIdx[pass]; - } - - // if there are vertex materials in the list then we may have just jumped - // to becoming a multi-vertex-material object. Take care of that here. - if ((!MultiVertexMaterial[pass]) && Peek_Material_Info()->Vertex_Material_Count() && (VertexMaterialIdx[pass] != -1) && Peek_Material_Info()->Peek_Vertex_Material(VertexMaterialIdx[pass]) != material) { - - // allocate the array of per-vertex vertex material overrides - VertexMaterialClass *mat = Peek_Material_Info()->Get_Vertex_Material(VertexMaterialIdx[pass]); - Model->Initialize_Material_Array(pass, mat); - mat->Release_Ref(); - - // flag that we need to write the per -vertex vertex material override array - MultiVertexMaterial[pass] = true; - } - - // add the material to the material info class if we cant find it in the - // list. if we are not supposed to search the list for it then just add - // it. - if (!dont_search) { - int lp = 0, found = 0; - for (; lp < Peek_Material_Info()->Vertex_Material_Count(); lp ++) { - VertexMaterialClass *mat = Peek_Material_Info()->Get_Vertex_Material(lp); - if (material == mat) { - VertexMaterialIdx[pass] = lp; - found = 1; - mat->Release_Ref(); - break; - } - mat->Release_Ref(); - } - if (!found) { - Peek_Material_Info()->Add_Vertex_Material(material); - VertexMaterialIdx[pass] = Peek_Material_Info()->Vertex_Material_Count() - 1; - } - } else { - Peek_Material_Info()->Add_Vertex_Material(material); - VertexMaterialIdx[pass] = Peek_Material_Info()->Vertex_Material_Count() - 1; - } - - if (!MultiVertexMaterial[pass]) { - Model->Set_Single_Material(Peek_Material_Info()->Peek_Vertex_Material(VertexMaterialIdx[pass]), pass); - } - return(VertexMaterialIdx[pass]); -} - -int DynamicMeshClass::Set_Texture(int idx, int pass) -{ - WWASSERT(idx < Peek_Material_Info()->Texture_Count()); - TextureIdx[pass] = idx; - if (!MultiTexture[pass]) { - TextureClass *tex = Peek_Material_Info()->Get_Texture(TextureIdx[pass]); - Model->Set_Single_Texture(tex, pass); - tex->Release_Ref(); - } - return TextureIdx[pass]; -} - -int DynamicMeshClass::Set_Texture(TextureClass *texture, bool dont_search, int pass) -{ - // Check if same as the last texture - if (Peek_Material_Info()->Texture_Count() && (TextureIdx[pass] != -1) && Peek_Material_Info()->Peek_Texture(TextureIdx[pass]) == texture) { - return TextureIdx[pass]; - } - - // if there are textures in the list then we may have just jumped - // to becoming a multi-texture object. Take care of that here. - if ((!MultiTexture[pass]) && Peek_Material_Info()->Texture_Count() && (TextureIdx[pass] != -1) && Peek_Material_Info()->Peek_Texture(TextureIdx[pass]) != texture) { - - // allocate the array of per polygon material over-rides - TextureClass *tex = Peek_Material_Info()->Get_Texture(TextureIdx[pass]); - Model->Initialize_Texture_Array(pass, 0, tex); - tex->Release_Ref(); - - // flag that we need to write the per polygon material overide array - MultiTexture[pass] = true; - } - - // add the material to the material info class if we cant find it in the - // list. if we are not supposed to search the list for it then just add - // it. - if (!dont_search) { - int lp = 0, found = 0; - for (; lp < Peek_Material_Info()->Texture_Count(); lp ++) { - TextureClass *tex = Peek_Material_Info()->Get_Texture(lp); - if (texture == tex) { - TextureIdx[pass] = lp; - found = 1; - tex->Release_Ref(); - break; - } - tex->Release_Ref(); - } - if (!found) { - Peek_Material_Info()->Add_Texture(texture); - TextureIdx[pass] = Peek_Material_Info()->Texture_Count() - 1; - } - } else { - Peek_Material_Info()->Add_Texture(texture); - TextureIdx[pass] = Peek_Material_Info()->Texture_Count() - 1; - } - - if (!MultiTexture[pass]) { - TextureClass *tex = Peek_Material_Info()->Get_Texture(TextureIdx[pass]); - Model->Set_Single_Texture(tex, pass); - tex->Release_Ref(); - } - return(TextureIdx[pass]); -} - -/* -** -*/ -// Remap locations to match a screen -void DynamicScreenMeshClass::Location( float x, float y, float z) -{ - DynamicMeshClass::Location( (x * 2) - 1, Aspect - (y * 2 * Aspect), 0); -} - -// For moving a vertex after the DynaMesh has already been created. -void DynamicScreenMeshClass::Move_Vertex(int index, float x, float y, float z) -{ - DynamicMeshClass::Move_Vertex( index, (x * 2) - 1, Aspect - (y * 2 * Aspect), 0); -} - -// Set position -void DynamicScreenMeshClass::Set_Position(const Vector3 &v) -{ - DynamicMeshClass::Set_Position(Vector3(v.X * 2, -(v.Y * 2 * Aspect), 0)); -} - -void DynamicScreenMeshClass::Reset( void ) -{ - Reset_Flags(); - Reset_Mesh_Counters(); -} - - diff --git a/Generals/Code/Libraries/Source/WWVegas/WW3D2/dynamesh.h b/Generals/Code/Libraries/Source/WWVegas/WW3D2/dynamesh.h deleted file mode 100644 index cba8c937a45..00000000000 --- a/Generals/Code/Libraries/Source/WWVegas/WW3D2/dynamesh.h +++ /dev/null @@ -1,582 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*************************************************************************** - *** 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 *** - *************************************************************************** - * * - * Project Name : Commando * - * * - * $Archive:: /Commando/Code/ww3d2/dynamesh.h $* - * * - * $Author:: Greg_h $* - * * - * $Modtime:: 12/03/01 4:20p $* - * * - * $Revision:: 15 $* - * * - *-------------------------------------------------------------------------*/ - - -#if defined(_MSC_VER) -#pragma once -#endif - -#ifndef DYNAMESH_H -#define DYNAMESH_H - -#include "meshgeometry.h" -#include "meshmatdesc.h" -#include "matinfo.h" -#include "rendobj.h" -#include "polyinfo.h" -#include "dx8wrapper.h" - -class ShaderClass; -class IntersectionClass; -class IntersectionResultClass; - -/* -** DynamicMeshModel: used for low-level rendering of DynamicMeshClass. -** It is composed of the same two classes (one base, one embedded as -** MeshModelClass, so many of its features are similar (see meshmdl.h) -*/ -class DynamicMeshModel : public MeshGeometryClass -{ - W3DMPO_GLUE(DynamicMeshModel) - -public: - - DynamicMeshModel(unsigned int max_polys, unsigned int max_verts); - DynamicMeshModel(unsigned int max_polys, unsigned int max_verts, MaterialInfoClass *mat_info); - DynamicMeshModel(const DynamicMeshModel &src); - ~DynamicMeshModel(void); - - // Inherited from MeshGeometryClass - virtual void Compute_Plane_Equations(void); - virtual void Compute_Vertex_Normals(void); - virtual void Compute_Bounds(Vector3 * verts); - - // Reset mesh (with existing max polygon and max vertex counts) - void Reset(void); - - // Render mesh - void Render(RenderInfoClass & rinfo); - - // Set current polygon and vertex counts - void Set_Counts(int pnum, int vnum) { DynamicMeshPNum = pnum; DynamicMeshVNum = vnum; } - - // Access to material stuff: - unsigned * Get_Color_Array(int color_array_index) { return MatDesc->Get_Color_Array(color_array_index); } - Vector2 * Get_UV_Array(int uv_array_index) { return MatDesc->Get_UV_Array_By_Index(uv_array_index); } - - void Set_Single_Material(VertexMaterialClass * vmat, int pass=0) { MatDesc->Set_Single_Material(vmat, pass); } - void Set_Single_Texture(TextureClass * tex, int pass=0, int stage=0) { MatDesc->Set_Single_Texture(tex, pass, stage); } - void Set_Single_Shader(ShaderClass shader, int pass=0) { MatDesc->Set_Single_Shader(shader, pass); } - - void Set_Material(int vidx, VertexMaterialClass * vmat, int pass=0) { MatDesc->Set_Material(vidx, vmat, pass); } - void Set_Shader(int pidx, ShaderClass shader, int pass=0) { MatDesc->Set_Shader(pidx, shader, pass); } - void Set_Texture(int pidx, TextureClass * tex, int pass=0, int stage=0) { MatDesc->Set_Texture(pidx, tex, pass, stage); } - void Set_Pass_Count(int passes) { MatDesc->Set_Pass_Count(passes); } - int Get_Pass_Count(void) const { return MatDesc->Get_Pass_Count(); } - - // Create the array (if it doesn't exist), fill it with the supplied value. - void Initialize_Texture_Array(int pass, int stage, TextureClass *texture = NULL); - void Initialize_Material_Array(int pass, VertexMaterialClass *vmat = NULL); - - // Accessors to material info: - MaterialInfoClass *Peek_Material_Info(void) { return MatInfo; } - MaterialInfoClass *Get_Material_Info(void) { if (MatInfo) MatInfo->Add_Ref(); return MatInfo;} - void Set_Material_Info(MaterialInfoClass *mat_info) - { - if (MatInfo) - MatInfo->Release_Ref(); - WWASSERT(MatInfo != 0); - MatInfo = mat_info; - MatInfo->Add_Ref(); - } - - // New geometry accessors (non-const) - TriIndex * Get_Non_Const_Polygon_Array(void); - Vector3 * Get_Non_Const_Vertex_Normal_Array(void); - -private: - - // These are current counts, as opposed to those in the mesh geometry and - // material description which are actually maximum counts. - int DynamicMeshPNum; - int DynamicMeshVNum; - - // All non-geometry properties (uvs, colors, textures, shaders, etc) - MeshMatDescClass * MatDesc; - - // Lists of textures and vertex materials for ease of processing - MaterialInfoClass * MatInfo; - -}; - -/* -** Dynamic Meshes -*/ -class DynamicMeshClass : public RenderObjClass { - -public: - - // constructor and destructor - DynamicMeshClass( int max_poly, int max_vert); - DynamicMeshClass( int max_poly, int max_vert, MaterialInfoClass *mat_info); - DynamicMeshClass( const DynamicMeshClass & src); - virtual ~DynamicMeshClass( void); - - // Inherited from RenderObjClass: - virtual RenderObjClass * Clone(void) const; - virtual int Class_ID(void) const { return CLASSID_DYNAMESH; } - virtual void Render(RenderInfoClass & rinfo); - - virtual MaterialInfoClass *Peek_Material_Info(void) { return Model->Peek_Material_Info(); } - virtual MaterialInfoClass *Get_Material_Info(void) { return Model->Get_Material_Info(); } - virtual void Set_Material_Info(MaterialInfoClass *mat_info) { Model->Set_Material_Info(mat_info); } - - // all render objects should be able to tell you how many polygons were - // used in the making of the render object. - virtual int Get_Num_Polys(void) const { return PolyCount; } - - // return the number of vertices used by this renderobject - virtual int Get_Num_Vertices(void) const { return VertCount; } - - // Get and set static sort level - virtual int Get_Sort_Level(void) const { return SortLevel; } - virtual void Set_Sort_Level(int level) { SortLevel = level; if(level != SORT_LEVEL_NONE) Disable_Sort();} - - // object space bounding volumes - virtual inline void Get_Obj_Space_Bounding_Sphere(SphereClass & sphere) const; - virtual inline void Get_Obj_Space_Bounding_Box(AABoxClass & box) const; - - // Set the vertex material for the current triangle - int Set_Vertex_Material( int idx, int pass = 0); - int Set_Vertex_Material( VertexMaterialClass *material, bool dont_search = false, int pass = 0); - - // Set the number of passes for the mesh - void Set_Pass_Count(int passes) { assert(PolyCount == 0); Model->Set_Pass_Count(passes); } - int Get_Pass_Count() { return Model->Get_Pass_Count(); } - - // Set the texture for the current triangle - int Set_Texture( int idx, int pass = 0); - int Set_Texture( TextureClass *texture, bool dont_search = false, int pass = 0); - - // Set the shader for the current triangle - int Set_Shader( const ShaderClass & shader, int pass = 0) { Model->Set_Single_Shader(shader, pass); return 0; } - - // set the shader, texture, and vertex material as found in the polygon info object - void Set_Polygon_Info(const PolygonInfoClass &polyInfo, bool dont_search_texture = false, bool dont_search_vertex_material = false, int pass = 0) - { - // there must be a shader.. - assert(polyInfo.Peek_Shader() != 0); - Set_Shader(* (polyInfo.Peek_Shader()), pass); - - assert(polyInfo.Peek_Vertex_Material() != 0); - Set_Vertex_Material(polyInfo.Peek_Vertex_Material(), dont_search_vertex_material, pass); - - if (polyInfo.Peek_Texture()) - Set_Texture(polyInfo.Peek_Texture(), dont_search_texture, pass); - } - - // Set vertex Color - inline int Set_Vertex_Color(const Vector4 & color, int color_array_index = 0); - inline int Set_Vertex_Color(const Vector3 & color, int color_array_index = 0); - - // reset the mesh flags - void Reset_Flags() { Set_Dirty(); } - - // Flush the mesh - void Reset_Native_Mesh() { Model->Reset(); } - - // reset our poly and vertex counts - void Reset_Mesh_Counters() - { - Model->Set_Counts(0, 0); - Disable_Sort(); - PolyCount = 0; - VertCount = 0; - } - - // Reset all polys and verts. Call the other reset functions directly if you do not want all - // characteristics to be reset. - virtual void Reset( void ) - { - // Note that the active poly count has changed since the last render call by setting the dirty flag - Reset_Flags(); - Reset_Native_Mesh(); - Reset_Mesh_Counters(); - - // reset all the texture & vertex material indices - int pass = MAX_PASSES; - while (pass--) { - TextureIdx[pass] = -1; - VertexMaterialIdx[pass] = -1; - MultiVertexMaterial[pass] = false; - } - } - - // Deletes mesh and recreates it with new max_polys and verts. - void Resize(int max_polys, int max_verts); - - // Triangle creation routines - void Begin_Tri_Strip( void ) { TriVertexCount = 0; TriMode = TRI_MODE_STRIPS; } - void Begin_Tri_Fan( void ) { TriVertexCount = 0; TriMode = TRI_MODE_FANS; FanVertex = VertCount; } - - // vertex creation routines - void Begin_Vertex( void) {} - - virtual void Location( float x, float y, float z); - - // version for speedier use in certain cases - void Location_Inline( float x, float y, float z ) - { - Vector3 * loc = Model->Get_Vertex_Array(); - assert(loc); - - loc[VertCount].X = x; - loc[VertCount].Y = y; - loc[VertCount].Z = z; - } - void Location_Inline(Vector3 &v) { Location_Inline(v.X,v.Y,v.Z); } - - // retrieve a reference to the vertex in the object - // WARNING: does not validate index - Vector3 & Get_Location(int index) { - return Model->Get_Vertex_Array()[index]; - } - - void Normal( float x, float y, float z) - { - Vector3 * norms = Model->Get_Non_Const_Vertex_Normal_Array(); - assert(norms); - - norms[VertCount].X = x; - norms[VertCount].Y = y; - norms[VertCount].Z = z; - } - void Normal(Vector3 &v) { Normal(v.X,v.Y,v.Z); } - - // retrieve a reference to the normal vector3 in the object - // WARNING: does not validate index - Vector3 & Get_Normal(int index) { return Model->Get_Non_Const_Vertex_Normal_Array()[index]; } - - void Color(float r, float g, float b, float a, int color_array_index = 0) - { -// Vector4 * color = Model->Get_Color_Array(color_array_index); - unsigned * color = Model->Get_Color_Array(color_array_index); - assert(color); - - color[VertCount]=DX8Wrapper::Convert_Color_Clamp(Vector4(r,g,b,a)); -// color[VertCount].X = r; -// color[VertCount].Y = g; -// color[VertCount].Z = b; -// color[VertCount].W = a; - } - void Color(const Vector4 &v, int color_array_index = 0) { Color(v.X, v.Y, v.Z, v.W, color_array_index); } - void Color(unsigned v, int color_array_index=0) - { - unsigned * color = Model->Get_Color_Array(color_array_index); - assert(color); - color[VertCount]=v; - } - - // retrieve a reference to a color entry in the object - // WARNING: does not validate index -// Vector4 & Get_Color(int index, int color_array_index = 0) { return Model->Get_Color_Array(color_array_index)[index]; } - unsigned Get_Color(int index, int color_array_index = 0) { return Model->Get_Color_Array(color_array_index)[index]; } - - void UV(float u, float v, int uv_array_index = 0) - { - Vector2 * uv = Model->Get_UV_Array(uv_array_index); - assert(uv); - - uv[VertCount].U = u; - uv[VertCount].V = v; - } - void UV( Vector2 &v, int uv_array_index = 0) { UV(v.U, v.V, uv_array_index); } - // retrieve a reference to a UV entry in the object - // WARNING: does not validate index - Vector2 & Get_UV(int index, int uv_array_index = 0 ) - { - return Model->Get_UV_Array(uv_array_index)[index]; - } - - bool End_Vertex( void); - - // vertex creation shortcut, performs a begin, projected, rotated, and end - bool Vertex(float x, float y, float z, float u, float v) - { - Begin_Vertex(); - Location(x, y, z); - UV(u, v); - return End_Vertex(); - } - - bool Vertex(Vector2 v) - { - Begin_Vertex(); - Location(v.X, v.Y, 0); - return End_Vertex(); - } - - void End_Tri_Strip( void ) - { - TriVertexCount = 0; - } - - void End_Tri_Fan( void ) - { - TriVertexCount = 0; - } - - // For moving a vertex after the DynaMesh has already been created. - virtual void Move_Vertex(int index, float x, float y, float z); - virtual void Get_Vertex(int index, float &x, float &y, float &z); - - // For moving all vertices in the mesh by a fixed amount - void Translate_Vertices(const Vector3 & offset); - - // For changing the color of a vertex after DynaMesh has been created. - virtual void Change_Vertex_Color(int index, const Vector4 &color, int color_array_index) - { - // check if switching to multivertexcolor - if (!MultiVertexColor[color_array_index]) { - Switch_To_Multi_Vertex_Color(color_array_index); - } - CurVertexColor[color_array_index].X = color.X; - CurVertexColor[color_array_index].Y = color.Y; - CurVertexColor[color_array_index].Z = color.Z; - CurVertexColor[color_array_index].W = color.W; -// Vector4 * color_list = Model->Get_Color_Array(color_array_index); - unsigned * color_list = Model->Get_Color_Array(color_array_index); - color_list[index] = DX8Wrapper::Convert_Color_Clamp(color); - } - - - /* - ** The following are a bunch of inlined functions for setting & clearing the mesh model's various flags - */ - // dirty flags - void Set_Dirty_Bounds(void) { Model->Set_Flag(MeshGeometryClass::DIRTY_BOUNDS, true); } - void Clear_Dirty_Bounds(void) { Model->Set_Flag(MeshGeometryClass::DIRTY_BOUNDS, false); } - void Set_Dirty_Planes(void) { Model->Set_Flag(MeshGeometryClass::DIRTY_PLANES, true); } - void Clear_Dirty_Planes(void) { Model->Set_Flag(MeshGeometryClass::DIRTY_PLANES, false); } - void Set_Dirty_Vertex_Normals(void) { Model->Set_Flag(MeshGeometryClass::DIRTY_VNORMALS, true); } - void Clear_Dirty_Vertex_Normals(void) { Model->Set_Flag(MeshGeometryClass::DIRTY_VNORMALS, false); } - - // control flags - void Disable_Sort(void) { Model->Set_Flag(MeshGeometryClass::SORT, false); } - void Enable_Sort(void) { Model->Set_Flag(MeshGeometryClass::SORT, true); } - bool Sort_Enabled(void) { return (Model->Get_Flag(MeshGeometryClass::SORT) != 0); } - - void Disable_Bounding_Box(void) { Model->Set_Flag(MeshGeometryClass::DISABLE_BOUNDING_BOX, true); } - void Enable_Bounding_Box(void) { Model->Set_Flag(MeshGeometryClass::DISABLE_BOUNDING_BOX, false); } - bool Test_Bounding_Box(void) { return (Model->Get_Flag(MeshGeometryClass::DISABLE_BOUNDING_BOX) == 0); } - - void Disable_Bounding_Sphere(void) { Model->Set_Flag(MeshGeometryClass::DISABLE_BOUNDING_SPHERE, true); } - void Enable_Bounding_Sphere(void) { Model->Set_Flag(MeshGeometryClass::DISABLE_BOUNDING_SPHERE, false); } - bool Test_Bounding_Sphere(void) { return (Model->Get_Flag(MeshGeometryClass::DISABLE_BOUNDING_SPHERE) == 0); } - - // this is called by the Reset function - void Set_Dirty( void) { Set_Dirty_Bounds(); Set_Dirty_Planes(); Set_Dirty_Vertex_Normals(); } - - enum { - MAX_COLOR_ARRAYS = MeshMatDescClass::MAX_COLOR_ARRAYS, - MAX_PASSES = MeshMatDescClass::MAX_PASSES - }; - - // USER BE WARNED: This hack is only here because DynamicMeshClass does not expose all of the - // features that DynamicMeshModel provides. It may be dangerous to modify the model behind the - // DynamicMeshClass's back so use at your own risk! - DynamicMeshModel * Peek_Model(void) { return Model; } - -protected: - - inline void Switch_To_Multi_Vertex_Color(int color_array_index = 0); - - // tells when the triangle needs to be back flipped - virtual bool Flip_Face( void) { return (!(TriVertexCount & 1)); } - - // Low-level mesh object - DynamicMeshModel * Model; - - int VertexMaterialIdx[MAX_PASSES]; - bool MultiVertexMaterial[MAX_PASSES]; - int TextureIdx[MAX_PASSES]; - bool MultiTexture[MAX_PASSES]; - - Vector4 CurVertexColor[MAX_COLOR_ARRAYS]; - bool MultiVertexColor[MAX_COLOR_ARRAYS]; - - // number of polygons in the mesh - int PolyCount; - - // number of vertices in the mesh - int VertCount; - - // triangle vertex number - int TriVertexCount; - - // base vertex when submitting fans - int FanVertex; - - // is user currently submitting strips or fans - enum { TRI_MODE_STRIPS = 0, TRI_MODE_FANS = 1 }; - int TriMode; - - // The static sort level - char SortLevel; -}; - -inline Vector3 * DynamicMeshModel::Get_Non_Const_Vertex_Normal_Array(void) -{ - if (Get_Flag(DIRTY_VNORMALS)) { - Compute_Vertex_Normals(); - } - return get_vert_normals(); -} - -inline TriIndex * DynamicMeshModel::Get_Non_Const_Polygon_Array(void) -{ - return get_polys(); -} - -inline void DynamicMeshClass::Get_Obj_Space_Bounding_Sphere(SphereClass & sphere) const -{ - if (!Bounding_Volumes_Valid()) { - Model->Compute_Bounds(NULL); - } - Model->Get_Bounding_Sphere(&sphere); -} - -inline void DynamicMeshClass::Get_Obj_Space_Bounding_Box(AABoxClass & box) const -{ - if (!Bounding_Volumes_Valid()) { - Model->Compute_Bounds(NULL); - } - Model->Get_Bounding_Box(&box); -} - -/* -** -*/ -void DynamicMeshClass::Switch_To_Multi_Vertex_Color(int color_array_index) -{ -/* Vector4 * color_list = Model->Get_Color_Array(color_array_index); - // set the proper color for all the existing vertices - for (int lp = 0; lp < VertCount; lp++) { - color_list[lp].X = CurVertexColor[color_array_index].X; - color_list[lp].Y = CurVertexColor[color_array_index].Y; - color_list[lp].Z = CurVertexColor[color_array_index].Z; - color_list[lp].W = CurVertexColor[color_array_index].W; - } -*/ - unsigned * color_list = Model->Get_Color_Array(color_array_index); - // set the proper color for all the existing vertices - unsigned vertex_color=DX8Wrapper::Convert_Color_Clamp(CurVertexColor[color_array_index]); - for (int lp = 0; lp < VertCount; lp++) { - color_list[lp]=vertex_color; - } - - MultiVertexColor[color_array_index] = true; -} - -/* -** Set the color of all vertices in the mesh for one color_array_index -*/ -int DynamicMeshClass::Set_Vertex_Color(const Vector4 & color, int color_array_index) -{ - // check if switching to multivertexcolor - if (!MultiVertexColor[color_array_index]) { - Switch_To_Multi_Vertex_Color(color_array_index); - } - - CurVertexColor[color_array_index] = color; - return 0; -} - -int DynamicMeshClass::Set_Vertex_Color(const Vector3 & color, int color_array_index) -{ - Set_Vertex_Color(Vector4(color.X,color.Y,color.Z,1),color_array_index); - return 0; -} - - -/* -** Dynamic Screen Meshes -** -** Same as DynamicMesh, but mapped in Screen Coordinates -** -** Screen -> 0,0 1,0 -** +---+ -** | | -** +---+ -** 0,1 1,1 -** -** -** View -> -1,1 1,1 -** +---+ -** | | -** +---+ -** -1,-1 1,-1 -** -** Note: since y is inverted, it switches from right handed to left handed -** (from counter-clockwise to clockwise), so Flip Face accounts for this -*/ -class DynamicScreenMeshClass : public DynamicMeshClass { - -public: - // constructor and destructor - DynamicScreenMeshClass( int max_poly, int max_vert, float aspect = 1.0f ) : DynamicMeshClass( max_poly, max_vert), Aspect( aspect ) {} - DynamicScreenMeshClass( const DynamicScreenMeshClass & src) : DynamicMeshClass(src), Aspect(src.Aspect) {} - virtual ~DynamicScreenMeshClass( void) {} - - // function to clone a dynamic screen mesh class - virtual RenderObjClass * Clone(void) const { return NEW_REF( DynamicScreenMeshClass, (*this)); } - - // class id of this render object - virtual int Class_ID(void) const { return CLASSID_DYNASCREENMESH; } - - // Remap locations to match a screen - virtual void Location( float x, float y, float z = 0.0f); - - // For moving a vertex after the DynaMesh has already been created. - virtual void Move_Vertex(int index, float x, float y, float z = 0.0f); - - // Set position - virtual void Set_Position(const Vector3 &v); - - virtual void Reset( void); - - virtual void Set_Aspect(float aspect) { Aspect=aspect; }; - -protected: - - // Aspect Ratio of the virtual screen. - // 1.0 gives a -1,-1 to 1,1 display - // 3/4 givs a -1,-3/4 to 1,3/4 display - float Aspect; - - // tells when the triangle needs to be back flipped - virtual bool Flip_Face( void) { return !DynamicMeshClass::Flip_Face(); } -}; - -#endif // DYNAMESH \ No newline at end of file diff --git a/Generals/Code/Libraries/Source/WWVegas/WW3D2/font3d.cpp b/Generals/Code/Libraries/Source/WWVegas/WW3D2/font3d.cpp deleted file mode 100644 index 7e66b43bebf..00000000000 --- a/Generals/Code/Libraries/Source/WWVegas/WW3D2/font3d.cpp +++ /dev/null @@ -1,429 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** Confidential - Westwood Studios *** - *********************************************************************************************** - * * - * Project Name : Commando / G 3D Library * - * * - * $Archive:: /Commando/Code/ww3d2/font3d.cpp $* - * * - * $Org Author:: Jani_p $* - * * - * $Author:: Kenny_m $* - * * - * $Modtime:: 08/05/02 10:44a $* - * * - * $Revision:: 17 $* - * * - * 08/05/02 KM Texture class redesign - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#include "font3d.h" -#include "assetmgr.h" -#include "texture.h" -#include -#include -#include "surfaceclass.h" -#include "texture.h" -#include "vector2i.h" - -static SurfaceClass *_surface; - -/*********************************************************************************************** - * * - * Font3DDataClass::Font3DDataClass -- constructor * - * * - * Constructs and load a Targa font image to create a texture matetial * - * * - ***********************************************************************************************/ -Font3DDataClass::Font3DDataClass( const char *filename ) -{ - Texture = NULL; - Load_Font_Image( filename); - Name = strdup( filename); - Name = strupr( Name); -} - - -/*********************************************************************************************** - * * - * Font3DDataClass::~Font3DDataClass -- destructor * - * * - ***********************************************************************************************/ -Font3DDataClass::~Font3DDataClass(void) -{ - if (Name != NULL) { - free(Name); - Name = NULL; - } - - REF_PTR_RELEASE(Texture); -} - - -/*********************************************************************************************** - * * - * FontClass::Minimize_Font_Image * - * * - * Rebuilds the give image to better pack characters and to insure a square power of two size * - * Must be called AFTER Make_Proportional() so each chars minimal bounding box is known * - * Will only create a new texture of size 128x128 or 256x256, dependent on original width * - * * - ***********************************************************************************************/ -SurfaceClass *Font3DDataClass::Minimize_Font_Image( SurfaceClass *surface ) -{ - SurfaceClass::SurfaceDescription sd; - - surface->Get_Description(sd); - - float current_width = sd.Width; - float current_height = sd.Height; - - // determine new width make the size of the new image either 128x128 or 256x256, - // dependent on the width of the original image - int new_width; - if (current_width < 256) { - new_width = 128; - } else { - new_width = 256; - } - - int new_height = new_width; - // create a new 4 bit alpha image to build into - // We dont support non-homogeneous copies just yet - SurfaceClass *new_surface = NEW_REF(SurfaceClass,(new_width, new_height,WW3D_FORMAT_A4R4G4B4)); - //SurfaceClass *new_surface0 = NEW_REF(SurfaceClass,(new_width, new_height,sd.Format)); - - // fill with transparent black - new_surface->Clear(); - - // indices for the location of each added char - int new_x = 0; - int new_y = 0; - - // for each character, copy minimum bounding area to (new_x, new_y) in the new image - for (int char_index = 0; char_index < 256; char_index++) { - - // find the lop left coordinate and the height and width of the char's bounding box - // (must convert the normalized uv tables to pixels and round off) - int src_x = (int)(UOffsetTable[ char_index ] * current_width + 0.5); - int src_y = (int)(VOffsetTable[ char_index ] * current_height + 0.5); - int width = (int)(UWidthTable[ char_index ] * current_width + 0.5); - int height = (int)(VHeight * current_height + 0.5); - - // if the character has any visible pixels at all... - if (width != 0) { - - // if this charactger will not fit on the current line, goto the next line - if (new_x + width > new_width) { - new_x = 0; - new_y += height; - - // if we have run out of lines, we have a problem - // we assert because we have already modified tables for some of the chars - if (new_y + height > new_height) { - new_y -= height; - WWDEBUG_SAY(( "Font doesn't fit texture 2 on char %c\n", char_index )); - } - } - - // blit from original image to new image - - new_surface->Copy(new_x, new_y,src_x,src_y,width,height,surface); - - } - - // update the U and V tables to show new character location - UOffsetTable[ char_index ] = (float)(new_x) / (float)new_width; - VOffsetTable[ char_index ] = (float)(new_y) / (float)new_width; - - // update width in terms of new normal image width - UWidthTable[ char_index ] *= (float)current_width / (float)new_width; - - new_x += width; - } - - // update height in terms of new normal image height - VHeight *= (float)current_height / (float)new_height; - - // be sure the new image is SMALLER than the old image -// assert ( (new_width * new_height) <= (current_width * current_height)); - - // release the old surface and return the new one - REF_PTR_RELEASE(surface); - - _surface = new_surface; - - return _surface; -} - -/*********************************************************************************************** - * * - * FontClass::Make_Proportional * - * * - * Modifys U and Width tables to convert a monospace font into a proportional font. Hieght * - * remains the same. Performed by getting the current mono-space bounding box and bringing * - * in the left and right edges to the first non-transparent ( != 0 ) pixel. Then the U and * - * width tables are updated with the new values. The image itself is not modified unless... * - * * - * we complete by calling Minimize_Font_Image to shink the image & insure a power of 2 square * - * * - ***********************************************************************************************/ -SurfaceClass *Font3DDataClass::Make_Proportional( SurfaceClass *surface ) -{ - SurfaceClass::SurfaceDescription sd; - surface->Get_Description(sd); - float width = sd.Width; - float height = sd.Height; - - // for each character in the font... - for (int char_index = 0; char_index < 256; char_index++) { - - // find the current bounding box - // (must convert the normalized uv tables to pixels and round off) - int x0 = (int)(UOffsetTable[ char_index ] * width + 0.5); - int y0 = (int)(VOffsetTable[ char_index ] * height + 0.5); - int x1 = x0 + (int)(UWidthTable[ char_index ] * width + 0.5); - int y1 = y0 + (int)(VHeight * height + 0.5); - - // find minimum bounding box by finding the minimum and maximum non-0 x pixel location - Vector2i minb(x0,y0); - Vector2i maxb(x1,y1); - - surface->FindBB(&minb,&maxb); - - // set the new edges - x0 = minb.I; - x1 = maxb.I+1; - - // if we didn't find ANY non-transparent pixels, the char has no width. - if (x1 < x0) { - x1 = x0; - } - - // turn off all character after del - if (char_index > 0x80) { - x1 = x0; - } - - // update the U and width tables - UOffsetTable[ char_index ] = (float)x0 / width; - UWidthTable[ char_index ] = (float)( x1 - x0 ) / width; - CharWidthTable[ char_index ] = x1 - x0; - } - - // now shink the image given the minimum char sizes -// surface = Minimize_Font_Image( surface ); - Minimize_Font_Image( _surface ); - return NULL; -} - -/*********************************************************************************************** - * * - * Font3DDataClass::Load_Font_Image( SR_SCENE *scene, char *filename ) * - * * - * Loads a targa font image file, arranged as 16x16 characters, and builds u v tables to * - * find each character. Converts the mono-space font into a proportional font, then uploads * - * the image to the scene as a textur material. * - * * - ***********************************************************************************************/ -bool Font3DDataClass::Load_Font_Image( const char *filename ) -{ - // get the font surface - SurfaceClass *surface = NEW_REF(SurfaceClass,(filename)); - WWASSERT(surface); - - SurfaceClass::SurfaceDescription sd; - surface->Get_Description(sd); - - // If input is a font strike (strip) process it as such - if ( sd.Width > 8 * sd.Height ) { - - // the height of the strike is the height of the characters - VHeight = 1; - CharHeight = sd.Height; - - int column = 0; - int width = sd.Width; - - - // for each char, find the uv start location and set the - // mono-spaced width and height in normalized screen units - for (int char_index = 0; char_index < 256; char_index++) { - - if ( char_index >= 0x7F ) { - - UOffsetTable[ char_index ] = 0; - VOffsetTable[ char_index ] = 0; - UWidthTable[ char_index ] = 0; - CharWidthTable[ char_index ] = 0; - - } else { - - // find the first non-transparent column... - while (( column < width ) && ( surface->Is_Transparent_Column(column) )) column++; - int start = column; - - // find the first transparent column... - while (( column < width ) && ( !surface->Is_Transparent_Column(column) )) column++; - int end = column; - - if ( end <= start ) { - WWDEBUG_SAY(( "Error Char %d start %d end %d width %d\n", char_index, start, end, width )); - } - -// WWASSERT( end > start ); - - UOffsetTable[ char_index ] = (float)start / width; - VOffsetTable[ char_index ] = 0; - UWidthTable[ char_index ] = (float)(end - start) / width; - CharWidthTable[ char_index ] = end - start; - } - - } - - // convert the just created mon-spaced font to proportional (optional) -// surface = Make_Proportional( surface ); - _surface = surface; - surface = NULL; - Minimize_Font_Image( _surface ); - - } else { - - // Determine the width and height of each mono spaced character in pixels - // (assumes 16x16 array of chars) - float font_width = sd.Width; - float font_height = sd.Height; - float mono_pixel_width = (font_width / 16); - float mono_pixel_height = (font_height / 16); - - // for each char, find the uv start location and set the - // mono-spaced width and height in normalized screen units - for (int char_index = 0; char_index < 256; char_index++) { - UOffsetTable[ char_index ] = (float)((char_index % 16) * mono_pixel_width) / font_width; - VOffsetTable[ char_index ] = (float)((char_index / 16) * mono_pixel_height) / font_height; - UWidthTable[ char_index ] = mono_pixel_width / font_width; - CharWidthTable[ char_index ] = mono_pixel_width; - } - VHeight = mono_pixel_height / font_height; - CharHeight = mono_pixel_height; - - // convert the just created mon-spaced font to proportional (optional) - - _surface = surface; - surface = NULL; - Make_Proportional( _surface ); - } - - // create the texture - if ( _surface ) { - Texture = NEW_REF(TextureClass,(_surface,MIP_LEVELS_1)); - REF_PTR_RELEASE(_surface); - } - - // return SUCCESS! - return true; -} - - -/*********************************************************************************************** - * * - * Font3DInstanceClass::Font3DInstanceClass -- constructor * - * * - * Constructs and load a Targa font image to create a texture matetial * - * * - ***********************************************************************************************/ -Font3DInstanceClass::Font3DInstanceClass( const char *filename ) -{ - FontData = WW3DAssetManager::Get_Instance()->Get_Font3DData( filename); - MonoSpacing = 0.0f; - Scale = 1.0f; - SpaceSpacing = (int)(FontData->Char_Width('H') / 2.0f); - InterCharSpacing = 1; - Build_Cached_Tables(); -} - -/*********************************************************************************************** - * * - * Font3DInstanceClass::~Font3DInstanceClass -- destructor * - * * - ***********************************************************************************************/ -Font3DInstanceClass::~Font3DInstanceClass(void) -{ - REF_PTR_RELEASE(FontData); -} - -/* -** -*/ -void Font3DInstanceClass::Set_Mono_Spaced( void ) -{ - MonoSpacing = FontData->Char_Width('W') + 1; - Build_Cached_Tables(); -} - -void Font3DInstanceClass::Build_Cached_Tables() -{ - // Rebuild the cached tables - for (int a=0;a<256;++a) { - float width = (float)FontData->Char_Width(a); - if ( a == ' ' ) { - width = SpaceSpacing; - } - - ScaledWidthTable[a] = Scale * width; - if (MonoSpacing != 0.0f) { - ScaledSpacingTable[a] = Scale * MonoSpacing; - } else { - ScaledSpacingTable[a] = Scale * (width + InterCharSpacing); - } - } - ScaledHeight = floorf(Scale * (float)FontData->Char_Height('A')); -} - -/*********************************************************************************************** - * * - * Font3DInstanceClass::String_Screen_Width( char *test_str ) * - * * - * Finds the normalized screenspace width of a character string - useful for checking before * - * printing to avoid overflowing the screen. * * - ***********************************************************************************************/ -float Font3DInstanceClass::String_Width( const WCHAR *test_str ) -{ - float width = 0.0; - for (; *test_str; test_str++) { - width += Char_Spacing(*test_str); - } - - return width; -} - -float Font3DInstanceClass::String_Width( const char *test_str ) -{ - float width = 0.0; - for (; *test_str; test_str++) { - width += Char_Spacing(*test_str); - } - - return width; -} - diff --git a/Generals/Code/Libraries/Source/WWVegas/WW3D2/font3d.h b/Generals/Code/Libraries/Source/WWVegas/WW3D2/font3d.h deleted file mode 100644 index d1f584dec86..00000000000 --- a/Generals/Code/Libraries/Source/WWVegas/WW3D2/font3d.h +++ /dev/null @@ -1,223 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** Confidential - Westwood Studios *** - *********************************************************************************************** - * * - * Project Name : Commando / G 3D Library * - * * - * $Archive:: /Commando/Code/ww3d2/font3d.h $* - * * - * $Author:: Byon_g $* - * * - * $Modtime:: 4/05/01 2:19p $* - * * - * $Revision:: 4 $* - * * - *---------------------------------------------------------------------------------------------*/ - - -#if defined(_MSC_VER) -#pragma once -#endif - -#ifndef FONT3D_H -#define FONT3D_H - -#include "always.h" -#include "refcount.h" -#include "vector4.h" -#include "widestring.h" -#include "rect.h" - -class TextureClass; -class SurfaceClass; - -/****************************************************************** -** -** Font3DDataClass -** -** This class provides an interface to a font texture. Once -** created and loaded with a font, the object can return texture -** u v coordinate for any character in the font, as well as the -** character width for proportional fonts. Fonts are loaded as -** 16-bit Targa files, then converted to proportional fonts by -** finding the minimum bounding box for each chacter. The font -** texture is then minimized to a 256x256 or 128x128 texture -** material by re-stacking chars by thier minimum bounding box. -** -** During use, this class is really no more than a data table accessor -** Only during creation is any real code run. -** -** Since the space char nevers needs to be drawn, do not use -** the conventional method of acessing and drawing chars (which will -** still work). Instead, call Get_Space_Width to determine the user- -** settable width, and skip the drawing. -** -*******************************************************************/ -class Font3DDataClass : public RefCountClass { - -public: - - /* - ** Constructor, Constructor which loads a targa file, - ** and Destructor - */ - Font3DDataClass( const char *filename ); - ~Font3DDataClass(); - - // the name of the font data (used for name matching and the like.) - char *Name; - - /* - ** access character width and height in pixels (clamp char to 0.255) - */ - - unsigned char Char_Width( WCHAR ch = (WCHAR)'H' ) { return CharWidthTable[ch&0xFF]; }// & 0xFF]; } // No need to "& 0xff" with chars!!! - unsigned char Char_Height( WCHAR /*ch = 'H'*/ ) { return CharHeight; } - - // u and v are in normalized texture space - inline float Char_U_Offset( WCHAR ch = (WCHAR)'H') { return UOffsetTable[ch&0xFF]; }// & 0xFF]; } - inline float Char_V_Offset( WCHAR ch = (WCHAR)'H') { return VOffsetTable[ch&0xFF]; }// & 0xFF]; } - inline float Char_U_Width( WCHAR ch = (WCHAR)'H' ) { return UWidthTable[ch&0xFF]; }// & 0xFF]; } - inline float Char_V_Height( WCHAR /*ch = 'H'*/) { return VHeight; } - - // get all four UV values as one vector4 - Vector4 Char_UV_Corners( WCHAR ch = (WCHAR)'H' ) - { -// ch &= 0xFF; - return Vector4( UOffsetTable[ch], VOffsetTable[ch], - UOffsetTable[ch] + UWidthTable[ch], - VOffsetTable[ch] + VHeight ); - } - - /* - ** access texture material - */ - TextureClass * Peek_Texture( void ) { return Texture; } - -private: - /* - ** The material (texture) which holds the font - */ - TextureClass * Texture; - - /* - ** Normalized texture page offsets for each character - */ - float UOffsetTable[ 256 ]; - float VOffsetTable[ 256 ]; - float UWidthTable[ 256 ]; - float VHeight; - - unsigned char CharWidthTable[ 256 ]; - unsigned char CharHeight; - - /* - ** load a targa font image (.TGA) - */ - bool Load_Font_Image( const char *filename ); - - /* - ** routines to convert a mono-spaced font to a proportional - ** font and minimize texture image size as a result - */ - SurfaceClass *Make_Proportional( SurfaceClass *font_image ); - SurfaceClass *Minimize_Font_Image( SurfaceClass *font_image ); - -}; - -/****************************************************************** -** -** Font3DInstanceClass -** -*******************************************************************/ -class Font3DInstanceClass : public RefCountClass { - -public: - /* - ** Constructor which creates/gets a Font3DDataClass object, - ** and Destructor - */ - Font3DInstanceClass( const char *filename ); - ~Font3DInstanceClass(); - - /* - ** access texture material - */ - TextureClass *Peek_Texture( void ) { return FontData->Peek_Texture(); } - - /* - ** The non-scaled monospace char width in pixels ( set to 0 for proportional spaced font ) - */ - void Set_Mono_Spaced( void ); - void Set_Proportional( void ) { MonoSpacing = 0; Build_Cached_Tables(); } - - - /* - ** Set the font scale (default to 1) - ** This amount will be automatically applied to all Char_Screen_Width calls - */ - void Set_Scale( float scale ) { Scale = scale; Build_Cached_Tables(); } - // float Get_Scale() const { return Scale; } - - /* - ** The scaled character pixel width, height, and spacing data (clamp char to 0.255) - */ - float Char_Width( WCHAR ch ) const { return ScaledWidthTable[ch&0xFF]; } - float Char_Spacing( WCHAR ch ) const { return ScaledSpacingTable[ch&0xFF]; } - float Char_Height( void ) const { return ScaledHeight; } - - - /* - ** The scaled pixel width of a string; useful before printing to avoid screen overflows. - */ - float String_Width( const WCHAR *test_str ); - float String_Width( const char *test_str ); - - /* - ** Char UVs - */ - // u and v are in normalized texture space - // inline float Char_U_Offset( WCHAR ch = (WCHAR)'H') { return FontData->Char_U_Offset( ch & 0xFF ); } - // inline float Char_V_Offset( WCHAR ch = (WCHAR)'H') { return FontData->Char_V_Offset( ch & 0xFF ); } - // inline float Char_U_Width( WCHAR ch = (WCHAR)'H' ) { return FontData->Char_U_Width( ch & 0xFF ); } - // inline float Char_V_Height( WCHAR ch = (WCHAR)'H') { return FontData->Char_V_Height( ch & 0xFF ); } - // Vector4 Char_UV_Corners( WCHAR ch = (WCHAR)'H' ) { return FontData->Char_UV_Corners( ch & 0xFF ); } - RectClass Char_UV( WCHAR ch ) { return RectClass( FontData->Char_U_Offset(ch), - FontData->Char_V_Offset(ch), - FontData->Char_U_Offset(ch) + FontData->Char_U_Width(ch), - FontData->Char_V_Offset(ch) + FontData->Char_V_Height(ch) ); } -private: - - Font3DDataClass * FontData; // The font data - float Scale; // The current scale factor - float SpaceSpacing; // non-scaled width of space in pixels ( defaults to 1/2 'H' width ) - float InterCharSpacing; // non-scaled width between chars in pixels - float MonoSpacing; // non-scaled monospace char width in pixels (0 for proportional) - - float ScaledWidthTable[256]; // scaled cache of the chars pixel widths - float ScaledSpacingTable[256]; // scaled cache of the chars pixel spacing - float ScaledHeight; // scaled cache of the chars pixel height - - void Build_Cached_Tables(); -}; - - -#endif \ No newline at end of file diff --git a/Generals/Code/Libraries/Source/WWVegas/WW3D2/formconv.cpp b/Generals/Code/Libraries/Source/WWVegas/WW3D2/formconv.cpp deleted file mode 100644 index 9c20e6b3e21..00000000000 --- a/Generals/Code/Libraries/Source/WWVegas/WW3D2/formconv.cpp +++ /dev/null @@ -1,252 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** 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 *** - *********************************************************************************************** - * * - * Project Name : WW3D * - * * - * $Archive:: /Commando/Code/ww3d2/formconv.cpp $* - * * - * Original Author:: Nathaniel Hoffman * - * * - * Author : Kenny Mitchell * - * * - * $Modtime:: 06/27/02 1:27p $* - * * - * $Revision:: 3 $* - * * - * 06/27/02 KM Z Format support * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#include "formconv.h" - -D3DFORMAT WW3DFormatToD3DFormatConversionArray[WW3D_FORMAT_COUNT] = { - D3DFMT_UNKNOWN, - D3DFMT_R8G8B8, - D3DFMT_A8R8G8B8, - D3DFMT_X8R8G8B8, - D3DFMT_R5G6B5, - D3DFMT_X1R5G5B5, - D3DFMT_A1R5G5B5, - D3DFMT_A4R4G4B4, - D3DFMT_R3G3B2, - D3DFMT_A8, - D3DFMT_A8R3G3B2, - D3DFMT_X4R4G4B4, - D3DFMT_A8P8, - D3DFMT_P8, - D3DFMT_L8, - D3DFMT_A8L8, - D3DFMT_A4L4, - D3DFMT_V8U8, // Bumpmap - D3DFMT_L6V5U5, // Bumpmap - D3DFMT_X8L8V8U8, // Bumpmap - D3DFMT_DXT1, - D3DFMT_DXT2, - D3DFMT_DXT3, - D3DFMT_DXT4, - D3DFMT_DXT5 -}; - -// adding depth stencil format conversion -D3DFORMAT WW3DZFormatToD3DFormatConversionArray[WW3D_ZFORMAT_COUNT] = -{ -#ifndef _XBOX - D3DFMT_UNKNOWN, - D3DFMT_D16_LOCKABLE, // 16-bit z-buffer bit depth. This is an application-lockable surface format. - D3DFMT_D32, // 32-bit z-buffer bit depth. - D3DFMT_D15S1, // 16-bit z-buffer bit depth where 15 bits are reserved for the depth channel and 1 bit is reserved for the stencil channel. - D3DFMT_D24S8, // 32-bit z-buffer bit depth using 24 bits for the depth channel and 8 bits for the stencil channel. - D3DFMT_D16, // 16-bit z-buffer bit depth. - D3DFMT_D24X8, // 32-bit z-buffer bit depth using 24 bits for the depth channel. - D3DFMT_D24X4S4, // 32-bit z-buffer bit depth using 24 bits for the depth channel and 4 bits for the stencil channel. -#else - D3DFMT_UNKNOWN, - D3DFMT_D16_LOCKABLE, // 16-bit z-buffer bit depth. This is an application-lockable surface format. - D3DFMT_D32, // 32-bit z-buffer bit depth. - D3DFMT_D15S1, // 16-bit z-buffer bit depth where 15 bits are reserved for the depth channel and 1 bit is reserved for the stencil channel. - D3DFMT_D24S8, // 32-bit z-buffer bit depth using 24 bits for the depth channel and 8 bits for the stencil channel. - D3DFMT_D16, // 16-bit z-buffer bit depth. - D3DFMT_D24X8, // 32-bit z-buffer bit depth using 24 bits for the depth channel. - D3DFMT_D24X4S4, // 32-bit z-buffer bit depth using 24 bits for the depth channel and 4 bits for the stencil channel. - - D3DFMT_LIN_D24S8, - D3DFMT_LIN_F24S8, - D3DFMT_LIN_D16, - D3DFMT_LIN_F16 -#endif -}; - - -/* -#define HIGHEST_SUPPORTED_D3DFORMAT D3DFMT_X8L8V8U8 //A4L4 -WW3DFormat D3DFormatToWW3DFormatConversionArray[HIGHEST_SUPPORTED_D3DFORMAT + 1] = { - WW3D_FORMAT_UNKNOWN, // 0 - WW3D_FORMAT_UNKNOWN, WW3D_FORMAT_UNKNOWN, WW3D_FORMAT_UNKNOWN, WW3D_FORMAT_UNKNOWN, - WW3D_FORMAT_UNKNOWN, WW3D_FORMAT_UNKNOWN, WW3D_FORMAT_UNKNOWN, WW3D_FORMAT_UNKNOWN, - WW3D_FORMAT_UNKNOWN, WW3D_FORMAT_UNKNOWN, WW3D_FORMAT_UNKNOWN, WW3D_FORMAT_UNKNOWN, - WW3D_FORMAT_UNKNOWN, WW3D_FORMAT_UNKNOWN, WW3D_FORMAT_UNKNOWN, WW3D_FORMAT_UNKNOWN, - WW3D_FORMAT_UNKNOWN, WW3D_FORMAT_UNKNOWN, WW3D_FORMAT_UNKNOWN, - WW3D_FORMAT_R8G8B8, // 20 - WW3D_FORMAT_A8R8G8B8, - WW3D_FORMAT_X8R8G8B8, - WW3D_FORMAT_R5G6B5, - WW3D_FORMAT_X1R5G5B5, - WW3D_FORMAT_A1R5G5B5, - WW3D_FORMAT_A4R4G4B4, - WW3D_FORMAT_R3G3B2, - WW3D_FORMAT_A8, - WW3D_FORMAT_A8R3G3B2, - WW3D_FORMAT_X4R4G4B4, // 30 - WW3D_FORMAT_UNKNOWN, WW3D_FORMAT_UNKNOWN, WW3D_FORMAT_UNKNOWN, WW3D_FORMAT_UNKNOWN, - WW3D_FORMAT_UNKNOWN, WW3D_FORMAT_UNKNOWN, WW3D_FORMAT_UNKNOWN, WW3D_FORMAT_UNKNOWN, - WW3D_FORMAT_UNKNOWN, - WW3D_FORMAT_A8P8, // 40 - WW3D_FORMAT_P8, - WW3D_FORMAT_UNKNOWN, WW3D_FORMAT_UNKNOWN, WW3D_FORMAT_UNKNOWN, WW3D_FORMAT_UNKNOWN, - WW3D_FORMAT_UNKNOWN, WW3D_FORMAT_UNKNOWN, WW3D_FORMAT_UNKNOWN, WW3D_FORMAT_UNKNOWN, - WW3D_FORMAT_L8, // 50 - WW3D_FORMAT_A8L8, - WW3D_FORMAT_A4L4 -}; -*/ - -#ifndef _XBOX -#define HIGHEST_SUPPORTED_D3DFORMAT D3DFMT_X8L8V8U8 -#define HIGHEST_SUPPORTED_D3DZFORMAT D3DFMT_D16 -#else -#define HIGHEST_SUPPORTED_D3DFORMAT D3DFMT_LIN_R8G8B8A8 -#define HIGHEST_SUPPORTED_D3DZFORMAT D3DFMT_LIN_F16 -#endif -WW3DFormat D3DFormatToWW3DFormatConversionArray[HIGHEST_SUPPORTED_D3DFORMAT + 1]; -WW3DZFormat D3DFormatToWW3DZFormatConversionArray[HIGHEST_SUPPORTED_D3DZFORMAT + 1]; - -D3DFORMAT WW3DFormat_To_D3DFormat(WW3DFormat ww3d_format) { - if (ww3d_format >= WW3D_FORMAT_COUNT) { - return D3DFMT_UNKNOWN; - } else { - return WW3DFormatToD3DFormatConversionArray[(unsigned int)ww3d_format]; - } -} - -WW3DFormat D3DFormat_To_WW3DFormat(D3DFORMAT d3d_format) -{ - switch (d3d_format) { - // The DXT-codes are created with FOURCC macro and thus can't be placed in the conversion table - case D3DFMT_DXT1: return WW3D_FORMAT_DXT1; - case D3DFMT_DXT2: return WW3D_FORMAT_DXT2; - case D3DFMT_DXT3: return WW3D_FORMAT_DXT3; - case D3DFMT_DXT4: return WW3D_FORMAT_DXT4; - case D3DFMT_DXT5: return WW3D_FORMAT_DXT5; - default: - if (d3d_format > HIGHEST_SUPPORTED_D3DFORMAT) { - return WW3D_FORMAT_UNKNOWN; - } else { - return D3DFormatToWW3DFormatConversionArray[(unsigned int)d3d_format]; - } - break; - } -} - -//********************************************************************************************** -//! Depth Stencil W3D to D3D format conversion -/*! KJM -*/ -D3DFORMAT WW3DZFormat_To_D3DFormat(WW3DZFormat ww3d_zformat) -{ - if (ww3d_zformat >= WW3D_ZFORMAT_COUNT) - { - return D3DFMT_UNKNOWN; - } - else - { - return WW3DZFormatToD3DFormatConversionArray[(unsigned int)ww3d_zformat]; - } -} - -//********************************************************************************************** -//! D3D to Depth Stencil W3D format conversion -/*! KJM -*/ -WW3DZFormat D3DFormat_To_WW3DZFormat(D3DFORMAT d3d_format) -{ - if (d3d_format>HIGHEST_SUPPORTED_D3DZFORMAT) - { - return WW3D_ZFORMAT_UNKNOWN; - } - else - { - return D3DFormatToWW3DZFormatConversionArray[(unsigned int)d3d_format]; - } -} - -//********************************************************************************************** -//! Init format conversion tables -/*! - * 06/27/02 KM Z Format support * -*/ -void Init_D3D_To_WW3_Conversion() -{ - int i=0; - for (;i. -*/ - -/*********************************************************************************************** - *** 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 *** - *********************************************************************************************** - * * - * Project Name : WW3D * - * * - * $Archive:: /Commando/Code/ww3d2/formconv.h $* - * * - * Original Author:: Nathaniel Hoffman * - * * - * Author : Kenny Mitchell * - * * - * $Modtime:: 06/27/02 1:27p $* - * * - * $Revision:: 3 $* - * * - * 06/27/02 KM Z Format support * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#if defined(_MSC_VER) -#pragma once -#endif - -#ifndef FORMCONV_H -#define FORMCONV_H - -#include "ww3dformat.h" -#include - -/* -** This file is used for conversions between D3DFORMAT and WW3DFormat. -*/ - -D3DFORMAT WW3DFormat_To_D3DFormat(WW3DFormat ww3d_format); -WW3DFormat D3DFormat_To_WW3DFormat(D3DFORMAT d3d_format); - -D3DFORMAT WW3DZFormat_To_D3DFormat(WW3DZFormat ww3d_zformat); -WW3DZFormat D3DFormat_To_WW3DZFormat(D3DFORMAT d3d_format); - -void Init_D3D_To_WW3_Conversion(); - -#endif \ No newline at end of file diff --git a/Generals/Code/Libraries/Source/WWVegas/WW3D2/framgrab.h b/Generals/Code/Libraries/Source/WWVegas/WW3D2/framgrab.h deleted file mode 100644 index 67a2a447391..00000000000 --- a/Generals/Code/Libraries/Source/WWVegas/WW3D2/framgrab.h +++ /dev/null @@ -1,117 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** 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 *** - *********************************************************************************************** - * * - * Project Name : WW3D * - * * - * $Archive:: /Commando/Code/ww3d2/framgrab.h $* - * * - * Author:: Greg Hjelstrom * - * * - * $Modtime:: 1/08/01 10:04a $* - * * - * $Revision:: 1 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - - -#if defined(_MSC_VER) -#pragma once -#endif - -#ifndef FRAMEGRAB_H -#define FRAMEGRAB_H - -#ifndef ALWAYS_H -#include "always.h" -#endif - -#if defined (_MSC_VER) -#pragma warning (push, 3) // (gth) system headers complain at warning level 4... -#endif - -#ifndef _WINDOWS_ -#include "windows.h" -#endif - -#ifndef _INC_WINDOWSX -#include "windowsx.h" -#endif - -#ifndef _INC_VFW -#include "vfw.h" -#endif - -#if defined (_MSC_VER) -#pragma warning (pop) -#endif - -// FramGrab.h: interface for the FrameGrabClass class. -// -////////////////////////////////////////////////////////////////////// - -class FrameGrabClass -{ -public: - enum MODE { - RAW, - AVI - }; - - // depending on which mode you select, it will produce either frames or an AVI. - FrameGrabClass(const char *filename, MODE mode, int width, int height, int bitdepth, float framerate ); - - virtual ~FrameGrabClass(); - - void ConvertGrab(void *BitmapPointer); - void Grab(void *BitmapPointer); - - long * GetBuffer() { return Bitmap; } - float GetFrameRate() { return FrameRate; } - -protected: - const char *Filename; - float FrameRate; - - MODE Mode; - long Counter; // used for incrementing filename cunter, etc. - - void GrabAVI(void *BitmapPointer); - void GrabRawFrame(void *BitmapPointer); - - // avi settings - PAVIFILE AVIFile; - long *Bitmap; - PAVISTREAM Stream; - AVISTREAMINFO AVIStreamInfo; - BITMAPINFOHEADER BitmapInfoHeader; - - // general purpose cleanup routine - void CleanupAVI(); - - // convert the SR image into AVI byte ordering - void ConvertFrame(void *BitmapPointer); - -}; - -#endif diff --git a/Generals/Code/Libraries/Source/WWVegas/WW3D2/hanim.cpp b/Generals/Code/Libraries/Source/WWVegas/WW3D2/hanim.cpp deleted file mode 100644 index c8bf589d3da..00000000000 --- a/Generals/Code/Libraries/Source/WWVegas/WW3D2/hanim.cpp +++ /dev/null @@ -1,468 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/* $Header: /Commando/Code/ww3d2/hanim.cpp 3 12/13/01 7:01p Patrick $ */ -/*********************************************************************************************** - *** Confidential - Westwood Studios *** - *********************************************************************************************** - * * - * Project Name : Commando / G 3D Library * - * * - * $Archive:: /Commando/Code/ww3d2/hanim.cpp $* - * * - * Author:: Greg_h * - * * - * $Modtime:: 12/13/01 6:54p $* - * * - * $Revision:: 3 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - - -#include "hanim.h" -#include "assetmgr.h" -#include "htree.h" -#include "motchan.h" -#include "chunkio.h" -#include "w3d_file.h" -#include "wwdebug.h" -#include -#include - - - -/* -** -** HAnimComboClass -** -** -*/ - - -NamedPivotMapClass::~NamedPivotMapClass(void) -{ -} - -NamedPivotMapClass::WeightInfoStruct & NamedPivotMapClass::WeightInfoStruct::operator = (WeightInfoStruct const &that) -{ - if(Name) delete [] Name; - assert(that.Name != 0); - Name = nstrdup(that.Name); - Weight = that.Weight; - return *this; -} - -// add a name & weight to the arrays -void NamedPivotMapClass::Add(const char *Name, float Weight) -{ - WeightInfoStruct info; - info.Name = (char *) Name; - info.Weight = Weight; - WeightInfo.Add(info); - info.Name = 0; -} - -// configure the base pivot map using the specified tree -void NamedPivotMapClass::Update_Pivot_Map(const HTreeClass *Tree) -{ - // first, resize the base pivot map to fit the tree - int numPivots = Tree->Num_Pivots(); - - Resize(numPivots); - ActiveCount = numPivots; - - // first, reset all weights to 1 (the default) - while(numPivots--) { - (*this)[numPivots] = 1.0f; - } - - // for each named pivot, find the correct index and set the weight if the indicated bone is present - // note: there is no check for redundant names - int count = WeightInfo.Count(); - while(count--) { - int actualPivot = Tree->Get_Bone_Index(WeightInfo[count].Name); - if(actualPivot != -1) { - (*this)[actualPivot] = WeightInfo[count].Weight; - } - } -} - -/* -** -*/ -DEFINE_AUTO_POOL(HAnimComboDataClass,256); - -HAnimComboDataClass::HAnimComboDataClass(bool shared) -: Shared(shared), HAnim(0), PivotMap(0), Frame(0), PrevFrame(0), Weight(1) -{} - - -HAnimComboDataClass::HAnimComboDataClass(const HAnimComboDataClass &src) -: PivotMap(src.Get_Pivot_Map()), - HAnim(src.Get_HAnim()) -{ - Shared = src.Is_Shared(); - Frame = src.Get_Frame(); - PrevFrame = src.Get_Prev_Frame(); - Weight = src.Get_Weight(); -} - -void HAnimComboDataClass::Copy(const HAnimComboDataClass *src) -{ - if(src) { - HAnim = src->Get_HAnim(); - PivotMap = src->Get_Pivot_Map(); - Frame = src->Get_Frame(); - PrevFrame = src->Get_Prev_Frame(); - Weight = src->Get_Weight(); - } else { - HAnim = 0; - PivotMap = 0; - Frame = 0; - PrevFrame = 0; - Weight = 1; - } -} - -HAnimComboDataClass::~HAnimComboDataClass(void) -{ - if(HAnim) - HAnim->Release_Ref(); - if(PivotMap) - PivotMap->Release_Ref(); -} - -void HAnimComboDataClass::Clear(void) -{ - if ( HAnim != NULL ) { - HAnim->Release_Ref(); - HAnim = NULL; - } - - // not sure if the pivot map should be deleted or just have everything set to one. - // removing it effectively sets it to one, so that's what I'm doing for now. - if(PivotMap) { - PivotMap->Release_Ref(); - PivotMap = NULL; - } - - Frame = 0.0f; - PrevFrame = 0.0f; - Weight = 1.0; - PivotMap = NULL; -} - -void HAnimComboDataClass::Set_HAnim(HAnimClass *motion) -{ - if ( motion != NULL ) { - motion->Add_Ref(); - } - if ( HAnim != NULL ) { - HAnim->Release_Ref(); - } - HAnim = motion; -} - - -void HAnimComboDataClass::Set_Pivot_Map(PivotMapClass *map) -{ - if ( map != NULL ) { - map->Add_Ref(); - } - if ( PivotMap != NULL ) { - PivotMap->Release_Ref(); - } - PivotMap = map; -} - -/* -** This function will replace the current pivot map (if any) with another pivot map that is -** set to 1 for only those pivot indices that actually have data. -*/ -void HAnimComboDataClass::Build_Active_Pivot_Map(void) -{ - if ( PivotMap != NULL ) { - PivotMap->Release_Ref(); - } - if(HAnim == NULL) { - PivotMap = 0; - return; - } - - int numpivots = HAnim->Get_Num_Pivots(); - PivotMap = NEW_REF( PivotMapClass, ()); - PivotMap->Resize(numpivots); - - int count = 0; - while(count < numpivots) { - if(HAnim->Is_Node_Motion_Present(count)) { - PivotMap->Add(1); - - } else { - PivotMap->Add(0); - } - count++; - } -} - -/* -** HAnimComboClass -** -** -*/ - -HAnimComboClass::HAnimComboClass(void) -{} - -HAnimComboClass::HAnimComboClass( int num_animations ) -{ - HAnimComboData.Resize(num_animations); - - while(num_animations--) { - HAnimComboData.Add(new HAnimComboDataClass()); - } -} - - -HAnimComboClass::~HAnimComboClass(void) -{ - Reset(); -} - - -void HAnimComboClass::Clear( void ) -{ - int numAnimations = HAnimComboData.Count(); - while ( numAnimations-- ) { - HAnimComboDataClass *data = HAnimComboData[numAnimations]; - if(data && (! data->Is_Shared())) - data->Clear(); - } -} - -void HAnimComboClass::Reset( void ) -{ - int numAnimations = HAnimComboData.Count(); - while ( numAnimations-- ) { - HAnimComboDataClass *data = HAnimComboData[numAnimations]; - if(data && (! data->Is_Shared())) { - delete data; - } - } - HAnimComboData.Reset_Active(); -} - -bool HAnimComboClass::Normalize_Weights(void) -{ - // NOTE: This can only work if either no anims have pivot weight maps (in which case we will - // adjust the anim weights to ensure normalization), or else if all do (in which case we will - // adjust the pivot maps). Otherwise we do nothing and return false. - int anim_count = Get_Num_Anims(); - if (!anim_count) return true; // Trivially succeeded - - // Loop over all anims. Check if all or none have pivot maps, and also calculate the minimum - // number of pivots. - int anim_idx = 0; - bool all_pivot_maps = true; - bool none_pivot_maps = true; - int num_anim_pivots = 100000; - for (anim_idx = 0; anim_idx < anim_count; anim_idx++ ) { - num_anim_pivots = MIN(num_anim_pivots, Peek_Motion(anim_idx)->Get_Num_Pivots()); - bool has_pivot_map = Peek_Pivot_Weight_Map(anim_idx) != NULL; - all_pivot_maps &= has_pivot_map; - none_pivot_maps &= !has_pivot_map; - } - if ( num_anim_pivots == 100000 ) { - num_anim_pivots = 0; - } - - if (none_pivot_maps) { - - // Calculate total weight of all active anims, ensure it is very close to 1. - float weight_total = 0.0f; - for (anim_idx = 0; anim_idx < anim_count; anim_idx++ ) { - if (Peek_Motion(anim_idx) != NULL ) { - float weight = Get_Weight(anim_idx); - weight_total += weight; - } - } - - // weight_total should be very close to 1. If not, normalize this pivot's weights - if (weight_total != 0.0 && WWMath::Fabs( weight_total - 1.0 ) > WWMATH_EPSILON) { - float oo_total = 1.0f / weight_total; - for (anim_idx = 0; anim_idx < anim_count; anim_idx++ ) { - if (Peek_Motion(anim_idx) != NULL ) { - Set_Weight(anim_idx, Get_Weight(anim_idx) * oo_total); - } - } - } - - } else { - - if (all_pivot_maps) { - - // For each pivot, calculate total weight of all active anims, ensure close to 1. - for (int piv_idx = 1; piv_idx < num_anim_pivots; piv_idx++) { - - float weight_total = 0.0f; - for (anim_idx = 0; anim_idx < anim_count; anim_idx++ ) { - if (Peek_Motion(anim_idx) != NULL ) { - float weight = Get_Weight(anim_idx) * (*Peek_Pivot_Weight_Map(anim_idx))[piv_idx]; - weight_total += weight; - } - } - - // weight_total should be very close to 1. If not, normalize this pivot's weights - if (weight_total != 0.0 && WWMath::Fabs( weight_total - 1.0 ) > WWMATH_EPSILON) { - float oo_total = 1.0f / weight_total; - for (anim_idx = 0; anim_idx < anim_count; anim_idx++ ) { - if (Peek_Motion(anim_idx) != NULL ) { - PivotMapClass *pivot_map = Get_Pivot_Weight_Map(anim_idx); - float new_weight = (*pivot_map)[piv_idx] * oo_total; - (*pivot_map)[piv_idx] = new_weight; - pivot_map->Release_Ref(); - } - } - } - - } - - } else { - return false; - } - } - - return true; - -} - -void HAnimComboClass::Set_Motion( int index, HAnimClass *motion ) -{ - HAnimComboDataClass *data = HAnimComboData[index]; - WWASSERT(data); - - data->Set_HAnim(motion); -} - -HAnimClass *HAnimComboClass::Get_Motion( int index ) -{ - HAnimComboDataClass *data = HAnimComboData[index]; - WWASSERT(data); - - HAnimClass *anim = data->Peek_HAnim(); - - if ( anim != NULL ) { - anim->Add_Ref(); - } - return anim; -} - -HAnimClass *HAnimComboClass::Peek_Motion( int index ) -{ - HAnimComboDataClass *data = HAnimComboData[index]; - WWASSERT(data); - - HAnimClass *anim = data->Peek_HAnim(); - return anim; -} - -void HAnimComboClass::Set_Frame( int index, float frame ) -{ - HAnimComboDataClass *data = HAnimComboData[index]; - WWASSERT(data); - - data->Set_Frame(frame); -} - -float HAnimComboClass::Get_Frame( int index ) -{ - HAnimComboDataClass *data = HAnimComboData[index]; - WWASSERT(data); - - return data->Get_Frame(); -} - -void HAnimComboClass::Set_Prev_Frame( int index, float frame ) -{ - HAnimComboDataClass *data = HAnimComboData[index]; - WWASSERT(data); - - data->Set_Prev_Frame(frame); -} - -float HAnimComboClass::Get_Prev_Frame( int index ) -{ - HAnimComboDataClass *data = HAnimComboData[index]; - WWASSERT(data); - - return data->Get_Prev_Frame(); -} - -void HAnimComboClass::Set_Weight( int index, float weight ) -{ - HAnimComboDataClass *data = HAnimComboData[index]; - WWASSERT(data); - - data->Set_Weight(weight); -} - -float HAnimComboClass::Get_Weight( int index ) -{ - HAnimComboDataClass *data = HAnimComboData[index]; - WWASSERT(data); - - return data->Get_Weight(); -} - -void HAnimComboClass::Set_Pivot_Weight_Map( int index, PivotMapClass *map ) -{ - HAnimComboDataClass *data = HAnimComboData[index]; - WWASSERT(data); - - data->Set_Pivot_Map(map); -} - -PivotMapClass *HAnimComboClass::Get_Pivot_Weight_Map( int index ) -{ - HAnimComboDataClass *data = HAnimComboData[index]; - WWASSERT(data); - - return data->Get_Pivot_Map(); -} - -PivotMapClass *HAnimComboClass::Peek_Pivot_Weight_Map( int index ) -{ - HAnimComboDataClass *data = HAnimComboData[index]; - WWASSERT(data); - - return data->Peek_Pivot_Map(); -} - -void HAnimComboClass::Append_Anim_Combo_Data(HAnimComboDataClass * Data) -{ - HAnimComboData.Add(Data); -} - -void HAnimComboClass::Remove_Anim_Combo_Data(HAnimComboDataClass * Data) -{ - HAnimComboData.Delete(Data); -} - - diff --git a/Generals/Code/Libraries/Source/WWVegas/WW3D2/hanim.h b/Generals/Code/Libraries/Source/WWVegas/WW3D2/hanim.h deleted file mode 100644 index c57f57056c6..00000000000 --- a/Generals/Code/Libraries/Source/WWVegas/WW3D2/hanim.h +++ /dev/null @@ -1,273 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/* $Header: /Commando/Code/ww3d2/hanim.h 3 12/13/01 7:01p Patrick $ */ -/*********************************************************************************************** - *** Confidential - Westwood Studios *** - *********************************************************************************************** - * * - * Project Name : Commando / G 3D Library * - * * - * $Archive:: /Commando/Code/ww3d2/hanim.h $* - * * - * Author:: Greg_h * - * * - * $Modtime:: 12/13/01 6:54p $* - * * - * $Revision:: 3 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - - -#if defined(_MSC_VER) -#pragma once -#endif - -#ifndef HANIM_H -#define HANIM_H - -#include "always.h" -#include "quat.h" -#include "refcount.h" -#include "w3d_file.h" -#include "hash.h" -#include "mempool.h" -#include -#include -#include - -struct NodeMotionStruct; -class MotionChannelClass; -class BitChannelClass; -class HTreeClass; -class ChunkLoadClass; -class ChunkSaveClass; -class HTreeClass; - - - -#define EMBEDDED_SOUND_BONE_INDEX_NOT_SET -1 -/********************************************************************************** - - HAnimClass - - This is the base class for all animation formats used in W3D. It - contains the virtual interface that all animations must support. - -**********************************************************************************/ -class HAnimClass : public RefCountClass, public HashableClass -{ -public: - enum - { - CLASSID_UNKNOWNANIM = 0xFFFFFFFF, - CLASSID_HRAWANIM = 0, - CLASSID_LASTANIM = 0x0000FFFF - }; - - HAnimClass(void) : - EmbeddedSoundBoneIndex (EMBEDDED_SOUND_BONE_INDEX_NOT_SET) { } - virtual ~HAnimClass(void) { } - - virtual const char * Get_Name(void) const = 0; - virtual const char * Get_HName(void) const = 0; - - virtual const char * Get_Key( void ) { return Get_Name(); } - - virtual int Get_Num_Frames(void) = 0; - virtual float Get_Frame_Rate() = 0; - virtual float Get_Total_Time() = 0; - -// virtual Vector3 Get_Translation(int pividx,float frame) = 0; -// virtual Quaternion Get_Orientation(int pividx,float frame) = 0; - // Jani: Changed to pass in reference of destination to avoid copying - virtual void Get_Translation(int pividx,float frame) {} // todo: remove - virtual void Get_Orientation(int pividx,float frame) {} // todo: remove - virtual void Get_Translation(Vector3& translation, int pividx,float frame) const = 0; - virtual void Get_Orientation(Quaternion& orientation, int pividx,float frame) const = 0; - virtual void Get_Transform(Matrix3D&, int pividx, float frame) const = 0; - virtual bool Get_Visibility(int pividx,float frame) = 0; - - virtual int Get_Num_Pivots(void) const = 0; - virtual bool Is_Node_Motion_Present(int pividx) = 0; - - // Methods that test the presence of a certain motion channel. - virtual bool Has_X_Translation (int pividx) { return true; } - virtual bool Has_Y_Translation (int pividx) { return true; } - virtual bool Has_Z_Translation (int pividx) { return true; } - virtual bool Has_Rotation (int pividx) { return true; } - virtual bool Has_Visibility (int pividx) { return true; } - virtual int Class_ID(void) const { return CLASSID_UNKNOWNANIM; } - - // Animated sound-triggering support - virtual bool Has_Embedded_Sounds (void) const { if (EmbeddedSoundBoneIndex < 0) return false; return true;} - virtual void Set_Embedded_Sound_Bone_Index (int bone) { EmbeddedSoundBoneIndex = bone; } - virtual int Get_Embedded_Sound_Bone_Index() {return EmbeddedSoundBoneIndex;} - -protected: - int EmbeddedSoundBoneIndex; -}; - - -/* -** The PivotMapClass is used by the HAnimComboDataClass (sometimes) to keep track of animation -** weights per-pivot point. -*/ -class NamedPivotMapClass; - -class PivotMapClass : public DynamicVectorClass, public RefCountClass -{ -public: - virtual NamedPivotMapClass * As_Named_Pivot_Map() { return 0; } -}; - - -/* -** The NamedPivotMapClass allows us to create HAnimComboDataClass objects with pivot maps without -** having to have the HAnim available. Later, when an HAnim is retrieved from the asset manager, -** the pivot map can be updated to produce the correct map. -*/ -class NamedPivotMapClass : public PivotMapClass -{ -public: - ~NamedPivotMapClass(void); - - virtual NamedPivotMapClass * As_Named_Pivot_Map() { return this; } - - // add a name & weight to the arrays - void Add(const char *Name, float Weight); - - // configure the base pivot map using the specified tree - void Update_Pivot_Map(const HTreeClass *Tree); - -private: - - // This info is packaged into a struct to minimize DynamicVectorClass overhead - struct WeightInfoStruct { - WeightInfoStruct() : Name(0) {} - ~WeightInfoStruct() { if(Name) delete [] Name; } - - char *Name; - float Weight; - - // operators required for the DynamicVectorClass - WeightInfoStruct & operator = (WeightInfoStruct const &that); - bool operator == (WeightInfoStruct const &that) const { return &that == this; } - bool operator != (WeightInfoStruct const &that) const { return &that != this; } - }; - - DynamicVectorClass WeightInfo; -}; - - -/* -** The HAnimComboDataClass is used by the new HAnimComboClass to allow for a mix of shared/unshared data -** which will allow us to have the anim combo refer to data whereever we wish to put it. -*/ -class HAnimComboDataClass : public AutoPoolClass { - public: - HAnimComboDataClass(bool shared = false); - HAnimComboDataClass(const HAnimComboDataClass &); - ~HAnimComboDataClass(void); - - void Copy(const HAnimComboDataClass *); - - void Clear(void); - void Set_HAnim(HAnimClass *motion); - void Give_HAnim(HAnimClass *motion) { if(HAnim) HAnim->Release_Ref(); HAnim = motion; } // used for giving this object the reference - - void Set_Frame(float frame) { PrevFrame = Frame; Frame = frame; } - void Set_Prev_Frame(float frame) { PrevFrame = frame; } - void Set_Weight(float weight) { Weight = weight; } - void Set_Pivot_Map(PivotMapClass *map); - - - HAnimClass * Peek_HAnim(void) const { return HAnim; } // note: does not add reference - HAnimClass * Get_HAnim(void) const { if(HAnim) HAnim->Add_Ref(); return HAnim; } // note: does not add reference - float Get_Frame(void) const { return Frame; } - float Get_Prev_Frame(void) const { return PrevFrame; } - float Get_Weight(void) const { return Weight; } - PivotMapClass * Peek_Pivot_Map(void) const { return PivotMap; } - PivotMapClass * Get_Pivot_Map(void) const { if(PivotMap) PivotMap->Add_Ref(); return PivotMap; } - bool Is_Shared(void) const { return Shared; } - - void Build_Active_Pivot_Map(void); - - private: - - HAnimClass *HAnim; - float Frame; - float PrevFrame; - float Weight; - PivotMapClass * PivotMap; - bool Shared; // this is set to false when the HAnimCombo allocates it -}; - -/* -** defines a combination of animations for blending/mixing -*/ -class HAnimComboClass { - -public: - - HAnimComboClass(void); - HAnimComboClass( int num_animations ); // allocates specified number of channels and sets then all to not-shared - ~HAnimComboClass(void); - - void Clear( void ); // zeros all data - - void Reset( void ); // empties the dynamic vector - - bool Normalize_Weights(void); // Normalizes all weights (returns true if succeeded) - int Get_Num_Anims( void ) { return HAnimComboData.Count(); } - - void Set_Motion( int indx, HAnimClass *motion ); - HAnimClass *Get_Motion( int indx ); - HAnimClass *Peek_Motion( int indx ); - - void Set_Frame( int indx, float frame ); - void Set_Prev_Frame( int indx, float frame ); - float Get_Frame( int indx ); - float Get_Prev_Frame( int indx ); - - void Set_Weight( int indx, float weight ); - float Get_Weight( int indx ); - - void Set_Pivot_Weight_Map( int indx, PivotMapClass * map ); - PivotMapClass * Get_Pivot_Weight_Map( int indx ); - PivotMapClass * Peek_Pivot_Weight_Map( int indx ); - - - // add an entry to the dynamic vector - void Append_Anim_Combo_Data(HAnimComboDataClass * AnimComboData); - - // remove an entry from the vector - void Remove_Anim_Combo_Data(HAnimComboDataClass * AnimComboData); - - // retrieve a specific combo data - HAnimComboDataClass * Peek_Anim_Combo_Data(int index) { return HAnimComboData[index]; } - -protected: - - DynamicVectorClass HAnimComboData; - -}; - -#endif diff --git a/Generals/Code/Libraries/Source/WWVegas/WW3D2/hcanim.cpp b/Generals/Code/Libraries/Source/WWVegas/WW3D2/hcanim.cpp deleted file mode 100644 index 04dfb8ba2cb..00000000000 --- a/Generals/Code/Libraries/Source/WWVegas/WW3D2/hcanim.cpp +++ /dev/null @@ -1,710 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/* $Header: /Commando/Code/ww3d2/hcanim.cpp 3 6/29/01 6:41p Jani_p $ */ -/*********************************************************************************************** - *** Confidential - Westwood Studios *** - *********************************************************************************************** - * * - * Project Name : Commando / G 3D Library * - * * - * $Archive:: /Commando/Code/ww3d2/hcanim.cpp $* - * * - * Author:: Greg_h * - * * - * $Modtime:: 6/27/01 7:50p $* - * * - * $Revision:: 3 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * NodeMotionStruct::NodeMotionStruct -- constructor * - * NodeMotionStruct::~NodeMotionStruct -- destructor * - * HCompressedAnimClass::HCompressedAnimClass -- constructor * - * HCompressedAnimClass::~HCompressedAnimClass -- Destructor * - * HCompressedAnimClass::Free -- De-allocates all memory in use * - * HCompressedAnimClass::Load -- Loads hierarchy animation from a file * - * HCompressedAnimClass::read_channel -- Reads in a single channel of motion * - * HCompressedAnimClass::add_channel -- Adds a motion channel to the animation * - * HCompressedAnimClass::Get_Translation -- returns the translation vector for the given fram* - * HCompressedAnimClass::Get_Orientation -- returns a quaternion for the orientation of the p* - * HCompressedAnimClass::read_bit_channel -- read a bit channel from the file * - * HCompressedAnimClass::add_bit_channel -- install a bit channel into the animation * - * HCompressedAnimClass::Get_Visibility -- return visibility state for given pivot/frame * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - - -#include "hcanim.h" -#include "assetmgr.h" -#include "htree.h" -#include "motchan.h" -#include "chunkio.h" -#include "w3d_file.h" -#include "wwdebug.h" -#include -#include - - -struct NodeCompressedMotionStruct -{ - NodeCompressedMotionStruct(); - ~NodeCompressedMotionStruct(); - - void SetFlavor(int flavor) {Flavor = flavor;} - - int Flavor; - - union { - struct { - TimeCodedMotionChannelClass * X; - TimeCodedMotionChannelClass * Y; - TimeCodedMotionChannelClass * Z; - TimeCodedMotionChannelClass * Q; - } tc; - - struct { - AdaptiveDeltaMotionChannelClass * X; - AdaptiveDeltaMotionChannelClass * Y; - AdaptiveDeltaMotionChannelClass * Z; - AdaptiveDeltaMotionChannelClass * Q; - - } ad; - - struct { - void * X; - void * Y; - void * Z; - void * Q; - } vd; - }; - - - TimeCodedBitChannelClass * Vis; -}; - -/*********************************************************************************************** - * NodeCompressedMotionStruct::NodeCompressedMotionStruct -- constructor * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - *=============================================================================================*/ -NodeCompressedMotionStruct::NodeCompressedMotionStruct() : - Vis(NULL) -{ - vd.X = NULL; - vd.Y = NULL; - vd.Z = NULL; - vd.Q = NULL; -} - - -/*********************************************************************************************** - * NodeCompressedMotionStruct::~NodeCompressedMotionStruct -- destructor * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 10/23/98 GTH : Created. * - * 02/02/00 JGA : Compressed * - *=============================================================================================*/ -NodeCompressedMotionStruct::~NodeCompressedMotionStruct() -{ - // Needs to be changed to call the correct destructors - - switch (Flavor) { - case ANIM_FLAVOR_TIMECODED: - if (tc.X) delete tc.X; - if (tc.Y) delete tc.Y; - if (tc.Z) delete tc.Z; - if (tc.Q) delete tc.Q; - break; - case ANIM_FLAVOR_ADAPTIVE_DELTA: - if (ad.X) delete ad.X; - if (ad.Y) delete ad.Y; - if (ad.Z) delete ad.Z; - if (ad.Q) delete ad.Q; - break; - default: - WWASSERT(0); // unknown flavor - break; - } - - if (Vis) delete Vis; - -} // ~NodeCompressedMotionStruct - - -/*********************************************************************************************** - * HCompressedAnimClass::HCompressedAnimClass -- constructor * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 08/11/1997 GH : Created. * - *=============================================================================================*/ -HCompressedAnimClass::HCompressedAnimClass(void) : - NumFrames(0), - NumNodes(0), - Flavor(0), - FrameRate(0), - NodeMotion(NULL) -{ - memset(Name,0,W3D_NAME_LEN); - memset(HierarchyName,0,W3D_NAME_LEN); -} - - -/*********************************************************************************************** - * HCompressedAnimClass::~HCompressedAnimClass -- Destructor * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 08/11/1997 GH : Created. * - *=============================================================================================*/ -HCompressedAnimClass::~HCompressedAnimClass(void) -{ - Free(); -} - - -/*********************************************************************************************** - * HCompressedAnimClass::Free -- De-allocates all memory in use * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 08/11/1997 GH : Created. * - *=============================================================================================*/ -void HCompressedAnimClass::Free(void) -{ - if (NodeMotion != NULL) { - delete[] NodeMotion; - } -} - - -/*********************************************************************************************** - * HCompressedAnimClass::Load -- Loads hierarchy animation from a file * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 08/11/1997 GH : Created. * - *=============================================================================================*/ -int HCompressedAnimClass::Load_W3D(ChunkLoadClass & cload) -{ - int i = 0; - /* - ** First make sure we release any memory in use - */ - Free(); - - /* - ** Open the first chunk, it should be the animation header - */ - if (!cload.Open_Chunk()) return LOAD_ERROR; - - if (cload.Cur_Chunk_ID() != W3D_CHUNK_COMPRESSED_ANIMATION_HEADER) { - // ERROR: Expected Animation Header! - return LOAD_ERROR; - } - - W3dCompressedAnimHeaderStruct aheader; - if (cload.Read(&aheader,sizeof(W3dAnimHeaderStruct)) != sizeof(W3dAnimHeaderStruct)) { - return LOAD_ERROR; - } - - cload.Close_Chunk(); - - strcpy(Name,aheader.HierarchyName); - strcat(Name,"."); - strcat(Name,aheader.Name); - - // TSS chasing crash bug 05/26/99 - WWASSERT(HierarchyName != NULL); - WWASSERT(aheader.HierarchyName != NULL); - WWASSERT(sizeof(HierarchyName) >= W3D_NAME_LEN); - strncpy(HierarchyName,aheader.HierarchyName,W3D_NAME_LEN); - - HTreeClass * base_pose = WW3DAssetManager::Get_Instance()->Get_HTree(HierarchyName); - if (base_pose == NULL) { - goto Error; - } - NumNodes = base_pose->Num_Pivots(); - - NumFrames = aheader.NumFrames; - FrameRate = aheader.FrameRate; - Flavor = aheader.Flavor; - - // Just for now - WWASSERT((Flavor == ANIM_FLAVOR_TIMECODED)||(Flavor == ANIM_FLAVOR_ADAPTIVE_DELTA)); - - NodeMotion = W3DNEWARRAY NodeCompressedMotionStruct[ NumNodes ]; - if (NodeMotion == NULL) { - goto Error; - } - - // Initialize Flavor - for (i=0; iGet_Pivot() < NumNodes) { - add_channel(tc_chan); - } else { - // PWG 12-14-98: we have only allocated space for NumNode pivots. - // If we have an index thats equal or higher than NumNode we are - // gonna trash memory. Boy will we trash memory. - // GTH 09-25-2000: print a warning and survive this error - delete tc_chan; - WWDEBUG_SAY(("ERROR! animation %s indexes a bone not present in the model. Please re-export!\r\n",Name)); - } - - break; - - case ANIM_FLAVOR_ADAPTIVE_DELTA: - if (!read_channel(cload,&ad_chan)) { - goto Error; - } - if (ad_chan->Get_Pivot() < NumNodes) { - add_channel(ad_chan); - } else { - // PWG 12-14-98: we have only allocated space for NumNode pivots. - // If we have an index thats equal or higher than NumNode we are - // gonna trash memory. Boy will we trash memory. - // GTH 09-25-2000: print a warning and survive this error - delete ad_chan; - WWDEBUG_SAY(("ERROR! animation %s indexes a bone not present in the model. Please re-export!\r\n",Name)); - } - break; - } - break; - - case W3D_CHUNK_COMPRESSED_BIT_CHANNEL: - if (!read_bit_channel(cload,&newbitchan)) { - goto Error; - } - if (newbitchan->Get_Pivot() < NumNodes) { - add_bit_channel(newbitchan); - } else { - // PWG 12-14-98: we have only allocated space for NumNode pivots. - // If we have an index thats equal or higher than NumNode we are - // gonna trash memory. Boy will we trash memory. - // GTH 09-25-2000: print a warning and survive this error - delete newbitchan; - WWDEBUG_SAY(("ERROR! animation %s indexes a bone not present in the model. Please re-export!\r\n",Name)); - } - - break; - - default: - break; - } - cload.Close_Chunk(); - } - - return OK; - -Error: - - Free(); - return LOAD_ERROR; - -} // Load_W3D - -/*********************************************************************************************** - * HCompressedAnimClass::read_channel -- Reads in a single channel of motion * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 08/11/1997 GH : Created. * - *=============================================================================================*/ -bool HCompressedAnimClass::read_channel(ChunkLoadClass & cload,TimeCodedMotionChannelClass * * newchan) -{ - *newchan = W3DNEW TimeCodedMotionChannelClass; - bool result = (*newchan)->Load_W3D(cload); - - return result; - -} // read_channel - -bool HCompressedAnimClass::read_channel(ChunkLoadClass & cload,AdaptiveDeltaMotionChannelClass * * newchan) -{ - *newchan = W3DNEW AdaptiveDeltaMotionChannelClass; - bool result = (*newchan)->Load_W3D(cload); - - return result; - -} // read_channel - - -/*********************************************************************************************** - * HCompressedAnimClass::add_channel -- Adds a motion channel to the animation * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 08/11/1997 GH : Created. * - *=============================================================================================*/ -void HCompressedAnimClass::add_channel(TimeCodedMotionChannelClass * newchan) -{ - int idx = newchan->Get_Pivot(); - - switch (newchan->Get_Type()) - { - case ANIM_CHANNEL_X: - NodeMotion[idx].tc.X = newchan; - break; - - case ANIM_CHANNEL_Y: - NodeMotion[idx].tc.Y = newchan; - break; - - case ANIM_CHANNEL_Z: - NodeMotion[idx].tc.Z = newchan; - break; - - case ANIM_CHANNEL_Q: - NodeMotion[idx].tc.Q = newchan; - break; - } - -} // add_channel - -void HCompressedAnimClass::add_channel(AdaptiveDeltaMotionChannelClass * newchan) -{ - int idx = newchan->Get_Pivot(); - - switch (newchan->Get_Type()) - { - case ANIM_CHANNEL_X: - NodeMotion[idx].ad.X = newchan; - break; - - case ANIM_CHANNEL_Y: - NodeMotion[idx].ad.Y = newchan; - break; - - case ANIM_CHANNEL_Z: - NodeMotion[idx].ad.Z = newchan; - break; - - case ANIM_CHANNEL_Q: - NodeMotion[idx].ad.Q = newchan; - break; - } - -} // add_channel - - - - -/*********************************************************************************************** - * HCompressedAnimClass::read_bit_channel -- read a bit channel from the file * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 1/19/98 GTH : Created. * - *=============================================================================================*/ -bool HCompressedAnimClass::read_bit_channel(ChunkLoadClass & cload,TimeCodedBitChannelClass * * newchan) -{ - *newchan = W3DNEW TimeCodedBitChannelClass; - bool result = (*newchan)->Load_W3D(cload); - - return result; - -} // read_bit_channel - - -/*********************************************************************************************** - * HCompressedAnimClass::add_bit_channel -- install a bit channel into the animation * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 1/19/98 GTH : Created. * - *=============================================================================================*/ -void HCompressedAnimClass::add_bit_channel(TimeCodedBitChannelClass * newchan) -{ - int idx = newchan->Get_Pivot(); - - switch (newchan->Get_Type()) - { - case BIT_CHANNEL_VIS: - NodeMotion[idx].Vis = newchan; - break; - } -} - -/*********************************************************************************************** - * HCompressedAnimClass::Get_Translation -- returns the translation vector for the given frame * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 08/11/1997 GH : Created. * - *=============================================================================================*/ -void HCompressedAnimClass::Get_Translation( Vector3& trans, int pividx, float frame ) const -{ - struct NodeCompressedMotionStruct * motion = &NodeMotion[pividx]; - - trans=Vector3(0,0,0); - - switch(Flavor) { - case ANIM_FLAVOR_TIMECODED: - if (motion->tc.X) motion->tc.X->Get_Vector(frame, &(trans[0])); - if (motion->tc.Y) motion->tc.Y->Get_Vector(frame, &(trans[1])); - if (motion->tc.Z) motion->tc.Z->Get_Vector(frame, &(trans[2])); - break; - case ANIM_FLAVOR_ADAPTIVE_DELTA: - if (motion->ad.X) motion->ad.X->Get_Vector(frame, &(trans[0])); - if (motion->ad.Y) motion->ad.Y->Get_Vector(frame, &(trans[1])); - if (motion->ad.Z) motion->ad.Z->Get_Vector(frame, &(trans[2])); - break; - default: - WWASSERT(0); // unknown flavor - break; - } -} - -/*********************************************************************************************** - * HCompressedAnimClass::Get_Orientation -- returns a quaternion for the orientation of the * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 08/11/1997 GH : Created. * - *=============================================================================================*/ -void HCompressedAnimClass::Get_Orientation(Quaternion& q, int pividx,float frame) const -{ - switch(Flavor) { - case ANIM_FLAVOR_TIMECODED: - if (NodeMotion[pividx].tc.Q) q = NodeMotion[pividx].tc.Q->Get_QuatVector(frame); - else q.Make_Identity(); - break; - case ANIM_FLAVOR_ADAPTIVE_DELTA: - if (NodeMotion[pividx].ad.Q) q = NodeMotion[pividx].ad.Q->Get_QuatVector(frame); - else q.Make_Identity(); - break; - default: - WWASSERT(0); // unknown flavor - break; - } -} // Get_Orientation - -/*********************************************************************************************** - * HCompressedAnimClass::Get_Transform -- returns the transform matrix for the given frame * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 08/11/1997 GH : Created. * - *=============================================================================================*/ -void HCompressedAnimClass::Get_Transform( Matrix3D& mtx, int pividx, float frame ) const -{ - struct NodeCompressedMotionStruct * motion = &NodeMotion[pividx]; - - switch(Flavor) { - case ANIM_FLAVOR_TIMECODED: - if (NodeMotion[pividx].tc.Q) { - Quaternion q; - q = NodeMotion[pividx].tc.Q->Get_QuatVector(frame); - ::Build_Matrix3D(q,mtx); - } - else mtx.Make_Identity(); - if (motion->tc.X) motion->tc.X->Get_Vector(frame, &(mtx[0][3])); - if (motion->tc.Y) motion->tc.Y->Get_Vector(frame, &(mtx[1][3])); - if (motion->tc.Z) motion->tc.Z->Get_Vector(frame, &(mtx[2][3])); - break; - case ANIM_FLAVOR_ADAPTIVE_DELTA: - if (NodeMotion[pividx].ad.Q) { - Quaternion q; - q = NodeMotion[pividx].ad.Q->Get_QuatVector(frame); - ::Build_Matrix3D(q,mtx); - } - else mtx.Make_Identity(); - - if (motion->ad.X) motion->ad.X->Get_Vector(frame, &(mtx[0][3])); - if (motion->ad.Y) motion->ad.Y->Get_Vector(frame, &(mtx[1][3])); - if (motion->ad.Z) motion->ad.Z->Get_Vector(frame, &(mtx[2][3])); - break; - default: - WWASSERT(0); // unknown flavor - break; - } -} - -/*********************************************************************************************** - * HCompressedAnimClass::Get_Visibility -- return visibility state for given pivot/frame * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 1/19/98 GTH : Created. * - *=============================================================================================*/ -bool HCompressedAnimClass::Get_Visibility(int pividx,float frame) -{ - - if (NodeMotion[pividx].Vis != NULL) { - return (NodeMotion[pividx].Vis->Get_Bit((int)frame) == 1); - } - - - // default to always visible... - return 1; -} - - - -/*********************************************************************************************** - * HAnimClass::Is_Node_Motion_Present -- return true if there is motion defined for this frame * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 3/23/99 EHC : Created. * - *=============================================================================================*/ -bool HCompressedAnimClass::Is_Node_Motion_Present(int pividx) -{ - WWASSERT((pividx >= 0) && (pividx < NumNodes)); - - if (NodeMotion[pividx].vd.X != NULL) return true; - if (NodeMotion[pividx].vd.Y != NULL) return true; - if (NodeMotion[pividx].vd.Z != NULL) return true; - if (NodeMotion[pividx].vd.Q != NULL) return true; - if (NodeMotion[pividx].Vis != NULL) return true; - - return false; -} - -bool HCompressedAnimClass::Has_X_Translation (int pividx) -{ - WWASSERT((pividx >= 0) && (pividx < NumNodes)); - return NodeMotion[pividx].vd.X != NULL; -} - -bool HCompressedAnimClass::Has_Y_Translation (int pividx) -{ - WWASSERT((pividx >= 0) && (pividx < NumNodes)); - return NodeMotion[pividx].vd.Y != NULL; -} - -bool HCompressedAnimClass::Has_Z_Translation (int pividx) -{ - WWASSERT((pividx >= 0) && (pividx < NumNodes)); - return NodeMotion[pividx].vd.Z != NULL; -} - -bool HCompressedAnimClass::Has_Rotation (int pividx) -{ - WWASSERT((pividx >= 0) && (pividx < NumNodes)); - return NodeMotion[pividx].vd.Q != NULL; -} - -bool HCompressedAnimClass::Has_Visibility (int pividx) -{ - WWASSERT((pividx >= 0) && (pividx < NumNodes)); - return NodeMotion[pividx].Vis != NULL; -} - - -// eof - hcanim.cpp diff --git a/Generals/Code/Libraries/Source/WWVegas/WW3D2/hcanim.h b/Generals/Code/Libraries/Source/WWVegas/WW3D2/hcanim.h deleted file mode 100644 index b3f646d197d..00000000000 --- a/Generals/Code/Libraries/Source/WWVegas/WW3D2/hcanim.h +++ /dev/null @@ -1,139 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/* $Header: /Commando/Code/ww3d2/hcanim.h 2 6/29/01 6:41p Jani_p $ */ -/*********************************************************************************************** - *** Confidential - Westwood Studios *** - *********************************************************************************************** - * * - * Project Name : Commando / G 3D Library * - * * - * $Archive:: /Commando/Code/ww3d2/hcanim.h $* - * * - * Author:: Greg_h * - * * - * $Modtime:: 6/27/01 7:35p $* - * * - * $Revision:: 2 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - - -#if defined(_MSC_VER) -#pragma once -#endif - -#ifndef HCANIM_H -#define HCANIM_H - -#include "always.h" -#include "quat.h" -#include "refcount.h" -#include "w3d_file.h" -#include "SLIST.H" -#include "Vector.H" -#include "hanim.h" - -struct NodeCompressedMotionStruct; -class TimeCodedMotionChannelClass; -class TimeCodedBitChannelClass; -class AdaptiveDeltaMotionChannelClass; -class HTreeClass; -class ChunkLoadClass; -class ChunkSaveClass; - - -/********************************************************************************** - - Hierarchy Compressed Animation Class - - Stores motion data to be applied to a HierarchyTree. Each frame - of the motion contains deltas from the HierarchyTree's base position - to the desired position. - -**********************************************************************************/ - -class HCompressedAnimClass : public HAnimClass -{ - -public: - - enum - { - OK, - LOAD_ERROR - }; - - HCompressedAnimClass(void); - ~HCompressedAnimClass(void); - - int Load_W3D(ChunkLoadClass & cload); - - const char * Get_Name(void) const { return Name; } - const char * Get_HName(void) const { return HierarchyName; } - int Get_Num_Frames(void) { return NumFrames; } - float Get_Frame_Rate() { return FrameRate; } - float Get_Total_Time() { return (float)NumFrames / FrameRate; } - int Get_Flavor() { return Flavor; } - -// Vector3 Get_Translation(int pividx,float frame); -// Quaternion Get_Orientation(int pividx,float frame); - void Get_Translation(Vector3& translation, int pividx,float frame) const; - void Get_Orientation(Quaternion& orientation, int pividx,float frame) const; - void Get_Transform(Matrix3D& transform, int pividx,float frame) const; - bool Get_Visibility(int pividx,float frame); - - bool Is_Node_Motion_Present(int pividx); - int Get_Num_Pivots(void) const { return NumNodes; } - - // Methods that test the presence of a certain motion channel. - bool Has_X_Translation (int pividx); - bool Has_Y_Translation (int pividx); - bool Has_Z_Translation (int pividx); - bool Has_Rotation (int pividx); - bool Has_Visibility (int pividx); - -private: - - char Name[2*W3D_NAME_LEN]; - char HierarchyName[W3D_NAME_LEN]; - - int NumFrames; - int NumNodes; - int Flavor; - float FrameRate; - - NodeCompressedMotionStruct * NodeMotion; - - void Free(void); - bool read_channel(ChunkLoadClass & cload,TimeCodedMotionChannelClass * * newchan); - bool read_channel(ChunkLoadClass & cload,AdaptiveDeltaMotionChannelClass * * newchan); - void add_channel(TimeCodedMotionChannelClass * newchan); - void add_channel(AdaptiveDeltaMotionChannelClass * newchan); - - - bool read_bit_channel(ChunkLoadClass & cload,TimeCodedBitChannelClass * * newchan); - void add_bit_channel(TimeCodedBitChannelClass * newchan); - -}; - - -#endif // hcanim.h - diff --git a/Generals/Code/Libraries/Source/WWVegas/WW3D2/hmdldef.H b/Generals/Code/Libraries/Source/WWVegas/WW3D2/hmdldef.H deleted file mode 100644 index 732998476cc..00000000000 --- a/Generals/Code/Libraries/Source/WWVegas/WW3D2/hmdldef.H +++ /dev/null @@ -1,112 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** 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 *** - *********************************************************************************************** - * * - * Project Name : WW3D * - * * - * $Archive:: /Commando/Code/ww3d2/hmdldef.h $* - * * - * Author:: Greg_h * - * * - * $Modtime:: 1/08/01 10:04a $* - * * - * $Revision:: 1 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - - -#if defined(_MSC_VER) -#pragma once -#endif - -#ifndef HMDLDEF_H -#define HMDLDEF_H - -#include "always.h" -#include "w3d_file.h" - -class FileClass; -class ChunkLoadClass; -class ChunkSaveClass; -class SnapPointsClass; - -/* -** Each render object to be attached into the hierarchy model -** will be defined by an instance of the following structure. -** The HmdlNodeDefStruct associates a named render object with -** an indexed pivot/bone in the hierarchy tree. -*/ -struct HmdlNodeDefStruct -{ - char RenderObjName[2*W3D_NAME_LEN]; - int PivotID; -}; - - -/* -** HModelDefClass -** -** "Hierarchy Model Definition Class" -** This class serves as a blueprint for creating HierarchyModelClasses. -** The asset manager stores these objects internally and uses them to -** create instances of HierarchyModels for the user. -*/ -class HModelDefClass -{ - -public: - - enum { - OK, - LOAD_ERROR - }; - - HModelDefClass(void); - ~HModelDefClass(void); - - int Load_W3D(ChunkLoadClass & cload); - const char * Get_Name(void) const { return Name; } - -private: - - char Name[2*W3D_NAME_LEN]; // . - char ModelName[W3D_NAME_LEN]; // name of the model - char BasePoseName[W3D_NAME_LEN]; // name of the base pose (hierarchy tree) - - int SubObjectCount; - HmdlNodeDefStruct * SubObjects; - SnapPointsClass * SnapPoints; - - void Free(void); - bool read_header(ChunkLoadClass & cload); - bool read_connection(ChunkLoadClass & cload,HmdlNodeDefStruct * con,bool pre30); - bool read_mesh_connection(ChunkLoadClass & cload,int idx,bool pre30); - bool read_collision_connection(ChunkLoadClass & cload,int idx,bool pre30); - bool read_skin_connection(ChunkLoadClass & cload,int idx,bool pre30); - - // HModelClass requires intimate knowlege of us - friend class HModelClass; - friend class HLodClass; -}; - -#endif diff --git a/Generals/Code/Libraries/Source/WWVegas/WW3D2/hmdldef.cpp b/Generals/Code/Libraries/Source/WWVegas/WW3D2/hmdldef.cpp deleted file mode 100644 index cb6caee841a..00000000000 --- a/Generals/Code/Libraries/Source/WWVegas/WW3D2/hmdldef.cpp +++ /dev/null @@ -1,257 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** 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 *** - *********************************************************************************************** - * * - * Project Name : WW3D * - * * - * $Archive:: /Commando/Code/ww3d2/hmdldef.cpp $* - * * - * Author:: Greg_h * - * * - * $Modtime:: 1/08/01 10:04a $* - * * - * $Revision:: 1 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * HModelDefClass::HModelDefClass -- Constructor * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - - -#include "hmdldef.H" -#include -#include -#include "w3d_file.h" -#include "chunkio.h" -#include "snapPts.h" - - -/*********************************************************************************************** - * HModelDefClass::HModelDefClass -- Constructor * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 12/15/97 GTH : Created. * - *=============================================================================================*/ -HModelDefClass::HModelDefClass(void) : - SubObjectCount(0), - SubObjects(NULL), - SnapPoints(NULL) -{ - -} - -/*********************************************************************************************** - * HModelDefClass::~HModelDefClass -- destructor * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 08/11/1997 GH : Created. * - *=============================================================================================*/ -HModelDefClass::~HModelDefClass(void) -{ - Free(); -} - -/*********************************************************************************************** - * HModelDefClass::Free -- de-allocate all memory in use * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 08/11/1997 GH : Created. * - *=============================================================================================*/ -void HModelDefClass::Free(void) -{ - if (SubObjects != NULL) { - delete[] SubObjects; - SubObjects = NULL; - } - SubObjectCount = 0; - - if (SnapPoints != NULL) { - SnapPoints->Release_Ref(); - SnapPoints = NULL; - } -} - - -/*********************************************************************************************** - * HModelDefClass::Load -- load a set of mesh connections from a file * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 08/11/1997 GH : Created. * - *=============================================================================================*/ -int HModelDefClass::Load_W3D(ChunkLoadClass & cload) -{ - bool pre30 = false; - int subobjcounter = 0; - - Free(); - - /* - ** Read the first chunk, it should be the header - */ - if (!cload.Open_Chunk()) { - return false; - } - - if (cload.Cur_Chunk_ID() != W3D_CHUNK_HMODEL_HEADER) { - goto Error; - } - - /* - ** read in the header - */ - W3dHModelHeaderStruct header; - if (cload.Read(&header,sizeof(W3dHModelHeaderStruct)) != sizeof(W3dHModelHeaderStruct)) { - goto Error; - } - - cload.Close_Chunk(); - - /* - ** process the header info - */ - strncpy(ModelName,header.Name,W3D_NAME_LEN); - ModelName[W3D_NAME_LEN - 1] = 0; - strncpy(BasePoseName,header.HierarchyName,W3D_NAME_LEN); - BasePoseName[W3D_NAME_LEN-1] = 0; - strcpy(Name,ModelName); - - /* - ** Just allocate a node for the number of sub objects we're expecting - */ - SubObjectCount = header.NumConnections; - SubObjects = W3DNEWARRAY HmdlNodeDefStruct[SubObjectCount]; - if (SubObjects == NULL) { - goto Error; - } - - /* - ** If this is pre-3.0 set a flag so that each render object's - ** bone id will be incremented by one to account for the new - ** root node added with version3.0 of the file format. Basically, - ** I'm making all of the code assume that node 0 is the root and - ** therefore, pre-3.0 files have to have it added and all of - ** the indices adjusted - */ - if (header.Version < W3D_MAKE_VERSION(3,0)) { - pre30 = true; - } - - /* - ** Process the rest of the chunks - */ - subobjcounter = 0; - - while (cload.Open_Chunk()) { - - switch (cload.Cur_Chunk_ID()) { - - case W3D_CHUNK_NODE: - case W3D_CHUNK_COLLISION_NODE: - case W3D_CHUNK_SKIN_NODE: - if (!read_connection(cload,&(SubObjects[subobjcounter]),pre30)) { - goto Error; - } - subobjcounter++; - break; - - case W3D_CHUNK_POINTS: - SnapPoints = W3DNEW SnapPointsClass; - SnapPoints->Load_W3D(cload); - break; - - default: - break; - } - cload.Close_Chunk(); - } - - return OK; - -Error: - - return LOAD_ERROR; - -} - - -/*********************************************************************************************** - * HModelDefClass::read_connection -- read a single connection from the file * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 08/11/1997 GH : Created. * - * 10/22/97 GH : Check for mesh connections with PivotID=-1 * - *=============================================================================================*/ -bool HModelDefClass::read_connection(ChunkLoadClass & cload,HmdlNodeDefStruct * node,bool pre30) -{ - - W3dHModelNodeStruct con; - if (cload.Read(&con,sizeof(W3dHModelNodeStruct)) != sizeof(W3dHModelNodeStruct)) { - return false; - } - - strcpy(node->RenderObjName,ModelName); - strcat(node->RenderObjName,"."); - strcat(node->RenderObjName,con.RenderObjName); - - if (pre30) { - if (con.PivotIdx == 65535) { - node->PivotID = 0; - } else { - node->PivotID = con.PivotIdx + 1; - } - } else { - assert(con.PivotIdx != 65535); - node->PivotID = con.PivotIdx; - } - - return true; -} - diff --git a/Generals/Code/Libraries/Source/WWVegas/WW3D2/htree.cpp b/Generals/Code/Libraries/Source/WWVegas/WW3D2/htree.cpp deleted file mode 100644 index b8dad6de2ff..00000000000 --- a/Generals/Code/Libraries/Source/WWVegas/WW3D2/htree.cpp +++ /dev/null @@ -1,1231 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/* $Header: /Commando/Code/ww3d2/htree.cpp 14 10/01/01 6:07p Patrick $ */ -/*********************************************************************************************** - *** Confidential - Westwood Studios *** - *********************************************************************************************** - * * - * Project Name : Commando / G 3D Library * - * * - * $Archive:: /Commando/Code/ww3d2/htree.cpp $* - * * - * Author:: Greg_h * - * * - * $Modtime:: 10/01/01 6:06p $* - * * - * $Revision:: 14 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * HTreeClass::HTreeClass -- constructor * - * HTreeClass::~HTreeClass -- destructor * - * HTreeClass::Load -- loads a hierarchy tree from a file * - * HTreeClass::read_pivots -- reads the pivots out of a file * - * HTreeClass::Free -- de-allocate all memory in use * - * HTreeClass::Base_Update -- Computes the base pose transform for each pivot * - * HTreeClass::Anim_Update -- Computes the transform for each pivot with motion * - * HTreeClass::Blend_Update -- computes each pivot as a blend of two anims * - * HTreeClass::Combo_Update -- compute each pivot's transform using an anim combo * - * HTreeClass::Get_Transform -- returns the transformation for the desired pivot * - * HTreeClass::Find_Bone -- Find a bone by name * - * HTreeClass::Get_Bone_Name -- get the name of a bone from its index * - * HTreeClass::Update_Parent_Need_Bits -- all "needed" children force their parents to be nee* - * HTreeClass::HTreeClass -- copy constructor * - * HTreeClass::Get_Parent_Index -- returns index of the parent of the given bone * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - - -#include "htree.h" -#include "hanim.h" -#include "hcanim.h" -#include -#include -#include "wwmath.h" -#include "chunkio.h" -#include "w3d_file.h" -#include "wwmemlog.h" -#include "hrawanim.h" -#include "motchan.h" - -/*********************************************************************************************** - * HTreeClass::HTreeClass -- constructor * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 08/11/1997 GH : Created. * - *=============================================================================================*/ -HTreeClass::HTreeClass(void) : - NumPivots(0), - Pivot(NULL), - ScaleFactor(1.0f) -{ -} - -void HTreeClass::Init_Default(void) -{ - Free (); - - NumPivots = 1; - Pivot = MSGW3DNEWARRAY("HTreeClass::Pivot") PivotClass[NumPivots]; - - Pivot[0].Index = 0; - Pivot[0].Parent = NULL; - Pivot[0].BaseTransform.Make_Identity(); - Pivot[0].Transform.Make_Identity(); - Pivot[0].IsVisible = true; - strcpy(Pivot[0].Name,"RootTransform"); - //::strcpy (Name, "Default"); - Name[0] = 0; - return ; - - - -} - -/*********************************************************************************************** - * HTreeClass::~HTreeClass -- destructor * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 08/11/1997 GH : Created. * - *=============================================================================================*/ -HTreeClass::~HTreeClass(void) -{ - Free(); - - - -} - - -/*********************************************************************************************** - * HTreeClass::HTreeClass -- copy constructor * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 3/4/98 GTH : Created. * - *=============================================================================================*/ -HTreeClass::HTreeClass(const HTreeClass & src) : - NumPivots(0), - Pivot(NULL), - ScaleFactor(1.0f) -{ - memcpy(&Name,&src.Name,sizeof(Name)); - - NumPivots = src.NumPivots; - if (NumPivots > 0) { - Pivot = MSGW3DNEWARRAY("HTreeClass::Pivot") PivotClass[NumPivots]; - } - - for (int pi = 0; pi < NumPivots; pi++) { - Pivot[pi] = src.Pivot[pi]; - - if (src.Pivot[pi].Parent != NULL) { - Pivot[pi].Parent = &(Pivot[src.Pivot[pi].Parent->Index]); - } else { - Pivot[pi].Parent = NULL; - } - } - - ScaleFactor = src.ScaleFactor; -} - -/*********************************************************************************************** - * HTreeClass::Load -- loads a hierarchy tree from a file * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 08/11/1997 GH : Created. * - *=============================================================================================*/ -int HTreeClass::Load_W3D(ChunkLoadClass & cload) -{ - Free(); - - /* - ** Read the first chunk, it should be the hierarchy header - */ - if (!cload.Open_Chunk()) return LOAD_ERROR; - - if (cload.Cur_Chunk_ID() != W3D_CHUNK_HIERARCHY_HEADER) { - // ERROR: Expected Hierarchy Header - return LOAD_ERROR; - } - - W3dHierarchyStruct header; - if (cload.Read(&header,sizeof(W3dHierarchyStruct)) != sizeof(W3dHierarchyStruct)) { - return LOAD_ERROR; - } - - cload.Close_Chunk(); - - /* - ** Check the version, if < 3.0 add a root node for everything - ** to attach to. The load_pivots function will also have to be - ** notified of this. - */ - bool pre30 = false; - if (header.Version < W3D_MAKE_VERSION(3,0)) { - header.NumPivots ++; - pre30 = true; - } - - /* - ** Allocate the array of pivots - */ - memcpy(Name,header.Name,W3D_NAME_LEN); - NumPivots = header.NumPivots; - if (NumPivots > 0) { - Pivot = MSGW3DNEWARRAY("HTreeClass::Pivot") PivotClass[NumPivots]; - } - - /* - ** Now, read in all of the other chunks for this hierarchy. - */ - - while (cload.Open_Chunk()) { - - switch (cload.Cur_Chunk_ID()) { - - case W3D_CHUNK_PIVOTS: - if (!read_pivots(cload,pre30)) { - goto Error; - } - break; - - default: - // ERROR: expected W3D_CHUNK_PIVOTS! - break; - } - cload.Close_Chunk(); - } - - return OK; - -Error: - - Free(); - return LOAD_ERROR; -} - - -/*********************************************************************************************** - * HTreeClass::read_pivots -- reads the pivots out of a file * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 08/11/1997 GH : Created. * - *=============================================================================================*/ -bool HTreeClass::read_pivots(ChunkLoadClass & cload,bool pre30) -{ - W3dPivotStruct piv; - Matrix3D mtx; - - int first_piv = 0; - - /* - ** At (w3d file format) version 3.0, I added a node for the root. Pre-3.0 htrees didn't have - ** this so we just put one in. - */ - if (pre30) { - Pivot[0].Index = 0; - Pivot[0].Parent = NULL; - Pivot[0].BaseTransform.Make_Identity(); - Pivot[0].Transform.Make_Identity(); - Pivot[0].IsVisible = true; - strcpy(Pivot[0].Name,"RootTransform"); - first_piv++; - } - - for (int pidx=first_piv; pidx < NumPivots; pidx++) { - - if (cload.Read(&piv,sizeof(W3dPivotStruct)) != sizeof(W3dPivotStruct)) { - return false; - } - - memcpy(Pivot[pidx].Name,piv.Name,W3D_NAME_LEN); - Pivot[pidx].Index = pidx; - - Pivot[pidx].BaseTransform.Make_Identity(); - Pivot[pidx].BaseTransform.Translate(Vector3(piv.Translation.X,piv.Translation.Y,piv.Translation.Z)); - -#ifdef ALLOW_TEMPORARIES - Pivot[pidx].BaseTransform = - Pivot[pidx].BaseTransform * - Build_Matrix3D( - Quaternion( - piv.Rotation.Q[0], - piv.Rotation.Q[1], - piv.Rotation.Q[2], - piv.Rotation.Q[3] - ), - mtx - ); -#else - Pivot[pidx].BaseTransform.postMul( - Build_Matrix3D( - Quaternion( - piv.Rotation.Q[0], - piv.Rotation.Q[1], - piv.Rotation.Q[2], - piv.Rotation.Q[3] - ), - mtx - ) - ); -#endif - - /* - ** At version 3.0 a root node was added, this "fixes up" pre-3.0 files - ** to have that root node - */ - if (pre30) { - piv.ParentIdx += 1; - } - - /* - ** Set the parent pointer. The first pivot will have a parent index - ** of -1 (in post-3.0 files) so set its parent to NULL. - */ - if (piv.ParentIdx == -1) { - Pivot[pidx].Parent = NULL; - assert(pidx == 0); - } else { - Pivot[pidx].Parent = &(Pivot[piv.ParentIdx]); - } - - } - - Pivot[0].Transform.Make_Identity(); - Pivot[0].IsVisible = true; - - return true; -} - - -/*********************************************************************************************** - * HTreeClass::Free -- de-allocate all memory in use * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 08/11/1997 GH : Created. * - *=============================================================================================*/ -void HTreeClass::Free(void) -{ - if (Pivot != NULL) { - delete[] Pivot; - Pivot = NULL; - } - NumPivots = 0; - - // Also clean up other members: - ScaleFactor = 1.0f; -} - - -/*********************************************************************************************** - * HTreeClass::Simple_Evaluate_Pivot -- Returns the transform of a pivot at the given frame. * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 04/13/2000 PDS : Created. * - *=============================================================================================*/ -bool HTreeClass::Simple_Evaluate_Pivot -( - HAnimClass * motion, - int pivot_index, - float frame, - const Matrix3D & obj_tm, - Matrix3D * end_tm -) const -{ - bool retval = false; - end_tm->Make_Identity (); - - if ( motion != NULL && - end_tm != NULL && - pivot_index >= 0 && - pivot_index < NumPivots) - { - // - // Loop over the hierarchy of pivots that this pivot is - // attached to and transform each. - // - for ( PivotClass *pivot = &Pivot[pivot_index]; - pivot != NULL && pivot->Parent != NULL; - pivot = pivot->Parent) - { - // - // Build a matrix that represents the animation for this pivot - // - - Matrix3D anim_tm; - motion->Get_Transform(anim_tm, pivot->Index, frame); - -// Quaternion q; -// motion->Get_Orientation (q, pivot->Index, frame); -// Matrix3D anim_tm = ::Build_Matrix3D(q); - - Vector3 trans; - anim_tm.Get_Translation(&trans); - anim_tm.Set_Translation(trans * ScaleFactor); - - // - // Transform the animation transform by the 'relative-to-parent' transform. - // - Matrix3D curr_tm; - Matrix3D::Multiply(pivot->BaseTransform, anim_tm, &curr_tm); - - // - // Transform the return value by this transform - // -#ifdef ALLOW_TEMPORARIES - Matrix3D::Multiply (curr_tm, *end_tm, end_tm); -#else - end_tm->preMul(curr_tm); -#endif - } - - // - // Transform the return value by the object's transform - // -#ifdef ALLOW_TEMPORARIES - Matrix3D::Multiply (obj_tm, *end_tm, end_tm); -#else - end_tm->preMul(obj_tm); -#endif - - // Success! - retval = true; - } - - return retval; -} - - - -/*********************************************************************************************** - * HTreeClass::Simple_Evaluate_Pivot -- Returns the transform of a pivot at the given frame. * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 04/13/2000 PDS : Created. * - *=============================================================================================*/ -bool HTreeClass::Simple_Evaluate_Pivot -( - int pivot_index, - const Matrix3D & obj_tm, - Matrix3D * end_tm -) const -{ - bool retval = false; - end_tm->Make_Identity (); - - if ( end_tm != NULL && - pivot_index >= 0 && - pivot_index < NumPivots) - { - // - // Loop over the hierarchy of pivots that this pivot is - // attached to and transform each. - // - for ( PivotClass *pivot = &Pivot[pivot_index]; - pivot != NULL && pivot->Parent != NULL; - pivot = pivot->Parent) - { - // - // Build a matrix that represents the animation for this pivot - // - Matrix3D anim_tm (1); - - // - // Transform the animation transform by the 'relative-to-parent' transform. - // - Matrix3D curr_tm; - Matrix3D::Multiply (pivot->BaseTransform, anim_tm, &curr_tm); - - // - // Transform the return value by this transform - // - Matrix3D::Multiply (curr_tm, *end_tm, end_tm); - } - - // - // Transform the return value by the object's transform - // - Matrix3D::Multiply (obj_tm, *end_tm, end_tm); - retval = true; - } - - return retval; -} - - -/*********************************************************************************************** - * HTreeClass::Base_Update -- Computes the base pose transform for each pivot * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 08/11/1997 GH : Created. * - *=============================================================================================*/ -void HTreeClass::Base_Update(const Matrix3D & root) -{ - PivotClass *pivot; - - Pivot[0].Transform = root; - Pivot[0].IsVisible = true; - - for (int piv_idx=1; piv_idx < NumPivots; piv_idx++) { - - pivot = &Pivot[piv_idx]; - - assert(pivot->Parent != NULL); - Matrix3D::Multiply(pivot->Parent->Transform, pivot->BaseTransform, &(pivot->Transform)); - pivot->IsVisible = 1; - - if (pivot->Is_Captured()) pivot->Capture_Update(); - } -} - -/*********************************************************************************************** - * HTreeClass::Anim_Update -- Computes the transform for each pivot with motion * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 08/11/1997 GH : Created. * - *=============================================================================================*/ -void HTreeClass::Anim_Update(const Matrix3D & root,HAnimClass * motion,float frame) -{ - PivotClass *pivot; - Matrix3D mtx; - - Pivot[0].Transform = root; - Pivot[0].IsVisible = true; - - int num_anim_pivots = motion->Get_Num_Pivots (); - - for (int piv_idx=1; piv_idx < NumPivots; piv_idx++) { - pivot = &Pivot[piv_idx]; - - // base pose - assert(pivot->Parent != NULL); - Matrix3D::Multiply(pivot->Parent->Transform, pivot->BaseTransform, &(pivot->Transform)); - - // Don't update this pivot if the HTree doesn't have animation data for it... - if (piv_idx < num_anim_pivots) { - - // animation - Vector3 trans; - motion->Get_Translation(trans,piv_idx,frame); - pivot->Transform.Translate(trans * ScaleFactor); - - Quaternion q; - motion->Get_Orientation(q,piv_idx,frame); - ::Build_Matrix3D(q,mtx); - -#ifdef ALLOW_TEMPORARIES - pivot->Transform = pivot->Transform * mtx; -#else - pivot->Transform.postMul(mtx); -#endif - - // visibility - pivot->IsVisible = motion->Get_Visibility(piv_idx,frame); - } - - if (pivot->Is_Captured()) - { - pivot->Capture_Update(); - pivot->IsVisible = true; - } - } -} - -/*Customized version of the above which excludes interpolation and assumes HRawAnimClass -For use by 'Generals' -MW*/ -void HTreeClass::Anim_Update(const Matrix3D & root,HRawAnimClass * motion,float frame) -{ - PivotClass *pivot,*endpivot,*lastAnimPivot; - - Pivot[0].Transform = root; - Pivot[0].IsVisible = true; - - int num_anim_pivots = motion->Get_Num_Pivots (); - - //Get integer frame - int iframe=WWMath::Float_To_Long(frame); - if (iframe >= motion->Get_Num_Frames()) - iframe = 0; - - Vector3 trans; - Quaternion q; - Matrix3D mtx; - - struct NodeMotionStruct * nodeMotion = ((HRawAnimClass*)motion)->Get_Node_Motion_Array(); - nodeMotion += 1; //skip the root node - - pivot = &Pivot[1]; - endpivot=pivot+(NumPivots-1); - lastAnimPivot = &Pivot[num_anim_pivots]; - - for (int piv_idx=1; pivot < endpivot; pivot++,nodeMotion++) { - - // base pose - assert(pivot->Parent != NULL); - Matrix3D::Multiply(pivot->Parent->Transform, pivot->BaseTransform, &(pivot->Transform)); - - // Don't update this pivot if the HTree doesn't have animation data for it... - if (pivot < lastAnimPivot) - { - - // animation - trans.Set(0.0f,0.0f,0.0f); - Matrix3D *xform=&pivot->Transform; - - if (nodeMotion->X != NULL) - nodeMotion->X->Get_Vector(iframe,&(trans[0])); - if (nodeMotion->Y != NULL) - nodeMotion->Y->Get_Vector(iframe,&(trans[1])); - if (nodeMotion->Z != NULL) - nodeMotion->Z->Get_Vector(iframe,&(trans[2])); - - if (ScaleFactor == 1.0f) - xform->Translate(trans); - else - xform->Translate(trans*ScaleFactor); - - if (nodeMotion->Q != NULL) - { nodeMotion->Q->Get_Vector_As_Quat(iframe, q); -#ifdef ALLOW_TEMPORARIES - *xform = *xform * ::Build_Matrix3D(q,mtx); -#else - xform->postMul(::Build_Matrix3D(q,mtx)); -#endif - } - - // visibility - if (nodeMotion->Vis != NULL) - pivot->IsVisible=(nodeMotion->Vis->Get_Bit(iframe) == 1); - else - pivot->IsVisible=1; - } - - if (pivot->Is_Captured()) - { - pivot->Capture_Update(); - pivot->IsVisible = true; - } - } -} - - -/*********************************************************************************************** - * HTreeClass::Blend_Update -- computes each pivot as a blend of two anims * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 3/4/98 GTH : Created. * - *=============================================================================================*/ -void HTreeClass::Blend_Update -( - const Matrix3D & root, - HAnimClass * motion0, - float frame0, - HAnimClass * motion1, - float frame1, - float percentage // 0.0 = motion0. 1.0 = motion1 -) -{ - PivotClass *pivot; - Matrix3D mtx; - - Pivot[0].Transform = root; - Pivot[0].IsVisible = true; - - int num_anim_pivots = MIN( motion0->Get_Num_Pivots (), motion1->Get_Num_Pivots () ); - - for (int piv_idx=1; piv_idx < NumPivots; piv_idx++) { - - pivot = &Pivot[piv_idx]; - - assert(pivot->Parent != NULL); - Matrix3D::Multiply(pivot->Parent->Transform,pivot->BaseTransform,&(pivot->Transform)); - - if (piv_idx < num_anim_pivots) { - // interpolated translation - Vector3 trans0; - motion0->Get_Translation(trans0,piv_idx,frame0); - Vector3 trans1; - motion1->Get_Translation(trans1,piv_idx,frame1); - Vector3 lerped = (1.0 - percentage) * trans0 + (percentage) * trans1; - pivot->Transform.Translate(lerped * ScaleFactor); - - // interpolated rotation - Quaternion q0; - motion0->Get_Orientation(q0,piv_idx,frame0); - Quaternion q1; - motion1->Get_Orientation(q1,piv_idx,frame1); - Quaternion q; - Fast_Slerp(q,q0,q1,percentage); -#ifdef ALLOW_TEMPORARIES - pivot->Transform = pivot->Transform * Build_Matrix3D(q); -#else - pivot->Transform.postMul(Build_Matrix3D(q,mtx)); -#endif - - pivot->IsVisible = (motion0->Get_Visibility(piv_idx,frame0) || motion1->Get_Visibility(piv_idx,frame1)); - } - - if (pivot->Is_Captured()) - { - pivot->Capture_Update(); - pivot->IsVisible = true; - } - } -} - - - -/*********************************************************************************************** - * HTreeClass::Combo_Update -- compute each pivot's transform using an anim combo * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 3/4/98 GTH : Created. * - *=============================================================================================*/ -void HTreeClass::Combo_Update -( - const Matrix3D & root, - HAnimComboClass *anim -) -{ - PivotClass *pivot; - Matrix3D mtx; - - Pivot[0].Transform = root; - Pivot[0].IsVisible = true; - - int num_anim_pivots = 100000; - for ( int anim_num = 0; anim_num < anim->Get_Num_Anims(); anim_num++ ) { - num_anim_pivots = MIN( num_anim_pivots, anim->Peek_Motion( anim_num )->Get_Num_Pivots() ); - } - if ( num_anim_pivots == 100000 ) { - num_anim_pivots = 0; - } - - for (int piv_idx=1; piv_idx < NumPivots; piv_idx++) { - - pivot = &Pivot[piv_idx]; - assert(pivot->Parent != NULL); - Matrix3D::Multiply(pivot->Parent->Transform,pivot->BaseTransform,&(pivot->Transform)); - - if (piv_idx < num_anim_pivots) { - -#define ASSUME_NORMALIZED_ANIM_COMBO_WEIGHTS - - Vector3 trans(0,0,0); - Quaternion q0; - Quaternion q1; -#ifndef ASSUME_NORMALIZED_ANIM_COMBO_WEIGHTS - float last_weight = 0; -#endif - float weight_total = 0; - int wcount = 0; - - int anim_num = 0; - for ( ; anim_num < anim->Get_Num_Anims(); anim_num++ ) { - - HAnimClass *motion = anim->Get_Motion( anim_num ); - - if ( motion != NULL ) { - - float frame_num = anim->Get_Frame( anim_num ); - - PivotMapClass * pivot_map = anim->Get_Pivot_Weight_Map( anim_num ); - - //float *pivot_map = anim->Get_Pivot_Weight_Map( anim_num ); - - float weight = anim->Get_Weight( anim_num ); - - if ( pivot_map != NULL ) { - weight *= (*pivot_map)[piv_idx]; - // GREG - Pivot maps are ref counted so shouldn't we - // release the rivot map here? - pivot_map->Release_Ref(); - } - - if ( weight != 0.0 ) { - - wcount++; - Vector3 temp_trans; - motion->Get_Translation( temp_trans, piv_idx, frame_num ); - trans += weight * ScaleFactor * temp_trans; - weight_total += weight; - -#ifdef ASSUME_NORMALIZED_ANIM_COMBO_WEIGHTS - motion->Get_Orientation(q1,piv_idx, frame_num ); - if ( wcount == 1 ) { - q0 = q1; - } else { - Fast_Slerp(q0, q0, q1, weight / weight_total ); - } -#else - q0 = q1; - motion->Get_Orientation(q1, piv_idx, frame_num ); - last_weight = weight; -#endif - } - - motion->Release_Ref(); - - } - } - -#ifdef ASSUME_NORMALIZED_ANIM_COMBO_WEIGHTS - - if (weight_total != 0.0f ) { - // SKB: Removed assert because I have a case where I don't want normalization. - // One anim moves X, the other moves Y. Assert was just in to warn programmers. -// WWASSERT(WWMath::Fabs( weight_total - 1.0 ) < WWMATH_EPSILON); - - pivot->Transform.Translate(trans); -#ifdef ALLOW_TEMPORARIES - pivot->Transform = pivot->Transform * Build_Matrix3D(q0); -#else - pivot->Transform.postMul(Build_Matrix3D(q0,mtx)); -#endif - } -#else - if (( weight_total != 0.0f ) && (wcount >= 2)) { - - pivot->Transform.Translate( trans / weight_total ); - Quaternion q = Slerp_( q0, q1, last_weight / weight_total ); - pivot->Transform = pivot->Transform * Build_Matrix3D(q); - - } else if (weight_total != 0.0f) { - - pivot->Transform.Translate( trans / weight_total ); - pivot->Transform = pivot->Transform * Build_Matrix3D(q1); - } -#endif - - pivot->IsVisible = false; - - for ( anim_num = 0; (anim_num < anim->Get_Num_Anims()) && (!pivot->IsVisible); anim_num++ ) { - HAnimClass *motion = anim->Get_Motion( anim_num ); - if ( motion != NULL ) { - float frame_num = anim->Get_Frame( anim_num ); - - pivot->IsVisible |= motion->Get_Visibility(piv_idx,frame_num); - - motion->Release_Ref(); - } - } - } - - if (pivot->Is_Captured()) - { - pivot->Capture_Update(); - pivot->IsVisible = true; - } - } -} - - -/*********************************************************************************************** - * HTreeClass::Find_Bone -- Find a bone by name * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 11/4/97 GTH : Created. * - *=============================================================================================*/ -int HTreeClass::Get_Bone_Index(const char * name) const -{ - for (int i=0; i < NumPivots; i++) { - if (stricmp(Pivot[i].Name,name) == 0) { - return i; - } - } - return 0; -} - - -/*********************************************************************************************** - * HTreeClass::Get_Bone_Name -- get the name of a bone from its index * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 11/4/97 GTH : Created. * - *=============================================================================================*/ -const char * HTreeClass::Get_Bone_Name(int boneidx) const -{ - assert(boneidx >= 0); - assert(boneidx < NumPivots); - - return Pivot[boneidx].Name; -} - - -/*********************************************************************************************** - * HTreeClass::Get_Parent_Index -- returns index of the parent of the given bone * - * * - * INPUT: * - * boneidx - the bone you are interested in * - * * - * OUTPUT: * - * the index of that bone's parent * - * * - * WARNINGS: * - * * - * HISTORY: * - * 4/12/2000 gth : Created. * - *=============================================================================================*/ -int HTreeClass::Get_Parent_Index(int boneidx) const -{ - assert(boneidx >= 0); - assert(boneidx < NumPivots); - - if (Pivot[boneidx].Parent != NULL) { - return Pivot[boneidx].Parent->Index; - } else { - return 0; - } -} - - -// Scale this HTree by a constant factor: -void HTreeClass::Scale(float factor) -{ - if (factor == 1.0f) return; - - // Scale pivot translations - for (int i = 0; i < NumPivots; i++) { - Matrix3D &pivot_transform = Pivot[i].BaseTransform; - Vector3 pivot_translation; - pivot_transform.Get_Translation(&pivot_translation); - pivot_translation *= factor; - pivot_transform.Set_Translation(pivot_translation); - } - - // Set state used later to scale animations: - ScaleFactor *= factor; -} - - - -void HTreeClass::Capture_Bone(int boneindex) -{ - assert(boneindex >= 0); - assert(boneindex < NumPivots); -#ifdef LAZY_CAP_MTX_ALLOC - if (Pivot[boneindex].CapTransformPtr == NULL) - { - Pivot[boneindex].CapTransformPtr = MSGW3DNEW("PivotClassCaptureBoneMtx") DynamicMatrix3D; - Pivot[boneindex].CapTransformPtr->Mat.Make_Identity(); - } -#else - Pivot[boneindex].IsCaptured = true; -#endif -} - -void HTreeClass::Release_Bone(int boneindex) -{ - assert(boneindex >= 0); - assert(boneindex < NumPivots); -#ifdef LAZY_CAP_MTX_ALLOC - if (Pivot[boneindex].CapTransformPtr) - { - delete Pivot[boneindex].CapTransformPtr; - Pivot[boneindex].CapTransformPtr = NULL; - } -#else - Pivot[boneindex].IsCaptured = false; -#endif -} - -bool HTreeClass::Is_Bone_Captured(int boneindex) const -{ - assert(boneindex >= 0); - assert(boneindex < NumPivots); - return Pivot[boneindex].Is_Captured(); -} - -void HTreeClass::Control_Bone(int boneindex,const Matrix3D & relative_tm,bool world_space_translation) -{ - assert(boneindex >= 0); - assert(boneindex < NumPivots); - assert(Pivot[boneindex].Is_Captured()); - -#ifdef LAZY_CAP_MTX_ALLOC - if (Pivot[boneindex].CapTransformPtr == NULL) - return; - Pivot[boneindex].WorldSpaceTranslation = world_space_translation; - Pivot[boneindex].CapTransformPtr->Mat = relative_tm; -#else - Pivot[boneindex].WorldSpaceTranslation = world_space_translation; - Pivot[boneindex].CapTransform = relative_tm; -#endif -} - -void HTreeClass::Get_Bone_Control(int boneindex, Matrix3D & relative_tm) const -{ - assert(boneindex >= 0); - assert(boneindex < NumPivots); - - // - // Return the bone's control transform to the caller - // - if (Pivot[boneindex].IsCaptured) { - relative_tm = Pivot[boneindex].CapTransform; - } else { - relative_tm.Make_Identity (); - } - - return ; -} - -HTreeClass * HTreeClass::Alter_Avatar_HTree( const HTreeClass *tree, Vector3 &scale) -{ - // This is a specific list of pivot names used in the avatar meshes that we need to special case for scaling - // The reason is due to the fact that we want to scale the avatar's bone structure with differing amount for - // each axis, and with the T-pos of the avatar skeleton, undesirable results are caused due to the arms and hands - // being stretched out on the Y-axis instead of the Z-axis like the rest of the bodies. Hence, the list of pivots - // below are ones that I will special case and scale them based on the Z-axis scaling factor instead of the Y-axis - // scaling factor. - const char * flip_list[] = { " RIGHTFOREARM", " RIGHTHAND", " LEFTFOREARM", " LEFTHAND", "RIGHTINDEX", "RIGHTFINGERS", "RIGHTTHUMB", "LEFTINDEX", "LEFTFINGERS", "LEFTTHUMB", 0 }; - - // Clone the new tree with the tree that is passed in - HTreeClass * new_tree = new HTreeClass( *tree ); - - // Go through each of the pivots and calculate and transform the pivots to match the desired scaling factor - for(int pi = 0; pi < new_tree->NumPivots; ++pi) { - PivotClass piv = tree->Pivot[pi]; - Vector3 adjusted_scale = scale; - - // If there is no parent, skip - if(!piv.Parent) continue; - - // If the pivot is on the flip list, use the Z scale to scale both the Z & Y axis - int index = 0; - while(true) { - if(!flip_list[index]) { - break; - } else if(strcmp(piv.Name, flip_list[index]) == 0) { - adjusted_scale.Y = scale.Z; - break; - } - ++index; - } - - // Get the positions of the pivot and the pivot's parent in worldspace & apply the altering scale to it - Vector3 pivot_pos = piv.Transform.Get_Translation(); - Vector3 pivot_parent_pos = piv.Parent->Transform.Get_Translation(); - pivot_pos.Scale(adjusted_scale); - pivot_parent_pos.Scale(adjusted_scale); - - // Get the pivot's parent's inverse transform - Matrix3D parent_inverse_transform; - piv.Parent->Transform.Get_Inverse(parent_inverse_transform); - - // Get the new desired vector in worldspace - Vector3 new_relative_vector = pivot_pos - pivot_parent_pos; - - // Rotate the new vector by the pivot's parent's inverse transform to put it in local space - new_relative_vector = parent_inverse_transform.Rotate_Vector(new_relative_vector); - - // Store the final result in the new HTree - new_tree->Pivot[pi].BaseTransform.Set_Translation( new_relative_vector ); - } - - return new_tree; -} - -// Morph the bones on the HTree using weights from a number of other HTrees -HTreeClass * HTreeClass::Create_Morphed( int num_morph_sources, - const float morph_weights[], - const HTreeClass *tree_array[] ) -{ - int i; - assert(num_morph_sources>0); - for(i=0;i=0.0f && morph_weights[i]<=1.0f ); - } - for(i=0;iNumPivots == tree_array[i+1]->NumPivots ); - } - - // Clone the first one, - HTreeClass * new_tree = W3DNEWARRAY HTreeClass( *tree_array[0] ); - - // Then interpolate all the pivots translations - for (int pi = 0; pi < new_tree->NumPivots; pi++) { - - Vector3 pos(0.0f,0.0f,0.0f); - for(int nm = 0; nm < num_morph_sources; nm++) { - pos.X += tree_array[nm]->Pivot[pi].BaseTransform.Get_Translation().X*morph_weights[nm]; - pos.Y += tree_array[nm]->Pivot[pi].BaseTransform.Get_Translation().Y*morph_weights[nm]; - pos.Z += tree_array[nm]->Pivot[pi].BaseTransform.Get_Translation().Z*morph_weights[nm]; - } - - new_tree->Pivot[pi].BaseTransform.Set_Translation( pos ); - } - - return new_tree; -} - -// Create an HTree by Interpolating between others -HTreeClass * HTreeClass::Create_Interpolated( const HTreeClass * tree_a0_b0, - const HTreeClass * tree_a0_b1, - const HTreeClass * tree_a1_b0, - const HTreeClass * tree_a1_b1, - float lerp_a, float lerp_b ) -{ - assert( tree_a0_b0->NumPivots == tree_a0_b1->NumPivots ); - assert( tree_a0_b0->NumPivots == tree_a1_b0->NumPivots ); - assert( tree_a0_b0->NumPivots == tree_a1_b1->NumPivots ); - - // Clone the first one, - HTreeClass * new_tree = W3DNEW HTreeClass( *tree_a0_b0 ); - - // Then interpolate all the pivots translations - Vector3 pos_a0, pos_a1, pos; - for (int pi = 0; pi < new_tree->NumPivots; pi++) { - - Vector3::Lerp( tree_a0_b0->Pivot[pi].BaseTransform.Get_Translation(), - tree_a0_b1->Pivot[pi].BaseTransform.Get_Translation(), - lerp_b, &pos_a0 ); - Vector3::Lerp( tree_a1_b0->Pivot[pi].BaseTransform.Get_Translation(), - tree_a1_b1->Pivot[pi].BaseTransform.Get_Translation(), - lerp_b, &pos_a1 ); - Vector3::Lerp( pos_a0, pos_a1, lerp_a, &pos ); - - new_tree->Pivot[pi].BaseTransform.Set_Translation( pos ); - } - - return new_tree; -} - -// Create an HTree by Interpolating between others -HTreeClass * HTreeClass::Create_Interpolated(const HTreeClass * tree_base, - const HTreeClass * tree_a, - const HTreeClass * tree_b, - float a_scale, float b_scale ) -{ - WWMEMLOG(MEM_ANIMATION); - assert( tree_base->NumPivots == tree_a->NumPivots ); - assert( tree_base->NumPivots == tree_b->NumPivots ); - - // Clone the first one, - HTreeClass * new_tree = W3DNEW HTreeClass( *tree_base ); - - float a_scale_abs = WWMath::Fabs( a_scale ); - float b_scale_abs = WWMath::Fabs( b_scale ); - - if ( a_scale_abs + b_scale_abs > 0 ) { - - // Then interpolate all the pivots translations - Vector3 pos_a, pos_b, pos; - for (int pi = 0; pi < new_tree->NumPivots; pi++) { - - Vector3::Lerp( tree_base->Pivot[pi].BaseTransform.Get_Translation(), - tree_a->Pivot[pi].BaseTransform.Get_Translation(), - a_scale, &pos_a ); - Vector3::Lerp( tree_base->Pivot[pi].BaseTransform.Get_Translation(), - tree_b->Pivot[pi].BaseTransform.Get_Translation(), - b_scale, &pos_b ); - - pos = (pos_a * a_scale_abs + pos_b * b_scale_abs ) / ( a_scale_abs + b_scale_abs ); - - new_tree->Pivot[pi].BaseTransform.Set_Translation( pos ); - } - } - - return new_tree; -} - diff --git a/Generals/Code/Libraries/Source/WWVegas/WW3D2/htree.h b/Generals/Code/Libraries/Source/WWVegas/WW3D2/htree.h deleted file mode 100644 index e022194833d..00000000000 --- a/Generals/Code/Libraries/Source/WWVegas/WW3D2/htree.h +++ /dev/null @@ -1,212 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/* $Header: /Commando/Code/ww3d2/htree.h 6 10/01/01 5:55p Patrick $ */ -/*********************************************************************************************** - *** Confidential - Westwood Studios *** - *********************************************************************************************** - * * - * Project Name : Commando / G 3D Library * - * * - * $Archive:: /Commando/Code/ww3d2/htree.h $* - * * - * Author:: Greg_h * - * * - * $Modtime:: 9/28/01 3:05p $* - * * - * $Revision:: 6 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#if defined(_MSC_VER) -#pragma once -#endif - -#ifndef HTREE_H -#define HTREE_H - -#include "always.h" -#include "pivot.h" -#include "quat.h" -#include "matrix3d.h" -#include "vector3.h" -#include "w3d_file.h" -#include "wwdebug.h" - -class HAnimClass; -class HAnimComboClass; -class MeshClass; -class ChunkLoadClass; -class ChunkSaveClass; -class HRawAnimClass; - -/* - - HTreeClass - - A hierarchy of coordinate systems in an initial - configuration. All motion data is applied to one - of these objects. Motion is stored as deltas from - the hierarchy tree's initial configuration. - - Normally, the user will probably not deal with - HTreeClasses; they are used internally - by the HierarchyModelClass. - -*/ -class HTreeClass : public W3DMPO -{ - W3DMPO_GLUE(HTreeClass) -public: - - enum - { - OK, - LOAD_ERROR - }; - - HTreeClass(void); - HTreeClass(const HTreeClass & src); - ~HTreeClass(void); - - int Load_W3D(ChunkLoadClass & cload); - void Init_Default(void); - - WWINLINE const char * Get_Name(void) const { return Name; } - WWINLINE int Num_Pivots(void) const { return NumPivots; } - int Get_Bone_Index(const char * name) const; - const char * Get_Bone_Name(int boneid) const; - int Get_Parent_Index(int bone_indx) const; - - void Base_Update(const Matrix3D & root); - - void Anim_Update( const Matrix3D & root, - HAnimClass * motion, - float frame); - void Anim_Update(const Matrix3D & root,HRawAnimClass * motion,float frame); - - void Blend_Update( const Matrix3D & root, - HAnimClass * motion0, - float frame0, - HAnimClass * motion1, - float frame1, - float percentage); - - void Combo_Update( const Matrix3D & root, - HAnimComboClass * anim); - - WWINLINE const Matrix3D & Get_Transform(int pivot) const; - WWINLINE bool Get_Visibility(int pivot) const; - - WWINLINE const Matrix3D & Get_Root_Transform(void) const; - - // User control over a bone. While a bone is captured, you can over-ride the - // animation transform used by the bone. - void Capture_Bone(int boneindex); - void Release_Bone(int boneindex); - bool Is_Bone_Captured(int boneindex) const; - void Control_Bone(int boneindex,const Matrix3D & relative_tm,bool world_space_translation = false); - void Get_Bone_Control(int boneindex, Matrix3D & relative_tm) const; - - - - // - // Simple pivot evaluation methods for when the caller doesn't want - // to update the whole animation, but needs to know the transform of - // a pivot at a given frame. - // - bool Simple_Evaluate_Pivot (HAnimClass *motion, int pivot_index, float frame, const Matrix3D &obj_tm, Matrix3D *end_tm) const; - bool Simple_Evaluate_Pivot (int pivot_index, const Matrix3D &obj_tm, Matrix3D *end_tm) const; - - // Scale this HTree by a constant factor: - void Scale(float factor); - - // Morph the bones on the HTree based on the scale passed in - static HTreeClass * Alter_Avatar_HTree( const HTreeClass *tree, Vector3 &scale ); - - // Morph the bones on the HTree using weights from a number of other HTrees - static HTreeClass * Create_Morphed( int num_morph_sources, - const float morph_weights[], - const HTreeClass *tree_array[] ); - - // Create an HTree by Interpolating between others - static HTreeClass * Create_Interpolated( const HTreeClass * tree_a0_b0, - const HTreeClass * tree_a0_b1, - const HTreeClass * tree_a1_b0, - const HTreeClass * tree_a1_b1, - float lerp_a, float lerp_b ); - - // Create an HTree by Interpolating between others - static HTreeClass * Create_Interpolated( const HTreeClass * tree_base, - const HTreeClass * tree_a, - const HTreeClass * tree_b, - float a_scale, float b_scale ); - -private: - - char Name[W3D_NAME_LEN]; - int NumPivots; - PivotClass * Pivot; - float ScaleFactor; - - void Free(void); - bool read_pivots(ChunkLoadClass & cload,bool pre30); - - friend class MeshClass; - - - -}; - -WWINLINE const Matrix3D & HTreeClass::Get_Root_Transform(void) const -{ - return Pivot[0].Transform; -} - -WWINLINE bool HTreeClass::Get_Visibility(int pivot) const -{ - WWASSERT(pivot >= 0); - WWASSERT(pivot < NumPivots); - return Pivot[pivot].IsVisible; -} - -/*********************************************************************************************** - * HTreeClass::Get_Transform -- returns the transformation for the desired pivot * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 08/11/1997 GH : Created. * - *=============================================================================================*/ -WWINLINE const Matrix3D & HTreeClass::Get_Transform(int pivot) const -{ - assert(pivot >= 0); - assert(pivot < NumPivots); - - return Pivot[pivot].Transform; -} - - - -#endif diff --git a/Generals/Code/Libraries/Source/WWVegas/WW3D2/intersec.cpp b/Generals/Code/Libraries/Source/WWVegas/WW3D2/intersec.cpp deleted file mode 100644 index 1849b5857ab..00000000000 --- a/Generals/Code/Libraries/Source/WWVegas/WW3D2/intersec.cpp +++ /dev/null @@ -1,444 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** 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 *** - *********************************************************************************************** - * * - * Project Name : G * - * * - * $Archive:: /Commando/Code/ww3d2/intersec.cpp $* - * * - * $Author:: Greg_h $* - * * - * $Modtime:: 2/06/01 5:41p $* - * * - * $Revision:: 3 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - - - -#include "intersec.h" -#include "camera.h" -#include "scene.h" -#include "intersec.inl" -#include "Utility/CppMacros.h" - - -////////////////////////////////////////////////////////////////////// -// Construction/Destruction -////////////////////////////////////////////////////////////////////// - -// these statics are used for single-threaded use of the IntersectionClass ONLY -Vector3 IntersectionClass::_RayLocation(0,0,0); -Vector3 IntersectionClass::_RayDirection(0,0,0); -Vector3 IntersectionClass::_IntersectionNormal(0,0,0); - - -bool IntersectionClass::Intersect_Screen_Point_RenderObject(float screen_x, float screen_y, const LayerClass &Layer, RenderObjClass *RObj, IntersectionResultClass *FinalResult) -{ - Get_Screen_Ray(screen_x, screen_y, Layer); - return Intersect_RenderObject(RObj, FinalResult); -} - -bool IntersectionClass::Intersect_RenderObject(RenderObjClass *RObj, IntersectionResultClass *FinalResult) -{ - if(FinalResult == 0) - FinalResult = &Result; - - return RObj->Intersect(this, FinalResult); -} - -// iterate through the layers of a world, front to back, returning true if/when an intersection -// with an object occurs. -bool IntersectionClass::Intersect_Screen_Point_Layer_Range -( - float screen_x, - float screen_y, - const LayerClass &TopLayer, - const LayerClass &BackLayer -) -{ - - // intersect from front layer to back layers. An intersection with an object - // in any layer is assumed to be in front of any potential intersections in layers - // below it. - - // find the last layer in the list - const LayerClass *Layer = &TopLayer; - - // iterate through all layers in list - while(Layer->Is_Valid()) { - if(Intersect_Screen_Point_Layer(screen_x, screen_y, *Layer)) - return true; - - // if this is the back layer then that is all we need to test - if(Layer == &BackLayer) - return false; - - Layer = Layer->Next(); - } - return false; -} - - -bool IntersectionClass::Intersect_Screen_Point_Layer(float screen_x, float screen_y, const LayerClass &Layer) -{ - // mark this object as not intersecting yet - Result.Intersects = false; - - // first, do a test to make sure the screen coords are within the rendering area for this layer. - const ViewportClass &v = Layer.Camera->Get_Viewport(); - - if((screen_x < v.Min.X) || - (screen_x > v.Max.X) || - (screen_y < v.Min.Y) || - (screen_y > v.Max.Y)) - return false; - - Result.Range = Layer.Camera->Get_Depth(); //scene->depth * scene->zstop; - - // get the ray for these screen coordinates - Get_Screen_Ray(screen_x, screen_y, Layer); - - return Intersect_Layer(Layer, false); -} - -bool IntersectionClass::Intersect_Layer(const LayerClass &Layer, bool Test_All) -{ - IntersectionResultClass FinalResult; - - Result.Intersects = false; - - SceneIterator *it = Layer.Scene->Create_Iterator(!Test_All); - - // select the first object - it->First(); - - // loop through all render objects in this layer: - while(!it->Is_Done()) { - - // get the render object - RenderObjClass * robj = it->Current_Item(); - it->Next(); - - // only intersect if it was visible or if we must test all in layer - // Added 'Generals' code to only detect intersection on matching Collision_Type. MW - if( robj->Get_Collision_Type() & Result.CollisionType && (Test_All || robj->Is_Really_Visible()) && robj->Intersect(this, &FinalResult)) { - if(FinalResult.Range < Result.Range) { - Copy_Results(&FinalResult); - } - } - } - - Layer.Scene->Destroy_Iterator(it); - - return Result.Intersects; -} - - -void IntersectionClass::Append_Object_Array( - int MaxCount, - int &CurrentCount, - RenderObjClass **ObjectArray, - RenderObjClass *Object) -{ - if(CurrentCount < MaxCount) { - ObjectArray[CurrentCount] = Object; - CurrentCount++; - return; - } - WWDEBUG_SAY(("IntersectionClass::Append_Object_Array - Too many objects\n")); -} - -// determines if specified plane-intersection point (co-planar with polygon) is within the the passed polygon. -// If Interpolated_Normal is specified, it will interpolate the normal for the intersection point -// note: Polygon normal MUST BE CORRECT - -// this will return true if the ray intersects the specified box -// sets the point of intersection within the Request->Result.Intersection vector -bool IntersectionClass::Intersect_Box(Vector3 &Box_Min, Vector3 &Box_Max, IntersectionResultClass *FinalResult) { - // Fast Ray-Box Intersection, modified from code written by Andrew Woo from "Graphics Gems", Academic Press, 1990 - - enum { - RIGHT = 0, - LEFT, - MIDDLE, - PLANE_COUNT - }; - - bool inside = true; - char quadrant[PLANE_COUNT]; - int counter; - float distance[PLANE_COUNT]; - float candidate_plane[PLANE_COUNT]; - - REGISTER Vector3 *intersection = &FinalResult->Intersection; - - // Find candidate planes and determine if the ray is outside the box - for (counter = 0; counter < PLANE_COUNT; counter++) { - if((*RayLocation)[counter] < Box_Min[counter]) { - quadrant[counter] = LEFT; - candidate_plane[counter] = Box_Min[counter]; - inside = false; - } else { - if ((*RayLocation)[counter] > Box_Max[counter]) { - quadrant[counter] = RIGHT; - candidate_plane[counter] = Box_Max[counter]; - inside = false; - } else { - quadrant[counter] = MIDDLE; - } - } - } - - // check to see if the ray origin is inside bounding box - if(inside) { - *intersection = *RayLocation; - return FinalResult->Intersects = true; - } - - // Calculate distances to candidate planes - for (counter = 0; counter < PLANE_COUNT; counter++) { - if ((quadrant[counter] != MIDDLE) && ((*RayDirection)[counter] != 0.0f)) - distance[counter] = (candidate_plane[counter] - (*RayLocation)[counter]) / (*RayDirection)[counter]; - else - distance[counter] = -1.0f; - } - - // get the largest of the distances for final choice of intersection - int nearest_plane = 0; - for (counter = 1; counter < PLANE_COUNT; counter++) { - if (distance[nearest_plane] < distance[counter]) - nearest_plane = counter; - } - - // Check to make sure the nearest plane is not behind the ray (inside box tested above) - if (distance[nearest_plane] < 0.0f) - return FinalResult->Intersects = false; - - for (counter = 0; counter < PLANE_COUNT; counter++) { - if (nearest_plane != counter) { - (*intersection)[counter] = (*RayLocation)[counter] + distance[nearest_plane] *(*RayDirection)[counter]; - if ((*intersection)[counter] < Box_Min[counter] || (*intersection)[counter] > Box_Max[counter]) - return FinalResult->Intersects = false; - } else { - (*intersection)[counter] = candidate_plane[counter]; - } - } - return FinalResult->Intersects = true; // ray hits box -} - - -// simply returns true if a ray hits the bounding sphere of any node in a hierarchy -// note: Result will only contain range, not the intersection point/normal. -bool IntersectionClass::Intersect_Hierarchy_Sphere_Quick(RenderObjClass *Hierarchy, IntersectionResultClass *FinalResult) -{ - - int counter = Hierarchy->Get_Num_Sub_Objects(); - while(counter--) { - RenderObjClass *obj = Hierarchy->Get_Sub_Object(counter); - obj->Release_Ref(); // you already own a reference to this object indirectly.. - if(obj->Intersect_Sphere_Quick(this, FinalResult)) - return true; - } - return false; -} - -// returns true if a ray hits the bounding sphere of any node in a hierarchy -// note: Result will contain range and the intersection point/normal. -bool IntersectionClass::Intersect_Hierarchy_Sphere(RenderObjClass *Hierarchy, IntersectionResultClass *FinalResult) { - - int counter = Hierarchy->Get_Num_Sub_Objects(); - while(counter--) { - RenderObjClass *obj = Hierarchy->Get_Sub_Object(counter); - obj->Release_Ref(); // you already own a reference to this object indirectly.. - if(obj->Intersect_Sphere(this, FinalResult)) - return true; - } - return false; -} - -void IntersectionClass::Append_Hierarchy_Objects( - int MaxCount, - int &CurrentCount, - RenderObjClass **ObjectArray, - RenderObjClass *Hierarchy, - bool Test_Bounding_Sphere, - bool Convex) -{ - IntersectionResultClass result; - - // first check the bounding spheres for hits (if specified) - int counter = Hierarchy->Get_Num_Sub_Objects(); - if(Test_Bounding_Sphere) { - while(counter--) { - RenderObjClass *obj = Hierarchy->Get_Sub_Object(counter); - obj->Release_Ref(); // you already own a reference to the object indirectly - if(obj->Intersect_Sphere_Quick(this, &result)) { - Append_Object_Array(MaxCount, CurrentCount, ObjectArray, obj); -// OutputDebugString("o"); // this shows one o per sphere intersection - } else { -// OutputDebugString("."); // this shows one . per sphere miss - } - } - - } else { - // simply copy the pointers into the array - while(counter--) { - RenderObjClass *obj = Hierarchy->Get_Sub_Object(counter); - Append_Object_Array(MaxCount, CurrentCount, ObjectArray, obj); - obj->Release_Ref(); // you already own a reference to this object indirectly.. - } - } -} - -bool IntersectionClass::Intersect_Hierarchy(RenderObjClass *Hierarchy, IntersectionResultClass *FinalResult, bool Test_Bounding_Sphere, bool Convex ) { - -// OutputDebugString("\n"); -// return FinalResult->Intersects = false; - - RenderObjClass *candidate_objects[MAX_HIERARCHY_NODE_COUNT]; - int candidate_count = 0; - - Append_Hierarchy_Objects(MAX_HIERARCHY_NODE_COUNT, candidate_count, candidate_objects, Hierarchy, Test_Bounding_Sphere, Convex); - - // make sure there's at least one sphere hit before continuing to more expensive tests below.. - if(candidate_count == 0) { - // OutputDebugString("/"); // no sphere intersections - return FinalResult->Intersects = false; - } - - // note: Test_Bounding_Sphere argument is false because the Append_Hierarchy_Objects will have - // already performed that test if indicated. - if(Intersect_Object_Array(candidate_count, candidate_objects, FinalResult, false, Convex)) { - return true; - } - return false; -} - -RenderObjClass *IntersectionClass::Intersect_Sub_Object(float screenx, float screeny, LayerClass &layer, RenderObjClass *robj, IntersectionResultClass *result) -{ - if (robj->Get_Num_Sub_Objects()) { - for (int lp = 0; lp < robj->Get_Num_Sub_Objects(); lp++) { - RenderObjClass *sub = robj->Get_Sub_Object(lp); - RenderObjClass *retval = Intersect_Sub_Object(screenx, screeny, layer, sub, result); - sub->Release_Ref(); - if (retval) return retval; - } - } - if (Intersect_Screen_Point_RenderObject(screenx, screeny, layer, robj, result)) { - return robj; - } - return NULL; -} - -// finds the intersection of the nearest object in the array. -// This will usually be the last stage after determining potential intersections -// using Intersect_Sphere_Quick() and adding hits to the array for this -// more accurate test, as done in Intersect_Heirarchy(). -bool IntersectionClass::Intersect_Object_Array( - int Object_Count, - RenderObjClass **ObjectArray, - IntersectionResultClass *FinalResult, - bool Test_Bounding_Sphere, - bool Convex - ) -{ - IntersectionResultClass TemporaryResults[MAX_HIERARCHY_NODE_COUNT]; - assert(Object_Count <= MAX_HIERARCHY_NODE_COUNT); - return Intersect_Object_Array(Object_Count, ObjectArray, FinalResult, TemporaryResults, Test_Bounding_Sphere, Convex); -} - -bool IntersectionClass::Intersect_Object_Array( - int Object_Count, - RenderObjClass **ObjectArray, - IntersectionResultClass *FinalResult, - IntersectionResultClass *TemporaryResults, - bool Test_Bounding_Sphere, - bool Convex - ) -{ - // Determine ranges for all intersections - IntersectionClass temp(this); - int counter = Object_Count; - bool hit = false; - - // if it's a convex hierarchy (ie a control panel) then find the first hit otherwise use the more expensive exact intersection routine - // for use with potentially concave hierarchies. - int nearest_index = -1; - if(ConvexTest || Convex) { - if(Test_Bounding_Sphere) { - while(counter--) { - if(ObjectArray[counter]->Intersect_Sphere_Quick(this, &TemporaryResults[counter])) { - hit = ObjectArray[counter]->Intersect(this, FinalResult); - } - if(hit) { - nearest_index = counter; - counter = 0; - } - } - } else { - while(counter--) { - hit = ObjectArray[counter]->Intersect(this, FinalResult); - if(hit) { - nearest_index = counter; - counter = 0; - } - } - } - } else { - if(Test_Bounding_Sphere) { - while(counter--) { - if(ObjectArray[counter]->Intersect_Sphere_Quick(this, &TemporaryResults[counter])) { - hit |= ObjectArray[counter]->Intersect(this, &TemporaryResults[counter]); - } - } - } else { - while(counter--) { - hit |= ObjectArray[counter]->Intersect(this, &TemporaryResults[counter]); - } - } - } - // test to see if anything actually hit a mesh - if( ! hit ) { -// OutputDebugString("!"); // no mesh intersections - return FinalResult->Intersects = false; - } - - if(! (Convex || ConvexTest)) { - // now find the nearest of the actual hits - float nearest_range = (float) (2<<28); - counter = Object_Count; - while(counter--) { - if(TemporaryResults[counter].Intersects && (nearest_range > TemporaryResults[counter].Range)) { - nearest_index = counter; - nearest_range = TemporaryResults[counter].Range; - } - } - Copy_Results(FinalResult, &TemporaryResults[nearest_index]); - } -// OutputDebugString("+"); -// Debug.Print("Mesh ", Object_Array[nearest_index]); -// Intersection_Node = candidate_indices[nearest_index]; - return true; -} - diff --git a/Generals/Code/Libraries/Source/WWVegas/WW3D2/intersec.h b/Generals/Code/Libraries/Source/WWVegas/WW3D2/intersec.h deleted file mode 100644 index 770625ae290..00000000000 --- a/Generals/Code/Libraries/Source/WWVegas/WW3D2/intersec.h +++ /dev/null @@ -1,404 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** 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 *** - *********************************************************************************************** - * * - * Project Name : G * - * * - * $Archive:: /Commando/Code/ww3d2/intersec.h $* - * * - * $Author:: Naty_h $* - * * - * $Modtime:: 3/28/01 11:29a $* - * * - * $Revision:: 5 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -/* - - Most of the functions of this class are inline functions and if you use them you will need - to include . - - Exceptions to this are the functions most commonly used by render objects: - - - - The constructors/destructors are inline & implemented here. - -*/ - -#if defined(_MSC_VER) -#pragma once -#endif - -#ifndef INTERSEC_H -#define INTERSEC_H - -#include "always.h" -#include "matrix3d.h" -#include "layer.h" -#include "sphere.h" -#include "coltype.h" - - -class RenderObjClass; -typedef unsigned short POLYGONINDEX; - - -/* -** -*/ -class IntersectionResultClass -{ -public: - RenderObjClass * IntersectedRenderObject; - POLYGONINDEX IntersectedPolygon; - - Matrix3D ModelMatrix; // this is required for transforming mesh normals from model coords - Vector3 ModelLocation; // ditto - Vector3 Intersection; // location of intersection is placed here - - float Range; // distance from ray to point of intersection - float Alpha, Beta; // stored for use by Process_Intersection_Results() - used to interpolate normal across a polygon - bool Intersects; // could be in the intersection_type, but it is used in a number of bool operations - int CollisionType; // mask for which object types to intersect with (added for 'Generals'. MW) - - enum INTERSECTION_TYPE { - NONE = 0, - GENERIC, - POLYGON - } IntersectionType; -}; - - -class IntersectionClass -{ - // member data - -public: - enum { - MAX_POLY_INTERSECTION_COUNT = 1000, // arbitrary size of stack array used for storing intersection results within Intersect_Mesh(). Non-recursive function. - MAX_HIERARCHY_NODE_COUNT = 256 - }; - - // this structure is used to store all intersections on the stack for sorting before - // copying the nearest intersection to IntersectionClassObject->Result. - // note: the convex intersection functions return with the first intersection results. - - Vector3 *RayLocation; // note: these pointers must be Set() to valid pointers by external code - Vector3 *RayDirection; - Vector3 *IntersectionNormal; // if non-zero then Process_Intersection_Results() will place the (perhaps vertex interpolated) surface normal here. - - // 2d screen coordinates for use by Intersect_Screen_Point...() routines. - float ScreenX, ScreenY; - - // if true, then interpolate the normal for a polygon intersection from the vertex normals. - // note: intersection routines below which take a FinalResult argument do not interpolate - // the normal since they are intended to be used to find the nearest of several intersections - // and interpolating the normal for intersections that are tossed would be wasteful. - // If you need the normal interpolated in that case anyways then call Interpolate_Normal(). - bool InterpolateNormal; - - // if true, then perform potentially much faster convex intersection test which will return - // the first valid intersection. Generally used for producing silhouettes. - // If true, all intersections will be convex tests. If false, test mode will be determined (generally) - // by the render object or whatever called the intersection functions and passes the Convex argument. - bool ConvexTest; - - // do not consider intersections beyond this range as an intersection. - // Note: Get_Screen_Ray sets this to scene->zstop. - float MaxDistance; - - // final intersection results are contained here - IntersectionResultClass Result; - - // - // Implementation - // - - // configures the member data to use the passed pointers - inline void Set(Vector3 *location, Vector3 *direction, Vector3 *intersection_normal, bool interpolate_normal, float max_distance, bool convex_test = false) - { - RayLocation = location; - RayDirection = direction; - IntersectionNormal = intersection_normal; - InterpolateNormal = interpolate_normal; - MaxDistance = max_distance; - ConvexTest = convex_test; - } - - - - // this constructor uses static variables for the location/direction/normal variables - // so can be only used one thread at a time unless the Set() function is used to - // set them to private vector3's - inline IntersectionClass() - : ConvexTest(false) - { - RayLocation = &_RayLocation; - RayDirection = &_RayDirection; - IntersectionNormal = &_IntersectionNormal; - Result.CollisionType=COLL_TYPE_ALL; //added for 'Generals'. MW - } - - - // This will be the most commonly used constructor - inline IntersectionClass(Vector3 *location, Vector3 *direction, Vector3 *intersection_normal, bool interpolate_normal = false, float max_distance = WWMATH_FLOAT_MAX, bool convex_test = false) - { - Set(location, direction, intersection_normal, interpolate_normal, max_distance, convex_test); - } - - - virtual ~IntersectionClass() {} - - - // this copy routine is used when the model coords are needed to be copied along with the other information. - inline void Copy_Results(IntersectionResultClass *Destination, IntersectionResultClass *Source) { - Destination->ModelMatrix = Source->ModelMatrix; - Destination->ModelLocation = Source->ModelLocation; - Copy_Partial_Results(Destination, Source); - Destination->IntersectedRenderObject = Source->IntersectedRenderObject; - } - - - inline void Copy_Results(IntersectionResultClass *Source) { - Copy_Results(&Result, Source); - } - - - // this is called only for the nearest intersection. If the request passes a Interpolated_Normal pointer then it will be calculated. - // otherwise the results are copied into the request structure. - // This does not copy the matrix or location members; it is intended to be used during poly testing - // where these values are identical between results, or as a completion function for Copy_Results() - inline void Copy_Partial_Results(IntersectionResultClass *Destination, IntersectionResultClass *Source) - { - Destination->IntersectedPolygon = Source->IntersectedPolygon; - Destination->Intersection = Source->Intersection; - Destination->Range = Source->Range; - Destination->Alpha = Source->Alpha; - Destination->Beta = Source->Beta; - Destination->Intersects = true; - Destination->IntersectionType = Source->IntersectionType; - } - - - // used for creating temporary copies - inline IntersectionClass(IntersectionClass *source) - { - *this = source; - } - - - inline IntersectionClass *operator =(IntersectionClass *source) - { - Set(source->RayLocation, source->RayDirection, source->IntersectionNormal, source->InterpolateNormal, source->MaxDistance, source->ConvexTest); - Copy_Results(&source->Result); - return this; - } - - - - // find the range to the intersection of the ray and sphere (if any) - // note: Intersection_Request->RayDirection must be a unit vector - // To find the actual intersection location and perhaps the intersection normal, use Intersection_Sphere() instead. - // loosly based on code found in Graphics Gems I, p388 - // this will only set the result's range if intersection occurs; it is intended to be used as a first pass intersection test - // before intersecting the mesh polygons itself. - // Note: Does NOT do Max_Distance testing - inline bool Intersect_Sphere_Quick(SphereClass &Sphere, IntersectionResultClass *FinalResult) - { - // make a unit vector from the ray origin to the sphere center - Vector3 sphere_vector(Sphere.Center - *RayLocation); - - // get the dot product between the sphere_vector and the ray vector - FinalResult->Alpha = Vector3::Dot_Product(sphere_vector, *RayDirection); - - FinalResult->Beta = Sphere.Radius * Sphere.Radius - (Vector3::Dot_Product(sphere_vector, sphere_vector) - FinalResult->Alpha * FinalResult->Alpha); - - if(FinalResult->Beta < 0.0f) { - return FinalResult->Intersects = false; - } - return FinalResult->Intersects = true; - } - - - // this will find the intersection with the sphere and the intersection normal if needed. - inline bool Intersect_Sphere(SphereClass &Sphere, IntersectionResultClass *FinalResult) - { - if(!Intersect_Sphere_Quick(Sphere, FinalResult)) - return false; - - // determine range to intersection based on stored alpha/beta values - float d = sqrtf(FinalResult->Beta); - FinalResult->Range = FinalResult->Alpha - d; - - if(FinalResult->Range > MaxDistance) return false; - - FinalResult->Intersection = *RayLocation + FinalResult->Range * (*RayDirection); - - if(IntersectionNormal != 0) { - (*IntersectionNormal) = FinalResult->Intersection - Sphere.Center; - } - return true; - } - - - // inline declarations - // Usage of these functions requires including intersec.inl - - // determine location & direction for projected screen coordinate ray - inline void Get_Screen_Ray(float ScreenX, float ScreenY, const LayerClass &Layer); - - // uses the Result's range & the Ray_Direction to calculate the actual point of intersection. - inline void Calculate_Intersection(IntersectionResultClass *Result); - - // interpolate the normal for a polygon intersection. Will ONLY work for polygon intersections, - // and the Results.Intersection_Data must refer to a polygon with a valid ->mesh pointer. - inline void Interpolate_Intersection_Normal(IntersectionResultClass *FinalResult); - - // various methods for performing intersections. - inline bool Intersect_Plane(IntersectionResultClass *Result, Vector3 &Plane_Normal, Vector3 &Plane_Point); - inline bool Intersect_Plane_Quick(IntersectionResultClass *Result, Vector3 &Plane_Normal, Vector3 &Plane_Point); - inline bool Intersect_Polygon(IntersectionResultClass *Result, Vector3 &PolygonNormal, Vector3 &v1, Vector3 &v2, Vector3 &v3); - inline bool Intersect_Polygon(IntersectionResultClass *Result, Vector3 &v1, Vector3 &v2, Vector3 &v3); - inline bool Intersect_Polygon_Z(IntersectionResultClass *Result, Vector3 &PolygonNormal, Vector3 &v1, Vector3 &v2, Vector3 &v3); - - /* - ** This function will fill the passed array with the set of points & uv values that represent - ** the boolean operation of the anding of the ClipPoints with the TrianglePoints. The UV values - ** provided for the TrianglePoints triangle are used to generate accurate UV values for any - ** new points created by this operation. - ** The clipped points have Z values that make them sit on the ClipPoints triangle plane. - */ - static inline int _Intersect_Triangles_Z( - Vector3 ClipPoints[3], - Vector3 TrianglePoints[3], - Vector2 UV[3], - Vector3 ClippedPoints[6], - Vector2 ClippedUV[6] - ); - - /* - ** This function will find the z elevation for the passed Vector3 whose x/y components - ** are defined, using the specified vertex & surface normal to determine the correct value - */ - static inline float _Get_Z_Elevation(Vector3 &Point, Vector3 &PlanePoint, Vector3 &PlaneNormal); - - - // test a 2d screen area with the intersection's screen coords, assigning a GENERIC intersection - // to the specified object. - inline bool Intersect_Screen_Object(IntersectionResultClass *Final_Result, Vector4 &Area, RenderObjClass *obj = 0); - - - // non-inlined declarations - - - // accumulates an object array for passing into Intersect_ObjectArray - void Append_Object_Array(int MaxCount, int &CurrentCount, RenderObjClass **ObjectArray, RenderObjClass *Object); - - // traverses an RenderObjClass object and adds it's subobjects, potentially performing - // a quick sphere intersection test before adding. - void Append_Hierarchy_Objects(int MaxCount, int &CurrentCount, RenderObjClass **ObjectArray, RenderObjClass *Heirarchy, bool Test_Bounding_Spheres, bool Convex); - - // top level intersection routines, most store intersection results in the Intersection.Result - // member structure and perform normal interpolation as a final step if indicated in the member data. - - bool Intersect_Object_Array(int ObjectCount, RenderObjClass **ObjectArray,IntersectionResultClass *FinalResult, bool Test_Bounding_Sphere, bool Convex); - bool Intersect_Object_Array(int ObjectCount, RenderObjClass **ObjectArray,IntersectionResultClass *FinalResult, IntersectionResultClass *TemporaryResults, bool Test_Bounding_Sphere, bool Convex); - bool Intersect_RenderObject(RenderObjClass *RObj, IntersectionResultClass *FinalResult = 0); - bool Intersect_Screen_Point_RenderObject(float screen_x, float screen_y, const LayerClass &Layer, RenderObjClass *RObj, IntersectionResultClass *FinalResult); - - bool Intersect_Screen_Point_Layer_Range(float ScreenX, float ScreenY, const LayerClass &TopLayer, const LayerClass &BackLayer); - bool Intersect_Screen_Point_Layer(float ScreenX, float ScreenY, const LayerClass &Layer); - bool Intersect_Layer(const LayerClass &Layer, bool Test_All = true); - - // the various intersection routines, all of which store their intersection results - // in the passed Intersection_Result strucuture. - bool Intersect_Box(Vector3 &Box_Min, Vector3 &Box_Max, IntersectionResultClass *FinalResult); - bool Intersect_Hierarchy(RenderObjClass *Hierarchy, IntersectionResultClass *FinalResult, bool Test_Bounding_Sphere = true, bool Convex = false); - bool Intersect_Hierarchy_Sphere(RenderObjClass *Hierarchy, IntersectionResultClass *FinalResult); - bool Intersect_Hierarchy_Sphere_Quick(RenderObjClass *Hierarchy, IntersectionResultClass *FinalResult); - - /* - ** Identifies exactly what sub object of a render object is under the screen space vector - */ - RenderObjClass *Intersect_Sub_Object(float screenx, float screeny, LayerClass &layer, RenderObjClass *robj, IntersectionResultClass *result); - - - /* - ** Functions related to determining if a 3d point is within a triangle. - */ - static inline void _Find_Polygon_Dominant_Plane(Vector3 &Normal, int &Axis_1, int &Axis_2); - static inline int _Largest_Normal_Index(Vector3 &v); - static inline bool _Point_In_Polygon(IntersectionResultClass *FinalResult, Vector3 &Normal, Vector3 &loc1, Vector3 &loc2, Vector3 &loc3); - static inline bool _Point_In_Polygon(IntersectionResultClass *FinalResult, Vector3 &loc1, Vector3 &loc2, Vector3 &loc3, int axis_1, int axis_2); - static inline bool _Point_In_Polygon(Vector3 &Point, Vector3 &loc1, Vector3 &loc2, Vector3 &loc3, int axis_1, int axis_2,float &Alpha,float &Beta); - static inline bool _Point_In_Polygon_Z(Vector3 &Point, Vector3 Corners[3]); - static inline bool _Point_In_Polygon_Z(Vector3 &Point, Vector3 &Corner1, Vector3 &Corner2, Vector3 &Corner3); - -protected: - - /* - ** Find the intersection between two lines and interpolate the UV values for the intersection. - ** Designed for use with _Intersect_Triangles_Z. - */ - //static inline void _Intersect_Lines_Z(Vector3 &A, Vector3 &B, Vector2 &UVStart, Vector2 &UVEnd, Vector3 &C, Vector3 &D, Vector3 ClippedPoints[6], Vector2 ClippedUV[6], int &DestIndex); - static inline bool In_Front_Of_Line - ( - const Vector3 & p, // point to test - const Vector3 & e0, // point on edge - const Vector3 & de // direction of edge - ); - - static inline float Intersect_Lines - ( - const Vector3 & p0, // start of line segment - const Vector3 & p1, // end of line segment - const Vector3 & e0, // point on clipping edge - const Vector3 & de // direction of clipping edge - ); - - static inline int Clip_Triangle_To_LineXY( - int incount, - Vector3 * InPoints, - Vector2 * InUVs, - Vector3 * OutPoints, - Vector2 * OutUVs, - const Vector3 & edge_point0, - const Vector3 & edge_point1 - ); - - - - inline float Plane_Z_Distance(Vector3 &PlaneNormal, Vector3 &PlanePoint); - inline void Transform_Model_To_World_Coords(IntersectionResultClass *FinalResult); - - /* - ** Static vars available for use by temporary intersection class objects. - */ - static Vector3 _RayLocation, _RayDirection, _IntersectionNormal; - -}; - - -#endif diff --git a/Generals/Code/Libraries/Source/WWVegas/WW3D2/intersec.inl b/Generals/Code/Libraries/Source/WWVegas/WW3D2/intersec.inl deleted file mode 100644 index a76df398fc4..00000000000 --- a/Generals/Code/Libraries/Source/WWVegas/WW3D2/intersec.inl +++ /dev/null @@ -1,1096 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - - -#if defined(_MSC_VER) -#pragma once -#endif - -#ifndef INTERSEC_INL -#define INTERSEC_INL - -#include "camera.h" - - -/// debug code that will be tossed - -#ifdef DEBUG_NORMALS - -#include "d:/g/app/main/debug_o.h" - -inline bool Verify_Normal(Vector3 &Normal, Vector3 &loc1, Vector3 &loc2, Vector3 &loc3) -{ - - double d1 = Vector3::Dot_Product(Normal, loc1); - double d2 = Vector3::Dot_Product(Normal, loc2); - double d3 = Vector3::Dot_Product(Normal, loc3); - - double e1 = d1 - d2; - double e2 = d2 - d3; - double e3 = d3 - d1; - - if((fabs(e1) > 0.001) || (fabs(e2) > 0.001) || (fabs(e3) > 0.001)) { - Debug.Print("----------\n"); - Debug.Print("dots", Vector3(d1,d2,d3)); - Debug.Print("err", Vector3(e1,e2,e3)); - return false; - } - return true; -} - -inline void Verify_Normal2(Vector3 &Normal, Vector3 &loc1, Vector3 &loc2, Vector3 &loc3) -{ - Vector3 v1 = loc2 - loc1; - Vector3 v2 = loc3 - loc1; - Vector3 normal = Vector3::Cross_Product(v1,v2); - normal.Normalize(); - if(!Verify_Normal(Normal, loc1,loc2,loc3)) { - Vector3 diff = Normal - normal; - if(Verify_Normal(normal, loc1,loc2,loc3)) { - Debug.Print("calculated worked.\n"); - - } - } -// Normal = normal; -} - -#endif - -//// end of debug code to toss - -/* -** Determine the ray that corresponds to the specified screen coordinates with respect -** to the camera location, direction and projection information. -*/ - -inline void IntersectionClass::Get_Screen_Ray(float screen_x, float screen_y, const LayerClass &Layer) -{ - - // copy screen coords to member data - ScreenX = screen_x; - ScreenY = screen_y; - - // extract needed pointers from the world - CameraClass *camera = Layer.Camera; - - // determine the ray corresponding to the camera and distance to projection plane - Matrix3D camera_matrix = camera->Get_Transform(); - Vector3 camera_location = camera->Get_Position(); - - // the projected ray has the same origin as the camera - *RayLocation = camera_location; - -// these 6 lines worked for SR 1.1 -// build the projected screen vector -// float x_offset = width / (float)Scene->width; // render width in pixels divided by display width in pixels = ratio of displayed area -// float y_offset = height / (float)Scene->height; -// float zmod = Scene->perspective; -// float xmod = ((ScreenX / x_offset) * width - xmid - Scene->xstart) * zmod * 16384.0f/ (Scene->axratio * 128.0f); -// float ymod = ((ScreenY / y_offset) * height - ymid - Scene->ystart) * zmod * 16384.0f/ (Scene->ayratio * 128.0f); - - // determine the location of the screen coordinate in camera-model space - const ViewportClass &viewport = camera->Get_Viewport(); - -// float aspect = camera->Get_Aspect_Ratio(); - - Vector2 min,max; - camera->Get_View_Plane(min,max); - float xscale = (max.X - min.X); - float yscale = (max.Y - min.Y); - - float zmod = -1.0; // Scene->vpd; // Note: view plane distance is now always 1.0 from the camera - float xmod = (-ScreenX + 0.5 + viewport.Min.X) * zmod * xscale;// / aspect; - float ymod = (ScreenY - 0.5 - viewport.Min.Y) * zmod * yscale;// * aspect; - -// float xmod = (ScreenX - 0.5 - viewport.Min.X) * zmod / Scene->axratio; -// float ymod = (ScreenY - 0.5 - viewport.Min.Y) * zmod / Scene->ayratio; - -// sr1.2 -// float xmod = (ScreenX - 0.5 - Scene->xstart) * zmod / Scene->axratio; -// float ymod = (ScreenY - 0.5 - Scene->ystart) * zmod / Scene->ayratio; -// sr1.1 -// float xmod = x_offset * zmod; //projection_width; -// float ymod = y_offset * zmod; //projection_height; - - // transform the screen coordinates by the camera's matrix into world coordinates. - float x = zmod * camera_matrix[0][2] + xmod * camera_matrix[0][0] + ymod * camera_matrix[0][1]; - float y = zmod * camera_matrix[1][2] + xmod * camera_matrix[1][0] + ymod * camera_matrix[1][1]; - float z = zmod * camera_matrix[2][2] + xmod * camera_matrix[2][0] + ymod * camera_matrix[2][1]; - - RayDirection->Set(x,y,z); - RayDirection->Normalize(); - - // set the maximum intersection distance to the back clipping plane - MaxDistance = camera->Get_Depth(); - //Max_Distance = Scene->zstop * Scene->depth; - -} - -/* -** This is the Point_In_Polygon_Z low level function, optimized for use by _Intersect_Triangles_Z. -** If it is inside, it will adjust the Z value of the point to be on the triangle plane. -*/ -inline bool IntersectionClass::_Point_In_Polygon_Z( - Vector3 &Point, - Vector3 &Corner1, - Vector3 &Corner2, - Vector3 &Corner3 -) -{ -// these defines could be variables if support for other axis were neccessary -#define AXIS_1 0 -#define AXIS_2 1 -#define AXIS_3 2 - - double u0 = Point[AXIS_1] - Corner1[AXIS_1]; - double v0 = Point[AXIS_2] - Corner1[AXIS_2]; - - // determine the 2d vectors on the dominant plane from the first vertex to the other two - double u1 = Corner2[AXIS_1] - Corner1[AXIS_1]; - double v1 = Corner2[AXIS_2] - Corner1[AXIS_2]; - double u2 = Corner3[AXIS_1] - Corner1[AXIS_1]; - double v2 = Corner3[AXIS_2] - Corner1[AXIS_2]; - - double alpha, beta; - bool intersect = false; - - // calculate alpha and beta as normalized (0..1) percentages across the 2d projected triangle - // and do bounds checking (sum <= 1) to determine whether or not the triangle intersection occurs. - - if (u1 == 0.0f) { - beta = u0 / u2; // beta is the percentage down the edge Corner1->Corner3 - if ((beta >= 0.0f) && (beta <= 1.0f)) { // make sure it's within the edge segment - alpha = (v0 - beta * v2) / v1; // alpha is the percentage down the edge Corner1->Corner2 - - // if alpha is valid & the sum of alpha & beta is <= 1 then it's within the triangle - // note: 0.00001 added after testing an intersection of a square in the middle indicated - // an error of 0.0000001350, apparently due to roundoff. - intersect = ((alpha >= 0.0) && ((alpha + beta) <= 1.0)); - } - } else { - beta = (v0 * u1 - u0 * v1) / (v2 * u1 - u2 * v1); - if ((beta >= 0.0) && (beta <= 1.0)) { - alpha = (u0 - beta * u2) / u1; - intersect = ((alpha >= 0.0) && ((alpha + beta) <= 1.0)); - } - } - - // if it is inside, adjust the Z value to sit upon the triangle plane. - if(intersect) { - float u3 = Corner2[AXIS_3] - Corner1[AXIS_3]; - float v3 = Corner3[AXIS_3] - Corner1[AXIS_3]; - - Point[AXIS_3] = u3 * alpha + v3 * beta + Corner1[AXIS_3]; - } - - return intersect; -} - -/* -** Another way to access the Point_In_Polygon function -** -*/ -inline bool IntersectionClass::_Point_In_Polygon_Z( - Vector3 &Point, - Vector3 Corners[3] -) -{ - return _Point_In_Polygon_Z(Point, Corners[0], Corners[1], Corners[2]); -} - -/* -** This is the general purpose Point_In_Polygon low level function. It can be called directly if you know -** the dominant projection axes, such as in the case of 2d intersecion with heightfields. -*/ -inline bool IntersectionClass::_Point_In_Polygon( - Vector3 &Point, - Vector3 &loc1, - Vector3 &loc2, - Vector3 &loc3, - int axis_1, - int axis_2, - float &Alpha, - float &Beta) -{ - - double u0 = Point[axis_1] - loc1[axis_1]; - double v0 = Point[axis_2] - loc1[axis_2]; - - // determine the 2d vectors on the dominant plane from the first vertex to the other two - double u1 = loc2[axis_1] - loc1[axis_1]; - double v1 = loc2[axis_2] - loc1[axis_2]; - double u2 = loc3[axis_1] - loc1[axis_1]; - double v2 = loc3[axis_2] - loc1[axis_2]; - - double alpha, beta; - bool intersect = false; - - // calculate alpha and beta as normalized (0..1) percentages across the 2d projected triangle - // and do bounds checking (sum <= 1) to determine whether or not the triangle intersection occurs. - -#ifdef DEBUG_NORMALS - bool debugmode = false; - if(FinalResult->Alpha == 777) { - debugmode = true; - } -#endif - - if (u1 == 0.0f) { - Beta = beta = u0 / u2; // beta is the percentage down the edge loc1->loc3 - if ((beta >= 0.0f) && (beta <= 1.0f)) { // make sure it's within the edge segment - Alpha = alpha = (v0 - beta * v2) / v1; // alpha is the percentage down the edge loc1->loc2 - - // if alpha is valid & the sum of alpha & beta is <= 1 then it's within the triangle - // note: 0.00001 added after testing an intersection of a square in the middle indicated - // an error of 0.0000001350, apparently due to roundoff. - intersect = ((alpha >= 0.0) && ((alpha + beta) <= 1.0)); - } - } else { - Beta = beta = (v0 * u1 - u0 * v1) / (v2 * u1 - u2 * v1); - if ((beta >= 0.0) && (beta <= 1.0)) { - Alpha = alpha = (u0 - beta * u2) / u1; - intersect = ((alpha >= 0.0) && ((alpha + beta) <= 1.0)); - } - } - -#ifdef DEBUG_NORMALS - if(debugmode) { - Debug.Print("Intersect", intersect); - Debug.Print("Normal ", Normal); - Debug.Print("Point 1", loc1); - Debug.Print("Point 2", loc2); - Debug.Print("Point 3", loc3); - Debug.Print("Inter ", FinalResult->Intersection); - Debug.Print("a/b", (float) alpha, (float) beta); - Debug.Print("sum", (float) alpha + (float) beta); - Debug.Print("diff", (float) (alpha - beta)); - float d1 = Vector3::Dot_Product(Normal, loc1); - float d2 = Vector3::Dot_Product(Normal, loc2); - float d3 = Vector3::Dot_Product(Normal, loc3); - - float e1 = d1 - d2; - float e2 = d2 - d3; - float e3 = d3 - d1; - - Debug.Print("dots", Vector3(d1,d2,d3)); - Debug.Print("err", Vector3(e1,e2,e3)); - } -#endif - - - return intersect; -} - -/* -** This version calls the base form using member data from the FinalResult struct for -** some of it's arguments. -*/ -inline bool IntersectionClass::_Point_In_Polygon( - IntersectionResultClass *FinalResult, - Vector3 &loc1, - Vector3 &loc2, - Vector3 &loc3, - int axis_1, - int axis_2) -{ - return (FinalResult->Intersects = _Point_In_Polygon( FinalResult->Intersection, loc1, loc2, loc3, - axis_1, axis_2, FinalResult->Alpha, FinalResult->Beta)); -} - -/* -** This version determines the dominant plane of the 3d triangle to be point-in-poly tested -** and then calls the next form of _Point_In_Polygon -*/ -inline bool IntersectionClass::_Point_In_Polygon(IntersectionResultClass *FinalResult, Vector3 &Normal, Vector3 &loc1, Vector3 &loc2, Vector3 &loc3) { - - // first, find the dominant axis and use the plane perpendicular to it as defined by axis_1, axis_2 - int axis_1, axis_2; - _Find_Polygon_Dominant_Plane(Normal, axis_1, axis_2); - - return _Point_In_Polygon(FinalResult, loc1, loc2, loc3, axis_1, axis_2); -} - - -/* -** Determine the Z distance to the specified polygon. -*/ -inline float IntersectionClass::Plane_Z_Distance(Vector3 &PlaneNormal, Vector3 &PlanePoint) -{ - // do a parallel check - float divisor = (PlaneNormal[0] *(*RayDirection)[0] + PlaneNormal[1] *(*RayDirection)[1] + PlaneNormal[2] * (*RayDirection)[2]); - if(divisor == 0) return false; // parallel - - // determine distance to plane - double d = - (PlanePoint[0] * PlaneNormal[0] + PlanePoint[1] * PlaneNormal[1] + PlanePoint[2] * PlaneNormal[2]); - - float value = - (d + PlaneNormal[0] * (*RayLocation)[0] + PlaneNormal[1] * (*RayLocation)[1] + PlaneNormal[2] * (*RayLocation)[2]) / divisor; - - return value; -} - -/* -** This function will find the z elevation for the passed Vector3 whose x/y components -** are defined, using the specified vertex & surface normal to determine the correct value -*/ -inline float IntersectionClass::_Get_Z_Elevation( - Vector3 &Point, - Vector3 &PlanePoint, - Vector3 &PlaneNormal) -{ - - // do a parallel check - if(PlaneNormal[2] == 0) return false; - - // determine distance to plane - double d = - (PlanePoint[0] * PlaneNormal[0] + PlanePoint[1] * PlaneNormal[1] + PlanePoint[2] * PlaneNormal[2]); - - float value = - (d + PlaneNormal[0] * Point[0] + PlaneNormal[1] * Point[1] ) / PlaneNormal[2]; - - return value; -} - -/* -** Optimized intersection test that only considers the x/y component of the intersection object -** and will determine the intersection location down the Z axis. -*/ -inline bool IntersectionClass::Intersect_Polygon_Z(IntersectionResultClass *Result, Vector3 &PolygonNormal, Vector3 &v1, Vector3 &v2, Vector3 &v3) -{ - - Result->Range = Plane_Z_Distance(PolygonNormal, v1); - (Result->Intersection)[0] = (*RayLocation)[0]; - (Result->Intersection)[1] = (*RayLocation)[1]; - (Result->Intersection)[2] = (*RayLocation)[2] - Result->Range; - return _Point_In_Polygon(Result, PolygonNormal, v1, v2, v3); -} - - -/* -** Scale the normalized direction ray to the distance of intersection -*/ -void IntersectionClass::Calculate_Intersection(IntersectionResultClass *Result) -{ - (Result->Intersection)[0] = (*RayLocation)[0] + (*RayDirection)[0] * Result->Range; - (Result->Intersection)[1] = (*RayLocation)[1] + (*RayDirection)[1] * Result->Range; - (Result->Intersection)[2] = (*RayLocation)[2] + (*RayDirection)[2] * Result->Range; -} - -/* -** Plane intersection test that assumes a normalized RayDirection. Only determines if -** plane is parallel and if not, the range to it (which may be negative or beyond MaxRange). -** It doesn't determine point of intersection either. -*/ -inline bool IntersectionClass::Intersect_Plane_Quick(IntersectionResultClass *Result, Vector3 &PlaneNormal, Vector3 &PlanePoint) -{ - // do a parallel check - float divisor = (PlaneNormal[0] *(*RayDirection)[0] + PlaneNormal[1] *(*RayDirection)[1] + PlaneNormal[2] * (*RayDirection)[2]); - if(divisor == 0) return false; // parallel - - // determine distance to plane - float d = - (PlanePoint[0] * PlaneNormal[0] + PlanePoint[1] * PlaneNormal[1] + PlanePoint[2] * PlaneNormal[2]); - Result->Range = - (d + PlaneNormal[0] * (*RayLocation)[0] + PlaneNormal[1] * (*RayLocation)[1] + PlaneNormal[2] * (*RayLocation)[2]) / divisor; - - return true; -} - -/* -** Determine if the specified ray will intersect the plane; returns false for planes -** parallel and behind ray origin. -** Sets Range to the distance from the ray location to the intersection. -** Note: Range is undefined if an intersection didn't occur. -*/ -inline bool IntersectionClass::Intersect_Plane(IntersectionResultClass *Result, Vector3 &PlaneNormal, Vector3 &PlanePoint) { - - // normalize the ray direction - RayDirection->Normalize(); - - // call the quick test routine - if(!Intersect_Plane_Quick(Result, PlaneNormal, PlanePoint)) return false; - - // check to make sure it's not behind the ray's origin - if(Result->Range <= 0) return false; - - // check to make sure it's not beyond max distance - if(Result->Range > MaxDistance) return false; - - // determine point of intersection - Calculate_Intersection(Result); - - return true; -} - - - -/* -** Return the index of the largest normal component 0..2 -** used by Find_Triangle_Dominant_Plane() -*/ -inline int IntersectionClass::_Largest_Normal_Index(Vector3 &v) -{ - float x = fabsf(v[0]); - float y = fabsf(v[1]); - float z = fabsf(v[2]); - if(x > y) { - if(x > z) { - return 0; // x > y && x > z --> x is the max - } - return 2; // x > y && !(x > z) --> z is the max - } - if(y > z) - return 1; // x <= y && y > z --> y is the max - return 2; // y > x && y > z --> z is the max -} - -/* -** Use the Polygon's currently defined surface normal to determine it's dominant axis. -** Axis_1 and Axis_2 are set to the indices of the two axis that define the dominant plane. -*/ -inline void IntersectionClass::_Find_Polygon_Dominant_Plane(Vector3 &Normal, int &Axis_1, int &Axis_2) -{ - switch (_Largest_Normal_Index(Normal)) - { - case 0: - // Dominant is the X axis - Axis_1 = 2; - Axis_2 = 1; - break; - case 1: - // Dominant is the Y axis - Axis_1 = 2; - Axis_2 = 0; - break; - case 2: - // Dominant is the Z axis - Axis_1 = 0; - Axis_2 = 1; - break; - } -} - -/* -** Returns true if ray intersects polygon. -** Changes passed Intersection argument to location of intersection if it occurs, -** and sets Range to the distance from the ray location to the intersection. -** If Interpolated_Normal is specified it will interpolate the surface normal based -** on the vertex normals. -*/ -inline bool IntersectionClass::Intersect_Polygon(IntersectionResultClass *Result, Vector3 &PolygonNormal, Vector3 &v1, Vector3 &v2, Vector3 &v3) -{ - // first check to see if it hits the plane; determine plane normal and find point on plane (from a vertex) - -#ifdef DEBUG_NORMALS - Verify_Normal2(PolygonNormal, v1,v2,v3); -#endif - - if(Intersect_Plane(Result, PolygonNormal, v1)) { - // then check to see if it it actually intersects the polygon. - return _Point_In_Polygon(Result, PolygonNormal, v1, v2, v3); - } - // doesn't even hit the plane, return false. - return false; -} - -/* -** This version will calc the normal for the polygon before calling -** a lower form of Intersect_Polygon -*/ -inline bool IntersectionClass::Intersect_Polygon(IntersectionResultClass *Result, Vector3 &v1, Vector3 &v2, Vector3 &v3) -{ - Vector3 vec1 = v2 - v1; - Vector3 vec2 = v3 - v1; -#ifdef ALLOW_TEMPORARIES - Vector3 normal = Vector3::Cross_Product(vec1, vec2); -#else - Vector3 normal; - Vector3::Cross_Product(vec1, vec2, &normal); -#endif - - return Intersect_Polygon(Result, normal, v1,v2,v3); -} - - -// called after Interpolate_Intersection_Normal. -// transform the intersection and the normal from model coords into world coords -inline void IntersectionClass::Transform_Model_To_World_Coords(IntersectionResultClass *FinalResult) -{ -#ifdef ALLOW_TEMPORARIES - FinalResult->Intersection = FinalResult->ModelMatrix * FinalResult->Intersection + FinalResult->ModelLocation; - if(IntersectionNormal != 0) - { - Vector3 normal(*IntersectionNormal); - *IntersectionNormal = FinalResult->ModelMatrix * normal; - } -#else - FinalResult->ModelMatrix.mulVector3(FinalResult->Intersection); - FinalResult->Intersection += FinalResult->ModelLocation; - if(IntersectionNormal != 0) - { - FinalResult->ModelMatrix.mulVector3(*IntersectionNormal); - } -#endif -} - - - -bool IntersectionClass::Intersect_Screen_Object( IntersectionResultClass *Final_Result, - Vector4 &Area, - RenderObjClass *obj) -{ - if(Final_Result->Intersects = ((ScreenX >= Area[0]) && (ScreenX <= Area[2]) && (ScreenY >= Area[1]) && (ScreenY <= Area[3]))) { - Final_Result->IntersectionType = IntersectionResultClass::GENERIC; - Final_Result->IntersectedRenderObject = obj; - Final_Result->Range = 0; - return true; - } - return false; -} - - -/* -** Determines the point of intersection, if any between the line segments AB and CD. -** If an intersection occurs, then the UV values are interpolated along AB. -** Disregards the Z value and considers only the X/Y data except for determining -** the Z value of the intersection. -** This function could be easily modified to support other axes. -* / -void IntersectionClass::_Intersect_Lines_Z( - Vector3 &A, - Vector3 &B, - Vector2 &UVStart, - Vector2 &UVEnd, - Vector3 &C, - Vector3 &D, - Vector3 ClippedPoints[6], - Vector2 ClippedUV[6], - int &DestIndex) -{ - /* - Let A,B,C,D be 2-space position vectors. Then the directed line segments AB & CD are given by: - - AB=A+r(B-A), r in [0,1] - CD=C+s(D-C), s in [0,1] - If AB & CD intersect, then - - A+r(B-A)=C+s(D-C), or - - Ax+r(Bx-Ax)=Cx+s(Dx-Cx) - Ay+r(By-Ay)=Cy+s(Dy-Cy) for some r,s in [0,1] - Solving the above for r and s yields - - (Ay-Cy)(Dx-Cx)-(Ax-Cx)(Dy-Cy) - r = ----------------------------- (eqn 1) - (Bx-Ax)(Dy-Cy)-(By-Ay)(Dx-Cx) - (Ay-Cy)(Bx-Ax)-(Ax-Cx)(By-Ay) - s = ----------------------------- (eqn 2) - (Bx-Ax)(Dy-Cy)-(By-Ay)(Dx-Cx) - Let P be the position vector of the intersection point, then - - P=A+r(B-A) or - - Px=Ax+r(Bx-Ax) - Py=Ay+r(By-Ay) - By examining the values of r & s, you can also determine some other limiting conditions: - - If 0<=r<=1 & 0<=s<=1, intersection exists - r<0 or r>1 or s<0 or s>1 line segments do not intersect - If the denominator in eqn 1 is zero, AB & CD are parallel - - If the numerator in eqn 1 is also zero, AB & CD are coincident - - If the intersection point of the 2 lines are needed (lines in this context mean infinite lines) regardless whether the two line segments intersect, then - - If r>1, P is located on extension of AB - If r<0, P is located on extension of BA - If s>1, P is located on extension of CD - If s<0, P is located on extension of DC - * / - - // the numerator is required for all execution routes - float numerator = (A[AXIS_2] - C[AXIS_2]) * (D[AXIS_1] - C[AXIS_1]) - (A[AXIS_1] - C[AXIS_1]) * (D[AXIS_2] - C[AXIS_2]); - - // if the denominator is zero, then the segments are parallel. - float denominator = (B[AXIS_1] - A[AXIS_1]) * (D[AXIS_2] - C[AXIS_2]) - (B[AXIS_2] - A[AXIS_2]) * (D[AXIS_1] - C[AXIS_1]); - - // r & s are percentages through the line segment. - float r, s; - - // check to see if they are parallel - if(denominator == 0) { - - // check to see if they are coincident - // a numerator of zero with a denominator of zero indicates coincident lines. - if (numerator != 0) { - - // parallel, not coincident lines (and segments) do not intersect. - return; - } - - // perform special case for parallel segments - - // determine relative position 0..1 of C and D on one of the 1d vectors of A-B - float len = B[AXIS_1] - A[AXIS_1]; - float cpos,dpos; - - // if the length of the edge on the first axis is zero, use the other axis instead. - if(len) { - len = 1.0 / len; - cpos = (C[AXIS_1] - A[AXIS_1]) * len; - dpos = (D[AXIS_1] - A[AXIS_1]) * len; - } else { - len = B[AXIS_2] - A[AXIS_2]; - - // degenerate triangle test - if(len == 0) - return; - - len = 1.0 / len; - cpos = (C[AXIS_2] - A[AXIS_2]) * len; - dpos = (D[AXIS_2] - A[AXIS_2]) * len; - } - - // check to see if there's any overlap - // one of the two pos values must be 0>pos>1 or there is no intersection. - // this test will ensure that cpos & dpos will not both be outside the same end of the segment. - if(((cpos < 0) && (dpos < 0)) || ((cpos > 1) && (dpos > 1))) - return; - - if(cpos < 0) { - // C is outside, therefore D is inside or on other side. - // use the original vertex. - ClippedPoints[DestIndex] = A; - ClippedUV[DestIndex++] = UVStart; - } else if (cpos > 1) { - // C is outside far side, therefore D is inside or on other side. - // use the far vertex. - ClippedPoints[DestIndex] = B; - ClippedUV[DestIndex++] = UVEnd; - } else { - // C is inside. - // Use C as the vertex, and interpolate the UV coords. - ClippedPoints[DestIndex] = C; - ClippedUV[DestIndex++] = (UVEnd - UVStart) * cpos + UVStart; - } - - if(dpos < 0) { - // D is outside near vertex, therefore C is inside or outside far vertex - // use near vertex - ClippedPoints[DestIndex] = A; - ClippedUV[DestIndex++] = UVStart; - } else if (dpos > 1) { - // D is outside far vertex, therefore C is inside or outside the near vertex. - // use the far vertex. - ClippedPoints[DestIndex] = B; - ClippedUV[DestIndex++] = UVEnd; - } else { - // D is inside. - // Use D as the vertex, and interpolate the UV coords. - ClippedPoints[DestIndex] = D; - ClippedUV[DestIndex++] = (UVEnd - UVStart) * dpos + UVStart; - } - return; - - } - - // determine the percentage into the line segments that the intersection occurs. - // an intersection of segments will produce r & s values between 0 & 1. - denominator = 1.0 / denominator; - r = numerator * denominator; - - numerator = (A[AXIS_2] - C[AXIS_2]) * (B[AXIS_1] - A[AXIS_1]) - (A[AXIS_1] - C[AXIS_1]) * (B[AXIS_2] - A[AXIS_2]); - s = numerator * denominator; - - // determine if the line intersect within the defined segments. - if((0.0 <= r) && (r <= 1.0) && (0.0 <= s) && (s <= 1.0)) { - - // they intersect. - // determine intersection point - Vector3 v = D - C; -// float len = v.Length(); - ClippedPoints[DestIndex] = C + v * s; - - // interpolate UV values - Vector2 uv = UVEnd - UVStart; -// len = uv.Length(); - ClippedUV[DestIndex++] = UVStart + uv * r; - } -} - -/* - A failed attempt to use a graphics gem vol 2 example - - - // Compute a1, b1, c1, where line joining points 1 and 2 - // is "a1 x + b1 y + c1 = 0". - float a1 = B[AXIS_2] - A[AXIS_2]; - float b1 = B[AXIS_1] - A[AXIS_1]; - float c1 = B[AXIS_2] * A[AXIS_1] - A[AXIS_1] * B[AXIS_2]; - - // Compute r3 & r4, the sign values - float r3 = a1 * C[AXIS_1] + b1 * C[AXIS_2] + c1; - float r4 = a1 * D[AXIS_1] + b1 * D[AXIS_2] + c1; - - // Check signs of r3 and r4. If both point 3 and point 4 lie on - // same side of line 1, the line segments do not intersect. - if ( r3 != 0 && r4 != 0 && (((r3 < 0) && (r4 < 0)) || ((r3 > 0) && (r4 > 0))) - return; // ( DONT_INTERSECT ); - - // Compute a2, b2, c2 - float a2 = D[AXIS_2] - C[AXIS_2]; - float b2 = C[AXIS_1] - D[AXIS_1]; - float c2 = D[AXIS_1] * C[AXIS_2] - C[AXIS_1] * D[AXIS_2]; - - // Compute r1 and r2 - float r1 = a2 * A[AXIS_1] + b2 * A[AXIS_2] + c2; - float r2 = a2 * B[AXIS_1] + b2 * B[AXIS_2] + c2; - - // Check signs of r1 and r2. If both point 1 and point 2 lie - // on same side of second line segment, the line segments do - // not intersect. - if ( r1 != 0 && r2 != 0 && (((r1 < 0) && (r2 < 0)) || ((r1 > 0) && (r2 > 0)))) - return; // ( DONT_INTERSECT ); - - // Line segments intersect: compute intersection point. - float denom = a1 * b2 - a2 * b1; - if ( denom == 0 ) - return; // ( COLLINEAR ); - - float offset = denom < 0 ? - denom * 0.5f : denom * 0.5f; - - // The denom/2 is to get rounding instead of truncating. It - // is added or subtracted to the numerator, depending upon the - // sign of the numerator. - - float num = b1 * c2 - b2 * c1; - float x = ( num < 0 ? num - offset : num + offset ) / denom; - - num = a2 * c1 - a1 * c2; - float y = ( num < 0 ? num - offset : num + offset ) / denom; - - ClippedPoints[DestIndex] = Vector3(x,y,0); - ClippedUV[DestIndex++] = Vector3 - return; //( DO_INTERSECT ); // lines_intersect -*/ - -inline bool IntersectionClass::In_Front_Of_Line -( - const Vector3 & p, // point to test - const Vector3 & e0, // point on edge - const Vector3 & de // direction of edge -) -{ - Vector3 dp = p - e0; - float val = de.X*dp.Y - de.Y*dp.X; - if (val > 0.0f) { - return true; - } - return false; -} - -inline float IntersectionClass::Intersect_Lines -( - const Vector3 & p0, // start of line segment - const Vector3 & p1, // end of line segment - const Vector3 & e0, // point on clipping edge - const Vector3 & de // direction of clipping edge -) -{ - float dpx = p1.X - p0.X; - float dpy = p1.Y - p0.Y; - - float den = de.Y * dpx - de.X * dpy; - - if (fabs(den) > WWMATH_EPSILON) { - - float num = p0.Y*de.X - p0.X*de.Y + e0.X*de.Y - e0.Y*de.X; - float t = num/den; - if ((t >= 0.0f) && (t <= 1.0f)) { - return t; - } - } - - return 0.0f; -} - - -#define EMIT(p,uv) OutPoints[outnum] = p; OutUVs[outnum] = uv; outnum++; - - -inline int IntersectionClass::Clip_Triangle_To_LineXY( - int incount, - Vector3 * InPoints, - Vector2 * InUVs, - Vector3 * OutPoints, - Vector2 * OutUVs, - const Vector3 & edge_point0, - const Vector3 & edge_point1 -) -{ - Vector3 e0 = edge_point0; - Vector3 de = edge_point1 - edge_point0; - - // number of verts output. - int outnum = 0; - - // start and end verts of the current edge - int p0,p1; - p0 = incount-1; - - // intersection temporaries. - float intersection; - Vector3 intersection_point; - Vector2 intersection_uv; - - // loop over each edge in the input polygon - for (p1=0; p1in, emit intersection and endpoint - intersection = Intersect_Lines(InPoints[p0], InPoints[p1], e0, de); - intersection_point = (1.0f - intersection) * InPoints[p0] + intersection * InPoints[p1]; - intersection_uv = (1.0f - intersection) * InUVs[p0] + intersection * InUVs[p1]; - EMIT(intersection_point,intersection_uv); - EMIT(InPoints[p1],InUVs[p1]); - } - } else { - - if (In_Front_Of_Line(InPoints[p0], e0, de)) { - - // edge going in->out, emit intersection - intersection = Intersect_Lines(InPoints[p0],InPoints[p1], e0, de); - intersection_point = (1.0f - intersection) * InPoints[p0] + intersection * InPoints[p1]; - intersection_uv = (1.0f - intersection) * InUVs[p0] + intersection * InUVs[p1]; - EMIT(intersection_point,intersection_uv); - - } - - } - - // move to next edge - p0 = p1; - } - - return outnum; -} - -inline int IntersectionClass::_Intersect_Triangles_Z( - Vector3 ClipPoints[3], - Vector3 TrianglePoints[3], - Vector2 UV[3], - Vector3 ClippedPoints[6], - Vector2 ClippedUV[6] -) -{ - int count; - Vector3 tmp_points[6]; - Vector2 tmp_uv[6]; - - count = Clip_Triangle_To_LineXY(3,TrianglePoints,UV,ClippedPoints,ClippedUV,ClipPoints[0],ClipPoints[1]); - count = Clip_Triangle_To_LineXY(count,ClippedPoints,ClippedUV,tmp_points,tmp_uv,ClipPoints[1],ClipPoints[2]); - count = Clip_Triangle_To_LineXY(count,tmp_points,tmp_uv,ClippedPoints,ClippedUV,ClipPoints[2],ClipPoints[0]); - - return count; -} - -/* -** This function will fill the passed array with the set of points & uv values that represent -** the boolean operation of the anding of the ClipPoints with the TrianglePoints. The UV values -** provided for the TrianglePoints triangle are used to generate accurate UV values for any -** new points created by this operation. -** This function returns the number of vertices it required to define the intersection. -* / -int IntersectionClass::_Intersect_Triangles_Z( - Vector3 ClipPoints[3], - Vector3 TrianglePoints[3], - Vector2 UV[3], - Vector3 ClippedPoints[6], - Vector2 ClippedUV[6] -) -{ - // first, check to see if all triangle points are inside clip area - // the point in polygon will drop any inside points to the clip triangle plane. - bool inside[3]; - - bool noclip; - noclip = inside[0] = _Point_In_Polygon_Z(TrianglePoints[0], ClipPoints); - noclip &= inside[1] = _Point_In_Polygon_Z(TrianglePoints[1], ClipPoints); - noclip &= inside[2] = _Point_In_Polygon_Z(TrianglePoints[2], ClipPoints); - - // if all points are inside clip area, then copy the triangle points & - // UV's to the destination & return 3 (the number of points in the clipped polygon). - if(noclip) { - ClippedPoints[0] = TrianglePoints[0]; - ClippedPoints[1] = TrianglePoints[1]; - ClippedPoints[2] = TrianglePoints[2]; - ClippedUV[0] = UV[0]; - ClippedUV[1] = UV[1]; - ClippedUV[2] = UV[2]; - - return 3; - } - - int points = 0; // number of output polygon points - - // not all uv triangle points are inside the clip triangle. - // Test to see if any clip points are inside the uv triangle - float alpha, beta; - if(_Point_In_Polygon(ClipPoints[0], TrianglePoints[0], TrianglePoints[1], TrianglePoints[2], 0, 1, alpha, beta)) { - ClippedPoints[points] = ClipPoints[0]; - Vector2 uv1 = UV[1] - UV[0]; - Vector2 uv2 = UV[2] - UV[0]; - ClippedUV[points++] = UV[0] + alpha * uv1 + beta * uv2; - } - - if(_Point_In_Polygon(ClipPoints[1], TrianglePoints[0], TrianglePoints[1], TrianglePoints[2], 0, 1, alpha, beta)) { - ClippedPoints[points] = ClipPoints[1]; - Vector2 uv1 = UV[1] - UV[0]; - Vector2 uv2 = UV[2] - UV[0]; - ClippedUV[points++] = UV[0] + alpha * uv1 + beta * uv2; - } - - if(_Point_In_Polygon(ClipPoints[2], TrianglePoints[0], TrianglePoints[1], TrianglePoints[2], 0, 1, alpha, beta)) { - ClippedPoints[points] = ClipPoints[2]; - Vector2 uv1 = UV[1] - UV[0]; - Vector2 uv2 = UV[2] - UV[0]; - ClippedUV[points++] = UV[0] + alpha * uv1 + beta * uv2; - } - - // if all 3 clip points are inside the decal triangle then return - if(points == 3) - return; - - // The clip triangle does not fully contain the uv triangle, and the uv triangle - // does not fully contain the clip triangle. - // Intersect any edge which has at least one outside point with all of the clip edges. - // First, determine which edges to test. Those points that are already clipped (by being inside) - // are immediately copied to the clipped point & uv arrays. - - // these bools indicate which edges of the triangle to be clipped are to be tested. - bool test_01 = false; - bool test_02 = false; - bool test_12 = false; - - if( inside[0] ) { ClippedPoints[points] = TrianglePoints[0]; ClippedUV[points++] = UV[0]; } - else { test_01 = test_02 = true; } - - if( inside[1] ) { ClippedPoints[points] = TrianglePoints[1]; ClippedUV[points++] = UV[1]; } - else { test_01 = test_12 = true; } - - if( inside[2] ) { ClippedPoints[points] = TrianglePoints[2]; ClippedUV[points++] = UV[2];} - else { test_02 = test_12 = true; } - - // Now test each indicated segment. - // Intersect_2D_Lines will interpolate the clipped UV values if an intersection occurs, and it - // will also increment the points variable (passed as a reference). - // Any intersections are stored in the passed ClippedPoints array. - if(test_01) { - _Intersect_Lines_Z( TrianglePoints[0], TrianglePoints[1], - UV[0], UV[1], - ClipPoints[0], ClipPoints[1], - ClippedPoints, - ClippedUV, - points); - _Intersect_Lines_Z( TrianglePoints[0], TrianglePoints[1], - UV[0], UV[1], - ClipPoints[0], ClipPoints[2], - ClippedPoints, - ClippedUV, - points); - _Intersect_Lines_Z( TrianglePoints[0], TrianglePoints[1], - UV[0], UV[1], - ClipPoints[1], ClipPoints[2], - ClippedPoints, - ClippedUV, - points); - } - if(test_02) { - _Intersect_Lines_Z( TrianglePoints[0], TrianglePoints[2], - UV[0], UV[2], - ClipPoints[0], ClipPoints[1], - ClippedPoints, - ClippedUV, - points); - _Intersect_Lines_Z( TrianglePoints[0], TrianglePoints[2], - UV[0], UV[2], - ClipPoints[0], ClipPoints[2], - ClippedPoints, - ClippedUV, - points); - _Intersect_Lines_Z( TrianglePoints[0], TrianglePoints[2], - UV[0], UV[2], - ClipPoints[1], ClipPoints[2], - ClippedPoints, - ClippedUV, - points); - } - if(test_12) { - _Intersect_Lines_Z( TrianglePoints[1], TrianglePoints[2], - UV[1], UV[2], - ClipPoints[0], ClipPoints[1], - ClippedPoints, - ClippedUV, - points); - _Intersect_Lines_Z( TrianglePoints[1], TrianglePoints[2], - UV[1], UV[2], - ClipPoints[0], ClipPoints[2], - ClippedPoints, - ClippedUV, - points); - _Intersect_Lines_Z( TrianglePoints[1], TrianglePoints[2], - UV[1], UV[2], - ClipPoints[1], ClipPoints[2], - ClippedPoints, - ClippedUV, - points); - } - - // If no intersections have occurred, then the triangle must be completely outside - // the clipping area. -/* - // if it is determined that no intersections have occurred, then copy the clip triangle points - // into the destination array and determine the correct UV values for the subset of the - // triangle that was clipped. - if(points == 0) { - ClippedPoints[0] = ClipPoints[0]; - ClippedPoints[1] = ClipPoints[1]; - ClippedPoints[2] = ClipPoints[2]; - ClippedUV[0] = UV[0]; - ClippedUV[1] = UV[1]; - ClippedUV[2] = UV[2]; - - return 3; - } -* / - // points will be 0, 3, 4, 5 or 6 - if(!((points == 0) || (points == 3) || (points == 4) || (points == 5) || (points == 6))) { - Debug.Print("points", points); - return 0; //_Intersect_Triangles_Z( ClipPoints, TrianglePoints, UV, ClippedPoints, ClippedUV); - } - - return points; - -} -*/ - - -#endif diff --git a/Generals/Code/Libraries/Source/WWVegas/WW3D2/inttest.h b/Generals/Code/Libraries/Source/WWVegas/WW3D2/inttest.h deleted file mode 100644 index e933eb64ce2..00000000000 --- a/Generals/Code/Libraries/Source/WWVegas/WW3D2/inttest.h +++ /dev/null @@ -1,256 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** 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 *** - *********************************************************************************************** - * * - * Project Name : WW3D * - * * - * $Archive:: /Commando/Code/ww3d2/inttest.h $* - * * - * Original Author:: Greg Hjelstrom * - * * - * $Author:: Greg_h $* - * * - * $Modtime:: 3/14/01 9:19a $* - * * - * $Revision:: 2 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#if defined(_MSC_VER) -#pragma once -#endif - -#ifndef INTTEST_H -#define INTTEST_H - -#include "always.h" -#include "aabox.h" -#include "obbox.h" -#include "tri.h" -#include "colmath.h" -#include "coltype.h" - - -///////////////////////////////////////////////////////////////////////////////////////////////////////////// -// IntersectionTestClass -// -// This is the base class for all of the 'Intersection' functions. The intersection tests are -// purely boolean tests. The base class only contains the CollisionType of the test. -// -// Every IntersectionTestClass should have the following functions: -// -// bool Cull(const Vector3 & min,const Vector3 & max); -// bool Cull(const AABoxClass & box); -// bool Intersect_Triangle(const TriClass & tri); -// -// These are not virtual because I don't want to pay the price of virtual function -// calls at the point in the code where these are used. It may be possible to -// write template functions if we use these exact function prototpyes for all -// collision test classes though. -// -///////////////////////////////////////////////////////////////////////////////////////////////////////////// -class IntersectionTestClass -{ -public: - IntersectionTestClass(int collision_type) : CollisionType(collision_type) { } - IntersectionTestClass(const IntersectionTestClass & that) : CollisionType(that.CollisionType) { } - -public: - int CollisionType; -}; - - -///////////////////////////////////////////////////////////////////////////////////////////////////////////// -// AABoxIntersectionTestClass -// -// This is an intersection test which uses an Axis-Aligned Box -// -///////////////////////////////////////////////////////////////////////////////////////////////////////////// -class AABoxIntersectionTestClass : public IntersectionTestClass -{ -public: - AABoxIntersectionTestClass(const AABoxClass & box,int collision_type) : - IntersectionTestClass(collision_type), - Box(box) - { - } - - AABoxIntersectionTestClass(const AABoxIntersectionTestClass & that) : - IntersectionTestClass(that), - Box(that.Box) - { - } - - bool Cull(const Vector3 & cull_min,const Vector3 & cull_max); - bool Cull(const AABoxClass & cull_box); - bool Intersect_Triangle(const TriClass & tri); - -public: - AABoxClass Box; // world space aabox that we want to test with - -}; - -inline bool AABoxIntersectionTestClass::Cull(const Vector3 & cull_min,const Vector3 & cull_max) -{ - Vector3 box_min; - Vector3::Subtract(Box.Center,Box.Extent,&box_min); - - Vector3 box_max; - Vector3::Add(Box.Center,Box.Extent,&box_max); - - if ((box_min.X > cull_max.X) || (box_max.X < cull_min.X)) return true; - if ((box_min.Y > cull_max.Y) || (box_max.Y < cull_min.Y)) return true; - if ((box_min.Z > cull_max.Z) || (box_max.Z < cull_min.Z)) return true; - - return false; -} - -inline bool AABoxIntersectionTestClass::Cull(const AABoxClass & cull_box) -{ - Vector3 dc; - Vector3 r; - Vector3::Subtract(cull_box.Center,Box.Center,&dc); - Vector3::Add(cull_box.Extent,Box.Extent,&r); - - if (WWMath::Fabs(dc.X) > r.X) return true; - if (WWMath::Fabs(dc.Y) > r.Y) return true; - if (WWMath::Fabs(dc.Z) > r.Z) return true; - - return false; -} - -inline bool AABoxIntersectionTestClass::Intersect_Triangle(const TriClass & tri) -{ - return CollisionMath::Intersection_Test(Box,tri); -} - - -///////////////////////////////////////////////////////////////////////////////////////////////////////////// -// OBBoxIntersectionTestClass -// -// This is an intersection test which uses an Axis-Aligned Box -// -///////////////////////////////////////////////////////////////////////////////////////////////////////////// -class OBBoxIntersectionTestClass : public IntersectionTestClass -{ -public: - - OBBoxIntersectionTestClass(const OBBoxClass & box,int collision_type); - OBBoxIntersectionTestClass(const OBBoxIntersectionTestClass & that); - OBBoxIntersectionTestClass(const OBBoxIntersectionTestClass & that,const Matrix3D & tm); - OBBoxIntersectionTestClass(const AABoxIntersectionTestClass & that,const Matrix3D & tm); - - bool Cull(const Vector3 & min,const Vector3 & max); - bool Cull(const AABoxClass & box); - bool Intersect_Triangle(const TriClass & tri); - -protected: - void update_bounding_box(void); - -public: - OBBoxClass Box; // world space obbox that we want to test with - AABoxClass BoundingBox; // axis aligned w-s bounding box -}; - - -inline OBBoxIntersectionTestClass::OBBoxIntersectionTestClass(const OBBoxClass & box,int collision_type) : - IntersectionTestClass(collision_type), - Box(box) -{ - update_bounding_box(); -} - -inline OBBoxIntersectionTestClass::OBBoxIntersectionTestClass(const OBBoxIntersectionTestClass & that) : - IntersectionTestClass(that), - Box(that.Box) -{ - update_bounding_box(); -} - -inline OBBoxIntersectionTestClass::OBBoxIntersectionTestClass -( - const OBBoxIntersectionTestClass & that, - const Matrix3D & tm -) : - IntersectionTestClass(that) -{ - OBBoxClass::Transform(tm,that.Box,&Box); - update_bounding_box(); -} - -inline OBBoxIntersectionTestClass::OBBoxIntersectionTestClass -( - const AABoxIntersectionTestClass & that, - const Matrix3D & tm -) : - IntersectionTestClass(that) -{ - Matrix3D::Transform_Vector(tm,that.Box.Center,&(Box.Center)); - Box.Extent = that.Box.Extent; - Box.Basis = tm; // copies the 3x3 rotation portion of the transform - update_bounding_box(); -} - -inline bool OBBoxIntersectionTestClass::Cull(const Vector3 & cull_min,const Vector3 & cull_max) -{ - Vector3 box_min; - Vector3::Subtract(BoundingBox.Center,BoundingBox.Extent,&box_min); - - Vector3 box_max; - Vector3::Add(BoundingBox.Center,BoundingBox.Extent,&box_max); - - if ((box_min.X > cull_max.X) || (box_max.X < cull_min.X)) return true; - if ((box_min.Y > cull_max.Y) || (box_max.Y < cull_min.Y)) return true; - if ((box_min.Z > cull_max.Z) || (box_max.Z < cull_min.Z)) return true; - - return false; -} - -inline bool OBBoxIntersectionTestClass::Cull(const AABoxClass & cull_box) -{ - Vector3 dc; - Vector3 r; - Vector3::Subtract(cull_box.Center,BoundingBox.Center,&dc); - Vector3::Add(cull_box.Extent,BoundingBox.Extent,&r); - - if (WWMath::Fabs(dc.X) > r.X) return true; - if (WWMath::Fabs(dc.Y) > r.Y) return true; - if (WWMath::Fabs(dc.Z) > r.Z) return true; - - return false; -} - -inline bool OBBoxIntersectionTestClass::Intersect_Triangle(const TriClass & tri) -{ - return CollisionMath::Intersection_Test(Box,tri); -} - -inline void OBBoxIntersectionTestClass::update_bounding_box(void) -{ - BoundingBox.Center = Box.Center; - Box.Basis.Rotate_AABox_Extent(Box.Extent,&BoundingBox.Extent); -} - - - -#endif \ No newline at end of file diff --git a/Generals/Code/Libraries/Source/WWVegas/WW3D2/layer.cpp b/Generals/Code/Libraries/Source/WWVegas/WW3D2/layer.cpp deleted file mode 100644 index d4c983a0cdd..00000000000 --- a/Generals/Code/Libraries/Source/WWVegas/WW3D2/layer.cpp +++ /dev/null @@ -1,289 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** 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 *** - *********************************************************************************************** - * * - * Project Name : WW3D * - * * - * $Archive:: /VSS_Sync/ww3d2/layer.cpp $* - * * - * $Author:: Vss_sync $* - * * - * $Modtime:: 8/29/01 7:29p $* - * * - * $Revision:: 3 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * LayerClass::LayerClass -- constructor * - * LayerClass::~LayerClass -- destructor * - * LayerClass::Set_Scene -- Set the scene used by this layer * - * LayerClass::Get_Scene -- get the scene being rendered by this layer * - * LayerClass::Peek_Scene -- get the scene being rendered by this layer w/o a ref * - * LayerClass::Set_Camera -- Set the camera being used by this layer * - * LayerClass::Get_Camera -- get the camera being used by this layer * - * LayerClass::LayerClass -- default constructor * - * LC::Peek_Camera -- Get copy of camera. * - * LC::Set -- Kinda like an assignment operator. * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - - -#include "layer.h" -#include "scene.h" -#include "camera.h" - - -/*********************************************************************************************** - * LayerClass::LayerClass -- default constructor * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 3/27/98 GTH : Created. * - *=============================================================================================*/ -LayerClass::LayerClass(void) : - Scene(NULL), - Camera(NULL), - Clear(false), - ClearZ(true), - ClearColor(0,0,0) -{ -} - -LayerClass::LayerClass(const LayerClass &src) : - Scene(src.Get_Scene()), - Camera(src.Get_Camera()), - Clear(src.Clear), - ClearZ(src.ClearZ), - ClearColor(src.ClearColor) -{ -} - -/*********************************************************************************************** - * LayerClass::LayerClass -- constructor * - * * - * simply constructs a layer class, initialized with the desired settings * - * * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 3/27/98 GTH : Created. * - *=============================================================================================*/ -LayerClass::LayerClass -( - SceneClass * scene, - CameraClass * cam, - bool clear, - bool clearz, - const Vector3 & color -) -{ - if (scene) scene->Add_Ref(); - Scene = scene; - - if (cam) cam->Add_Ref(); - Camera = cam; - - Clear = clear; - ClearZ = clearz; - ClearColor = color; -} - - -/*********************************************************************************************** - * LayerClass::~LayerClass -- destructor * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 3/27/98 GTH : Created. * - *=============================================================================================*/ -LayerClass::~LayerClass(void) -{ - if (Scene) { - Scene->Release_Ref(); - Scene=0; - } - if (Camera) { - Camera->Release_Ref(); - Camera=0; - } -} - - -/*********************************************************************************************** - * LayerClass::Set_Scene -- Set the scene used by this layer * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 3/27/98 GTH : Created. * - *=============================================================================================*/ -void LayerClass::Set_Scene(SceneClass * scene) -{ - if (Scene) { - Scene->Release_Ref(); - } - Scene = scene; - if (Scene) { - Scene->Add_Ref(); - } -} - - -/*********************************************************************************************** - * LayerClass::Get_Scene -- get the scene being rendered by this layer * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 3/27/98 GTH : Created. * - *=============================================================================================*/ -SceneClass * LayerClass::Get_Scene(void) const -{ - if (Scene) { - Scene->Add_Ref(); - } - return Scene; -} - - -/*********************************************************************************************** - * LayerClass::Peek_Scene -- get the scene being rendered by this layer * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 3/8/99 NH : Created. * - *=============================================================================================*/ -SceneClass * LayerClass::Peek_Scene(void) const -{ - return Scene; -} - - -/*********************************************************************************************** - * LayerClass::Set_Camera -- Set the camera being used by this layer * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 3/27/98 GTH : Created. * - *=============================================================================================*/ -void LayerClass::Set_Camera(CameraClass * cam) -{ - if (Camera) { - Camera->Release_Ref(); - } - Camera = cam; - if (Camera) { - Camera->Add_Ref(); - } -} - - -/*********************************************************************************************** - * LayerClass::Get_Camera -- get the camera being used by this layer * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 3/27/98 GTH : Created. * - *=============================================================================================*/ -CameraClass * LayerClass::Get_Camera(void) const -{ - if (Camera) { - Camera->Add_Ref(); - } - return Camera; -} - - -/*********************************************************************************************** - * LC::Peek_Camera -- Get copy of camera. * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 08/14/2001 SKB : Created. * - *=============================================================================================*/ -CameraClass * LayerClass::Peek_Camera(void) const -{ - return Camera; -} - - -/*********************************************************************************************** - * LC::Set -- Kinda like an assignment operator. * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 08/14/2001 SKB : Created. * - *=============================================================================================*/ -void LayerClass::Set(const LayerClass & layer) -{ - Set_Camera(layer.Peek_Camera()); - Set_Scene(layer.Peek_Scene()); - Clear = layer.Clear; - ClearZ = layer.ClearZ; - ClearColor = layer.ClearColor; -} diff --git a/Generals/Code/Libraries/Source/WWVegas/WW3D2/layer.h b/Generals/Code/Libraries/Source/WWVegas/WW3D2/layer.h deleted file mode 100644 index 35af8af2839..00000000000 --- a/Generals/Code/Libraries/Source/WWVegas/WW3D2/layer.h +++ /dev/null @@ -1,100 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** 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 *** - *********************************************************************************************** - * * - * Project Name : WW3D * - * * - * $Archive:: /VSS_Sync/ww3d2/layer.h $* - * * - * $Author:: Vss_sync $* - * * - * $Modtime:: 8/29/01 7:29p $* - * * - * $Revision:: 2 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - - -#if defined(_MSC_VER) -#pragma once -#endif - -#ifndef LAYER_H -#define LAYER_H - -#include "always.h" -#include "LISTNODE.H" -#include "vector3.h" - -class SceneClass; -class CameraClass; - -class LayerClass; -typedef Node LayerNodeClass; - -class LayerClass : public LayerNodeClass -{ - -public: - - LayerClass(void); - LayerClass(SceneClass * s,CameraClass * c,bool clear = false,bool clearz = false,const Vector3 & color = Vector3(0,0,0)); - LayerClass(const LayerClass & src); - ~LayerClass(void); - - - /* - ** The following functions will handle the references of the Scene and Camera - ** objects properly. - */ - void Set_Scene(SceneClass * scene); - SceneClass * Get_Scene(void) const; - SceneClass * Peek_Scene(void) const; - void Set_Camera(CameraClass * cam); - CameraClass * Get_Camera(void) const; - CameraClass * Peek_Camera(void) const; - - - // [SKB: Aug 14 2001 @ 1:53pm] : - // Add a method to copy one layer to another - I would like to create an assignment - // operator but it could break old code. - void Set(const LayerClass & layer); - - /* - ** LayerClass members are public since this is a "lightweight" class - */ - bool Clear; - bool ClearZ; - Vector3 ClearColor; - - SceneClass * Scene; - CameraClass * Camera; - -}; - -typedef List LayerListClass; - - -#endif //LAYER_H - - diff --git a/Generals/Code/Libraries/Source/WWVegas/WW3D2/line3d.cpp b/Generals/Code/Libraries/Source/WWVegas/WW3D2/line3d.cpp deleted file mode 100644 index 231abe92c2e..00000000000 --- a/Generals/Code/Libraries/Source/WWVegas/WW3D2/line3d.cpp +++ /dev/null @@ -1,514 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*************************************************************************** - *** 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 *** - *************************************************************************** - * * - * Project Name : G * - * * - * $Archive:: /Commando/Code/ww3d2/line3d.cpp $* - * * - * $Author:: Jani_p $* - * * - * $Modtime:: 7/05/01 4:15p $* - * * - * $Revision:: 11 $* - * * - *-------------------------------------------------------------------------* - * Functions: * - * Line3DClass::Line3DClass -- Constructor * - * Line3DClass::Line3DClass -- Copy constructor. * - * Line3DClass::operator = -- assignment operator * - * Line3DClass::~Line3DClass -- Destructor. * - * Line3DClass::Clone -- Creates a clone of this Line3D * - * Line3DClass::Scale -- Scale object * - * Line3DClass::Scale -- Scale object * - * Line3DClass::Update_Cached_Bounding_Volumes -- update bounding vols * - * Line3DClass::Reset -- Reset line start and end points. * - * Line3DClass::Reset -- Reset line start and end points, and line width.* - * Re_Color -- Reset the line color. * - * Set_Opacity -- Reset the line opacity. * - * Line3DClass::Render -- render the 3d line * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#include "line3d.h" -#include "vertmaterial.h" -#include "shader.h" -#include "wwdebug.h" -#include "ww3d.h" -#include "rinfo.h" -#include "dx8wrapper.h" -#include "dx8vertexbuffer.h" -#include "dx8indexbuffer.h" -#include "dx8fvf.h" - -// 12 Triangles for index buffer -const unsigned short Indices[]= -{ - 3,5,1, - 7,5,3, - 1,5,0, - 5,4,0, - 4,2,0, - 4,6,2, - 7,3,2, - 6,7,2, - 7,6,5, - 5,6,4, - 2,3,1, - 2,1,0 -}; - - -/************************************************************************** - * Line3DClass::Line3DClass -- Constructor * - * * - * INPUT: Vector3 start, end - start, end points of line (world coords).* - * float width - width of line (in world units). * - * float r, g, b - R, G, B components of line color. * - * float opacity - opacity of line. * - * * - * OUTPUT: none. * - * * - * WARNINGS: * - * * - * HISTORY: * - * 01/15/1998 NH : Created. * - * 04/21/1998 NH : Ported to SR 1.3. * - * 02/16/2001 HY : Ported to DX8 * - *========================================================================*/ -Line3DClass::Line3DClass (const Vector3 & start, const Vector3 & end, - float width, float r, float g, float b, float opacity) -{ - Length = (end - start).Length(); - Width = width; - - // Create box model with origin at start point (X is major axis). - - // 8 Vertices - float halfw = Width * 0.5f; - - vert[0].X = 0.0f; - vert[0].Y = -halfw; - vert[0].Z = -halfw; - vert[1].X = 0.0f; - vert[1].Y = halfw; - vert[1].Z = -halfw; - vert[2].X = 0.0f; - vert[2].Y = -halfw; - vert[2].Z = halfw; - vert[3].X = 0.0f; - vert[3].Y = halfw; - vert[3].Z = halfw; - vert[4].X = Length; - vert[4].Y = -halfw; - vert[4].Z = -halfw; - vert[5].X = Length; - vert[5].Y = halfw; - vert[5].Z = -halfw; - vert[6].X = Length; - vert[6].Y = -halfw; - vert[6].Z = halfw; - vert[7].X = Length; - vert[7].Y = halfw; - vert[7].Z = halfw; - - Color.X=r; - Color.Y=g; - Color.Z=b; - Set_Opacity(opacity); - - // Set box transform so that the origin is at the start point and it - // 'looks towards' the endpoint. - Matrix3D transform(true); - transform.Obj_Look_At(start, end, 0.0); - Set_Transform(transform); -} - - -/************************************************************************** - * Line3DClass::Line3DClass -- Copy constructor. * - * * - * INPUT: const Line3DClass & src - source to copy from. * - * * - * OUTPUT: none. * - * * - * WARNINGS: * - * * - * HISTORY: * - * 01/15/1998 NH : Created. * - * 04/21/1998 NH : Ported to SR 1.3. * - * 02/16/2001 HY : Ported to DX8 * - *========================================================================*/ -Line3DClass::Line3DClass(const Line3DClass & src) : - RenderObjClass(src), - Length(src.Length), - Width(src.Width), - Shader(src.Shader), - Color(src.Color) -{ - for (int i=0; i<8; i++) vert[i]=src.vert[i]; -} - - -/************************************************************************** - * Line3DClass::operator = -- assignment operator * - * * - * INPUT: const Line3DClass & that - source to copy from. * - * * - * OUTPUT: Line3DClass & - result of assignment. * - * * - * WARNINGS: * - * * - * HISTORY: * - * 01/15/1998 NH : Created. * - * 04/21/1998 NH : Ported to SR 1.3. * - * 02/16/2001 HY : Ported to DX8 * - *========================================================================*/ -Line3DClass & Line3DClass::operator = (const Line3DClass & that) -{ - // Naty: need to add MatInfo and remapper to do this Byon - WWASSERT(0); - - RenderObjClass::operator = (that); - - if (this != &that) { - Length = that.Length; - Width = that.Width; - Shader=that.Shader; - Color=that.Color; - for (int i=0; i<8; i++) - vert[i]=that.vert[i]; - } - - return * this; -} - - -/************************************************************************** - * Line3DClass::~Line3DClass -- Destructor. * - * * - * INPUT: none. * - * * - * OUTPUT: none. * - * * - * WARNINGS: * - * * - * HISTORY: * - * 01/15/1998 NH : Created. * - * 04/21/1998 NH : Ported to SR 1.3. * - * 02/16/2001 HY : Ported to DX8 * - *========================================================================*/ -Line3DClass::~Line3DClass(void) -{ -} - - -/************************************************************************** - * Line3DClass::Clone -- Creates a clone of this Line3D * - * * - * INPUT: none. * - * * - * OUTPUT: RenderObjClass * - pointer to cloned object. * - * * - * WARNINGS: * - * * - * HISTORY: * - * 01/15/1998 NH : Created. * - *========================================================================*/ -RenderObjClass * Line3DClass::Clone(void) const -{ - return NEW_REF( Line3DClass, (*this)); -} - -/*********************************************************************************************** - * Line3DClass::Render -- render the 3d line * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 12/8/98 GTH : Created. * - * 02/16/2001 HY : Ported to DX8 * - *=============================================================================================*/ - -void Line3DClass::Render(RenderInfoClass & rinfo) -{ - if (Is_Not_Hidden_At_All() == false) { - return; - } - - // If static sort lists are enabled and this mesh has a sort level, put it on the list instead - // of rendering it. - unsigned int sort_level = (unsigned int)Get_Sort_Level(); - - if (WW3D::Are_Static_Sort_Lists_Enabled() && sort_level != SORT_LEVEL_NONE) - { - WW3D::Add_To_Static_Sort_List(this, sort_level); - return; - } - - DX8Wrapper::Set_Shader(Shader); - DX8Wrapper::Set_Texture(0,NULL); - VertexMaterialClass *vm=VertexMaterialClass::Get_Preset(VertexMaterialClass::PRELIT_DIFFUSE); - DX8Wrapper::Set_Material(vm); - REF_PTR_RELEASE(vm); - - DX8Wrapper::Set_Transform(D3DTS_WORLD,Transform); - - DynamicVBAccessClass vb(BUFFER_TYPE_DYNAMIC_DX8,dynamic_fvf_type,8); - { - DynamicVBAccessClass::WriteLockClass Lock(&vb); - const FVFInfoClass &fi=vb.FVF_Info(); - unsigned char *vb=(unsigned char*)Lock.Get_Formatted_Vertex_Array(); - int i; - unsigned int color=DX8Wrapper::Convert_Color(Color); - - for (i=0; i<8; i++) - { - *(Vector3*)(vb+fi.Get_Location_Offset())=vert[i]; - *(unsigned int*)(vb+fi.Get_Diffuse_Offset())=color; - vb+=fi.Get_FVF_Size(); - } - } - - DynamicIBAccessClass ib(BUFFER_TYPE_DYNAMIC_DX8,36); - { - DynamicIBAccessClass::WriteLockClass Lock(&ib); - unsigned short *mem=Lock.Get_Index_Array(); - for (int i=0; i<36; i++) - mem[i]=Indices[i]; - } - - DX8Wrapper::Set_Vertex_Buffer(vb); - DX8Wrapper::Set_Index_Buffer(ib,0); - DX8Wrapper::Draw_Triangles(0,36/3,0,8); -} - -/************************************************************************** - * Line3DClass::Scale -- Scale object * - * * - * INPUT: float scale - uniform scale factor. * - * * - * OUTPUT: none. * - * * - * WARNINGS: * - * * - * HISTORY: * - * 01/27/1998 NH : Created. * - * 04/21/1998 NH : Ported to SR 1.3. * - * 02/16/2001 HY : Ported to DX8 * - *========================================================================*/ -void Line3DClass::Scale(float scale) -{ - for (int i=0; i<8; i++) vert[i]*=scale; - Length *= scale; - Width *= scale; - - Invalidate_Cached_Bounding_Volumes(); - - // Now update the object space bounding volumes of this object's container: - RenderObjClass *container = Get_Container(); - if (container) container->Update_Obj_Space_Bounding_Volumes(); -} - - -/************************************************************************** - * Line3DClass::Scale -- Scale object * - * * - * INPUT: float scalex, scaley, scalez - axis scale factors. * - * * - * OUTPUT: none. * - * * - * WARNINGS: * - * * - * HISTORY: * - * 01/27/1998 NH : Created. * - * 04/21/1998 NH : Ported to SR 1.3. * - * 02/16/2001 HY : Ported to DX8 * - *========================================================================*/ -void Line3DClass::Scale(float scalex, float scaley, float scalez) -{ - // The line width is always the same in the y and z axes (the line - // approximates a cylinder). - Vector3 scale(scalex,scaley,scalez); - for (int i=0; i<8; i++) vert[i].Scale(scale); - Length *= scalex; - Width *= scaley; - - Invalidate_Cached_Bounding_Volumes(); - - // Now update the object space bounding volumes of this object's container: - RenderObjClass *container = Get_Container(); - if (container) container->Update_Obj_Space_Bounding_Volumes(); -} - - -void Line3DClass::Get_Obj_Space_Bounding_Sphere(SphereClass & sphere) const -{ - float half_l = Length * 0.5f; - sphere.Center.Set(half_l, 0.0f, 0.0f); - sphere.Radius = half_l; -} - - -void Line3DClass::Get_Obj_Space_Bounding_Box(AABoxClass & box) const -{ - float half_l = Length * 0.5f; - box.Center.Set(half_l, 0.0f, 0.0f); - box.Extent.Set(half_l, 0.0f, 0.0f); -} - -/************************************************************************** - * Line3DClass::Reset -- Reset line start and end points. * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 01/19/1998 NH : Created. * - * 04/21/1998 NH : Ported to SR 1.3. * - *========================================================================*/ -void Line3DClass::Reset(const Vector3 & new_start, const Vector3 & new_end) -{ - // Adjust length of line: - float new_length = (new_end - new_start).Length(); - if (new_length == 0) { - new_length = 0.001f; // make sure we don't have a zero length BMG - } - Scale((new_length / Length), 1.0f, 1.0f); - Length = new_length; - - // Adjust transform of line: - Matrix3D transform(true); - transform.Obj_Look_At(new_start, new_end, 0.0); - Set_Transform(transform); - - Invalidate_Cached_Bounding_Volumes(); - - // Now update the object space bounding volumes of this object's container: - RenderObjClass *container = Get_Container(); - if (container) container->Update_Obj_Space_Bounding_Volumes(); -} - - -/************************************************************************** - * Line3DClass::Reset -- Reset line start and end points, and line width. * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 01/19/1998 NH : Created. * - * 04/21/1998 NH : Ported to SR 1.3. * - *========================================================================*/ -void Line3DClass::Reset(const Vector3 & new_start, const Vector3 & new_end, float new_width) -{ - // Adjust length and width of line: - float new_length = (new_end - new_start).Length(); - if (new_length == 0) { - new_length = 0.001f; // make sure we don't have a zero length BMG - } - float width_scale = new_width / Width; - Scale((new_length / Length), width_scale, width_scale); - Length = new_length; - Width = new_width; - - // Adjust transform of line: - Matrix3D transform(true); - transform.Obj_Look_At(new_start, new_end, 0.0); - Set_Transform(transform); - Matrix3D inv; - transform.Get_Orthogonal_Inverse(inv); -#ifdef ALLOW_TEMPORARIES -// Vector3 test = inv * Vector3(new_end); -#else -// Vector3 test; -// inv.mulVector3(new_end, test); -#endif - - Invalidate_Cached_Bounding_Volumes(); - - // Now update the object space bounding volumes of this object's container: - RenderObjClass *container = Get_Container(); - if (container) container->Update_Obj_Space_Bounding_Volumes(); -} - - -/************************************************************************** - * Re_Color -- Reset the line color. * - * * - * INPUT: float r, g, b - components of the new color. * - * * - * OUTPUT: none. * - * * - * WARNINGS: * - * * - * HISTORY: * - * 01/26/1998 NH : Created. * - * 04/21/1998 NH : Ported to SR 1.3. * - *========================================================================*/ -void Line3DClass::Re_Color(float r, float g, float b) -{ - Color=Vector4(r,g,b,Color.W); -} - - -/************************************************************************** - * Set_Opacity -- Reset the line opacity. * - * * - * INPUT: float opacity - new opacity. * - * * - * OUTPUT: none. * - * * - * WARNINGS: * - * * - * HISTORY: * - * 11/03/1998 NH : Created. * - *========================================================================*/ -void Line3DClass::Set_Opacity(float opacity) -{ - if (opacity < 1.0f) - { Shader=ShaderClass::_PresetAlphaSolidShader; - Set_Sort_Level(1); - } - else - { Shader=ShaderClass::_PresetOpaqueSolidShader; - Set_Sort_Level(SORT_LEVEL_NONE); - } - Color.W=opacity; -} - -/* -** -*/ -int Line3DClass::Get_Num_Polys(void) const -{ - return 12; -} - diff --git a/Generals/Code/Libraries/Source/WWVegas/WW3D2/line3d.h b/Generals/Code/Libraries/Source/WWVegas/WW3D2/line3d.h deleted file mode 100644 index 8d601e8f6b0..00000000000 --- a/Generals/Code/Libraries/Source/WWVegas/WW3D2/line3d.h +++ /dev/null @@ -1,124 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*************************************************************************** - *** 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 *** - *************************************************************************** - * * - * Project Name : G * - * * - * $Archive:: /Commando/Code/ww3d2/line3d.h $* - * * - * $Author:: Hector_y $* - * * - * $Modtime:: 2/16/01 3:52p $* - * * - * $Revision:: 2 $* - * * - *-------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#if defined(_MSC_VER) -#pragma once -#endif - -#ifndef LINE3D_H -#define LINE3D_H - -#include "always.h" -#include "rendobj.h" -#include "vector3.h" -#include "vector4.h" -#include "shader.h" - -class VertexMaterialClass; -class RenderInfoClass; - -/* -** Line3DClass -- Render3DObject for rendering 3D line segments. -** These are conceptually cylinders with a given width - some approximation -** of this will be rendered. (The current approximation assumes that -** Line3DCLass objects are unlit, therefore only the sihouette needs to be -** approximated). -*/ -class Line3DClass : public W3DMPO, public RenderObjClass -{ - W3DMPO_GLUE(Line3DClass) - - public: - - Line3DClass (const Vector3 & start, const Vector3 & end, float width, - float r, float g, float b, float opacity = 1.0f); - Line3DClass(const Line3DClass & src); - Line3DClass & operator = (const Line3DClass & that); - virtual ~Line3DClass(void); - virtual RenderObjClass * Clone(void) const; - - // class id of this render object - virtual int Class_ID(void) const { return CLASSID_LINE3D; } - - virtual void Render(RenderInfoClass & rfinfo); - - // scale the 3D line symmetrically about its center. - virtual void Scale(float scale); - virtual void Scale(float scalex, float scaley, float scalez); - - // returns the number of polygons in the render object - virtual int Get_Num_Polys(void) const; - - // Get the object space bounding volumes - virtual void Get_Obj_Space_Bounding_Sphere(SphereClass & sphere) const; - virtual void Get_Obj_Space_Bounding_Box(AABoxClass & box) const; - - // The following functions are unique to Line3DClass: - - // Reset the line start and end points - void Reset(const Vector3 & new_start, const Vector3 & new_end); - - // Reset line start and end points, and the line width - void Reset(const Vector3 & new_start, const Vector3 & new_end, float new_width); - - // Reset the line color - void Re_Color(float r, float g, float b); - - // Reset the line opacity - void Set_Opacity(float opacity); - - // For non-opaque lines, allow them to render last. - void Set_Sort_Level(int level) { SortLevel = level; } - int Get_Sort_Level(void) const { return SortLevel; } - - protected: - - // This is kept to facilitate changing the line endpoints. - float Length; - - // This is kept to facilitate changing the line width. - float Width; - - // shader - ShaderClass Shader; - // vertices - Vector3 vert[8]; - // color - Vector4 Color; - char SortLevel; -}; - -#endif \ No newline at end of file diff --git a/Generals/Code/Libraries/Source/WWVegas/WW3D2/matinfo.cpp b/Generals/Code/Libraries/Source/WWVegas/WW3D2/matinfo.cpp deleted file mode 100644 index dc491266418..00000000000 --- a/Generals/Code/Libraries/Source/WWVegas/WW3D2/matinfo.cpp +++ /dev/null @@ -1,429 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** 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 *** - *********************************************************************************************** - * * - * Project Name : MatInfo.h * - * * - * $Archive:: /Commando/Code/ww3d2/matinfo.cpp $* - * * - * Author:: Greg Hjelstrom * - * * - * $Modtime:: 6/15/01 5:50p $* - * * - * $Revision:: 10 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - - -#include "matinfo.h" -#include "wwdebug.h" -#include "meshmdl.h" -#include "texture.h" - -MaterialInfoClass::MaterialInfoClass(void) -{ -} - -MaterialInfoClass::MaterialInfoClass(const MaterialInfoClass & src) -{ - for (int mi=0; miClone(); - VertexMaterials.Add(vmat); - } - - for (int ti=0; tiAdd_Ref(); - Textures.Add(tex); - } -} - - -MaterialInfoClass::~MaterialInfoClass(void) -{ - Free(); -} - - -MaterialInfoClass * MaterialInfoClass::Clone(void) const -{ - return W3DNEW MaterialInfoClass(*this); -} - -int MaterialInfoClass::Add_Texture(TextureClass * tex) -{ - WWASSERT(tex != NULL); - tex->Add_Ref(); - int index = Textures.Count(); - Textures.Add(tex); - return index; -} - -int MaterialInfoClass::Get_Texture_Index(const char * name) -{ - for (int i=0; iGet_Texture_Name()) == 0) { - return i; - } - } - return -1; -} - -TextureClass * MaterialInfoClass::Get_Texture(int index) -{ - WWASSERT(index >= 0); - WWASSERT(index < Textures.Count()); - Textures[index]->Add_Ref(); - return Textures[index]; -} - -/* - -void MaterialInfoClass::Set_Texture_Reduction_Factor(float trf) -{ - for (int i = 0; i < Textures.Count(); i++) { - Textures[i]->Set_Reduction_Factor(trf); - } -} - - -void MaterialInfoClass::Process_Texture_Reduction(void) -{ - for (int i = 0; i < Textures.Count(); i++) { - Textures[i]->Process_Reduction(); - } -} -*/ -void MaterialInfoClass::Free(void) -{ - int i; - - for (i=0; iTexture_Count() == dest->Texture_Count()); - WWASSERT(src->Vertex_Material_Count() == dest->Vertex_Material_Count()); - - SrcMatInfo = src; - SrcMatInfo->Add_Ref(); - DestMatInfo = dest; - DestMatInfo->Add_Ref(); - - if (src->Vertex_Material_Count() > 0) { - VertexMaterialCount = src->Vertex_Material_Count(); - VertexMaterialRemaps = W3DNEWARRAY VmatRemapStruct[VertexMaterialCount]; - for (int i=0; iVertex_Material_Count(); i++) { - VertexMaterialRemaps[i].Src = src->Peek_Vertex_Material(i); - VertexMaterialRemaps[i].Dest = dest->Peek_Vertex_Material(i); - } - } - - if (src->Texture_Count() > 0) { - TextureCount = src->Texture_Count(); - TextureRemaps = W3DNEWARRAY TextureRemapStruct[TextureCount]; - for (int i=0; iTexture_Count(); i++) { - TextureRemaps[i].Src = src->Peek_Texture(i); - TextureRemaps[i].Dest = dest->Peek_Texture(i); - } - } -} - -MaterialRemapperClass::~MaterialRemapperClass(void) -{ - SrcMatInfo->Release_Ref(); - DestMatInfo->Release_Ref(); - - if (TextureRemaps) { - delete[] TextureRemaps; - } - if (VertexMaterialRemaps) { - delete[] VertexMaterialRemaps; - } -} - -TextureClass * MaterialRemapperClass::Remap_Texture(TextureClass * src) -{ - if (src == NULL) return src; - if (src == LastSrcTex) return LastDestTex; - for (int i=0; iVertex_Material_Count() >= 1) { - - for (int pass = 0;pass < srcmeshmatdesc->Get_Pass_Count(); pass++) { - - if (srcmeshmatdesc->Has_Material_Array(pass)) { - - for (int vert_index = 0; vert_index < srcmeshmatdesc->Get_Vertex_Count(); vert_index++) { - VertexMaterialClass * src = srcmeshmatdesc->Peek_Material(vert_index, pass); - destmeshmatdesc->Set_Material(vert_index, Remap_Vertex_Material(src),pass); - } - - } else { - - VertexMaterialClass * src = srcmeshmatdesc->Peek_Single_Material(pass); - destmeshmatdesc->Set_Single_Material(Remap_Vertex_Material(src), pass); - - } - } - } - - /* - ** Remap the textures if there is at least one of them - */ - if (SrcMatInfo->Texture_Count() >= 1) { - - for (int pass = 0;pass < srcmeshmatdesc->Get_Pass_Count(); pass++) { - - for (int stage = 0; stage < MeshMatDescClass::MAX_TEX_STAGES; stage++) { - - if (srcmeshmatdesc->Has_Texture_Array(pass, stage)) { - - for (int poly_index = 0; poly_index < srcmeshmatdesc->Get_Polygon_Count(); poly_index++) { - TextureClass * src = srcmeshmatdesc->Peek_Texture(poly_index, pass, stage); - destmeshmatdesc->Set_Texture(poly_index, Remap_Texture(src), pass, stage); - } - - } else { - - TextureClass * src = srcmeshmatdesc->Peek_Single_Texture(pass, stage); - destmeshmatdesc->Set_Single_Texture(Remap_Texture(src), pass, stage); - - } - } - } - } -} - -MaterialCollectorClass::MaterialCollectorClass(void) -{ - LastShader = ShaderClass(0xFFFFFFFF); - LastMaterial = NULL; - LastTexture = NULL; -} - -MaterialCollectorClass::~MaterialCollectorClass(void) -{ - Reset(); -} - -void MaterialCollectorClass::Collect_Materials(MeshModelClass * mesh) -{ - for (int pass = 0;pass < mesh->Get_Pass_Count(); pass++) { - - // Vertex materials (either single or per vertex) - if (mesh->Has_Material_Array(pass)) { - - for (int vert_index = 0;vert_index < mesh->Get_Vertex_Count(); vert_index++) { - VertexMaterialClass * mat = mesh->Peek_Material(vert_index,pass); - Add_Vertex_Material(mat); - } - - } else { - VertexMaterialClass * mat = mesh->Get_Single_Material(pass); - Add_Vertex_Material(mat); - REF_PTR_RELEASE(mat); - } - - - // Shaders (single or per poly...) - if (mesh->Has_Shader_Array(pass)) { - for (int poly_index=0; poly_index < mesh->Get_Polygon_Count(); poly_index++) { - Add_Shader(mesh->Get_Shader(poly_index,pass)); - } - } else { - ShaderClass sh = mesh->Get_Single_Shader(pass); - Add_Shader(sh); - } - - - // Textures per pass, per stage (either array or single...) - for (int stage = 0; stage < MeshMatDescClass::MAX_TEX_STAGES; stage++) { - - if (mesh->Has_Texture_Array(pass,stage)) { - - for (int poly_index = 0;poly_index < mesh->Get_Polygon_Count(); poly_index++) { - TextureClass * tex = mesh->Peek_Texture(poly_index,pass,stage); - Add_Texture(tex); - } - - } else { - - TextureClass * tex = mesh->Peek_Single_Texture(pass,stage); - Add_Texture(tex); - - } - } - } -} - -void MaterialCollectorClass::Reset(void) -{ - for (int ti=0; tiAdd_Ref(); - LastTexture = tex; -} - -void MaterialCollectorClass::Add_Shader(ShaderClass shader) -{ - if (shader == LastShader) return; - if (Find_Shader(shader) != -1) return; - Shaders.Add(shader); - LastShader = shader; -} - -void MaterialCollectorClass::Add_Vertex_Material(VertexMaterialClass * vmat) -{ - if (vmat == NULL) return; - if (vmat == LastMaterial) return; - if (Find_Vertex_Material(vmat) != -1) return; - VertexMaterials.Add(vmat); - vmat->Add_Ref(); - LastMaterial = vmat; -} - -int MaterialCollectorClass::Get_Shader_Count(void) -{ - return Shaders.Count(); -} - -int MaterialCollectorClass::Get_Vertex_Material_Count(void) -{ - return VertexMaterials.Count(); -} - -int MaterialCollectorClass::Get_Texture_Count(void) -{ - return Textures.Count(); -} - -ShaderClass MaterialCollectorClass::Peek_Shader(int i) -{ - return Shaders[i]; -} - -TextureClass * MaterialCollectorClass::Peek_Texture(int i) -{ - return Textures[i]; -} - -VertexMaterialClass * MaterialCollectorClass::Peek_Vertex_Material(int i) -{ - return VertexMaterials[i]; -} - -int MaterialCollectorClass::Find_Shader(const ShaderClass & shader) -{ - for (int si=0; si. -*/ - -/*********************************************************************************************** - *** 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 *** - *********************************************************************************************** - * * - * Project Name : WW3D * - * * - * $Archive:: /VSS_Sync/ww3d2/matinfo.h $* - * * - * Author:: Greg Hjelstrom * - * * - * $Modtime:: 8/29/01 7:29p $* - * * - * $Revision:: 11 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - - -#if defined(_MSC_VER) -#pragma once -#endif - -#ifndef MATINFO_H -#define MATINFO_H - -#include "always.h" -#include "wwdebug.h" -#include "Vector.H" -#include "vertmaterial.h" -#include "texture.h" -#include "shader.h" -#ifdef _UNIX -#include "osdep.h" -#endif - -class MeshModelClass; -class MeshMatDescClass; - -/*********************************************************************************************** -** MaterialInfoClass -** -** This class gives an interface to the "changeable" material parameters inside a -** W3D render object. Typically, this will include things like the following: -** - one or more textures, -** - the vertex material used by the mesh (defines lighting properties, etc) -** -** Another purpose of this class is to actually hold onto a ref for each material -** object that a mesh uses. The "per-triangle" pointer arrays are not ref counted -** so the material info serves as a place to hold a reference to each material object -** that the mesh is using. -** -***********************************************************************************************/ -class MaterialInfoClass : public W3DMPO, public RefCountClass -{ - W3DMPO_GLUE(MaterialInfoClass) -public: - - MaterialInfoClass(); - MaterialInfoClass(const MaterialInfoClass & src); - ~MaterialInfoClass(); - MaterialInfoClass * Clone(void) const; - - void Reset(void) { Free(); } - int Vertex_Material_Count(void) const { return VertexMaterials.Count(); } - int Texture_Count(void) const { return Textures.Count(); } - - int Add_Vertex_Material(VertexMaterialClass * vmat); - int Add_Texture(TextureClass * tex); - - int Get_Vertex_Material_Index(const char * name); - int Get_Texture_Index(const char * name); - - VertexMaterialClass * Get_Vertex_Material(int index); - VertexMaterialClass * Get_Vertex_Material(const char * name); - VertexMaterialClass * Peek_Vertex_Material(int index); - VertexMaterialClass * Peek_Vertex_Material(const char * name); - void Replace_Material(int index, VertexMaterialClass *newMaterial); - void Reset_Texture_Mappers(void); - void Make_Vertex_Materials_Unique(void); - bool Has_Time_Variant_Texture_Mappers(void); - - TextureClass * Get_Texture(int index); - TextureClass * Get_Texture(const char * name); - TextureClass * Peek_Texture(int index); - TextureClass * Peek_Texture(const char * name); - void Replace_Texture(int index, TextureClass *newTexture); - -// void Set_Texture_Reduction_Factor(float trf); -// void Process_Texture_Reduction(void); - -private: - - void Free(void); - - DynamicVectorClass VertexMaterials; - DynamicVectorClass Textures; - -}; - - - -/*********************************************************************************************** -** MaterialRemapperClass -** This class is used when we need to "remap" all of the material pointers in a mesh -** to a new set of cloned materials. Basically, it assumes that you are going to initialize -** it with two identical material info objects (src and dest) and then you can give it pointers -** to materials in the "src" material info and it will give you back pointers to materials -** in the "dest" material info class. -** -** This class attempts to take advantage of the fact that meshes should normally be sorted -** with respect to their materials so we shouldn't really be doing a linear search for -** each remap... -** -** Please Note: this class does not hold references to the materials and is meant only to -** be used in a temporary fashion. Create it, do your conversion, then delete it :-) -***********************************************************************************************/ -class MaterialRemapperClass -{ -public: - MaterialRemapperClass(MaterialInfoClass * src,MaterialInfoClass * dest); - ~MaterialRemapperClass(void); - - TextureClass * Remap_Texture(TextureClass * src); - VertexMaterialClass * Remap_Vertex_Material(VertexMaterialClass * src); - void Remap_Mesh(const MeshMatDescClass * srcmeshmatdesc, MeshMatDescClass * destmeshmatdesc); - -private: - - struct VmatRemapStruct - { - VertexMaterialClass * Src; - VertexMaterialClass * Dest; - }; - - struct TextureRemapStruct - { - TextureClass * Src; - TextureClass * Dest; - }; - - MaterialInfoClass * SrcMatInfo; - MaterialInfoClass * DestMatInfo; - - int TextureCount; - TextureRemapStruct * TextureRemaps; - int VertexMaterialCount; - VmatRemapStruct * VertexMaterialRemaps; - - VertexMaterialClass * LastSrcVmat; - VertexMaterialClass * LastDestVmat; - TextureClass * LastSrcTex; - TextureClass * LastDestTex; -}; - -/*********************************************************************************************** -** MaterialCollectorClass -** -** This class can be used to collect all of the unique instances of materials from a mesh. -** Its original motivation is to solve a problem encountered in trying to save a mesh -** to disk. There are arrays of pointers to vertex materials in the mesh but no record of -** the set of unique vertex materials (all pointers could point to the same one...) Similar -** to the remapper, it tries to take advantage of the fact that the materials and textures -** should be in sorted order to optimize the lookups... -** -** NOTE: pointer comparisons are used to determine if the objects are unique. I don't -** check whether the contents of the objects are identical. (Exporter does this, I assume -** that if there are two separate objects, they are that way for a reason here.) -***********************************************************************************************/ -class MaterialCollectorClass -{ -public: - - MaterialCollectorClass(void); - ~MaterialCollectorClass(void); - - void Reset(void); - void Collect_Materials(MeshModelClass * mesh); - void Add_Texture(TextureClass * tex); - void Add_Shader(ShaderClass shader); - void Add_Vertex_Material(VertexMaterialClass * vmat); - - int Get_Shader_Count(void); - int Get_Vertex_Material_Count(void); - int Get_Texture_Count(void); - - ShaderClass Peek_Shader(int i); - TextureClass * Peek_Texture(int i); - VertexMaterialClass * Peek_Vertex_Material(int i); - - int Find_Shader(const ShaderClass & shader); - int Find_Texture(TextureClass * tex); - int Find_Vertex_Material(VertexMaterialClass * mat); - -protected: - - DynamicVectorClass Shaders; - DynamicVectorClass VertexMaterials; - DynamicVectorClass Textures; - - ShaderClass LastShader; - VertexMaterialClass * LastMaterial; - TextureClass * LastTexture; -}; - - - -inline int MaterialInfoClass::Add_Vertex_Material(VertexMaterialClass * vmat) -{ - if (vmat != NULL) { - vmat->Add_Ref(); - } - int index = VertexMaterials.Count(); - VertexMaterials.Add(vmat); - return index; -} - -inline int MaterialInfoClass::Get_Vertex_Material_Index(const char * name) -{ - for (int i=0; iGet_Name()) == 0) { - return i; - } - } - return -1; -} - -inline VertexMaterialClass * MaterialInfoClass::Get_Vertex_Material(int index) -{ - WWASSERT(index >= 0); - WWASSERT(index < VertexMaterials.Count()); - if (VertexMaterials[index]) { - VertexMaterials[index]->Add_Ref(); - } - return VertexMaterials[index]; -} - -inline VertexMaterialClass * MaterialInfoClass::Get_Vertex_Material(const char * name) -{ - int index = Get_Vertex_Material_Index(name); - if (index == -1) { - return NULL; - } else { - return Get_Vertex_Material(index); - } -} - -inline VertexMaterialClass * MaterialInfoClass::Peek_Vertex_Material(int index) -{ - WWASSERT(index >= 0); - WWASSERT(index < VertexMaterials.Count()); - return VertexMaterials[index]; -} - -inline VertexMaterialClass * MaterialInfoClass::Peek_Vertex_Material(const char * name) -{ - int index = Get_Vertex_Material_Index(name); - if (index == -1) { - return NULL; - } else { - return Peek_Vertex_Material(index); - } -} - -inline void MaterialInfoClass::Replace_Material(int index, VertexMaterialClass *newMaterial) -{ - REF_PTR_SET(VertexMaterials[index],newMaterial); -} - -inline void MaterialInfoClass::Reset_Texture_Mappers(void) -{ - int vmat_count = VertexMaterials.Count(); - for (int i = 0; i < vmat_count; i++) { - VertexMaterials[i]->Reset_Mappers(); - } -} - -inline bool MaterialInfoClass::Has_Time_Variant_Texture_Mappers(void) -{ - int vmat_count = VertexMaterials.Count(); - for (int i = 0; i < vmat_count; i++) { - if (VertexMaterials[i]->Are_Mappers_Time_Variant()) return true; - } - return false; -} - -inline void MaterialInfoClass::Make_Vertex_Materials_Unique(void) -{ - int vmat_count = VertexMaterials.Count(); - for (int i = 0; i < vmat_count; i++) { - VertexMaterials[i]->Make_Unique(); - } -} - -inline TextureClass * MaterialInfoClass::Get_Texture(const char * name) -{ - int index = Get_Texture_Index(name); - if (index == -1) { - return NULL; - } else { - return Get_Texture(index); - } -} - -inline TextureClass * MaterialInfoClass::Peek_Texture(int index) -{ - WWASSERT(index >= 0); - WWASSERT(index < Textures.Count()); - return Textures[index]; -} - -inline void MaterialInfoClass::Replace_Texture(int index, TextureClass *newTexture) -{ - REF_PTR_SET(Textures[index],newTexture); -} - -#endif // MATINFO_H diff --git a/Generals/Code/Libraries/Source/WWVegas/WW3D2/meshdam.cpp b/Generals/Code/Libraries/Source/WWVegas/WW3D2/meshdam.cpp deleted file mode 100644 index acbb3e091cb..00000000000 --- a/Generals/Code/Libraries/Source/WWVegas/WW3D2/meshdam.cpp +++ /dev/null @@ -1,266 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** 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 *** - *********************************************************************************************** - * * - * Project Name : WW3D * - * * - * $Archive:: /Commando/Code/ww3d2/meshdam.cpp $* - * * - * Author:: Greg_h * - * * - * $Modtime:: 1/08/01 10:04a $* - * * - * $Revision:: 1 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - - -#if 0 - - -#include "meshdam.h" -#include "w3d_file.h" -#include "w3derr.h" -#include "chunkio.h" -//#include - - -/*********************************************************************************************** - * DamageClass::DamageClass -- constructor * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 10/28/1997 GH : Created. * - *=============================================================================================*/ -DamageClass::DamageClass(void): - DamageIndex(0), - NumMaterials(0), - NumVerts(0), - NumColors(0), - Verts(NULL), - Colors(NULL) -{ -} - - -/*********************************************************************************************** - * DamageClass::~DamageClass -- destructor * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 10/28/1997 GH : Created. * - *=============================================================================================*/ -DamageClass::~DamageClass(void) -{ - if (Verts != NULL) { - delete [] Verts; - Verts = NULL; - } - - if (Colors != NULL) { - delete[] Colors; - Colors = NULL; - } -} - -/*********************************************************************************************** - * DamageClass::Load -- load damage data from a W3D file * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 10/28/1997 GH : Created. * - *=============================================================================================*/ -WW3DErrorType DamageClass::Load(ChunkLoadClass & cload,MeshModelClass * basemesh) -{ -#if 0 - /* - ** Open the first chunk, it should be the damage header - */ - cload.Open_Chunk(); - - if (cload.Cur_Chunk_ID() != W3D_CHUNK_DAMAGE_HEADER) { - return WW3D_ERROR_LOAD_FAILED; - } - - W3dMeshDamageStruct header; - if (cload.Read(&header,sizeof(W3dMeshDamageStruct)) != sizeof(W3dMeshDamageStruct)) { - return WW3D_ERROR_LOAD_FAILED; - } - - cload.Close_Chunk(); - - /* - ** allocate the arrays based on the info in the header - */ - NumVerts = header.NumDamageVerts; - if (NumVerts > 0) { - Verts = W3DNEWARRAY DamageVertexStruct[NumVerts]; - } - - NumColors = header.NumDamageColors; - if (NumColors > 0) { - Colors = W3DNEWARRAY DamageColorStruct[NumColors]; - } - - // TODO: allocate materials - - /* - ** Now read in the rest of the chunks - */ - while (1) { - - /* - ** Read in the chunk header - ** If there are no more chunks within the chunk, we are done. - */ - if (!cload.Open_Chunk()) { - return WW3D_ERROR_OK; - } - - /* - ** Process the chunk - */ - int error = WW3D_ERROR_OK; - - switch (cload.Cur_Chunk_ID()) { - -// case W3D_CHUNK_DAMAGE_MATERIALS: -// //TODO: read new set of materials -// break; - - case W3D_CHUNK_DAMAGE_VERTICES: - error = read_vertices(cload,basemesh); - break; - - case W3D_CHUNK_DAMAGE_COLORS: - error = read_colors(cload,basemesh); - break; - - default: - break; - - } - - cload.Close_Chunk(); - - if (error != WW3D_ERROR_OK) { - return error; - } - } -#endif - - return WW3D_ERROR_OK; -} - -/*********************************************************************************************** - * DamageClass::read_vertices -- read damage vertices from a W3D file * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 11/04/1997 GH : Created. * - *=============================================================================================*/ -WW3DErrorType DamageClass::read_vertices(ChunkLoadClass & cload,MeshModelClass * basemesh) -{ -#if 0 - W3dMeshDamageVertexStruct dv; - - for (int i=0; igetVertexLoc(); - - srVector3 sr_v; - sr_v = vert_array[dv.VertexIndex]; - - Verts[i].VertexIdx = dv.VertexIndex; - Verts[i].Vertex0.Set(sr_v[0],sr_v[1],sr_v[2]); - Verts[i].Vertex1.Set(dv.NewVertex.X,dv.NewVertex.Y,dv.NewVertex.Z); - } -#endif - return WW3D_ERROR_OK; -} - -/*********************************************************************************************** - * DamageClass::read_colors -- read damage colors from a w3d file * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 11/04/1997 GH : Created. * - *=============================================================================================*/ -WW3DErrorType DamageClass::read_colors(ChunkLoadClass & cload,MeshModelClass * basemesh) -{ -#if 0 - W3dMeshDamageColorStruct dc; - - for (int i=0; i. -*/ - -/*********************************************************************************************** - *** 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 *** - *********************************************************************************************** - * * - * Project Name : WW3D * - * * - * $Archive:: /Commando/Code/ww3d2/meshdam.h $* - * * - * $Author:: Greg_h $* - * * - * $Modtime:: 1/08/01 10:04a $* - * * - * $Revision:: 1 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#if 0 - -#if defined(_MSC_VER) -#pragma once -#endif - -#ifndef MESHDAM_H -#define MESHDAM_H - -#include "always.h" -#include "vector3.h" -#include "bittype.h" -#include "w3derr.h" - -class MeshModelClass; -class ChunkLoadClass; - -struct RGBStruct -{ - uint8 R,G,B; -}; - -struct DamageVertexStruct -{ - int VertexIdx; // index of the vertex to "damage" - Vector3 Vertex0; // original vertex position - Vector3 Vertex1; // damaged vertex position -}; - -struct DamageColorStruct -{ - int VertexIdx; // index of the vertex to damage. - RGBStruct Color0; // original color. - RGBStruct Color1; // damaged color. -}; - - -/* -** DamageClass - this class encapsulates the information needed -** to apply damage to meshes. It contains replacement vertices, -** vertex colors and materials -*/ -class DamageClass -{ -public: - - DamageClass(void); - ~DamageClass(void); - - WW3DErrorType Load_W3D(ChunkLoadClass & cload,MeshModelClass * basemesh); - -protected: - - WW3DErrorType read_vertices(ChunkLoadClass & cload,MeshModelClass * basemesh); - WW3DErrorType read_colors(ChunkLoadClass & cload,MeshModelClass * basemesh); - - int DamageIndex; - int NumMaterials; - int NumVerts; - int NumColors; - - DamageVertexStruct * Verts; - DamageColorStruct * Colors; - - friend class MeshClass; -}; - - -#endif - - -#endif //0 \ No newline at end of file diff --git a/Generals/Code/Libraries/Source/WWVegas/WW3D2/metalmap.cpp b/Generals/Code/Libraries/Source/WWVegas/WW3D2/metalmap.cpp deleted file mode 100644 index a5a034fd991..00000000000 --- a/Generals/Code/Libraries/Source/WWVegas/WW3D2/metalmap.cpp +++ /dev/null @@ -1,423 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** 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 *** - *********************************************************************************************** - * * - * Project Name : G * - * * - * $Archive:: /Commando/Code/ww3d2/metalmap.cpp $* - * * - * $Author:: Hector_y $* - * * - * $Modtime:: 6/27/01 4:59p $* - * * - * $Revision:: 3 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * MMMC::MetalMapManagerClass -- Create metal map manager according to given metal parameters* - * MMMC::MetalMapManagerClass -- Create metal map manager from INI * - * MMMC::~MetalMapManagerClass -- MetalMapManagerClass destructor * - * MMMC::Get_Metal_Map -- Get the texture for a metal map by id number * - * MMMC::Metal_Map_Count -- Get the number of metal maps in the manager * - * MMMC::Update_Lighting -- Update the lighting parameters used for generating the maps * - * MMMC::Update_Textures -- Update metal map textures (call once/frame before rendering) * - * MMMC::initialize_normal_table -- Utility function to initialize the normal table * - * MMMC::initialize_metal_params -- Utility function (shared CTor code) * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#include "metalmap.h" -#include "texture.h" -#include "ww3dformat.h" -#include "ww3d.h" -#include -#include -#include -#include -#include -#include -#include - -/* -** Class static members: -*/ -Vector3 * MetalMapManagerClass::_NormalTable = 0; - -/*********************************************************************************************** - * MMMC::MetalMapManagerClass -- Create metal map manager from INI * - * * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 11/23/1999 NH : Created. * - *=============================================================================================*/ -MetalMapManagerClass::MetalMapManagerClass(INIClass &ini) : - MapCount(0), - Textures(0), - MetalParameters(0), - CurrentAmbient(0.0f, 0.0f, 0.0f), - CurrentMainLightColor(0.0f, 0.0f, 0.0f), - CurrentMainLightDir(1.0f, 0.0f, 0.0f), - CurrentCameraDir(1.0f,0.0f,0.0f), - Use16Bit(false) -{ - - // If the static normal table has not been initialized yet, initialize it - if (!_NormalTable) { - initialize_normal_table(); - } - - // Determine how many metals are in this file - char section[255]; - - int lp = 0; - for (; ; lp++) { - sprintf(section, "Metal%02d", lp); - if (!ini.Find_Section(section)) { - break; // NAK - Mar 8, 2000: changed to a break to fix off by one error in lp - } - } - - if (lp > 0) { - // Create metal params structs and fill from INI: - MetalParams *metal_params = W3DNEWARRAY MetalParams[lp]; - TPoint3D white_tpoint(255.0f, 255.0f, 255.0f); - Vector3 white(1.0f, 1.0f, 1.0f); - Vector3 black(0.0f, 0.0f, 0.0f); - for (int i = 0; i < lp; i++) { - sprintf(section, "Metal%02d", i); - static const float cf = 0.003921568627451f; // 1 / 255 - TPoint3D color; - color = ini.Get_Point(section, "AmbientColor", white_tpoint); - metal_params[i].AmbientColor.Set(color.X * cf, color.Y * cf, color.Z * cf); - metal_params[i].AmbientColor.Update_Min(white); - metal_params[i].AmbientColor.Update_Max(black); - color = ini.Get_Point(section, "DiffuseColor", white_tpoint); - metal_params[i].DiffuseColor.Set(color.X * cf, color.Y * cf, color.Z * cf); - metal_params[i].AmbientColor.Update_Min(white); - metal_params[i].AmbientColor.Update_Max(black); - color = ini.Get_Point(section, "SpecularColor", white_tpoint); - metal_params[i].SpecularColor.Set(color.X * cf, color.Y * cf, color.Z * cf); - metal_params[i].AmbientColor.Update_Min(white); - metal_params[i].AmbientColor.Update_Max(black); - float shininess = ini.Get_Float(section, "Shininess", 0.0f); - metal_params[i].Shininess = WWMath::Clamp(shininess, 0.0f, 127.0f); - } - - initialize_metal_params(lp, metal_params); - delete [] metal_params; - } else { - assert(0); - } - - int w,h,bits; - bool windowed; - - WW3D::Get_Device_Resolution(w,h,bits,windowed); - Use16Bit=(bits<=16); - - WW3DFormat format=(Use16Bit?WW3D_FORMAT_A4R4G4B4:WW3D_FORMAT_A8R8G8B8); - - - for (int i = 0; i < lp; i++) { - Textures[i]=NEW_REF(TextureClass,(METALMAP_SIZE,METALMAP_SIZE,format,MIP_LEVELS_1)); - Textures[i]->Get_Filter().Set_U_Addr_Mode(TextureFilterClass::TEXTURE_ADDRESS_CLAMP); - Textures[i]->Get_Filter().Set_V_Addr_Mode(TextureFilterClass::TEXTURE_ADDRESS_CLAMP); - StringClass tex_name; - tex_name.Format("!m%02d.tga", i); - Textures[i]->Set_Texture_Name(tex_name); - } -} - - -/*********************************************************************************************** - * MMMC::~MetalMapManagerClass -- MetalMapManagerClass destructor * - * * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 11/19/1999 NH : Created. * - *=============================================================================================*/ -MetalMapManagerClass::~MetalMapManagerClass(void) -{ - if (Textures) { - for (int i = 0; i < MapCount; i++) { - REF_PTR_RELEASE(Textures[i]); - } - delete [] Textures; - Textures = 0; - } - if (MetalParameters) { - delete [] MetalParameters; - MetalParameters = 0; - } -} - - -/*********************************************************************************************** - * MMMC::Get_Metal_Map -- Get the texture for a metal map by id number * - * * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 11/19/1999 NH : Created. * - *=============================================================================================*/ -TextureClass * MetalMapManagerClass::Get_Metal_Map(int id) -{ - if (id < 0 || id >= MapCount) return 0; - Textures[id]->Add_Ref(); - return Textures[id]; -} - - -/*********************************************************************************************** - * MMMC::Metal_Map_Count -- Get the number of metal maps in the manager * - * * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 11/19/1999 NH : Created. * - *=============================================================================================*/ -int MetalMapManagerClass::Metal_Map_Count(void) -{ - return MapCount; -} - - -/*********************************************************************************************** - * MMMC::Update_Lighting -- Update the lighting parameters used for generating the maps * - * * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 11/19/1999 NH : Created. * - *=============================================================================================*/ -void MetalMapManagerClass::Update_Lighting(const Vector3& ambient, const Vector3& main_light_color, - const Vector3& main_light_dir, const Vector3& camera_dir) -{ - CurrentAmbient = ambient; - CurrentMainLightColor = main_light_color; - CurrentMainLightDir = main_light_dir; - CurrentCameraDir= camera_dir; -} - -/*********************************************************************************************** - * MMMC::Update_Textures -- Update metal map textures (call once/frame before rendering) * - * * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 11/19/1999 NH : Created. * - *=============================================================================================*/ -void MetalMapManagerClass::Update_Textures(void) -{ - // Currently the lighting is done using a simple Phong (actually Blinn) model. - Vector3 &l = CurrentMainLightDir; - Vector3 &v = CurrentCameraDir; - - // Calculate halfway vector - Vector3 h = l+v; - h.Normalize(); - - // NOTE: when our lighting equation gets more complicated we might want to do some testing to - // detect zero components... - - // Calculate quantities which are the same for all metal maps - float n_dot_l[METALMAP_SIZE_2]; - float n_dot_h[METALMAP_SIZE_2]; - - VectorProcessorClass::DotProduct(n_dot_l,l,_NormalTable,METALMAP_SIZE_2); - VectorProcessorClass::ClampMin(n_dot_l, n_dot_l, 0.0f, METALMAP_SIZE_2); - VectorProcessorClass::DotProduct(n_dot_h,h,_NormalTable, METALMAP_SIZE_2); - VectorProcessorClass::ClampMin(n_dot_h, n_dot_h, 0.0f, METALMAP_SIZE_2); - - // Loop over each metal map and update it - for (int i = 0; i < MapCount; i++) { - MetalParams &cur_params = MetalParameters[i]; - - // If shinyness > 1, apply it to specular value array - float *specular = 0; - float temp_specular[METALMAP_SIZE_2]; - float shinyness = cur_params.Shininess; - if (shinyness > 1.0f) { - VectorProcessorClass::Power(temp_specular, n_dot_h, shinyness, METALMAP_SIZE_2); - specular = &(temp_specular[0]); - } else { - specular = &(n_dot_h[0]); - } - - // Generate metal map row by row - Vector3 specular_color(cur_params.SpecularColor.X * CurrentMainLightColor.X, - cur_params.SpecularColor.Y * CurrentMainLightColor.Y, - cur_params.SpecularColor.Z * CurrentMainLightColor.Z); - Vector3 diffuse_color(cur_params.DiffuseColor.X * CurrentMainLightColor.X, - cur_params.DiffuseColor.Y * CurrentMainLightColor.Y, - cur_params.DiffuseColor.Z * CurrentMainLightColor.Z); - Vector3 ambient_color(cur_params.AmbientColor.X * CurrentAmbient.X, - cur_params.AmbientColor.Y * CurrentAmbient.Y, - cur_params.AmbientColor.Z * CurrentAmbient.Z); - Vector3 white(1.0f, 1.0f, 1.0f); - - SurfaceClass * metal_map_surface = Textures[i]->Get_Surface_Level(0); - int pitch; - unsigned char *map=(unsigned char *) metal_map_surface->Lock(&pitch); - int idx=0; - for (int y = 0; y < METALMAP_SIZE; y++) { - for (int x = 0; x < METALMAP_SIZE; x++) { - Vector3 result = ambient_color + (diffuse_color * n_dot_l[idx]) + (specular_color * specular[idx]); - result.Update_Min(white); // Clamp to white - - unsigned char b,g,r,a; - b= (unsigned char)WWMath::Floor(result.Z * 255.99f); // B - g= (unsigned char)WWMath::Floor(result.Y * 255.99f); // G - r= (unsigned char)WWMath::Floor(result.X * 255.99f); // R - a= 0xFF; // A - - if (Use16Bit) { - unsigned short tmp; - tmp=(a&0xf0)<<8; - tmp|=(r&0xf0)<<4; - tmp|=(g&0xf0); - tmp|=(b&0xf0)>>4; - *(unsigned short*)&map[2*x]=tmp; - } else { - map[4*x]=b; - map[4*x+1]=g; - map[4*x+2]=r; - map[4*x+3]=a; - } - idx++; - } - map+=pitch; - } - metal_map_surface->Unlock(); - REF_PTR_RELEASE(metal_map_surface); - } // for i -} - -/*********************************************************************************************** - * MMMC::initialize_normal_table -- Utility function to initialize the normal table * - * * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 11/19/1999 NH : Created. * - *=============================================================================================*/ -void MetalMapManagerClass::initialize_normal_table(void) -{ - // NOTE: changing the actual static _NormalTable member must be the last thing this function - // does to avoid synchronization errors. - - static Vector3 _normal_table[METALMAP_SIZE_2]; - - // Calculate vectors (area outside sphere should be filled with a radial fill of the vectors at - // the sphere's edge to avoid aliasing artifacts) - float step = 2.0f / (float)METALMAP_SIZE; - int idx = 0; - for (int y = 0; y < METALMAP_SIZE; y++) { - for (int x = 0; x < METALMAP_SIZE; x++) { - Vector3 &normal = _normal_table[idx]; - // Set vector to point to surface of unit sphere - normal.Set((step * (float)x) - 1.0f, (step * (float)y) - 1.0f, 0.0f); - float z2 = 1 - ((normal.X * normal.X) + (normal.Y * normal.Y)); - z2 = MAX(z2, 0.0f); // If outside the sphere, treat as if on its edge - normal.Z = sqrt(z2); - normal.Normalize(); // Needed for "outside sphere" case and for safety's sake - - idx++; - } - } - - _NormalTable = &(_normal_table[0]); - -} - -/*********************************************************************************************** - * MMMC::initialize_metal_params -- Utility function (shared CTor code) * - * * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 11/23/1999 NH : Created. * - *=============================================================================================*/ -void MetalMapManagerClass::initialize_metal_params(int map_count, MetalParams *metal_params) -{ - MapCount = map_count; - if (MapCount > 0) { - Textures = W3DNEWARRAY TextureClass *[MapCount]; - MetalParameters = W3DNEWARRAY MetalParams[MapCount]; - - for (int i = 0; i < MapCount; i++) { - - // Copy metal parameters (assert if invalid) - MetalParameters[i] = metal_params[i]; - assert(MetalParameters[i].AmbientColor.X >= 0.0f && MetalParameters[i].AmbientColor.X <= 1.0f); - assert(MetalParameters[i].AmbientColor.Y >= 0.0f && MetalParameters[i].AmbientColor.Y <= 1.0f); - assert(MetalParameters[i].AmbientColor.Z >= 0.0f && MetalParameters[i].AmbientColor.Z <= 1.0f); - assert(MetalParameters[i].DiffuseColor.X >= 0.0f && MetalParameters[i].DiffuseColor.X <= 1.0f); - assert(MetalParameters[i].DiffuseColor.Y >= 0.0f && MetalParameters[i].DiffuseColor.Y <= 1.0f); - assert(MetalParameters[i].DiffuseColor.Z >= 0.0f && MetalParameters[i].DiffuseColor.Z <= 1.0f); - assert(MetalParameters[i].SpecularColor.X >= 0.0f && MetalParameters[i].SpecularColor.X <= 1.0f); - assert(MetalParameters[i].SpecularColor.Y >= 0.0f && MetalParameters[i].SpecularColor.Y <= 1.0f); - assert(MetalParameters[i].SpecularColor.Z >= 0.0f && MetalParameters[i].SpecularColor.Z <= 1.0f); - assert(MetalParameters[i].Shininess > 0.0f); - } - } -} diff --git a/Generals/Code/Libraries/Source/WWVegas/WW3D2/metalmap.h b/Generals/Code/Libraries/Source/WWVegas/WW3D2/metalmap.h deleted file mode 100644 index 00e93108e63..00000000000 --- a/Generals/Code/Libraries/Source/WWVegas/WW3D2/metalmap.h +++ /dev/null @@ -1,121 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** 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 *** - *********************************************************************************************** - * * - * Project Name : G * - * * - * $Archive:: /Commando/Code/ww3d2/metalmap.h $* - * * - * $Author:: Hector_y $* - * * - * $Modtime:: 6/27/01 4:30p $* - * * - * $Revision:: 2 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#if defined(_MSC_VER) -#pragma once -#endif - -#ifndef METALMAP_H -#define METALMAP_H - -#include - -class TextureClass; -class INIClass; - -/* -** MetalMapManagerClass: This class updates the procedural environment maps -** (aka metal maps) based on the global lighting environment. -** At the moment the metal maps are shaded using a simple Phong model - in -** future this may be extended to more complex and realistic shading -** (Cook-Torrance, etc.) which would require changing the metal parameters. -** Another possible extension would be to support a large dynamic range for -** the main light source (currently its color is treated as an RGB triple -** which is bound to 0,1). -*/ - -// If this is increased too much the metal map updates will be too expensive -#define METALMAP_SIZE 16 -#define METALMAP_SIZE_2 (METALMAP_SIZE * METALMAP_SIZE) - -class MetalMapManagerClass { - -public: - - // These parameters are for a simple Phong reflectance model - struct MetalParams { - Vector3 AmbientColor; - Vector3 DiffuseColor; - Vector3 SpecularColor; - float Shininess; - }; - - // Create metal map manager with maps specified by INI file - MetalMapManagerClass(INIClass &ini); - ~MetalMapManagerClass(void); - - // Get the texture for a metal map by id number - TextureClass * Get_Metal_Map(int id); - - // Get the number of metal maps in the manager - int Metal_Map_Count(void); - - // Update the lighting parameters used for generating the maps - void Update_Lighting(const Vector3& ambient, const Vector3& main_light_color, - const Vector3& main_light_dir, const Vector3& camera_dir); - - // Update the metal map textures (should call once/frame before rendering) - void Update_Textures(void); - -private: - - // 16 x 16 table of cameraspace normals for the environment maps - static Vector3 * _NormalTable; - void initialize_normal_table(void); // Utility function - - // Utility function - shared CTor code - void initialize_metal_params(int map_count, MetalParams *metal_params); - - // Number of metal maps - int MapCount; - - // Array of metal map texture pointers - TextureClass ** Textures; - - // Array of metal parameters - MetalParams * MetalParameters; - - // Current lighting parameters - Vector3 CurrentAmbient; - Vector3 CurrentMainLightColor; - Vector3 CurrentMainLightDir; - Vector3 CurrentCameraDir; - - // Use 16-bit metal maps or not - bool Use16Bit; -}; - -#endif \ No newline at end of file diff --git a/Generals/Code/Libraries/Source/WWVegas/WW3D2/missingtexture.cpp b/Generals/Code/Libraries/Source/WWVegas/WW3D2/missingtexture.cpp deleted file mode 100644 index df80ba92b01..00000000000 --- a/Generals/Code/Libraries/Source/WWVegas/WW3D2/missingtexture.cpp +++ /dev/null @@ -1,711 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -// 08/05/02 KM Texture class redesign -#include "missingtexture.h" -#include "texture.h" -#include "dx8wrapper.h" -#include - -static unsigned missing_image_width=128; -static unsigned missing_image_height=128; -static unsigned missing_image_depth=24; - -extern unsigned int missing_image_palette[]; -extern unsigned int missing_image_pixels[]; - -static IDirect3DTexture8 * _MissingTexture = NULL; - -IDirect3DTexture8* MissingTexture::_Get_Missing_Texture() -{ - WWASSERT(_MissingTexture); - _MissingTexture->AddRef(); - return _MissingTexture; -} - -IDirect3DSurface8* MissingTexture::_Create_Missing_Surface() -{ - IDirect3DSurface8 *texture_surface = NULL; - DX8_ErrorCode(_MissingTexture->GetSurfaceLevel(0, &texture_surface)); - D3DSURFACE_DESC texture_surface_desc; - ::ZeroMemory(&texture_surface_desc, sizeof(D3DSURFACE_DESC)); - DX8_ErrorCode(texture_surface->GetDesc(&texture_surface_desc)); - - IDirect3DSurface8 *surface = NULL; - DX8CALL(CreateImageSurface( - texture_surface_desc.Width, - texture_surface_desc.Height, - texture_surface_desc.Format, - &surface)); - DX8CALL(CopyRects(texture_surface, NULL, 0, surface, NULL)); - texture_surface->Release(); - return surface; -} - -void MissingTexture::_Init() -{ - WWASSERT(!_MissingTexture); - - IDirect3DTexture8* tex=DX8Wrapper::_Create_DX8_Texture - ( - missing_image_width, - missing_image_height, - WW3D_FORMAT_A8R8G8B8, - MIP_LEVELS_ALL - ); - - D3DLOCKED_RECT locked_rect; - RECT rect; - rect.left=0; - rect.right=missing_image_width; - rect.top=0; - rect.bottom=missing_image_height; - DX8_ErrorCode( - tex->LockRect( - 0, - &locked_rect, - &rect, - 0)); - - unsigned *buffer=(unsigned*)locked_rect.pBits; - unsigned char *pixels=(unsigned char *)missing_image_pixels; - for (unsigned y=0;yUnlockRect(0)); - - for (unsigned i=1;iGetLevelCount();++i) { - IDirect3DSurface8 *src,*dst; - DX8_ErrorCode(tex->GetSurfaceLevel(i-1,&src)); - DX8_ErrorCode(tex->GetSurfaceLevel(i,&dst)); - - DX8_ErrorCode(D3DXLoadSurfaceFromSurface( - dst, - NULL, // palette - NULL, // rect - src, - NULL, // palette - NULL, // rect - D3DX_FILTER_BOX, // box is good for 2:1 filtering - 0)); - - src->Release(); - dst->Release(); - } - - _MissingTexture=tex; -/* - //Load an 8-bit tga and generate text representation - FILE *fp; - fp=fopen("missing.tga","rb"); - if (fp) - { - char image[128*128]; //make enough storage for image and palette - char palette[256*3]; - fread(image,18,1,fp); //skip over the header - fread(palette,256,3,fp); //read the palette - fread(image,1,128*128,fp); - FILE *output=fopen("missing.txt","w"); - fprintf(output,"palette:\n"); - for (int i=0; i<256; i++) - { int color=(((int)palette[i*3+0] & 0x000000ff)|(((int)palette[i*3+1] << 8)&0x0000ff00)|(((int)palette[i*3+2] << 16)&0x00ff0000)) | 0x7f000000; - fprintf(output,"0x%.8X",color); - if ((i&7) == 7) //check for end of 8 element line - fprintf(output,",\n"); //new line - else - fprintf(output,","); //continue existing line - } - fprintf(output,"image:\n"); - for (int y=0; y<128; y++) - { - for (int x=0; x<32; x++) - { int color=*((int *)(&image[y*128+x*4])); - fprintf(output,"0x%.8X",color); - if ((x&7)==7) //check for end of 8 element line - fprintf(output,",\n"); //new line - else - fprintf(output,","); //continue existing line - } - } - fclose(output); - fclose(fp); - } -*/ -} - -void MissingTexture::_Deinit() -{ - _MissingTexture->Release(); - _MissingTexture=0; -} - -static unsigned int missing_image_palette[]={ -0x7F040204,0x7F048AC4,0x7F84829C,0x7FFC0204,0x7F0442AB,0x7FFCFE04,0x7F444244,0x7F0462FC, -0x7F84CEE4,0x7FC4C6CF,0x7F9CA6B2,0x7FC4E6F4,0x7F04FE04,0x7F4C82D4,0x7F2452A1,0x7F0442D4, -0x7F446AB0,0x7FA4A6B6,0x7F2C62C2,0x7FE4E6E9,0x7F646264,0x7F0402FC,0x7FC4D6E1,0x7F44B6DC, -0x7FB4C6D4,0x7F8496A9,0x7F049ECC,0x7F0C52C9,0x7FA4B6C4,0x7FA4DEEC,0x7F0472FC,0x7F3C72C4, -0x7F84A6DF,0x7F748294,0x7F24A6D4,0x7F1442A4,0x7F0452DA,0x7FE4F6FC,0x7FD4D6D6,0x7F849EC9, -0x7F242224,0x7FBCD6F7,0x7FB4B6C2,0x7FD4F6F7,0x7F747274,0x7F0442BF,0x7F4C7ABC,0x7FACC6EC, -0x7F9496AB,0x7F343234,0x7F042A98,0x7F648ADC,0x7F1C5AD4,0x7F545254,0x7F1C62D8,0x7FDCE6E9, -0x7F0452EE,0x7F043AA2,0x7FC4CED3,0x7F2C62D4,0x7F34B6D4,0x7FB4BED9,0x7F6CA6EC,0x7F2C72EC, -0x7F94B6E8,0x7F8482A4,0x7F8CA6CC,0x7F5C72AC,0x7FE4EEEF,0x7FC4D6FC,0x7F1472FC,0x7F7C96C4, -0x7FF4F6F7,0x7FD4DEE3,0x7F6C728C,0x7F949EA4,0x7F5CC6E4,0x7F245ABC,0x7F4472C4,0x7F149ECD, -0x7F6C82BC,0x7F34AED5,0x7F242251,0x7FB4BEC9,0x7F044AC8,0x7FBCCEF0,0x7F1462FC,0x7FD4EEF4, -0x7FC4CEDC,0x7F7C7A97,0x7F0C4AB4,0x7FA4AEBC,0x7F3C62B4,0x7F646284,0x7FBCCEE4,0x7F1C52B7, -0x7F0C5AE2,0x7F043294,0x7F3472E8,0x7F9CB6E1,0x7F74C6E4,0x7F2482FC,0x7F0C42AD,0x7F44426A, -0x7F9CDEEC,0x7F5C9EFC,0x7FB4C6E1,0x7F8C9EAC,0x7FACBED0,0x7F5C7AAC,0x7FB4CEF2,0x7F35325C, -0x7F4C5274,0x7FD4E6F9,0x7F64BEDF,0x7FECEEF2,0x7FDCDEE2,0x7F747A94,0x7F949EB0,0x7F19A6D4, -0x7F342A58,0x7F0C4AC0,0x7F746A8C,0x7F96D6EC,0x7F4C82EC,0x7F345AB0,0x7F044ADA,0x7F4C72B9, -0x7FCCD6E2,0x7F141214,0x7F6496EC,0x7F0696CC,0x7F7C9ECC,0x7F1482FC,0x7F241A4C,0x7FB8E6F4, -0x7F58BEDC,0x7F7CA6E4,0x7F544A74,0x7F5C5A7D,0x7F9CAED0,0x7F443A64,0x7F8CBEFC,0x7F3C6AC9, -0x7F1C5AC8,0x7F848A9C,0x7F8CAEEC,0x7F7C8A9C,0x7F144AB4,0x7F247AFC,0x7FC4DEF4,0x7F6CC6E4, -0x7F2C2A56,0x7F146AF8,0x7F347AF4,0x7F4C4A70,0x7F448AFC,0x7F6C9EFC,0x7F8BD6EC,0x7FC8EEF4, -0x7F2C5AA4,0x7F0A7AFC,0x7FECFEFC,0x7F2C2A2C,0x7F045AF4,0x7F848AA5,0x7F94AED0,0x7FFCFEFC, -0x7F6C8AC4,0x7F646A8A,0x7F3C3A62,0x7F0A6AFC,0x7F9CAEBC,0x7F2C6ACC,0x7FACE6EC,0x7F28AED4, -0x7F043AAF,0x7F2C6ADB,0x7F157AFC,0x7F245AD4,0x7F0432A0,0x7F79CEE4,0x7F7CAEF4,0x7F3C72D8, -0x7F8C96A7,0x7F1452BC,0x7FACB6C3,0x7F7C8299,0x7F0C52D8,0x7F547AC3,0x7FB4C6EC,0x7FCCD6EC, -0x7FBCBEC5,0x7FACAEC0,0x7F94BEF4,0x7F8C8A8E,0x7F1C4AA4,0x7F2C7AEC,0x7F1C6AF0,0x7F3C7AE4, -0x7FCCE6FC,0x7F5482D0,0x7FECE6EC,0x7FBCC6D1,0x7F0C72FB,0x7FECF6F5,0x7FDCF6FA,0x7F0C3AA4, -0x7FCCCECD,0x7F3CB6D7,0x7FBCBED4,0x7FFCF6FC,0x7F74728F,0x7F9C9E9C,0x7F64C6E3,0x7F4C72C5, -0x7F1C9ED0,0x7F3CAED7,0x7FDCEEFC,0x7FCCCEDF,0x7F0C328C,0x7F2C82F4,0x7FBCC6DC,0x7F545275, -0x7FDCE6F8,0x7F9C9EB0,0x7FCCDEEC,0x7F0C5AF0,0x7F8C8AA5,0x7F748ABC,0x7F6C6A8A,0x7F0442B4, -0x7F0C62FC,0x7FC4C6DC,0x7F9CA6BC,0x7F0442E4,0x7F446ABC,0x7F2C62CC,0x7F4CB6DC,0x7F0C9ECC, -0x7FACDEEC,0x7F2CA6D4,0x7F0452E4,0x7FD4D6E4,0x7F849ED4,0x7FB4B6CC,0x7F4C7ACC,0x7FACC6FC, -0x7F9496B4,0x7F042AA4,0x7F1C62E4,0x7F74A6EC,0x7FE4EEFC,0x7F1C72FC,0x7FD4DEEC,0x7F2C5ABC}; - -static unsigned int missing_image_pixels[]={ -0x03030303,0x03030303,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0x05050505,0x05050505, -0x03030303,0x03030303,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0x05050505,0x05050505, -0x03030303,0x03030303,0xA7A7A7A7,0xD574A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xC3C3C3C0,0xA7A7A7C3,0xA7A7A7A7,0x05050505,0x05050505, -0x03030303,0x03030303,0xA7A7A7A7,0x00C3A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A700A7,0xA7A7A7A7, -0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0xA7A7A700,0xA7A7A7A7,0x00000006,0xA7A70000,0xA7A7A7A7,0x05050505,0x05050505, -0x03030303,0x03030303,0xA7A7A7A7,0x00C3A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A70000,0xA7A7A7A7, -0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0xA7A70000,0xA7A7A7A7,0xA7A70606,0xA7C300A7,0xA7A7A7A7,0x05050505,0x05050505, -0x03030303,0x03030303,0xA7A7A7A7,0x00C3A7A7,0xA7A7A7A7,0x3174A7A7,0xA33131A3,0x31A33131, -0x3131A331,0xA33131A3,0x31A33131,0x3131A331,0xA33131A3,0x31A33131,0x3131A331,0xA33131A3, -0x31A33131,0x3131A331,0xA33131A3,0x31A33131,0x3131A331,0xA33131A3,0x31A33131,0x3131A331, -0xA33131A3,0x74A33131,0xA7A7A7A7,0xC3C32806,0xA7C00014,0xA7A7A7A7,0x05050505,0x05050505, -0x03030303,0x03030303,0xA7A7A7A7,0x00C3A7A7,0xA7A7A7A7,0x0026A7A7,0x00000000,0x00000000, -0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000, -0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000, -0x00000000,0x26000000,0xA7A7A7A7,0x00000006,0xA7A72C00,0xA7A7A7A7,0x05050505,0x05050505, -0x03030303,0x03030303,0xA7A7A7A7,0x00C3A7A7,0xA7A7A7A7,0xD0D3A7A7,0xD0D00000,0xD0D0D0D0, -0xD0D0D0D0,0xD0D0D0D0,0xD0D0D0D0,0xD0D0D0D0,0xD0D0D0D0,0xD0D0D0D0,0xD0D0D0D0,0xD0D0D0D0, -0xD0D0D0D0,0xD0D0D0D0,0xD0D0D0D0,0xD0D0D0D0,0xD0D0D0D0,0xD0D0D0D0,0xD0D0D0D0,0xD0D0D0D0, -0xD0D0D0D0,0xD3D00000,0xA7A7A7A7,0x74A70606,0xA7A7D500,0xA7A7A7A7,0x05050505,0x05050505, -0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0x00C3A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A700A7,0xA7A7A7A7, -0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0xA7A7A700,0xA7A7A7A7,0xA7A70606,0xA7A7002C,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0x00C3A7A7,0xC3000000,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A70606,0xA70681A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xC0A7A7A7,0xC3C3C3C3,0xA7A7A7C3,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0x14A7A7A7,0x00000000,0xA7A7A700,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0xA700C3A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0xA700C3A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0xA700C3A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0xA700C3A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0xA700C3A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0xA700C3A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0x48D026A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0x2600A3A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0x0000A300,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0x00A7A7A7,0x00002800,0xA7A7A700,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0x2600A3A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0x2600A3A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0x2600A3A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0x48D348A2, -0xA7A7A7D3,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0x2600A3A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0x7373D3A7,0x44131313,0x73737373, -0x73737373,0xD3CD4873,0xA7A7A7D3,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0x2600A3A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0x1348A7A7,0x2680D026,0x44CA37FE,0xCDCDCD73, -0xCDCDCDCD,0x737348CD,0x26487373,0xA7A748C0,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0x2600A3A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0x2AD226D3,0x26DB3ACB,0x73443774,0x484848CD, -0x48D348D3,0xCDCDCD48,0xFE48CDCD,0xCA2A5902,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0x2600A3A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0x0973A7A7,0x2ABA5B5B,0xFEDB3ACB,0x733774FE,0xCD48A273, -0xA7A2A748,0xCDD3A7A2,0x48CD4848,0x7A30CBBF,0xA7A7CA11,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0x2600A3A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xF8E10948,0xCBF5C1EA,0x37BF0909,0xF558BFFE,0xA519F8C1, -0x5BF8B819,0xA7A28053,0xCD48A2A7,0xCBF3F374,0xA7C15930,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0x2600A3A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0xA7A7A7A7,0xF3A7A7A7,0xE1B8E4E1,0xDBD2C15B,0xEADBBF80,0x5B76BBBB,0xC0C0532A, -0x5B2A5309,0x7691A5E1,0xA7A2133D,0xBF588073,0x02E43DF3,0xA7A7A7F3,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0x2600A3A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0xA7A7A7A7,0x59C0A7A7,0xC1F8E459,0xBFFE74DB,0x0AD4BB53,0xA748CAD0,0xA7A7A7A7, -0xA7A7A7A7,0xC074D3A7,0x740A4A91,0xF3BFFE48,0xBA80BF58,0xA7A72AE6,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0x2600A3A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0xA7A7A7A7,0x59D41173,0xBF5811E4,0xBB7616FE,0xA7730911,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0xA7A7A7A7,0x4B2ACAA7,0xFEFEBA91,0xF35858BF,0xA7304AD2,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0x2600A3A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0x13A7A7A7,0xB8D45D02,0x58BF583D,0x745B91F8,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0x5B937609,0xBFBFFEFE,0x59A95880,0xA7A7A773,0xA7A7A7A7, -0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0x2600A3A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0xD426A7A7,0x58EAD48B,0xBBBABF58,0xA7A774D5,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0x9109A7A7,0x58FE58B8,0xA980BFBF,0xA7A773E6,0xA7A7A7A7, -0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0x2600A3A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0x9B5D74A7,0x74803DD4,0x80BB76F3,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xD3A7A7A7,0x135375BA,0xBFF3DBDB,0xA7485DA9,0xA7A7A7A7, -0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0x2600A3A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0x759BA9CA,0x58BF80F5,0xA748B8B8,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xACBBD0A7,0x588080FE,0xA77A7058,0xA7A7A7A7, -0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0x2600A3A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0x48A7A7A7,0x5859AAD4,0x2158BF80,0xA7A7A711,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0x9173A7A7,0x80BFFEB8,0xE4AAD280,0xA7A7A7A7, -0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0x2600A3A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xE4A7A7A7,0xF3807598,0xC07558FE,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0x48A7A7A7,0x80FEA530,0x9811FEBF,0xA7A7A7C1, -0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0x2600A3A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0x5211A7A7,0x49F3585D,0xA709BB58,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xFE6BE1D3,0x7549BFBF,0xA7A7DB98, -0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0x2600A3A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0x676F74A7,0xFEBF803D,0xA7A7BABB,0xA7A7A7A7,0x48A7A7A7,0x48484848,0x48484848,0x48484848, -0x48484848,0xA7A7A748,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xF891A7A7,0xE9FE8074,0xA7A78B6F, -0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0x2600A3A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xEA985DA7,0xA58058F3,0xA7A7A70A,0xA7A7A7A7,0x8F55A7A7,0x4ED74ED7,0x4ED74ED7,0x4ED74ED7, -0x8F7F4ED7,0xA7A748A8,0xA7A77463,0xA7A7A7A7,0xA7A7A7A7,0xBB73A7A7,0x8058FEBA,0xA711520A, -0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0x2600A3A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xFEE4862A,0xBBEABF58,0xA7A7A7D3,0xA7A7A7A7,0xB45CCDA7,0xB0B039F9,0x39B0B0B0,0xB0B039B0, -0xF9B0B039,0x6EA7A742,0xA7A75039,0xA7A7A7A7,0xA7A7A7A7,0x49A7A7A7,0xDB745875,0x73AA8BFE, -0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0x2600A3A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0x73A7A7A7, -0xBF80DF9B,0x13BB5880,0xA7A7A7A7,0xA7A7A7A7,0x043984A7,0xE7040404,0xE7545AE7,0x5A2D5A54, -0xBDB05A54,0x1FCDA7A7,0xA7DE04F9,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xBFFEB8C0,0xE452BA80, -0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0x2600A3A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0x11A7A7A7, -0x80F3BA86,0xA7539337,0xA7A7A7A7,0xA7A7A7A7,0x39B404DB,0xB0B0B0B0,0xB0B0B0B0,0xB0B0B0B0, -0x7494B0B0,0xB089A7A7,0x737D3904,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xFEACB8A7,0x985DBFF3, -0xA7A7A7CA,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0x2600A3A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xDF48A7A7, -0xBF58808B,0xA7D3913D,0xA7A7A7A7,0xA7A7A7A7,0xBDBD7F8C,0xBDC9BDBD,0xBDBDC9BD,0xC9BDBDC9, -0xA7A6D7BD,0x041B96A7,0x47390404,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0x809126A7,0x98E1F3BF, -0xA7A7A711,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0x2600A3A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0x98F5A7A7, -0xBFBFBFBA,0xA7A726BB,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0x5AB00DA2,0x6639045A,0xA7A7A780,0xA7A7A7A7,0xA7A7A7A7,0xEA0AA7A7,0x7058BFF3, -0xA7A773DF,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0x2600A3A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0x8B5DA7A7, -0xBA74BFFE,0xA7A7D3A5,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0x5A542D40,0xB0E75A5A,0xA7A7485C,0xA7A7A7A7,0xA7A7A7A7,0x91F3A7A7,0x59BFF3BF, -0xA7A72A6F,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0x2600A3A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0x116F26A7, -0xB8BF80FE,0xA7A7A7D0,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xDAA7A7A7,0x545A2D90,0x045A5A2D,0xA7A7A639,0xA7A7A7A7,0xA7A7A7A7,0xE1A7A7A7,0xBAFEFEBA, -0xA7A7E667,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0x2600A3A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0x589BE1A7, -0xBBDEDB58,0xA7A7A773,0xA7A7A7A7,0xFCDACDA7,0xFCFCFCFC,0xDAFCFC25,0xFCFCFCFC,0xA7CDE073, -0x82A7A7A7,0x541B247E,0x5A2D544D,0xA7E00EB0,0xA7A7A7A7,0xA7A7A7A7,0x09A7A7A7,0xD2BFFEBB, -0xA7FEDF8B,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0x2600A3A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xFE41E6A7, -0x76F8DBDB,0xA7A7A7A7,0xA7A7A7A7,0x124DD773,0xED12124D,0xB1B1ADB3,0xB1B1B1B1,0xA7553BC6, -0x246EA7A7,0xED54241B,0x5AB0BDE2,0xA7A8F9E7,0xA7A7A7A7,0xA7A7A7A7,0xD3A7A7A7,0xBFFE5875, -0xA7C09BD4,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0x2600A3A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0x80CB8B73, -0xD0BB5858,0xA7A7A7A7,0xA7A7A7A7,0x39B43227,0xE7B039B0,0x542DE72D,0x3824547E,0xA74833EB, -0x383FDAA7,0x637EBCA4,0xE7B9BFA7,0x6C39E75A,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xBFFEF811, -0xA7E170B8,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0x2600A3A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xF3FE5D2A, -0xD3BB58DB,0xA7A7A7A7,0x5EA7A7A7,0x66043966,0x5A545AE7,0x24245454,0x38A4A460,0xA7A7733F, -0xA4389DA7,0xD3C97EA4,0x2D20A7A7,0x0EB05A5A,0xA7A7A737,0xA7A7A7A7,0xA7A7A7A7,0xFEFEBB26, -0x73598B0A,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0x2600A3A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0x80FEBBE4, -0xA74B6CFE,0xA7A7A7A7,0xA0FCA7A7,0x04043932,0x54545AE7,0x7E540F2D,0x3838387E,0xA7A7A763, -0x56E8E845,0xA77156A4,0xD7A7A7A7,0x39045A2D,0xA7A7A7E5,0xA7A7A7A7,0xA7A7A7A7,0x805891D3, -0x13E65DF5,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0x2600A3A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xDE58F859, -0xA7C0EABF,0xA7A7A7A7,0x4713A7A7,0x045C42F4,0x5F2D5A5A,0x202020F4,0x40202020,0x48A7A7D3, -0x07AB079C,0xA7A792A4,0xF6FB89CD,0x04E75A2D,0xA7A7E966,0xA7A7A7A7,0xA7A7A7A7,0xFE3D0AA7, -0xF3E6D4DE,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0x2600A3A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xDBDBBA59, -0xA7F3B8BF,0xA7A7A7A7,0xA7A7A7A7,0x04FF48A7,0xF40454E7,0xA7A7A7A7,0xA7A7A7A7,0xC2A7A7A7, -0x0746CC1E,0xA7A7487C,0x542D0FB6,0x045A5A5A,0xA7485C39,0xA7A7A7A7,0xA7A7A7A7,0xFE5BBAA7, -0xD0E6BB58,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0x2600A3A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0x73A7A7A7,0xDBE9DEE4, -0xA713BBBF,0xA7A7A7A7,0xA7A7A7A7,0xE7B0A8A7,0xD34E2D5A,0xA7A7A7A7,0xA7A7A7A7,0xB2C8A7A7, -0xABCCCCCC,0x29A7A745,0x5424BCA4,0x66E75454,0xA7276104,0xA7A7A7A7,0xA7A7A7A7,0xFEF8C0A7, -0xCBD4E458,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0x2600A3A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xCAA7A7A7,0xBF585830, -0xA7D3BB58,0xA7A7A7A7,0xA7A7A7A7,0xE704CF5E,0xA7805A66,0xA7A7A7A7,0xA7A7A7A7,0x1E69A7A7, -0x3EABA1A1,0x9A48A7A7,0x0F7EF27E,0x0404E72D,0x74943904,0xA7A7A7A7,0xA7A7A7A7,0xF3B8D0A7, -0xF5BBE480,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0x2600A3A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0x74A7A7A7,0xF358DEB8, -0xA7D3BB58,0xA7A7A7A7,0x48A7A7A7,0xE766398F,0xC8C80DB0,0xC8C8C80B,0xC871C8C8,0xA1858E71, -0x73DDA185,0x9AF7A7A7,0x8FC7B79A,0x04B98F8F,0x43610466,0xA7A7A7A7,0xA7A7A7A7,0xF3A580A7, -0x2ABBF858,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0x2600A3A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xF3A7A7A7,0xDBE9D2B8, -0xA7A7BBDE,0xA7A7A7A7,0x84A7A7A7,0xE7660432,0x3490905A,0x99993636,0x65B2FD46,0x85A1A165, -0xA72F1E85,0xFC48A7A7,0x73737373,0x5F554873,0x61663904,0xA7A7A7AC,0xA7A7A7A7,0xBFA526A7, -0x5302E1BF,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0x2600A3A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0x26A7A7A7,0x58DBE9F8, -0xA7A79118,0xA7A7A7A7,0x0480A7A7,0xE7040439,0x542D2D5A,0xA4F2247E,0x1EAB07E8,0x8585A1CC, -0xA7A73E1E,0xA7A7A7A7,0xA7A7A7A7,0xA6A7A7A7,0x390404B0,0xA7A7370E,0xA7A7A7A7,0xF39149A7, -0xC0E4E109,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0x2600A3A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xF3A7A7A7,0xBF585830, -0xA7A741D2,0xA7A7A7A7,0x321048A7,0xE7040439,0x54542DE7,0xA4A42424,0x1EABAB07,0xA1A1A1A1, -0xA7A71365,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xB439B42E,0xA7A76D61,0xA7A7A7A7,0x80A5F3A7, -0xD2301158,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0x2600A3A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0x74A7A7A7,0xBF585830, -0xA7D3BB58,0xA7A7A7A7,0x3932A6A7,0x04393939,0x542DE704,0xE3242454,0xABABE8E3,0xCC1ECCCC, -0xA7A7A7C2,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0x39B46616,0xA76ADC61,0xA7A7A7A7,0xFEB8D0A7, -0xD0E111D2,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0x2600A3A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xCAA7A7A7,0xBF58D2B8, -0xA773BB13,0xA7A7A7A7,0x6A3DF3A7,0xBE6A6A6A,0xBE6ABE6A,0x6E6EBE6A,0x6E6E6E6E,0x456E6E55, -0xA7A7A748,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0x6A3DBFA7,0xA7746C6A,0xA7A7A7A7,0xFEA509A7, -0xDB11C13D,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0x2600A3A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0x48A7A7A7,0x7358D2B8, -0xA713B8A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0xA2A7A7A2,0xA248A2A2,0xA7A7A2CD,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xFE0AC0A7, -0x74C12AE9,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0x2600A3A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA237BA91, -0xA7D00AA7,0xA7A7A7A7,0x4F77B5A7,0x77EF77EF,0xA7A7A2D6,0x0B77D6A7,0x48A7A7A7,0xA7A764F1, -0xF0A7A7A7,0x770B0B77,0x77777777,0xA2CD51EF,0xAFAF7797,0x9F873C77,0xA7F07B9E,0xFE1CC1A7, -0xCAF553C0,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0x2600A3A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xCDD358E1, -0xA7BA5BA7,0xA7A7A7A7,0x88774F71,0x77888888,0xA7A78701,0xEE831A87,0x25A7A7A7,0xA7AE0177, -0xEFA2A7A7,0x83878783,0x6464B551,0x7BA20897,0x6464D101,0x2BD80197,0xA7F0689F,0x58DE30A7, -0x73C0D2CB,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0x2600A3A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xCDCD7373, -0xA7B858A7,0xA7A7A7A7,0xA7648387,0x57A7A7A7,0xA2A75797,0x1AB52288,0x25A7A70B,0xA25183AF, -0x8397A7A7,0x8387871A,0xA7A7A77B,0xB5A7A7A7,0xA7A78783,0xCD887BA7,0xA7A7A7A7,0x26809148, -0xD3580958,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0x2600A3A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xCD48CDA7, -0x73934448,0xA7A7A7A7,0xA7971A0B,0x878787A7,0x9FA7A287,0x1AA77B83,0x25A7A797,0x647797AF, -0x9E1A1DA7,0x8387871A,0x7B7297F1,0x9EA7A7A7,0x9E7B8883,0xA7251D9E,0xA7A7A7A7,0xFEFEBB09, -0xA7F3D080,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0x2600A3A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0x48CD48A7, -0xC0F8A748,0xA7A7A7A7,0xA797EF87,0x1A4F22CE,0xD6A78783,0x88A2DAD8,0xCDA70B83,0xEF7B8777, -0x9F972287,0x1A87871A,0x88EF771A,0xA2A7A7A7,0xEF4F4F88,0x25D9834F,0xA7A7A7A7,0xF337EAB8, -0xA7138026,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0x2600A3A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xCD7348A7, -0xB8BAA248,0xA7A7A7A7,0xA7641A0B,0x649FDAA7,0x1A258701,0x7717D91A,0x25A7D601,0xAFA7F077, -0x0BCDAF83,0x8387871A,0xA7A2A708,0xDAA7A7A7,0x25CECE9F,0x571A1757,0x73A7A7A7,0x74F3BF75, -0xA7D349FE,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0x2600A3A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xCD73A7A7, -0xBB58A7CD,0xA7A7A713,0xA2D6EF87,0x08A7A2CD,0x83B59F01,0xD951D917,0x25CE1A4F,0x87A71D77, -0x87A76801,0x8387AE1A,0xA2A2A264,0xAFA7A2CD,0xA7A7A7F1,0x2B8388A7,0x53A7A7A7,0x1374FE76, -0xA7A73774,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0x2600A3A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0x7373A7A7, -0xB848A248,0xA7A7A753,0x228377CE,0x4FF12222,0x88D81DEF,0xA2A2A2A2,0x2564017B,0xA7A77BEF, -0x87A74868,0x83878783,0x2222F14F,0x88CED977,0x3C3C5101,0xCD7783F1,0x30A7A7A7,0x1373FE53, -0xA7A77313,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0x2600A3A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0x44D3A7A7, -0xDEA7CD48,0xA7A77375,0x88721DA7,0x88888888,0x9F72871D,0xA7A7A7A7,0xCD64B5A7,0xA7A78797, -0xDAA7A7A7,0xD6DA574C,0x88888888,0xCD25D688,0x888888B5,0xA70BD688,0xBB09A7A7,0x447373BF, -0xA7A7A713,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0x2600A3A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xCDA7A7A7, -0x48A24873,0xA7A7C0BB,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0x5BB8A7A7,0x4448CD48, -0xA7A7A748,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0x2600A3A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xD3A7A7A7, -0xA248CD73,0xA748D4DB,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xE07509A7,0x73CD48A2, -0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0x2600A3A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA248CD73,0xA75BB848,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7BABB48,0x48734848, -0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0x2600A3A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xCD4873D3,0xD075F3A2,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA248E40A,0xA273CD48, -0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0x2600A3A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xCD7373A7,0x59F5FC48,0xA7A7A737,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xC0A7A7A7,0xCDA2FE4A,0xA7487348, -0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0x2600A3A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0x4873D3A7,0xBA74CD48,0xA7A748B8,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0x7526A7A7,0xCD48A2DE,0xA7A773CD, -0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0x2600A3A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0x7348A7A7,0xFEE07373,0xA7A730B8,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xBA7573A7,0xCD4848A7,0xA7A7D373, -0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0x2600A3A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0x44A7A7A7,0xF3134444,0xA7E1A5BF,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7CBBB73,0x73CD48A2,0xA7A7A748, -0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0x2600A3A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xD3A7A7A7,0xFE3713E0,0x307680FE,0xA7A7A7D3,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0x74A7A7A7,0x48A73DBB,0x4873CDCD,0xA7A7A7A7, -0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0x2600A3A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0x49747473,0xA580FE49,0xA7A713E4,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xBB3AA7A7,0xCDD3A7BA,0xA7737348,0xA7A7A7A7, -0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0x2600A3A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0x26F313A7,0x74DB80DB,0xA7DB755B,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xFE2111A7,0xCDCDD3A7,0xA7A773CD,0xA7A7A7A7, -0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0x2600A3A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0xDB74A7A7,0x80CB093A,0xBABBBAFE,0xA7A7A748,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0x13A7A7A7,0xA737194B,0x48CDCDD3,0xA7A74873,0xA7A7A7A7, -0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0x2600A3A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0x49A7A7A7,0xD2C0D2CB,0xB8BFFEF3,0xA7A73A59,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0x4AC173A7,0x13E0FE5B,0x4473CD73,0xA7A7A7D3,0xA7A7A7A7, -0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0x2600A3A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0xA7A7A7A7,0x2AF55374,0xFEBFD211,0x0902A5DB,0xA7A7A773,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0xA7A7A7A7,0x74A7A7A7,0xBFB875C1,0x5880DBFE,0x74E4D2BF,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0x2600A3A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0xA7A7A7A7,0x5BBA74A7,0xF3F5115B,0xB86C80FE,0xA726E1BB,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0xA7A7A7A7,0x93B8CB48,0xFEFEE90A,0xFE58F3BF,0xA7C04A11,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0x2600A3A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0xA7A7A7A7,0xBACAA7A7,0x5B30E1E1,0xFEFEBFE9,0x59BBEAD2,0x48135811,0xA7A7A7A7, -0xA7A7A7A7,0xE1CB7473,0xBF5B9175,0x58F3FEFE,0xE4585858,0xA7A72659,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0x2600A3A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0xA7A7A7A7,0xD3A7A7A7,0xE4B83009,0xBF58C1E4,0x5858FEFE,0x21930ABA,0xB8E491BB, -0xBB91E4E4,0xF5EAA5BB,0xBFFEFE58,0x80585858,0x1175BADB,0xA7A7A7D3,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0x2600A3A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xE45B13A7,0xEAA5BBBB,0xFEFEF309,0x5880FEFE,0xBABAF5DE, -0xDB3DC11C,0xBF74FEBF,0xDBDBDBBF,0xC180FEF3,0xA726B802,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0x2600A3A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0x26A7A7A7,0xE6E65911,0x585B3059,0xF3FE49BF,0xF3FEF3FE, -0xF3FEBFFE,0x5858BF80,0xFEBF8058,0x3041B8CB,0xA7A7A7D2,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0x2600A3A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xD411F3A7,0xD48B8B8B,0x80DEC1B8,0xF3FEF3BF, -0xDBBFF3F3,0x49FE80BF,0xE630CBF3,0xD3D0915D,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0x2600A3A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xCAA7A7A7,0x9BE6E42A,0xE6DF6767,0x0AF8A559, -0xEAEA5BEA,0xA9BBE4F8,0x11595D8B,0xA7A7A7CA,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0x2600A3A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xC073A7A7,0x8A5D5930,0x986F6F8D, -0xAA6F6F78,0x025DDF67,0xA7A7732A,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0x2600A3A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0x73D3A7A7,0xD209D074, -0x74D009C0,0xA7A7A773,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0x2600A3A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0x00A7A7A7,0x00002800,0xA7A7A700,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0x0000A300,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0x743135A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0x74A7A7A7,0xC0C3C3C3,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xC3A7A7A7,0x00000000,0xA7A7A731,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xC3A7A7A7,0x74A7A700,0xA7A7A700,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xC3A7A7A7,0x35C3C300,0xA7A7A700,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xC3A7A7A7,0x00000000,0xA7A7A7A3,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xC3A7A7A7,0xA7A7A700,0xA7A7D500,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xC3A7A7A7,0xC0A7A700,0xA7A7D500,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xC3A7A7A7,0x00000000,0xA7A7A706,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0x0C0C0C0C,0x0C0C0C0C,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0x15151515,0x15151515, -0x0C0C0C0C,0x0C0C0C0C,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0x15151515,0x15151515, -0x0C0C0C0C,0x0C0C0C0C,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0x15151515,0x15151515, -0x0C0C0C0C,0x0C0C0C0C,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0x15151515,0x15151515, -0x0C0C0C0C,0x0C0C0C0C,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0x15151515,0x15151515, -0x0C0C0C0C,0x0C0C0C0C,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0x15151515,0x15151515, -0x0C0C0C0C,0x0C0C0C0C,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0x15151515,0x15151515, -0x0C0C0C0C,0x0C0C0C0C,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, -0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0x15151515,0x15151515}; diff --git a/Generals/Code/Libraries/Source/WWVegas/WW3D2/missingtexture.h b/Generals/Code/Libraries/Source/WWVegas/WW3D2/missingtexture.h deleted file mode 100644 index d6130ea06ec..00000000000 --- a/Generals/Code/Libraries/Source/WWVegas/WW3D2/missingtexture.h +++ /dev/null @@ -1,42 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -#if defined(_MSC_VER) -#pragma once -#endif - -#ifndef DX8_MISSING_TEXTURE_H -#define DX8_MISSING_TEXTURE_H - -#include "always.h" - -struct IDirect3DTexture8; -struct IDirect3DSurface8; - -class MissingTexture -{ -public: - static void _Init(); - static void _Deinit(); - - static IDirect3DTexture8* _Get_Missing_Texture(); // Return a reference to missing texture - static IDirect3DSurface8* _Create_Missing_Surface(); // Create new surface which contain missing texture image -}; - - -#endif // DX8_MISSING_TEXTURE \ No newline at end of file diff --git a/Generals/Code/Libraries/Source/WWVegas/WW3D2/pivot.cpp b/Generals/Code/Libraries/Source/WWVegas/WW3D2/pivot.cpp deleted file mode 100644 index 95acf22f9ec..00000000000 --- a/Generals/Code/Libraries/Source/WWVegas/WW3D2/pivot.cpp +++ /dev/null @@ -1,171 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/* $Header: /Commando/Code/ww3d2/pivot.cpp 1 1/22/01 3:36p Greg_h $ */ -/*********************************************************************************************** - *** Confidential - Westwood Studios *** - *********************************************************************************************** - * * - * Project Name : Commando / G 3D Library * - * * - * $Archive:: /Commando/Code/ww3d2/pivot.cpp $* - * * - * Author:: Greg_h * - * * - * $Modtime:: 1/08/01 10:04a $* - * * - * $Revision:: 1 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * PivotClass::PivotClass -- Constructor for PivotClass * - * PivotClass::Compute_Transform -- Update the pivot's transformation matrix * - * PivotClass::Compute_Transform -- Update the pivot's transformation matrix * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#include "pivot.h" -#include "wwmath.h" -#include - - -/*********************************************************************************************** - * PivotClass::PivotClass -- Constructor for PivotClass * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 07/24/1997 GH : Created. * - *=============================================================================================*/ -PivotClass::PivotClass(void) : - Parent(NULL), - BaseTransform(1), - Transform(1), -#ifdef LAZY_CAP_MTX_ALLOC - CapTransformPtr(NULL), - Index(0), - IsVisible(true), - WorldSpaceTranslation(false) -#else - CapTransform(1), - Index(0), - IsVisible(true), - WorldSpaceTranslation(false), - IsCaptured(false), - Unused(false) -#endif -{ - Name[0] = 0; -} - -PivotClass::PivotClass(const PivotClass& that) : - Parent(that.Parent), - BaseTransform(that.BaseTransform), - Transform(that.Transform), -#ifdef LAZY_CAP_MTX_ALLOC - CapTransformPtr(NULL), - Index(that.Index), - IsVisible(that.IsVisible), - WorldSpaceTranslation(that.WorldSpaceTranslation) -#else - CapTransform(that.CapTransform), - Index(that.Index), - IsVisible(that.IsVisible), - WorldSpaceTranslation(that.WorldSpaceTranslation), - IsCaptured(that.IsCaptured), - Unused(that.Unused) -#endif -{ - memcpy(Name, that.Name, sizeof(Name)); -#ifdef LAZY_CAP_MTX_ALLOC - if (that.CapTransformPtr != NULL) - { - CapTransformPtr = MSGW3DNEW("PivotClassCaptureBoneMtx") DynamicMatrix3D; - CapTransformPtr->Mat = that.CapTransformPtr->Mat; - } -#endif -} - -PivotClass& PivotClass::operator=(const PivotClass& that) -{ - if (this != &that) - { - memcpy(Name, that.Name, sizeof(Name)); - Parent = that.Parent; - BaseTransform = that.BaseTransform; - Transform = that.Transform; - #ifdef LAZY_CAP_MTX_ALLOC - CapTransformPtr = NULL; - Index = that.Index; - IsVisible = that.IsVisible; - WorldSpaceTranslation = that.WorldSpaceTranslation; - if (that.CapTransformPtr != NULL) - { - CapTransformPtr = MSGW3DNEW("PivotClassCaptureBoneMtx") DynamicMatrix3D; - CapTransformPtr->Mat = that.CapTransformPtr->Mat; - } - #else - CapTransform = that.CapTransform; - Index = that.Index; - IsVisible = that.IsVisible; - WorldSpaceTranslation = that.WorldSpaceTranslation; - IsCaptured = that.IsCaptured; - Unused = that.Unused; - #endif - } - return *this; -} - -void PivotClass::Capture_Update(void) -{ -#ifdef LAZY_CAP_MTX_ALLOC - if (!CapTransformPtr) - return; - - const Matrix3D* ct = &CapTransformPtr->Mat; -#else - const Matrix3D* ct = &CapTransform; -#endif - - if ( WorldSpaceTranslation ) - { - // The Translation of CapTransform is meant to be in world space, - // so remove before applying orientation - Matrix3D CapOrientation = *ct; - CapOrientation.Set_Translation( Vector3( 0,0,0 ) ); -#ifdef ALLOW_TEMPORARIES - Matrix3D::Multiply(Transform,CapOrientation,&(Transform)); -#else - Transform.postMul(CapOrientation); -#endif - // Now apply translation in world space - Transform.Adjust_Translation( ct->Get_Translation() ); - } - else - { -#ifdef ALLOW_TEMPORARIES - Matrix3D::Multiply(Transform, *ct, &(Transform)); -#else - Transform.postMul(*ct); -#endif - } -} - diff --git a/Generals/Code/Libraries/Source/WWVegas/WW3D2/pivot.h b/Generals/Code/Libraries/Source/WWVegas/WW3D2/pivot.h deleted file mode 100644 index c083133df3b..00000000000 --- a/Generals/Code/Libraries/Source/WWVegas/WW3D2/pivot.h +++ /dev/null @@ -1,114 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/* $Header: /Commando/Code/ww3d2/pivot.h 1 1/22/01 3:36p Greg_h $ */ -/*********************************************************************************************** - *** Confidential - Westwood Studios *** - *********************************************************************************************** - * * - * Project Name : Commando / G 3D Library * - * * - * $Archive:: /Commando/Code/ww3d2/pivot.h $* - * * - * Author:: Greg_h * - * * - * $Modtime:: 1/08/01 10:04a $* - * * - * $Revision:: 1 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#if defined(_MSC_VER) -#pragma once -#endif - -#ifndef PIVOT_H -#define PIVOT_H - -#include "always.h" -#include "vector3.h" -#include "matrix3d.h" -#include "quat.h" -#include "w3d_file.h" - - -/* - - PivotClass - - Each node of the hierarchy tree is represented by a - PivotClass. - -*/ - -//#define LAZY_CAP_MTX_ALLOC - -struct PivotClass -{ -public: - - PivotClass(void); - PivotClass(const PivotClass& that); - PivotClass& operator=(const PivotClass& that); - - ~PivotClass(void) - { -#ifdef LAZY_CAP_MTX_ALLOC - if (CapTransformPtr) - delete CapTransformPtr; -#endif - } - - void Capture_Update(void); - bool Is_Captured() const - { -#ifdef LAZY_CAP_MTX_ALLOC - return CapTransformPtr != NULL; -#else - return IsCaptured; -#endif - } - -public: - char Name[W3D_NAME_LEN]; - PivotClass * Parent; - Matrix3D BaseTransform; // base-pose transform (relative to parent). - Matrix3D Transform; // computed transform for this pivot - // User control. When a pivot is 'captured' animation data is ignored and the - // user data is used to control the pivot. -#ifdef LAZY_CAP_MTX_ALLOC - DynamicMatrix3D* CapTransformPtr; - short Index; - bool IsVisible; // result of the visibility channel - bool WorldSpaceTranslation; -#else - Matrix3D CapTransform; - int Index; - bool IsVisible; // result of the visibility channel - bool WorldSpaceTranslation; - bool IsCaptured; - bool Unused; // padding -#endif - -}; - - - -#endif \ No newline at end of file diff --git a/Generals/Code/Libraries/Source/WWVegas/WW3D2/pointgr.cpp b/Generals/Code/Libraries/Source/WWVegas/WW3D2/pointgr.cpp deleted file mode 100644 index eb959c193df..00000000000 --- a/Generals/Code/Libraries/Source/WWVegas/WW3D2/pointgr.cpp +++ /dev/null @@ -1,1916 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*************************************************************************** - *** 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 *** - *************************************************************************** - * * - * Project Name : G * - * * - * $Archive:: /VSS_Sync/ww3d2/pointgr.cpp $* - * * - * Org Author:: Greg Hjelstrom * - * * - * $Author:: Kenny Mitchell * - * * - * $Modtime:: 06/26/02 4:04p $* - * * - * $Revision:: 38 $* - * * - * 06/26/02 KM Matrix name change to avoid MAX conflicts * - *-------------------------------------------------------------------------* - * Functions: * - * PointGroupClass::PointGroupClass -- PointGroupClass CTor. * - * PointGroupClass::~PointGroupClass -- PointGroupClass DTor. * - * PointGroupClass::operator = -- PointGroupClass assignment operator. * - * PointGroupClass::Set_Arrays -- Set point location/color/enable arrays.* - * PointGroupClass::Set_Point_Size -- Set default point size. * - * PointGroupClass::Get_Point_Size -- Get default point size. * - * PointGroupClass::Set_Point_Color -- Set default point color. * - * PointGroupClass::Get_Point_Color -- Get default point color. * - * PointGroupClass::Set_Point_Alpha -- Set default point alpha. * - * PointGroupClass::Get_Point_Alpha -- Get default point alpha. * - * PointGroupClass::Set_Point_Orientation -- Set default point orientatio* - * PointGroupClass::Get_Point_Orientation -- Get default point orientatio* - * PointGroupClass::Set_Point_Frame -- Set default point frame. * - * PointGroupClass::Get_Point_Frame -- Get default point frame. * - * PointGroupClass::Set_Point_Mode -- Set point rendering method. * - * PointGroupClass::Get_Point_Mode -- Get point rendering method. * - * PointGroupClass::Set_Flag -- Set given flag to on or off. * - * PointGroupClass::Get_Flag -- Get current value (on/off) of given flag.* - * PointGroupClass::Set_Texture -- Set texture used. * - * PointGroupClass::Get_Texture -- Get texture used. * - * PointGroupClass::Set_Shader -- Set shader used. * - * PointGroupClass::Get_Shader -- Get shader used. * - * PointGroupClass::Set_Billboard -- Set whether to billboard. * - * PointGroupClass::Get_Billboard -- Get whether to billboard. * - * PointGroupClass::Get_Discrete_Orientation_Count_Log2 -- what it says * - * PointGroupClass::Set_Discrete_Orientation_Count_Log2 -- what it says. * - * PointGroupClass::Get_Frame_Row_Column_Count_Log2 -- what it says * - * PointGroupClass::Set_Frame_Row_Column_Count_Log2 -- what it says. * - * PointGroupClass::Get_Polygon_Count -- Get estimated polygon count. * - * PointGroupClass::Render -- draw point group. * - * PointGroupClass::vInstance -- Create instance of class. * - * PointGroupClass::sGetClassName -- Get name of class. * - * PointGroupClass::Update_Arrays -- Update all arrays used in rendering * - * PointGroupClass::Peek_Texture -- Peeks texture * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#include "pointgr.h" -#include "vertmaterial.h" -#include "ww3d.h" -#include "aabox.h" -#include "statistics.h" -#include "simplevec.h" -#include "texture.h" -#include "Vector.H" -#include "vp.h" -#include "matrix4.h" -#include "dx8wrapper.h" -#include "dx8vertexbuffer.h" -#include "dx8indexbuffer.h" -#include "rinfo.h" -#include "camera.h" -#include "dx8fvf.h" -#include "d3dx8math.h" -#include "sortingrenderer.h" - -// Upgraded to DX8 2/2/01 HY - -// static data members -Vector3 PointGroupClass::_TriVertexLocationOrientationTable[256][3]; -Vector3 PointGroupClass::_QuadVertexLocationOrientationTable[256][4]; -Vector2 *PointGroupClass::_TriVertexUVFrameTable[5] = { NULL, NULL, NULL, NULL, NULL}; -Vector2 *PointGroupClass::_QuadVertexUVFrameTable[5] = { NULL, NULL, NULL, NULL, NULL}; -VertexMaterialClass *PointGroupClass::PointMaterial=NULL; - -// Static arrays for intermediate calcs (never resized down, just up): -VectorClass PointGroupClass::compressed_loc; // point locations 'compressed' by APT -VectorClass PointGroupClass::compressed_diffuse; // point colors 'compressed' by APT -VectorClass PointGroupClass::compressed_size; // point sizes 'compressed' by APT -VectorClass PointGroupClass::compressed_orient; // point orientations 'compressed' by APT -VectorClass PointGroupClass::compressed_frame; // point frames 'compressed' by APT -VectorClass PointGroupClass::transformed_loc; // transformed point locations - -// This array has vertex locations for screenspace mode - calculated to cover exactly 1x1 and 2x2 pixels. -Vector3 PointGroupClass::_ScreenspaceVertexLocationSizeTable[2][3] = -{ - Vector3(0.5f, 0.0f, -1.0f), - Vector3(1.0f, 1.0f, -1.0f), - Vector3(0.0f, 1.0f, -1.0f), - Vector3(1.0f, -0.5f, -1.0f), - Vector3(2.7f, 2.0f, -1.0f), - Vector3(-0.7f, 2.0f, -1.0f) -}; - -// useful for particles that aren't aligned with the screen. -static Vector3 GroundMultiplierX(1.0f, 0.0f, 0.0f); -static Vector3 GroundMultiplierY(0.0f, 1.0f, 0.0f); - -// Some internal variables -VectorClass VertexLoc; // camera-space vertex locations -VectorClass VertexDiffuse; // vertex diffuse/alpha colors -VectorClass VertexUV; // vertex texture coords - -// Some DX 8 variables -#define MAX_VB_SIZE 2048 -#define MAX_TRI_POINTS MAX_VB_SIZE/3 -#define MAX_TRI_IB_SIZE 3*MAX_TRI_POINTS -#define MAX_QUAD_POINTS MAX_VB_SIZE/4 -#define MAX_QUAD_IB_SIZE 6*MAX_QUAD_POINTS - -DX8IndexBufferClass *Tris, *Quads; // Index buffers. -SortingIndexBufferClass *SortingTris, *SortingQuads; // Sorting index buffers. - -/************************************************************************** - * PointGroupClass::PointGroupClass -- PointGroupClass CTor. * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 11/17/1998 NH : Created. * - *========================================================================*/ -PointGroupClass::PointGroupClass(void) : - PointLoc(NULL), - PointDiffuse(NULL), - APT(NULL), - PointSize(NULL), - PointOrientation(NULL), - PointFrame(NULL), - PointCount(0), - FrameRowColumnCountLog2(0), - Texture(NULL), - Flags(0), - Shader(ShaderClass::_PresetAdditiveSpriteShader), - PointMode(TRIS), - DefaultPointSize(0.0f), - DefaultPointColor(1.0f, 1.0f, 1.0f), - DefaultPointAlpha(1.0f), - DefaultPointOrientation(0), - DefaultPointFrame(0), - VPXMin(0.0f), - VPYMin(0.0f), - VPXMax(0.0f), - VPYMax(0.0f) -{ -} - -/************************************************************************** - * PointGroupClass::~PointGroupClass -- PointGroupClass DTor. * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 11/17/1998 NH : Created. * - *========================================================================*/ -PointGroupClass::~PointGroupClass(void) -{ - if (PointLoc) { - PointLoc->Release_Ref(); - PointLoc = NULL; - } - if (PointDiffuse) { - PointDiffuse->Release_Ref(); - PointDiffuse=NULL; - } - if (APT) { - APT->Release_Ref(); - APT = NULL; - } - if (PointSize) { - PointSize->Release_Ref(); - PointSize = NULL; - } - if (PointOrientation) { - PointOrientation->Release_Ref(); - PointOrientation = NULL; - } - if (PointFrame) { - PointFrame->Release_Ref(); - PointFrame = NULL; - } - if (Texture) { - REF_PTR_RELEASE(Texture); - Texture = NULL; - } -} - -/************************************************************************** - * PointGroupClass::operator = -- PointGroupClass assignment operator. * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 11/17/1998 NH : Created. * - *========================================================================*/ -PointGroupClass & PointGroupClass::operator = (const PointGroupClass & that) -{ - if (this != &that) { - WWASSERT(0); // If you hit this assert implement the function! - } - return *this; -} - - -/************************************************************************** - * PointGroupClass::Set_Arrays -- Set point location/color/enable arrays. * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * NOTES: colors, alphas, APT, sizes, orientations and frames are * - * optional. active_point_count can also be used with a NULL apt.* - * In this case active_point_count is ignored if it is -1 * - * (default value) and otherwise it indicates the first N active * - * points in the arrays. * - * The view plane rectangle may optionally be passed as well - * - * this is only used in SCREENSPACE mode. * - * * - * HISTORY: * - * 11/17/1998 NH : Created. * - * 08/25/1999 NH : Alphas added. * - * 06/28/2000 NH : Orientations and frames added. * - * 02/08/2001 HY : Upgraded to DX8 * - *========================================================================*/ -void PointGroupClass::Set_Arrays( - ShareBufferClass *locs, - ShareBufferClass *diffuse, - ShareBufferClass *apt, - ShareBufferClass *sizes, - ShareBufferClass *orientations, - ShareBufferClass *frames, - int active_point_count, - float vpxmin, - float vpymin, - float vpxmax, - float vpymax) -{ - // The point locations array is NOT optional! - WWASSERT(locs); - - // Ensure lengths of all arrays are the same: - WWASSERT(!diffuse || locs->Get_Count() == diffuse->Get_Count()); - WWASSERT(!apt || locs->Get_Count() == apt->Get_Count()); - WWASSERT(!sizes || locs->Get_Count() == sizes->Get_Count()); - WWASSERT(!orientations || locs->Get_Count() == orientations->Get_Count()); - WWASSERT(!frames || locs->Get_Count() == frames->Get_Count()); - - REF_PTR_SET(PointLoc,locs); - REF_PTR_SET(PointDiffuse,diffuse); - REF_PTR_SET(APT,apt); - REF_PTR_SET(PointSize,sizes); - REF_PTR_SET(PointOrientation,orientations); - REF_PTR_SET(PointFrame,frames); - - if (APT) { - PointCount = active_point_count; - } else { - PointCount = (active_point_count >= 0) ? active_point_count : PointLoc->Get_Count(); - } - - // Store view plane rectangle (only used in SCREENSPACE mode) - VPXMin = vpxmin; - VPYMin = vpymin; - VPXMax = vpxmax; - VPYMax = vpymax; -} - -/************************************************************************** - * PointGroupClass::Set_Point_Size -- Set default point size. * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: This size is ignored if a size array is present. * - * * - * HISTORY: * - * 11/17/1998 NH : Created. * - *========================================================================*/ -void PointGroupClass::Set_Point_Size(float size) -{ - DefaultPointSize = size; -} - - -/************************************************************************** - * PointGroupClass::Get_Point_Size -- Get default point size. * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: This size is ignored if a size array is present. * - * * - * HISTORY: * - * 11/17/1998 NH : Created. * - *========================================================================*/ -float PointGroupClass::Get_Point_Size(void) -{ - return DefaultPointSize; -} - - -/************************************************************************** - * PointGroupClass::Set_Point_Color -- Set default point color. * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: This color is ignored if a color array is present. * - * * - * HISTORY: * - * 04/20/1999 NH : Created. * - *========================================================================*/ -void PointGroupClass::Set_Point_Color(Vector3 color) -{ - DefaultPointColor = color; -} - -/************************************************************************** - * PointGroupClass::Get_Point_Color -- Get default point color. * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: This color is ignored if a color array is present. * - * * - * HISTORY: * - * 04/20/1999 NH : Created. * - *========================================================================*/ -Vector3 PointGroupClass::Get_Point_Color(void) -{ - return DefaultPointColor; -} - -/************************************************************************** - * PointGroupClass::Set_Point_Alpha -- Set default point alpha. * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: This alpha is ignored if an alpha array is present. * - * * - * HISTORY: * - * 08/25/1999 NH : Created. * - *========================================================================*/ -void PointGroupClass::Set_Point_Alpha(float alpha) -{ - DefaultPointAlpha = alpha; -} - - -/************************************************************************** - * PointGroupClass::Get_Point_Alpha -- Get default point alpha. * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: This alpha is ignored if an alpha array is present. * - * * - * HISTORY: * - * 08/25/1999 NH : Created. * - *========================================================================*/ -float PointGroupClass::Get_Point_Alpha(void) -{ - return DefaultPointAlpha; -} - - -/************************************************************************** - * PointGroupClass::Set_Point_Orientation -- Set default point orientation* - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: This is ignored if an orientation array is present. * - * * - * NOTE: No need to ensure value in valid range - it will be masked later.* - * * - * HISTORY: * - * 06/28/2000 NH : Created. * - *========================================================================*/ -void PointGroupClass::Set_Point_Orientation(unsigned char orientation) -{ - DefaultPointOrientation = orientation; -} - - -/************************************************************************** - * PointGroupClass::Get_Point_Orientation -- Get default point orientation* - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: This is ignored if an orientation array is present. * - * * - * HISTORY: * - * 06/28/2000 NH : Created. * - *========================================================================*/ -unsigned char PointGroupClass::Get_Point_Orientation(void) -{ - return DefaultPointOrientation; -} - - -/************************************************************************** - * PointGroupClass::Set_Point_Frame -- Set default point frame. * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: This frame is ignored if an frame array is present. * - * * - * NOTE: No need to ensure value in valid range - it will be masked later.* - * * - * HISTORY: * - * 06/28/2000 NH : Created. * - *========================================================================*/ -void PointGroupClass::Set_Point_Frame(unsigned char frame) -{ - DefaultPointFrame = frame; -} - - -/************************************************************************** - * PointGroupClass::Get_Point_Frame -- Get default point frame. * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: This frame is ignored if an frame array is present. * - * * - * HISTORY: * - * 06/28/2000 NH : Created. * - *========================================================================*/ -unsigned char PointGroupClass::Get_Point_Frame(void) -{ - return DefaultPointFrame; -} - - -/************************************************************************** - * PointGroupClass::Set_Point_Mode -- Set point rendering method. * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 11/17/1998 NH : Created. * - *========================================================================*/ -void PointGroupClass::Set_Point_Mode(PointModeEnum mode) -{ - PointMode = mode; -} - - -/************************************************************************** - * PointGroupClass::Get_Point_Mode -- Get point rendering method. * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 11/17/1998 NH : Created. * - *========================================================================*/ -PointGroupClass::PointModeEnum PointGroupClass::Get_Point_Mode(void) -{ - return PointMode; -} - - -/************************************************************************** - * Set_Flag -- PointGroupClass::Set given flag to on or off. * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 11/17/1998 NH : Created. * - *========================================================================*/ -void PointGroupClass::Set_Flag(FlagsType flag, bool onoff) -{ - if (onoff) Flags|=1<>flag) & 0x1; -} - -/************************************************************************** - * PointGroupClass::Set_Texture -- Set texture used. * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 11/17/1998 NH : Created. * - * 02/08/2001 HY : Upgraded to DX8 * - *========================================================================*/ -void PointGroupClass::Set_Texture(TextureClass* texture) -{ - REF_PTR_SET(Texture,texture); -} - -/************************************************************************** - * PointGroupClass::Get_Texture -- Get texture used. * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 11/17/1998 NH : Created. * - * 02/08/2001 HY : Upgraded to DX8 * - *========================================================================*/ -TextureClass * PointGroupClass::Get_Texture(void) -{ - if (Texture) Texture->Add_Ref(); - return Texture; -} - - -/*********************************************************************************************** - * PointGroupClass::Peek_Texture -- Peeks texture * - * * - * * - * * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 4/12/2001 hy : Created. * - *=============================================================================================*/ -TextureClass * PointGroupClass::Peek_Texture(void) -{ - return Texture; -} - -/************************************************************************** - * PointGroupClass::Set_Shader -- Set shader used. * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: the primary gradient will be set to MODULATE/DISABLE in * - * the shader depending on whether a color or alpha array was * - * passed in Set_Point_Arrays. also, texturing will be * - * enabled or disabled dependent on whether a non-NULL * - * texture was set. * - * these will override the primary gradient/texturing * - * settings in the given shader. * - * * - * HISTORY: * - * 11/17/1998 NH : Created. * - * 02/08/2001 HY : Upgraded to DX8 * - *========================================================================*/ -void PointGroupClass::Set_Shader(ShaderClass shader) -{ - Shader = shader; -} - - -/************************************************************************** - * PointGroupClass::Get_Shader -- Get shader used. * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 11/17/1998 NH : Created. * - * 02/08/2001 HY : Upgraded to DX8 * - *========================================================================*/ -ShaderClass PointGroupClass::Get_Shader(void) -{ - return Shader; -} - -/************************************************************************** - * PointGroupClass::Set_Billboard -- Set whether to Billboard. * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 04/25/2002 JM : Created. * - *========================================================================*/ -void PointGroupClass::Set_Billboard(bool shouldBillboard) -{ - Billboard = shouldBillboard; -} - -/************************************************************************** - * PointGroupClass::Get_Billboard -- Get whether to Billboard. * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 04/25/2002 JM : Created. * - *========================================================================*/ -bool PointGroupClass::Get_Billboard(void) -{ - return Billboard; -} - -/************************************************************************** - * PointGroupClass::Get_Frame_Row_Column_Count_Log2 -- what it says * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 06/28/2000 NH : Created. * - * 02/08/2001 HY : Upgraded to DX8 * - *========================================================================*/ -unsigned char PointGroupClass::Get_Frame_Row_Column_Count_Log2(void) -{ - return FrameRowColumnCountLog2; -} - - -/************************************************************************** - * PointGroupClass::Set_Frame_Row_Column_Count_Log2 -- what it says. * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 06/28/2000 NH : Created. * - * 02/08/2001 HY : Upgraded to DX8 * - *========================================================================*/ -void PointGroupClass::Set_Frame_Row_Column_Count_Log2(unsigned char frccl2) -{ - FrameRowColumnCountLog2 = MIN(frccl2, 4); -} - -/************************************************************************** - * PointGroupClass::Get_Polygon_Count -- Get estimated polygon count. * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 11/18/1998 NH : Created. * - * 02/08/2001 HY : Upgraded to DX8 * - *========================================================================*/ -int PointGroupClass::Get_Polygon_Count(void) -{ - switch (PointMode) { - case TRIS: - case SCREENSPACE: - return PointCount; - break; - case QUADS: - return PointCount * 2; - break; - } - WWASSERT(0); - return 0; -} - -/************************************************************************** - * PointGroupClass::Render -- draw point group. * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 12/10/1998 NH : Created. * - * 02/08/2001 HY : Upgraded to DX8 * - *========================================================================*/ -static SimpleVecClass remap; -void PointGroupClass::Render(RenderInfoClass &rinfo) -{ - /// @todo lorenzen asks: is particle culling in the shader perhaps faster than in DoParticles? Fix winding and find out... - // NB: the winding for pointgroups is wrong, but we - // are disabling culling for particles anyway - Shader.Set_Cull_Mode(ShaderClass::CULL_MODE_DISABLE); - - // If no points, do nothing: - if (PointCount == 0) return; - - WWASSERT(PointLoc && PointLoc->Get_Array()); - - // Process texture reductions: -// if (Texture) Texture->Process_Reduction(); - - // Pointers which point into existing buffers (member or static): - Vector3 *current_loc = NULL; - Vector4 *current_diffuse = NULL; - float *current_size = NULL; - unsigned char *current_orient = NULL; - unsigned char *current_frame = NULL; - - // If there is a color or alpha array enable gradient in shader - otherwise disable. - float value_255 = 0.9961f; //254 / 255 - bool default_white_opaque = ( DefaultPointColor.X > value_255 && - DefaultPointColor.Y > value_255 && - DefaultPointColor.Z > value_255 && - DefaultPointAlpha > value_255); - - // The reason we check for lack of texture here is that SR seems to render black triangles - // rather than white triangles as would be expected) when there is no texture AND no gradient. - if (PointDiffuse || !default_white_opaque || !Texture) { - Shader.Set_Primary_Gradient(ShaderClass::GRADIENT_MODULATE); - } else { - Shader.Set_Primary_Gradient(ShaderClass::GRADIENT_DISABLE); - } - - // If Texture is non-NULL enable texturing in shader - otherwise disable. - if (Texture) { - Shader.Set_Texturing(ShaderClass::TEXTURING_ENABLE); - } else { - Shader.Set_Texturing(ShaderClass::TEXTURING_DISABLE); - } - - // If there is an active point table, use it to compress the point - // locations/colors/alphas/sizes/orientations/frames. - if (APT) { - // Resize compressed result arrays if needed (2x guardband to prevent - // frequent reallocations): - - /// @todo lorenzen sez: precompute pointers to indexed array elements, below - - if (compressed_loc.Length() < PointCount) { - compressed_loc.Resize(PointCount * 2); - } - VectorProcessorClass::CopyIndexed(&compressed_loc[0], - PointLoc->Get_Array(), APT->Get_Array(), PointCount); - current_loc = &compressed_loc[0]; - if (PointDiffuse) { - if (compressed_diffuse.Length() < PointCount) { - compressed_diffuse.Resize(PointCount * 2); - } - VectorProcessorClass::CopyIndexed(&compressed_diffuse[0], - PointDiffuse->Get_Array(), APT->Get_Array(), PointCount); - current_diffuse = &compressed_diffuse[0]; - } - if (PointSize) { - if (compressed_size.Length() < PointCount) { - compressed_size.Resize(PointCount * 2); - } - VectorProcessorClass::CopyIndexed(&compressed_size[0], - PointSize->Get_Array(), APT->Get_Array(), PointCount); - current_size = &compressed_size[0]; - } - if (PointOrientation) { - if (compressed_orient.Length() < PointCount) { - compressed_orient.Resize(PointCount * 2); - } - VectorProcessorClass::CopyIndexed(&compressed_orient[0], - PointOrientation->Get_Array(), APT->Get_Array(), PointCount); - current_orient = &compressed_orient[0]; - } - if (PointFrame) { - if (compressed_frame.Length() < PointCount) { - compressed_frame.Resize(PointCount * 2); - } - VectorProcessorClass::CopyIndexed(&compressed_frame[0], - PointFrame->Get_Array(), APT->Get_Array(), PointCount); - current_frame = &compressed_frame[0]; - } - } else { - current_loc = PointLoc->Get_Array(); - if (PointDiffuse) { - current_diffuse = PointDiffuse->Get_Array(); - } - if (PointSize) { - current_size = PointSize->Get_Array(); - } - if (PointOrientation) { - current_orient = PointOrientation->Get_Array(); - } - if (PointFrame) { - current_frame = PointFrame->Get_Array(); - } - } - - // Get the world and view matrices - Matrix4x4 view; - DX8Wrapper::Get_Transform(D3DTS_VIEW,view); - - // Transform the point locations from worldspace to camera space if needed - // (i.e. if they are not already in camera space): - - // need to interrupt this processing. If we are not billboarding, then we need the actual position - // of the vertice to lay it down flat. - - // (gth) changed this 'if' to use OR rather than AND... The way it was caused all emitters to break - if (Get_Flag(TRANSFORM) && Billboard) { - // Resize transformed location array if needed (2x guardband to prevent - // frequent reallocations): - if (transformed_loc.Length() < PointCount) { - transformed_loc.Resize(PointCount * 2); - } - // Not using vector processor class because we are discarding w - // Not using T&L in DX8 because we don't want DX8 to transform - // 3 times per particle when we can do it once - for (int i=0; iGet_Count(), vnum, pnum); - - // the locations are now in view space - // so set world and view matrices to identity and render - - Matrix4x4 identity(true); - DX8Wrapper::Set_Transform(D3DTS_WORLD,identity); - DX8Wrapper::Set_Transform(D3DTS_VIEW,identity); - - DX8Wrapper::Set_Material(PointMaterial); - DX8Wrapper::Set_Shader(Shader); - DX8Wrapper::Set_Texture(0,Texture); - - // Enable sorting if the primitives are translucent and alpha testing is not enabled. - const bool sort = (Shader.Get_Dst_Blend_Func() != ShaderClass::DSTBLEND_ZERO) && (Shader.Get_Alpha_Test() == ShaderClass::ALPHATEST_DISABLE) && (WW3D::Is_Sorting_Enabled()); - - IndexBufferClass *indexbuffer; - int verticesperprimitive;/// lorenzen fixed - int current; - int delta; - - /// @todo lorenzen sez: if tri-based particles are not supported, elim this test - if (PointMode == QUADS) { - verticesperprimitive = 2; - indexbuffer = sort ? static_cast (SortingQuads) : static_cast (Quads); - } else { - verticesperprimitive = 3; - indexbuffer = sort ? static_cast (SortingTris) : static_cast (Tris); - } - - current = 0; - while (current MAX_VOLUME_PARTICLE_DEPTH ) - depth = MAX_VOLUME_PARTICLE_DEPTH; // sanity - - Shader.Set_Cull_Mode(ShaderClass::CULL_MODE_DISABLE); - - if (PointCount == 0) - return; - - WWASSERT(PointLoc && PointLoc->Get_Array()); - - // Pointers which point into existing buffers (member or static): - Vector3 *current_loc = NULL; - Vector4 *current_diffuse = NULL; - float *current_size = NULL; - unsigned char *current_orient = NULL; - unsigned char *current_frame = NULL; - - // If there is a color or alpha array enable gradient in shader - otherwise disable. - float value_255 = 0.9961f; //254 / 255 - bool default_white_opaque = ( DefaultPointColor.X > value_255 && - DefaultPointColor.Y > value_255 && - DefaultPointColor.Z > value_255 && - DefaultPointAlpha > value_255); - - // The reason we check for lack of texture here is that SR seems to render black triangles - // rather than white triangles as would be expected) when there is no texture AND no gradient. - if (PointDiffuse || !default_white_opaque || !Texture) { - Shader.Set_Primary_Gradient(ShaderClass::GRADIENT_MODULATE); - } else { - Shader.Set_Primary_Gradient(ShaderClass::GRADIENT_DISABLE); - } - - // If Texture is non-NULL enable texturing in shader - otherwise disable. - if (Texture) { - Shader.Set_Texturing(ShaderClass::TEXTURING_ENABLE); - } else { - Shader.Set_Texturing(ShaderClass::TEXTURING_DISABLE); - } - - // Get the world and view matrices - Matrix4x4 view; - DX8Wrapper::Get_Transform(D3DTS_VIEW,view); - - - - //// VOLUME_PARTICLE LOOP /////////////// - for ( int t = 0; t < depth; ++t ) - { - - - - - - // If there is an active point table, use it to compress the point - // locations/colors/alphas/sizes/orientations/frames. - if (APT) { - // Resize compressed result arrays if needed (2x guardband to prevent - // frequent reallocations): - - /// @todo lorenzen sez: precompute pointers to indexed array elements, below - - if (compressed_loc.Length() < PointCount) { - compressed_loc.Resize(PointCount * 2); - } - VectorProcessorClass::CopyIndexed(&compressed_loc[0], - PointLoc->Get_Array(), APT->Get_Array(), PointCount); - current_loc = &compressed_loc[0]; - if (PointDiffuse) { - if (compressed_diffuse.Length() < PointCount) { - compressed_diffuse.Resize(PointCount * 2); - } - VectorProcessorClass::CopyIndexed(&compressed_diffuse[0], - PointDiffuse->Get_Array(), APT->Get_Array(), PointCount); - current_diffuse = &compressed_diffuse[0]; - } - if (PointSize) { - if (compressed_size.Length() < PointCount) { - compressed_size.Resize(PointCount * 2); - } - VectorProcessorClass::CopyIndexed(&compressed_size[0], - PointSize->Get_Array(), APT->Get_Array(), PointCount); - current_size = &compressed_size[0]; - } - if (PointOrientation) { - if (compressed_orient.Length() < PointCount) { - compressed_orient.Resize(PointCount * 2); - } - VectorProcessorClass::CopyIndexed(&compressed_orient[0], - PointOrientation->Get_Array(), APT->Get_Array(), PointCount); - current_orient = &compressed_orient[0]; - } - if (PointFrame) { - if (compressed_frame.Length() < PointCount) { - compressed_frame.Resize(PointCount * 2); - } - VectorProcessorClass::CopyIndexed(&compressed_frame[0], - PointFrame->Get_Array(), APT->Get_Array(), PointCount); - current_frame = &compressed_frame[0]; - } - } else { - current_loc = PointLoc->Get_Array(); - if (PointDiffuse) { - current_diffuse = PointDiffuse->Get_Array(); - } - if (PointSize) { - current_size = PointSize->Get_Array(); - } - if (PointOrientation) { - current_orient = PointOrientation->Get_Array(); - } - if (PointFrame) { - current_frame = PointFrame->Get_Array(); - } - } - - - - - - // Transform the point locations from worldspace to camera space if needed - // (i.e. if they are not already in camera space): - - // need to interrupt this processing. If we are not billboarding, then we need the actual position - // of the vertice to lay it down flat. - if (Get_Flag(TRANSFORM) && Billboard) { - // Resize transformed location array if needed (2x guardband to prevent - // frequent reallocations): - if (transformed_loc.Length() < PointCount) { - transformed_loc.Resize(PointCount * 2); - } - // Not using vector processor class because we are discarding w - // Not using T&L in DX8 because we don't want DX8 to transform - // 3 times per particle when we can do it once - float recipDepth = 0.1f / (float)depth; - - float shiftInc = ( t * *current_size * recipDepth ); - - Vector3 volumeLayerShift; - Vector3 cameraPosition = rinfo.Camera.Get_Position(); - - for (int i=0; iX *= attenuator; - //current_diffuse->Y *= attenuator; - //current_diffuse->Z *= attenuator; - //current_diffuse->W *= attenuator; - - Update_Arrays(current_loc, current_diffuse, current_size, current_orient, current_frame, - PointCount, PointLoc->Get_Count(), vnum, pnum); - - // the locations are now in view space - // so set world and view matrices to identity and render - - Matrix4x4 identity(true); - DX8Wrapper::Set_Transform(D3DTS_WORLD,identity); - DX8Wrapper::Set_Transform(D3DTS_VIEW,identity); - - DX8Wrapper::Set_Material(PointMaterial); - DX8Wrapper::Set_Shader(Shader); - DX8Wrapper::Set_Texture(0,Texture); - - // Enable sorting if the primitives are translucent and alpha testing is not enabled. - const bool sort = (Shader.Get_Dst_Blend_Func() != ShaderClass::DSTBLEND_ZERO) && (Shader.Get_Alpha_Test() == ShaderClass::ALPHATEST_DISABLE) && (WW3D::Is_Sorting_Enabled()); - - IndexBufferClass *indexbuffer; - int verticesperprimitive;/// lorenzen fixed - int current; - int delta; - - /// @todo lorenzen sez: if tri-based particles are not supported, elim this test - if (PointMode == QUADS) { - verticesperprimitive = 2; - indexbuffer = sort ? static_cast (SortingQuads) : static_cast (Quads); - } else { - verticesperprimitive = 3; - indexbuffer = sort ? static_cast (SortingTris) : static_cast (Tris); - } - - - float nudge = 0; - - current = 0; - while (current. -*/ - -/*************************************************************************** - *** 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 *** - *************************************************************************** - * * - * Project Name : G * - * * - * $Archive:: /Commando/Code/ww3d2/pointgr.h $* - * * - * $Author:: Naty_h $* - * * - * $Modtime:: 8/02/01 8:34p $* - * * - * $Revision:: 10 $* - * * - *-------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#if defined(_MSC_VER) -#pragma once -#endif - -#ifndef POINTGR_H -#define POINTGR_H - -#include "sharebuf.h" -#include "shader.h" -#include "vector4.h" -#include "vector3.h" -#include "vector2.h" -#include "Vector.H" - -class VertexMaterialClass; -class RenderInfoClass; -class TextureClass; - -/* -** PointGroupClass -- a custom object for rendering -** groups of points (such as particle systems). -** It is possible to change mode/number of points/shader/etc. but these -** changes tend to be expensive if done often. Expected usage is to set the -** point location/color/active arrays each frame the object is visible (with -** the same number of points) and perform other changes relatively rarely. -** NOTE: Currently it is implemented using general triangles (1 or 2 per -** point), so it is probably suboptimal for software rasterization devices -** (which would probably perform better with some kind of blit/sprite code). -*/ -class PointGroupClass -{ -public: - - enum PointModeEnum { - TRIS, // each point is a triangle - QUADS, // each point is a quad formed out of two triangles - SCREENSPACE // each point is a tri placed to affect certain pixels (should be used with 2D camera) - }; - - enum FlagsType { - TRANSFORM, // transform points w. modelview matrix (worldspace points) - }; - - PointGroupClass(void); - virtual ~PointGroupClass(void); - PointGroupClass & operator = (const PointGroupClass & that); - - // PointGroupClass interface: - void Set_Arrays(ShareBufferClass *locs, - ShareBufferClass *diffuse = NULL, - ShareBufferClass *apt = NULL, - ShareBufferClass *sizes = NULL, - ShareBufferClass *orientations = NULL, - ShareBufferClass *frames = NULL, - int active_point_count = -1, - float vpxmin = 0.0f, float vpymin = 0.0f, - float vpxmax = 0.0f, float vpymax = 0.0f); - void Set_Point_Size(float size); - float Get_Point_Size(void); - void Set_Point_Color(Vector3 color); - Vector3 Get_Point_Color(void); - void Set_Point_Alpha(float alpha); - float Get_Point_Alpha(void); - void Set_Point_Orientation(unsigned char orientation); - unsigned char Get_Point_Orientation(void); - void Set_Point_Frame(unsigned char frame); - unsigned char Get_Point_Frame(void); - void Set_Point_Mode(PointModeEnum mode); - PointModeEnum Get_Point_Mode(void); - void Set_Flag(FlagsType flag, bool onoff); - int Get_Flag(FlagsType flag); - void Set_Texture(TextureClass* texture); - TextureClass * Get_Texture(void); - TextureClass * Peek_Texture(void); - void Set_Shader(ShaderClass shader); - ShaderClass Get_Shader(void); - void Set_Billboard(bool shouldBillboard); - bool Get_Billboard(void); - - // The frame property is taken from a set of possible frames. The rows/columns in the frame - // texture determine the number of possible frames. Since it must be a power of 2, we represent - // it as its log base 2. This number cannot be greater than 4 (which corresponds to a 16x16 - // square of frames, i.e. 256 frames). - unsigned char Get_Frame_Row_Column_Count_Log2(void); - void Set_Frame_Row_Column_Count_Log2(unsigned char frccl2); - - int Get_Polygon_Count(void); - - void Render(RenderInfoClass &rinfo); - void RenderVolumeParticle(RenderInfoClass &rinfo, unsigned int depth); - -protected: - // Update arrays. - void Update_Arrays(Vector3 *point_loc, - Vector4 *point_diffuse, - float *point_size, - unsigned char *point_orientation, - unsigned char *point_frame, - int active_points, - int total_points, - int &vnum, - int &pnum); - - // These shared buffers are used for communication to the point group - to - // pass point locations, colors and enables. The location and color arrays - // are 'compressed' using the active point table (if present) and then - // are processed into other arrays which are passed to the GERD. - // SR rather than WWMath types are used so Vector Processors can be used. - // The arrays override the default value if present. - // The orientation and frame properties are "index properties": they select one out of a small - // group of possibilities for each point. - // Orientation: this is the 2D rotation of the point about its center. There are 256 discrete - // orientations. The unit circle is evenly subdivided 256 times to create the set of - // orientations. The reason we discretize orientation is for performance: this way we can - // precalculate vertex offsets. - // Frame: the texture is divided into a 2D square grid, and each point uses one grid square - // instead of the whole texture. The number of possible frames is not invariant - it depends - // on the number of rows / columns in the grid. The reason we do this instead of having - // different textures is to avoid texture state changes. Also for performance reasons, the - // number of possible frames must be a power of two - for this reason the number of frame rows - // and columns, orientations, etc. are represented as the log base 2 of the actual number. - ShareBufferClass * PointLoc; // World/cameraspace point locs - ShareBufferClass * PointDiffuse; // (NULL if not used) RGBA values - ShareBufferClass * APT; // (NULL if not used) active point table - ShareBufferClass * PointSize; // (NULL if not used) size override table - ShareBufferClass * PointOrientation; // (NULL if not used) orientation indices - ShareBufferClass * PointFrame; // (NULL if not used) frame indices - int PointCount; // Active (if APT) or total point count - - // See comments for Get/Set_Frame_Row_Column_Count_Log2 above - unsigned char FrameRowColumnCountLog2; // MUST be equal or lesser than 4 - - // These parameters are passed to the GERD: - TextureClass* Texture; - ShaderClass Shader; // (default created in CTor) - - // Internal state: - PointModeEnum PointMode; // are points tris or quads? - unsigned int Flags; // operation control flags - float DefaultPointSize; // point size (size array overrides if present) - Vector3 DefaultPointColor; // point color (color array overrides if present) - float DefaultPointAlpha; // point alpha (alpha array overrides if present) - unsigned char DefaultPointOrientation;// point orientation (orientation array overrides if present) - unsigned char DefaultPointFrame; // point texture frame (frame array overrides if present) - - // View plane rectangle (only used in SCREENSPACE mode - set by Set_Arrays - // and used in Update_GERD_Arrays). - float VPXMin; - float VPYMin; - float VPXMax; - float VPYMax; - - bool Billboard; - - // Static stuff: - // For performance / memory reasons we prepare vertex location and UV - // arrays for various orientations and texture frames, as static data - // members of this class. This avoids the need to create such arrays over - // again for each object. The values in the UV arrays are used as-is, the - // values in the location arrays normally need to be scaled to the point - // sizes and added to the point location before use. We have distinct sets - // of arrays for each point mode. - // There are tables of vertex positions for each of triangle and quad mode - // with 256 discrete orientations. Each entry contains 3 (for triangle - // mode) or 4 (for quad mode) Vector3s. - // There are five tables of texture UVs for each of triangle and quad mode: - // with 1x1(1), 2x2(4), 4x4(16), 8x8(64) and 16x16(256) frames. Each entry - // contains 3 (for triangle mode) or 4 (for quad mode) Vector2s. - // In addition, there is one array of vertex positions for screenspace mode - // with 2 entries (for size 1 and size 2). Each entry contains 3 Vector3s. - // the Init function (which is called by WW3D::Init()) creates these - // arrays, and the Shutdown function (which is called by WW3D::Shutdown() - // releases them. -public: - static void _Init(void); - static void _Shutdown(void); - -private: - static Vector3 _TriVertexLocationOrientationTable[256][3]; - static Vector3 _QuadVertexLocationOrientationTable[256][4]; - static Vector3 _ScreenspaceVertexLocationSizeTable[2][3]; - static Vector2 *_TriVertexUVFrameTable[5]; - static Vector2 *_QuadVertexUVFrameTable[5]; - static VertexMaterialClass *PointMaterial; - - // Static arrays for intermediate calcs (never resized down, just up): - static VectorClass compressed_loc; // point locations 'compressed' by APT - static VectorClass compressed_diffuse; // point colors 'compressed' by APT - static VectorClass compressed_size; // point sizes 'compressed' by APT - static VectorClass compressed_orient; // point orientations 'compressed' by APT - static VectorClass compressed_frame; // point frames 'compressed' by APT - static VectorClass transformed_loc; // transformed point locations -}; - - -class SegmentGroupClass : public PointGroupClass -{ -public: - SegmentGroupClass(void); - virtual ~SegmentGroupClass(void); - -}; - - - -#endif \ No newline at end of file diff --git a/Generals/Code/Libraries/Source/WWVegas/WW3D2/polyinfo.cpp b/Generals/Code/Libraries/Source/WWVegas/WW3D2/polyinfo.cpp deleted file mode 100644 index ab13c19fde5..00000000000 --- a/Generals/Code/Libraries/Source/WWVegas/WW3D2/polyinfo.cpp +++ /dev/null @@ -1,85 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** 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 *** - *********************************************************************************************** - * * - * Project Name : WW3D * - * * - * $Archive:: /Commando/Code/ww3d2/polyinfo.cpp $* - * * - * Original Author:: Greg Hjelstrom * - * * - * $Author:: Greg_h $* - * * - * $Modtime:: 2/07/01 12:50p $* - * * - * $Revision:: 3 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - - -#include "polyinfo.h" -#include "texture.h" -#include "vertmaterial.h" -#include "shader.h" - -void PolygonInfoClass::Set_Texture(TextureClass *texture) -{ - if(texture) - texture->Add_Ref(); - if(Texture) - Texture->Release_Ref(); - Texture = texture; -} -void PolygonInfoClass::Set_Vertex_Material(VertexMaterialClass *vertexMaterial) -{ - if(vertexMaterial) - vertexMaterial->Add_Ref(); - if(VertexMaterial) - VertexMaterial->Release_Ref(); - - VertexMaterial = vertexMaterial; -} - -void PolygonInfoClass::Set_Shader(ShaderClass *shader) -{ - if(Shader) - delete Shader; - - // todo : update for refcounted shaders - Shader = W3DNEW ShaderClass(* shader); -} - - -PolygonInfoClass::~PolygonInfoClass() -{ - if(Texture) - Texture->Release_Ref(); - if(VertexMaterial) - VertexMaterial->Release_Ref(); - - // todo : update for refcounted shaders - if(Shader) - delete Shader; -} - - diff --git a/Generals/Code/Libraries/Source/WWVegas/WW3D2/polyinfo.h b/Generals/Code/Libraries/Source/WWVegas/WW3D2/polyinfo.h deleted file mode 100644 index cccd45e9182..00000000000 --- a/Generals/Code/Libraries/Source/WWVegas/WW3D2/polyinfo.h +++ /dev/null @@ -1,94 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** 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 *** - *********************************************************************************************** - * * - * Project Name : ww3d * - * * - * $Archive:: /Commando/Code/ww3d2/polyinfo.h $* - * * - * $Author:: Greg_h $* - * * - * $Modtime:: 2/07/01 12:48p $* - * * - * $Revision:: 2 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - - -#ifndef POLYINFO_H -#define POLYINFO_H - -#if _MSC_VER >= 1000 -#pragma once -#endif // _MSC_VER >= 1000 - -class TextureClass; -class VertexMaterialClass; -class ShaderClass; - - -/** -** PolyInfo.h -** -** This class is a simple storage class that keeps track of a texture, vertex material -** and a shader. -** -*/ -class PolygonInfoClass -{ - -public: - - TextureClass * Peek_Texture() const { return Texture; } - VertexMaterialClass * Peek_Vertex_Material() const { return VertexMaterial; } - ShaderClass * Peek_Shader() const { return Shader; } - - void Set_Texture(TextureClass *texture); - void Set_Vertex_Material(VertexMaterialClass *vertexMaterial); - void Set_Shader(ShaderClass *shader); - - void Set(TextureClass *texture, VertexMaterialClass *vertexMaterial, ShaderClass *shader) - { - Set_Texture(texture); - Set_Vertex_Material(vertexMaterial); - Set_Shader(shader); - } - - PolygonInfoClass(TextureClass *texture = 0, VertexMaterialClass *vertexMaterial = 0, ShaderClass *shader = 0) - : Texture(0), VertexMaterial(0), Shader(0) - { - Set(texture, vertexMaterial, shader); - } - - ~PolygonInfoClass(); - - -protected: - - TextureClass *Texture; - VertexMaterialClass *VertexMaterial; - ShaderClass *Shader; -}; - -#endif - diff --git a/Generals/Code/Libraries/Source/WWVegas/WW3D2/predlod.cpp b/Generals/Code/Libraries/Source/WWVegas/WW3D2/predlod.cpp deleted file mode 100644 index fc4e7620c2a..00000000000 --- a/Generals/Code/Libraries/Source/WWVegas/WW3D2/predlod.cpp +++ /dev/null @@ -1,406 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*************************************************************************** - *** 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 *** - *************************************************************************** - * * - * Project Name : G * - * * - * $Archive:: /Commando/Code/ww3d2/predlod.cpp $* - * * - * $Author:: Jani_p $* - * * - * $Modtime:: 9/20/01 10:10a $* - * * - * $Revision:: 5 $* - * * - *-------------------------------------------------------------------------* - * Functions: * - * PredictiveLODOptimizerClass::Clear -- clear object list and total cost* - * PredictiveLODOptimizerClass::Add_Object -- adds object to list, cost * - * PredictiveLODOptimizerClass::Optimize_LODs -- does LOD optimization * - * PredictiveLODOptimizerClass::Free -- releases all memory used. * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#include "predlod.h" -#include - -/* NOTE: The LODHeapNode and LODHeap classes are defined here for use in the - * Optimize_LODs() member function. */ - -// A node entry for a heap. It has no son/father pointers since it will be -// used in an array implementation of a heap. - -/* -** NOTE: LODHeapNodes contain pointers to RenderObjClass, but these pointers -** are NOT tracked via refcounting. This is because the heaps are created and -** destroyed within one function, so all references created are necessary; -** and performing Add_Ref and Release_Ref every time a pointer is copied -** would hurt performance. -*/ - -class LODHeapNode { - public: - LODHeapNode(void) { Item = NULL; } - LODHeapNode (float key) { Item = NULL; Key = key; } - LODHeapNode (RenderObjClass * item, float key) { Item = item; Key = key; } - - ~LODHeapNode(void) { } - - RenderObjClass * Get_Item(void) { return(Item); } - - float Get_Key(void) { return(Key); } - void Set_Key(float key) { Key = key; } - - int operator < (const LODHeapNode& node) { return(Key < node.Key); } - int operator <= (const LODHeapNode& node) { return(Key <= node.Key); } - int operator > (const LODHeapNode& node) { return(Key > node.Key); } - int operator >= (const LODHeapNode& node) { return(Key >= node.Key); } - int operator == (const LODHeapNode& node) { return(Key == node.Key); } - int operator != (const LODHeapNode& node) { return(Key != node.Key); } - - private: - RenderObjClass *Item; - float Key; -}; - -// A Heap implemented as a complete binary tree in an array. -class LODHeap { - public: - // This constructor receives an array of HeapNodes and arranges it to - // fulfil the heap condition. Note: the array will be used inside the - // heap, so it should never be used or deleted outside. The resulting - // heap is full - no nodes can be added until some are removed. - LODHeap(int count, LODHeapNode *NodeArray) { - Nodes = NodeArray; - Num = Max = count; - // Now build a heap from the array by working backwards, building - // subheaps from the bottom up. (starting at the middle of the array - // since the single-node subtrees at the leaves are already heaps) - int index; - for (index = Num/2; index >= 1; index--) Downheap(index); - } - - ~LODHeap(void) { -// delete []Nodes; - } - - LODHeapNode *Top(void) { - return &(Nodes[1]); - } - - // This changes the key value of the entry at the top of the heap and - // adjusts the heap accordingly. - void Change_Key_Top(float new_key) { - Nodes[1].Set_Key(new_key); - Downheap(1); - } - - // This searches for an entry which has a certain Item value, and - // changes its key to a new one. The heap is then adjusted accordingly. - void Change_Key(RenderObjClass *item, float new_key) { - for (int i=1; i <= Num; i++) { - if (Nodes[i].Get_Item() == item) { - float old_key = Nodes[i].Get_Key(); - Nodes[i].Set_Key(new_key); - // If the key has been decreased, adjust the node downwards. - // Otherwise, adjust it upwards. - if (new_key < old_key) Downheap(i); - else Upheap(i); - break; - } - } - } - - private: - LODHeap(void) {} // Just to ensure the default constructor is not used. - - // The node and key arrays have one extra entry because entry [0] is - // reserved for various uses. - LODHeapNode * Nodes; // The nodes - - int Max; // The maximum number of nodes - int Num; // the current number of nodes - - // Two utility methods used by various other methods: both take a - // single entry which violates the heap condition and moves it in the - // heap until the heap condition is fulfilled. - - // Upheap takes an entry with a (possibly) overlarge key and moves it - // up until the heap condition is satisfied. (this is a private - // method, so no error checking is needed). - // Note that Upheap puts a sentinel in Nodes[0]. - void Upheap(int index) { - LODHeapNode node = Nodes[index]; - Nodes[0].Set_Key(FLT_MAX); - while (Nodes[index/2] <= node) { - Nodes[index] = Nodes[index/2]; - index = index/2; - } - Nodes[index] = node; - } - - // Downheap takes an entry with a (possibly) oversmall key and moves it - // down until the heap condition is satisfied. (this is a private - // method, so no error checking is needed). - void Downheap(int index) { - LODHeapNode node = Nodes[index]; - while (index <= Num/2) { - int child_index = index + index; - if ((child_index < Num) && (Nodes[child_index] < Nodes[child_index+1])) child_index++; - if (node >= Nodes[child_index]) break; - Nodes[index] = Nodes[child_index]; - index = child_index; - } - Nodes[index] = node; - } -}; - -// Static PredictiveLODOptimizerClass data members: -RenderObjClass ** PredictiveLODOptimizerClass::ObjectArray = NULL; -int PredictiveLODOptimizerClass::ArraySize = 0; -int PredictiveLODOptimizerClass::NumObjects = 0; -float PredictiveLODOptimizerClass::TotalCost = 0.0f; -LODHeapNode * PredictiveLODOptimizerClass::VisibleObjArray1; -LODHeapNode * PredictiveLODOptimizerClass::VisibleObjArray2; -int PredictiveLODOptimizerClass::VisibleObjArraySize; - - -/************************************************************************** - * PredictiveLODOptimizerClass::Clear -- clear object list and total cost * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 03/12/1999 NH : Created. * - *========================================================================*/ -void PredictiveLODOptimizerClass::Clear(void) -{ - if (ObjectArray) { - // Release refs to all objects in the list: - for (int i = 0; i < NumObjects; i++) { - if (ObjectArray[i]) { - ObjectArray[i]->Release_Ref(); - ObjectArray[i] = NULL; - } - } - } - - TotalCost = 0.0f; - NumObjects = 0; -} - - -/************************************************************************** - * PredictiveLODOptimizerClass::Add_Object -- adds object to list, cost * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 03/12/1999 NH : Created. * - *========================================================================*/ -void PredictiveLODOptimizerClass::Add_Object(RenderObjClass *robj) -{ - // If array present but too small, free it and copy it to new array. - if (ObjectArray) { - if (ArraySize <= NumObjects) { - int new_array_size = NumObjects + 100; - RenderObjClass **new_array = W3DNEWARRAY RenderObjClass *[new_array_size]; - memcpy(new_array, ObjectArray, sizeof(RenderObjClass *) * NumObjects); - delete [] ObjectArray; - ObjectArray = new_array; - ArraySize = new_array_size; - } - } else { - // Create new object array. - ObjectArray = W3DNEWARRAY RenderObjClass *[100]; - } - - // Copy pointer and add ref - ObjectArray[NumObjects] = robj; - ObjectArray[NumObjects]->Add_Ref(); - NumObjects++; - - float cost = robj->Get_Cost(); - // Some sanity checking so one object doesn't mess up the entire scene - WWASSERT (cost >= 0.0f); - WWASSERT (cost < 1.0e6); - TotalCost += cost; -} - - -/************************************************************************** - * PredictiveLODOptimizerClass::Optimize_LODs -- does LOD optimization * - * * - * INPUT: float max_cost - the upper bound on the total scene Cost. * - * * - * OUTPUT: none. * - * * - * WARNINGS: * - * * - * HISTORY: * - * 12/08/1997 NH : Created. * - * 04/23/1997 NH : Ported to SR 1.3. * - * 03/12/1999 NH : Moved to PredictiveLODOptimizerClass. * - * * - * COMMENTS: * - * This function implements the algorithm outlined in "Adaptive * - * Display Algorithm for Interactive Frame Rates During Visualization * - * of Complex Virtual Environments", Thomas Funkhouser & Carlo Sequin, * - * SIGGRAPH '93 Proceedings, pp. 247-253. * - * Modifications have been made to support screensize clamping of LODs. * - *========================================================================*/ -void PredictiveLODOptimizerClass::Optimize_LODs(float max_cost) -{ - if (!ObjectArray || NumObjects == 0) return; - - AllocVisibleObjArrays(NumObjects); - - // Allocate and fill arrays. (one extra entry since the zeroth entry is not used). -// LODHeapNode *visible_obj_array1 = W3DNEWARRAY LODHeapNode[NumObjects + 1]; -// LODHeapNode *visible_obj_array2 = W3DNEWARRAY LODHeapNode[NumObjects + 1]; - - // Insert objects into arrays: (0th entry reserved for sentinel values) - for (int i = 0; i < NumObjects; i++) { - RenderObjClass *robj = ObjectArray[i]; - // We use minus Value for the first queue to make it ordered by minimum Value. - VisibleObjArray1[i + 1] = LODHeapNode(robj, -(robj->Get_Value())); - VisibleObjArray2[i + 1] = LODHeapNode(robj, robj->Get_Post_Increment_Value()); - } - - // Build priority queues: - LODHeap min_current_value_queue(NumObjects, VisibleObjArray1); - LODHeap max_post_increment_value_queue(NumObjects, VisibleObjArray2); - // These memory areas now are pointed to within the heaps: -// visible_obj_array1 = NULL; -// visible_obj_array2 = NULL; - - // Main loop: iteratively increment/decrement tuples. - bool done = false; - RenderObjClass *max_data, *min_data; - - while (!done) { - // Initialize max_data and min_data so comparison at end of loop uses correct values. - max_data = NULL; - min_data = NULL; - - // Increment incrementable tuple with maximum next value. - if (TotalCost <= max_cost) { - // If tuple with maximum next value is already at maximum lod, all - // tuples are (since AT_MAX_LOD is smaller than any Value), so stop. - if (max_post_increment_value_queue.Top()->Get_Key() == RenderObjClass::AT_MAX_LOD) { - done = true; - break; - } - - // Get (incrementable) tuple with maximum next value. - max_data = max_post_increment_value_queue.Top()->Get_Item(); - - // Increment tuple (and update TotalCost accordingly). - TotalCost -= max_data->Get_Cost(); - max_data->Increment_LOD(); - TotalCost += max_data->Get_Cost(); - - // Update priority queues with incremented tuple. - max_post_increment_value_queue.Change_Key_Top(max_data->Get_Post_Increment_Value()); - min_current_value_queue.Change_Key(max_data, -(max_data->Get_Value())); - } - - // Decrement decerementable tuples with minimum current value. - while (TotalCost > max_cost) { - // If tuple with minimum current value is already at minimum lod, all - // tuples are (since AT_MIN_LOD is smaller than any (negated) Value), - // so stop. - if (min_current_value_queue.Top()->Get_Key() == -RenderObjClass::AT_MIN_LOD) { - done = true; - break; - } - - // Get (decrementable) tuple with minimum current value. - min_data = min_current_value_queue.Top()->Get_Item(); - - // Decrement tuple (and update TotalCost accordingly). - TotalCost -= min_data->Get_Cost(); - min_data->Decrement_LOD(); - TotalCost += min_data->Get_Cost(); - - // Update priority queues with incremented tuple. - min_current_value_queue.Change_Key_Top(-(min_data->Get_Value())); - max_post_increment_value_queue.Change_Key(min_data, min_data->Get_Post_Increment_Value()); - - // Check termination criterion (same tuple incremented and decremented). - if (max_data == min_data) { - done = true; - break; - } - } - } - - // Clear optimizer: - Clear(); -} - - -/************************************************************************** - * PredictiveLODOptimizerClass::Free -- releases all memory used. * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 03/12/1999 NH : Created. * - *========================================================================*/ -void PredictiveLODOptimizerClass::Free(void) -{ - Clear(); - - if (ObjectArray) { - delete [] ObjectArray; - ObjectArray = NULL; - ArraySize = 0; - } - - // Only the array number one has been allocated... - if (VisibleObjArray1) delete[] VisibleObjArray1; - VisibleObjArray1=NULL; - VisibleObjArray2=NULL; - VisibleObjArraySize = 0; -} - -void PredictiveLODOptimizerClass::AllocVisibleObjArrays(int num_objects) -{ - if (VisibleObjArraySize. -*/ - -/*************************************************************************** - *** 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 *** - *************************************************************************** - * * - * Project Name : G * - * * - * $Archive:: /Commando/Code/ww3d2/predlod.h $* - * * - * $Author:: Jani_p $* - * * - * $Modtime:: 9/20/01 10:10a $* - * * - * $Revision:: 3 $* - * * - *-------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#if defined(_MSC_VER) -#pragma once -#endif - -#ifndef PREDLOD_H -#define PREDLOD_H - -// This file contains the classes which support predictive LOD management -// similar to that outlined in "Adaptive Display Algorithm for Interactive -// Frame Rates During Visualization of Complex Virtual Environments", -// Thomas Funkhouser & Carlo Sequin, SIGGRAPH '93 Proceedings, pp. 247-253. -// To this "pure predictive" LOD we have added distance (actually screensize) -// clamping to control quality degradation. - -#include "rendobj.h" -#include "float.h" -#include "Vector.H" - -class LODHeapNode; - -/* -** PredictiveLODOptimizerClass: Class which performs the predictive LOD -** optimization. All the members of this class are static. -*/ -class PredictiveLODOptimizerClass { - - public: - - static void Clear(void); - static void Add_Object(RenderObjClass *robj); - static void Add_Cost(float cost) { TotalCost += cost; } - static void Optimize_LODs(float max_cost); - static float Get_Total_Cost(void) { return TotalCost; } - static void Free(void); // frees all memory - - private: - static void AllocVisibleObjArrays(int num_objects); - - static RenderObjClass ** ObjectArray; - static int ArraySize; - static int NumObjects; - static float TotalCost; - - static LODHeapNode *VisibleObjArray1; - static LODHeapNode *VisibleObjArray2; - static int VisibleObjArraySize; - -}; - -#endif diff --git a/Generals/Code/Libraries/Source/WWVegas/WW3D2/prim_anim.cpp b/Generals/Code/Libraries/Source/WWVegas/WW3D2/prim_anim.cpp deleted file mode 100644 index 79fe8e40ba2..00000000000 --- a/Generals/Code/Libraries/Source/WWVegas/WW3D2/prim_anim.cpp +++ /dev/null @@ -1,40 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** 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 *** - *********************************************************************************************** - * * - * Project Name : WW3D * - * * - * $Archive:: /Commando/Code/ww3d2/prim_anim.cpp $* - * * - * Author:: Patrick Smith * - * * - * $Modtime:: 1/08/01 10:04a $* - * * - * $Revision:: 1 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - - -#include "prim_anim.h" -#include "chunkio.h" - diff --git a/Generals/Code/Libraries/Source/WWVegas/WW3D2/prim_anim.h b/Generals/Code/Libraries/Source/WWVegas/WW3D2/prim_anim.h deleted file mode 100644 index c4a00e97322..00000000000 --- a/Generals/Code/Libraries/Source/WWVegas/WW3D2/prim_anim.h +++ /dev/null @@ -1,391 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** 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 *** - *********************************************************************************************** - * * - * Project Name : WW3D * - * * - * $Archive:: /Commando/Code/ww3d2/prim_anim.h $* - * * - * Author:: Patrick Smith * - * * - * $Modtime:: 1/29/01 5:43p $* - * * - * $Revision:: 2 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#if defined(_MSC_VER) -#pragma once -#endif - -#ifndef __PRIM_ANIM_H -#define __PRIM_ANIM_H - - -#include "simplevec.h" -#include "chunkio.h" - - -// Forward declarations -class ChunkSaveClass; -class ChunkLoadClass; - - -///////////////////////////////////////////////////////////////////// -// -// PrimitiveAnimationChannelClass -// -// This template class provides animated 'channels' of data for the -// RingRenderObjClass and SphereRenderObjClass objects. -// -///////////////////////////////////////////////////////////////////// -template -class PrimitiveAnimationChannelClass -{ -public: - - ///////////////////////////////////////////////////////// - // Public constructors/destructors - ///////////////////////////////////////////////////////// - PrimitiveAnimationChannelClass (void) - : m_LastIndex (0) { } - virtual ~PrimitiveAnimationChannelClass (void) { Reset (); } - - ///////////////////////////////////////////////////////// - // Public data types - ///////////////////////////////////////////////////////// - class KeyClass - { - public: - KeyClass (void) - : m_Time (0) {} - - KeyClass (const T &value, float time) - : m_Value (value), - m_Time (time) {} - - float Get_Time (void) const { return m_Time; } - const T & Get_Value (void) const { return m_Value; } - T & Get_Value (void) { return m_Value; } - - float Set_Time (float time) { m_Time = time; } - void Set_Value (const T &value) { m_Value = value; } - - private: - T m_Value; - float m_Time; - }; - - ///////////////////////////////////////////////////////// - // Public operators - ///////////////////////////////////////////////////////// - const PrimitiveAnimationChannelClass &operator= (const PrimitiveAnimationChannelClass &src); - const KeyClass & operator[] (int index) { return Get_Key (index); } - - ///////////////////////////////////////////////////////// - // Public methods - ///////////////////////////////////////////////////////// - virtual T Evaluate (float time) = 0; - - int Get_Key_Count (void) const; - const KeyClass & Get_Key (int index) const; - void Set_Key (int index, const T &value, float time); - void Set_Key_Value (int index, const T &value); - void Add_Key (const T &value, float time); - void Insert_Key (int index, const T &value, float time); - void Delete_Key (int index); - void Reset (void); - - virtual void Save (ChunkSaveClass &csave); - virtual void Load (ChunkLoadClass &cload); - -protected: - - ///////////////////////////////////////////////////////// - // Protected constants - ///////////////////////////////////////////////////////// - enum - { - CHUNKID_VARIABLES = 0x03150809, - }; - - enum - { - VARID_KEY = 1, - }; - - ///////////////////////////////////////////////////////// - // Protected methods - ///////////////////////////////////////////////////////// - void Load_Variables (ChunkLoadClass &cload); - -protected: - - ///////////////////////////////////////////////////////// - // Protected member data - ///////////////////////////////////////////////////////// - SimpleDynVecClass< KeyClass > m_Data; - int m_LastIndex; -}; - - -///////////////////////////////////////////////////////////////////// -// -// LERPAnimationChannelClass -// -// This template class provides a simple LERP implementation of the -// Evaluate () method. -// -///////////////////////////////////////////////////////////////////// -template -class LERPAnimationChannelClass : public PrimitiveAnimationChannelClass -{ - using PrimitiveAnimationChannelClass::m_Data; - using PrimitiveAnimationChannelClass::m_LastIndex; -public: - using PrimitiveAnimationChannelClass::KeyClass; - -public: - - ///////////////////////////////////////////////////////// - // Public methods - ///////////////////////////////////////////////////////// - virtual T Evaluate (float time); -}; - - -///////////////////////////////////////////////////////// -// Set_Key -///////////////////////////////////////////////////////// -template -int PrimitiveAnimationChannelClass::Get_Key_Count (void) const -{ - return m_Data.Count (); -} - -///////////////////////////////////////////////////////// -// Set_Key_Value -///////////////////////////////////////////////////////// -template -typename const PrimitiveAnimationChannelClass::KeyClass &PrimitiveAnimationChannelClass::Get_Key (int index) const -{ - return m_Data[index]; -} - -///////////////////////////////////////////////////////// -// Set_Key -///////////////////////////////////////////////////////// -template -void PrimitiveAnimationChannelClass::Set_Key (int index, const T &value, float time) -{ - m_Data[index].Set_Value (value); - m_Data[index].Set_Time (time); - return ; -} - -///////////////////////////////////////////////////////// -// Set_Key_Value -///////////////////////////////////////////////////////// -template -void PrimitiveAnimationChannelClass::Set_Key_Value (int index, const T &value) -{ - m_Data[index].Set_Value (value); - return ; -} - -///////////////////////////////////////////////////////// -// Add_Key -///////////////////////////////////////////////////////// -template -void PrimitiveAnimationChannelClass::Add_Key (const T &value, float time) -{ - m_Data.Add (KeyClass (value, time)); - return ; -} - -///////////////////////////////////////////////////////// -// Insert_Key -///////////////////////////////////////////////////////// -template -void PrimitiveAnimationChannelClass::Insert_Key (int index, const T &value, float time) -{ - m_Data.Insert (index, KeyClass (value, time)); - return ; -} - -///////////////////////////////////////////////////////// -// Delete_Key -///////////////////////////////////////////////////////// -template -void PrimitiveAnimationChannelClass::Delete_Key (int index) -{ - m_Data.Delete (index); - return ; -} - -///////////////////////////////////////////////////////// -// Reset -///////////////////////////////////////////////////////// -template -void PrimitiveAnimationChannelClass::Reset (void) -{ - m_Data.Delete_All (); - m_LastIndex = 0; - return ; -} - -///////////////////////////////////////////////////////////////////// -// operator= -///////////////////////////////////////////////////////////////////// -template const PrimitiveAnimationChannelClass & -PrimitiveAnimationChannelClass::operator= (const PrimitiveAnimationChannelClass &src) -{ - Reset (); - - // - // Copy the data array - // - for (int index = 0; index < src.Get_Key_Count (); index ++) { - m_Data.Add (src.Get_Key (index)); - } - - m_LastIndex = src.m_LastIndex; - return *this; -} - -///////////////////////////////////////////////////////////////////// -// Save -///////////////////////////////////////////////////////////////////// -template void -PrimitiveAnimationChannelClass::Save (ChunkSaveClass &csave) -{ - csave.Begin_Chunk (CHUNKID_VARIABLES); - - // - // Save each key - // - for (int index = 0; index < m_Data.Count (); index ++) { - KeyClass &value = m_Data[index]; - WRITE_MICRO_CHUNK (csave, VARID_KEY, value); - } - - csave.End_Chunk (); - - return ; -} - -///////////////////////////////////////////////////////////////////// -// Load -///////////////////////////////////////////////////////////////////// -template void -PrimitiveAnimationChannelClass::Load (ChunkLoadClass &cload) -{ - Reset (); - - while (cload.Open_Chunk ()) { - switch (cload.Cur_Chunk_ID ()) { - - case CHUNKID_VARIABLES: - Load_Variables (cload); - break; - } - - cload.Close_Chunk (); - } - - return ; -} - -///////////////////////////////////////////////////////////////////// -// Load_Variables -///////////////////////////////////////////////////////////////////// -template void -PrimitiveAnimationChannelClass::Load_Variables (ChunkLoadClass &cload) -{ - // - // Loop through all the microchunks that define the variables - // - while (cload.Open_Micro_Chunk ()) { - switch (cload.Cur_Micro_Chunk_ID ()) { - - case VARID_KEY: - { - KeyClass value; - cload.Read (&value, sizeof (value)); - m_Data.Add (value); - } - break; - } - - cload.Close_Micro_Chunk (); - } - - return ; -} - -///////////////////////////////////////////////////////////////////// -// Evaluate -///////////////////////////////////////////////////////////////////// -template T -LERPAnimationChannelClass::Evaluate (float time) -{ - int key_count = m_Data.Count (); - T value = m_Data[key_count - 1].Get_Value (); - - // - // Don't interpolate past the last keyframe - // - if (time < m_Data[key_count - 1].Get_Time ()) { - - // Check to see if the last key index is valid - if (time < m_Data[m_LastIndex].Get_Time ()) { - m_LastIndex = 0; - } - - KeyClass *key1 = &m_Data[m_LastIndex]; - KeyClass *key2 = &m_Data[key_count - 1]; - - // - // Search, using last_key as our starting point - // - for (int keyidx = m_LastIndex; keyidx < (key_count - 1); keyidx ++) { - - if (time < m_Data[keyidx+1].Get_Time ()) { - key1 = &m_Data[keyidx]; - key2 = &m_Data[keyidx+1]; - m_LastIndex = keyidx; - break; - } - } - - // Calculate the linear percent between the two keys - float percent = (time - key1->Get_Time ()) / (key2->Get_Time () - key1->Get_Time ()); - - // Interpolate the value - value = (key1->Get_Value () + (key2->Get_Value () - key1->Get_Value ()) * percent); - } - - return value; -} - -#endif //__PRIM_ANIM_H diff --git a/Generals/Code/Libraries/Source/WWVegas/WW3D2/projector.cpp b/Generals/Code/Libraries/Source/WWVegas/WW3D2/projector.cpp deleted file mode 100644 index 92d2dfcf8bc..00000000000 --- a/Generals/Code/Libraries/Source/WWVegas/WW3D2/projector.cpp +++ /dev/null @@ -1,236 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** 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 *** - *********************************************************************************************** - * * - * Project Name : WW3D * - * * - * $Archive:: /Commando/Code/ww3d2/projector.cpp $* - * * - * Original Author:: Greg Hjelstrom * - * * - * $Author:: Kenny Mitchell * - * * - * $Modtime:: 06/26/02 4:04p $* - * * - * $Revision:: 6 $* - * * - * 06/26/02 KM Matrix name change to avoid MAX conflicts * - *---------------------------------------------------------------------------------------------* - * Functions: * - * ProjectorClass::ProjectorClass -- Constructor * - * ProjectorClass::~ProjectorClass -- Destructor * - * ProjectorClass::Set_Transform -- Set the transform for the projector * - * ProjectorClass::Get_Transform -- Returns the current transform * - * ProjectorClass::Set_Perspective_Projection -- Set up a perspective projection * - * ProjectorClass::Set_Ortho_Projection -- Set up an orthographic projection * - * ProjectorClass::Compute_Texture_Coordinate -- computes texcoord for given world-space poi * - * ProjectorClass::Update_WS_Bounding_Volume -- Recalculate the world-space bounding box * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#include "projector.h" -#include "refcount.h" -#include "matrixmapper.h" - - -/*********************************************************************************************** - * ProjectorClass::ProjectorClass -- Constructor * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - *=============================================================================================*/ -ProjectorClass::ProjectorClass(void) : - Transform(1), - Projection(1), - LocalBoundingVolume(Vector3(0,0,0),Vector3(1,1,1)), - WorldBoundingVolume(Vector3(0,0,0),Vector3(1,1,1),Matrix3x3(1)) -{ - Mapper=NEW_REF(MatrixMapperClass,(0)); -} - - -/*********************************************************************************************** - * ProjectorClass::~ProjectorClass -- Destructor * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - *=============================================================================================*/ -ProjectorClass::~ProjectorClass(void) -{ - REF_PTR_RELEASE(Mapper); -} - -/*********************************************************************************************** - * ProjectorClass::Set_Transform -- Set the transform for the projector * - * * - * Projectors can be positioned in world space just like cameras! Just point the -Z axis * - * at the target. * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 1/11/00 gth : Created. * - * 1/27/00 gth : Created. * - *=============================================================================================*/ -void ProjectorClass::Set_Transform(const Matrix3D & tm) -{ - Transform = tm; - Update_WS_Bounding_Volume(); -} - - -/*********************************************************************************************** - * ProjectorClass::Get_Transform -- Returns the current transform * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 1/11/00 gth : Created. * - *=============================================================================================*/ -const Matrix3D & ProjectorClass::Get_Transform(void) const -{ - return Transform; -} - - -/*********************************************************************************************** - * ProjectorClass::Set_Perspective_Projection -- Set up a perspective projection * - * * - * INPUT: * - * hfov - radians, horizontal field of view of the projection * - * vfov - radians, vertical field of view of the projection * - * znear - distance to near clipping plane * - * zfar - distance to far clipping plane * - * * - * OUTPUT: * - * * - * WARNINGS: * - * Remember that znear and zfar are *distances*. They are positive numbers as in the OpenGL * - * convention even though the coordinates will be negative. * - * * - * HISTORY: * - * 1/11/00 gth : Created. * - *=============================================================================================*/ -void ProjectorClass::Set_Perspective_Projection(float hfov,float vfov,float znear,float zfar) -{ - Mapper->Set_Type(MatrixMapperClass::PERSPECTIVE_PROJECTION); - Projection.Init_Perspective(hfov,vfov,0.1f,zfar); // don't use znear for the projection matrix - - float tan_hfov2 = tan(hfov) * 0.5f; - float tan_vfov2 = tan(vfov) * 0.5f; - - LocalBoundingVolume.Center.Set(0.0f,0.0f,-(zfar+znear)*0.5f); // note, zcenter is negative - LocalBoundingVolume.Extent.X = zfar * tan_hfov2; - LocalBoundingVolume.Extent.Y = zfar * tan_vfov2; - LocalBoundingVolume.Extent.Z = (zfar-znear)*0.5f; - - Update_WS_Bounding_Volume(); -} - - -/*********************************************************************************************** - * ProjectorClass::Set_Ortho_Projection -- Set up an orthographic projection * - * * - * INPUT: * - * xmin - "left" x coordinate in texture (camera) space * - * xmax - "right" x coordinate * - * ymin - "bottom" y coordinate * - * ymax - "top" y coordinate * - * znear - distance to near clipping plane * - * zfar - distance to far clipping plane * - * * - * OUTPUT: * - * * - * WARNINGS: * - * Remember that znear and zfar are *distances*. They are positive numbers as in the OpenGL * - * convention even though the coordinates will be negative. * - * * - * HISTORY: * - * 1/11/00 gth : Created. * - *=============================================================================================*/ -void ProjectorClass::Set_Ortho_Projection(float xmin,float xmax,float ymin,float ymax,float znear,float zfar) -{ - Mapper->Set_Type(MatrixMapperClass::ORTHO_PROJECTION); - Projection.Init_Ortho(xmin,xmax,ymin,ymax,0.1f,zfar); // don't use znear for the projection matrix - - LocalBoundingVolume.Center.Set((xmax+xmin)*0.5f, (ymax+ymin)*0.5f, -(zfar+znear)*0.5f); - LocalBoundingVolume.Extent.Set((xmax-xmin)*0.5f, (ymax-ymin)*0.5f, (zfar-znear)*0.5f); - - Update_WS_Bounding_Volume(); -} - - -/*********************************************************************************************** - * ProjectorClass::Compute_Texture_Coordinate -- computes texcoord for given world-space point * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 1/27/00 gth : Created. * - *=============================================================================================*/ -void ProjectorClass::Compute_Texture_Coordinate(const Vector3 & point,Vector3 * set_stq) -{ - Mapper->Compute_Texture_Coordinate(point,set_stq); -} - - -/*********************************************************************************************** - * ProjectorClass::Update_WS_Bounding_Volume -- Recalculate the world-space bounding box * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 1/11/00 gth : Created. * - *=============================================================================================*/ -void ProjectorClass::Update_WS_Bounding_Volume(void) -{ - /* - ** Recompute our world-space bounding volume - */ - OBBoxClass localbox(LocalBoundingVolume.Center,LocalBoundingVolume.Extent,Matrix3x3(1)); - OBBoxClass::Transform(Transform,localbox,&WorldBoundingVolume); -} - diff --git a/Generals/Code/Libraries/Source/WWVegas/WW3D2/projector.h b/Generals/Code/Libraries/Source/WWVegas/WW3D2/projector.h deleted file mode 100644 index 6d58c06ae4c..00000000000 --- a/Generals/Code/Libraries/Source/WWVegas/WW3D2/projector.h +++ /dev/null @@ -1,92 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** 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 *** - *********************************************************************************************** - * * - * Project Name : WW3D * - * * - * $Archive:: /Commando/Code/ww3d2/projector.h $* - * * - * Original Author:: Greg Hjelstrom * - * * - * $Author:: Kenny Mitchell * - * * - * $Modtime:: 06/26/02 4:04p $* - * * - * $Revision:: 2 $* - * * - * 06/26/02 KM Matrix name change to avoid MAX conflicts * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#ifndef PROJECTOR_H -#define PROJECTOR_H - -#include "always.h" -#include "matrix3d.h" -#include "matrix4.h" -#include "aabox.h" -#include "obbox.h" - - -class MatrixMapperClass; - - -/** -** ProjectorClass -** This is a class which encapsulates the data needed to describe a projection. It isn't -** really useful by itself but it is a common base class between TexProjectClass and DecalGeneratorClass. -*/ -class ProjectorClass -{ -public: - - ProjectorClass(void); - virtual ~ProjectorClass(void); - - virtual void Set_Transform(const Matrix3D & tm); - virtual const Matrix3D & Get_Transform(void) const; - - virtual void Set_Perspective_Projection(float hfov,float vfov,float znear,float zfar); - virtual void Set_Ortho_Projection(float xmin,float xmax,float ymin,float ymax,float znear,float zfar); - - const OBBoxClass & Get_Bounding_Volume(void) const { return WorldBoundingVolume; } - void Compute_Texture_Coordinate(const Vector3 & point,Vector3 * set_stq); - - MatrixMapperClass* Peek_Mapper() const { return Mapper; } - -protected: - - virtual void Update_WS_Bounding_Volume(void); - - Matrix3D Transform; - Matrix4x4 Projection; - - AABoxClass LocalBoundingVolume; - OBBoxClass WorldBoundingVolume; - - MatrixMapperClass * Mapper; -}; - - -#endif - - diff --git a/Generals/Code/Libraries/Source/WWVegas/WW3D2/proto.cpp b/Generals/Code/Libraries/Source/WWVegas/WW3D2/proto.cpp deleted file mode 100644 index 12a543c52d9..00000000000 --- a/Generals/Code/Libraries/Source/WWVegas/WW3D2/proto.cpp +++ /dev/null @@ -1,180 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** 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 *** - *********************************************************************************************** - * * - * Project Name : WW3D * - * * - * $Archive:: /Commando/Code/ww3d2/proto.cpp $* - * * - * Org Author:: Greg Hjelstrom * - * * - * Author : Kenny Mitchell * - * * - * $Modtime:: 06/27/02 3:51p $* - * * - * $Revision:: 2 $* - * * - * 06/26/02 KM Integrating shader system - *---------------------------------------------------------------------------------------------* - * Functions: * - * MeshLoaderClass::Load -- reads in a mesh and creates a prototype for it * - * HModelLoaderClass::Load -- reads in an hmodel definition and creates a prototype for it * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - - -#include "proto.h" -#include "mesh.h" -#include "hmdldef.H" -#include "hlod.h" -#include "w3derr.h" - -/* -** Global instances of the default loaders for the asset manager to install -*/ -MeshLoaderClass _MeshLoader; -HModelLoaderClass _HModelLoader; - - -/* -** Prototype Classes -** These prototypes are the "built-in" ones for the W3D library. -*/ -PrimitivePrototypeClass::PrimitivePrototypeClass(RenderObjClass * proto) -{ - Proto = proto; - assert(Proto); - Proto->Add_Ref(); -} -PrimitivePrototypeClass::~PrimitivePrototypeClass(void) -{ - if (Proto) { - Proto->Release_Ref(); - } -} - -const char * PrimitivePrototypeClass::Get_Name(void) const -{ - return Proto->Get_Name(); -} - -int PrimitivePrototypeClass::Get_Class_ID(void) const -{ - return Proto->Class_ID(); -} - -RenderObjClass * PrimitivePrototypeClass::Create(void) -{ - return (RenderObjClass *)( SET_REF_OWNER( Proto->Clone() ) ); -} - - -class HModelPrototypeClass : public W3DMPO, public PrototypeClass -{ - W3DMPO_GLUE(HModelPrototypeClass) -public: - HModelPrototypeClass(HModelDefClass * def) { HModelDef = def; assert(HModelDef); } - - virtual const char * Get_Name(void) const { return HModelDef->Get_Name(); } - virtual int Get_Class_ID(void) const { return RenderObjClass::CLASSID_HLOD; } - virtual RenderObjClass * Create(void) { return NEW_REF( HLodClass, (*HModelDef) ); } - virtual void DeleteSelf() { delete this; } - - HModelDefClass * HModelDef; - -protected: - virtual ~HModelPrototypeClass(void) { if (HModelDef) delete HModelDef; } - -}; - - -/*********************************************************************************************** - * MeshLoaderClass::Load -- reads in a mesh and creates a prototype for it * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 7/28/98 GTH : Created. * - *=============================================================================================*/ -PrototypeClass * MeshLoaderClass::Load_W3D(ChunkLoadClass & cload) -{ - MeshClass * mesh = NEW_REF( MeshClass, () ); - - if (mesh == NULL) { - return NULL; - } - - if (mesh->Load_W3D(cload) != WW3D_ERROR_OK) { - - // if the load failed, delete the mesh - assert(mesh->Num_Refs() == 1); - mesh->Release_Ref(); - return NULL; - - } else { - - // create the prototype and add it to the lists - PrimitivePrototypeClass * newproto = W3DNEW PrimitivePrototypeClass(mesh); - mesh->Release_Ref(); - return newproto; - - } -} - - -/*********************************************************************************************** - * HModelLoaderClass::Load -- reads in an hmodel and creates a prototype for it * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 7/28/98 GTH : Created. * - *=============================================================================================*/ -PrototypeClass * HModelLoaderClass::Load_W3D(ChunkLoadClass & cload) -{ - HModelDefClass * hdef = W3DNEW HModelDefClass; - - if (hdef == NULL) { - return NULL; - } - - if (hdef->Load_W3D(cload) != HModelDefClass::OK) { - - // load failed, delete the model and return an error - delete hdef; - return NULL; - - } else { - - // ok, accept this model! - HModelPrototypeClass * hproto = W3DNEW HModelPrototypeClass(hdef); - return hproto; - - } -} - diff --git a/Generals/Code/Libraries/Source/WWVegas/WW3D2/proto.h b/Generals/Code/Libraries/Source/WWVegas/WW3D2/proto.h deleted file mode 100644 index dadeb291230..00000000000 --- a/Generals/Code/Libraries/Source/WWVegas/WW3D2/proto.h +++ /dev/null @@ -1,183 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** 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 *** - *********************************************************************************************** - * * - * Project Name : WW3D * - * * - * $Archive:: /Commando/Code/ww3d2/proto.h $* - * * - * Author:: Greg Hjelstrom * - * * - * $Modtime:: 1/08/01 10:04a $* - * * - * $Revision:: 1 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - - -#if defined(_MSC_VER) -#pragma once -#endif - -#ifndef PROTO_H -#define PROTO_H - -#include "always.h" -#include -#include "w3d_file.h" - -class RenderObjClass; -class ChunkLoadClass; - -/* -** W3D Prototype system -** -** Prototypes are basically abstract factories for render objects. -** Prototype Loaders are abstract factories for prototypes. -** Here is an example of the sequence of events that happen when -** a mesh is loaded into the asset manager and then used by the -** user: -** -** - At initialization time, a mesh prototype loader is installed automatically -** - User asks the asset manager to load "mesh.w3d" -** - asset manager encounters a W3D_CHUNK_MESH -** - asset manager looks through its loaders to find one that claims to handle this chunk -** - the meshloader object is found and its Load method called -** - the meshloader creates a mesh prototype object which the asset manager adds to its list -** - User asks for the render object named "Mesh" -** - asset manager searches through its prototypes to find the one named "Mesh" -** - the mesh prototype object is found and the asset manager calls its "Create" method -** - the mesh prototype creates a mesh (clones the one it contains) which is returned to the user. -*/ - -/* -** PrototypeClass -** This class is a generic interface to a render object prototype. -** The asset manager will store a these and use them whenever the -** user wants to create an instance of a named render object. -** Some simple render objects will be created through cloning. In -** that case, their associated prototype simply stores an object and -** clones it whenever the Create method is called. More complex -** composite render objects will be created from a "blueprint" object. -** Basically this class simply associates a name with a render object -** creation function. -*/ -class PrototypeClass -{ - -public: - - PrototypeClass(void) : NextHash(NULL) {} - - virtual const char * Get_Name(void) const = 0; - virtual int Get_Class_ID(void) const = 0; - virtual RenderObjClass * Create(void) = 0; - virtual void DeleteSelf() = 0; - - inline void friend_setNextHash(PrototypeClass* n) { NextHash = n; } - inline PrototypeClass* friend_getNextHash() { return NextHash; } - -protected: - virtual ~PrototypeClass(void) {}; - -private: - PrototypeClass * NextHash; - - // Not Implemented - PrototypeClass(const PrototypeClass & that); - PrototypeClass & operator = (const PrototypeClass & that); -}; - -class PrimitivePrototypeClass : public W3DMPO, public PrototypeClass -{ - W3DMPO_GLUE(PrimitivePrototypeClass) -public: - PrimitivePrototypeClass(RenderObjClass * proto); - - virtual const char * Get_Name(void) const; - virtual int Get_Class_ID(void) const; - virtual RenderObjClass * Create(void); - virtual void DeleteSelf() { delete this; } - - RenderObjClass * Proto; - -protected: - virtual ~PrimitivePrototypeClass(void); -}; - -/* -** PrototypeLoaderClass -** This is the interface for an object which recognizes a certain -** chunk type in a W3D file and can load it and create a PrototypeClass -** for it. -*/ -class PrototypeLoaderClass -{ - -public: - - PrototypeLoaderClass(void) {} - ~PrototypeLoaderClass(void) {} - - virtual int Chunk_Type(void) = 0; - virtual PrototypeClass * Load_W3D(ChunkLoadClass & cload) = 0; - -private: - - // Not Implemented: - PrototypeLoaderClass(const PrototypeLoaderClass & that); - PrototypeLoaderClass & operator = (const PrototypeLoaderClass & that); - -}; - - -/* -** Default Prototype Loaders for Meshes and HModels -*/ -class MeshLoaderClass : public PrototypeLoaderClass -{ -public: - - virtual int Chunk_Type(void) { return W3D_CHUNK_MESH; } - virtual PrototypeClass * Load_W3D(ChunkLoadClass & cload); -}; - -class HModelLoaderClass : public PrototypeLoaderClass -{ -public: - - virtual int Chunk_Type(void) { return W3D_CHUNK_HMODEL; } - virtual PrototypeClass * Load_W3D(ChunkLoadClass & cload); -}; - - -/* -** Instances of the default loaders which the asset manager can -** automatically install at creation time -*/ -extern MeshLoaderClass _MeshLoader; -extern HModelLoaderClass _HModelLoader; - - - -#endif diff --git a/Generals/Code/Libraries/Source/WWVegas/WW3D2/proxy.h b/Generals/Code/Libraries/Source/WWVegas/WW3D2/proxy.h deleted file mode 100644 index 90b3953e2d7..00000000000 --- a/Generals/Code/Libraries/Source/WWVegas/WW3D2/proxy.h +++ /dev/null @@ -1,115 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** 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 *** - *********************************************************************************************** - * * - * Project Name : WW3D * - * * - * $Archive:: /Commando/Code/ww3d2/proxy.h $* - * * - * Author:: Patrick Smith * - * * - * $Modtime:: 1/08/01 10:04a $* - * * - * $Revision:: 1 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#if defined(_MSC_VER) -#pragma once -#endif - -#ifndef __PROXY_H -#define __PROXY_H - -#include "wwstring.h" -#include "matrix3d.h" - - -////////////////////////////////////////////////////////////////////////////////// -// -// ProxyClass -// -////////////////////////////////////////////////////////////////////////////////// -class ProxyClass -{ -public: - - /////////////////////////////////////////////////////////// - // Public constructors/destructors - /////////////////////////////////////////////////////////// - ProxyClass (void) { } - ProxyClass (const char *name, const Matrix3D &tm) : - Name (name), - Transform (tm) { } - - /////////////////////////////////////////////////////////// - // Public operators - /////////////////////////////////////////////////////////// - bool operator== (const ProxyClass &src); - bool operator!= (const ProxyClass &src); - - /////////////////////////////////////////////////////////// - // Public methods - /////////////////////////////////////////////////////////// - - // - // Accessors - // - const char * Get_Name (void) const { return Name; } - void Set_Name (const char *name) { Name = name; } - - const Matrix3D & Get_Transform (void) const { return Transform; } - void Set_Transform (const Matrix3D &tm) { Transform = tm; } - -private: - - /////////////////////////////////////////////////////////// - // Private member data - /////////////////////////////////////////////////////////// - StringClass Name; - Matrix3D Transform; -}; - - -/////////////////////////////////////////////////////////// -// operator== -/////////////////////////////////////////////////////////// -inline bool -ProxyClass::operator== (const ProxyClass &src) -{ - return ((Name == src.Name) && (Transform == src.Transform)); -} - - -/////////////////////////////////////////////////////////// -// operator!= -/////////////////////////////////////////////////////////// -inline bool -ProxyClass::operator!= (const ProxyClass &src) -{ - return ((Name != src.Name) || (Transform != src.Transform)); -} - - -#endif //__PROXY_H - diff --git a/Generals/Code/Libraries/Source/WWVegas/WW3D2/rddesc.h b/Generals/Code/Libraries/Source/WWVegas/WW3D2/rddesc.h deleted file mode 100644 index 502684e2c28..00000000000 --- a/Generals/Code/Libraries/Source/WWVegas/WW3D2/rddesc.h +++ /dev/null @@ -1,172 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** 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 *** - *********************************************************************************************** - * * - * Project Name : WW3D * - * * - * $Archive:: /Commando/Code/ww3d2/rddesc.h $* - * * - * $Author:: Jani_p $* - * * - * $Modtime:: 12/04/01 5:20p $* - * * - * $Revision:: 6 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - - -#if defined(_MSC_VER) -#pragma once -#endif - -#ifndef RDDESC_H -#define RDDESC_H - -#include "Vector.H" -#include "wwstring.h" -#include -#include - -class ResolutionDescClass -{ -public: - ResolutionDescClass(void) : Width(0), Height(0), BitDepth(0) { } - ResolutionDescClass(int w,int h,int bits) : Width(w), Height(h), BitDepth(bits) { } - bool operator == (const ResolutionDescClass & src) { return ((Width==src.Width) && (Height==src.Height) && (BitDepth==src.BitDepth)); } - bool operator != (const ResolutionDescClass & src) { return ((Width!=src.Width) || (Height!=src.Height) || (BitDepth!=src.BitDepth)); } - - int Width; - int Height; - int BitDepth; - int RefreshRate; -}; - - -class RenderDeviceDescClass -{ - -public: - - RenderDeviceDescClass(void) : DeviceName(NULL), DeviceVendor(NULL), DevicePlatform(NULL), - DriverName(NULL), DriverVendor(NULL), DriverVersion(NULL), - HardwareName(NULL), HardwareVendor(NULL), HardwareChipset(NULL) - { - } - - ~RenderDeviceDescClass(void) - { - } - - RenderDeviceDescClass & operator = (const RenderDeviceDescClass & src) - { - set_device_name(src.Get_Device_Name()); - set_device_vendor(src.Get_Device_Vendor()); - set_device_platform(src.Get_Device_Platform()); - set_driver_name(src.Get_Driver_Name()); - set_driver_vendor(src.Get_Driver_Vendor()); - set_driver_version(src.Get_Driver_Version()); - set_hardware_name(src.Get_Hardware_Name()); - set_hardware_vendor(src.Get_Hardware_Vendor()); - set_hardware_chipset(src.Get_Hardware_Chipset()); - Caps=src.Caps; - AdapterIdentifier=src.AdapterIdentifier; - ResArray = src.ResArray; - return *this; - } - - bool operator == (const RenderDeviceDescClass & /*src*/) { return false; } - bool operator != (const RenderDeviceDescClass & /*src*/) { return true; } - - const char * Get_Device_Name() const { return DeviceName; } - const char * Get_Device_Vendor() const { return DeviceVendor; } - const char * Get_Device_Platform() const { return DevicePlatform; } - - const char * Get_Driver_Name() const { return DriverName; } - const char * Get_Driver_Vendor() const { return DriverVendor; } - const char * Get_Driver_Version() const { return DriverVersion; } - - const char * Get_Hardware_Name() const { return HardwareName; } - const char * Get_Hardware_Vendor() const { return HardwareVendor; } - const char * Get_Hardware_Chipset() const { return HardwareChipset; } - - const DynamicVectorClass & Enumerate_Resolutions(void) const { return ResArray; } - const D3DCAPS8& Get_Caps() const { return Caps; } - const D3DADAPTER_IDENTIFIER8& Get_Adapter_Identifier() const { return AdapterIdentifier; } - -private: - - void set_device_name(const char * name) { DeviceName=name; } - void set_device_vendor(const char * name) { DeviceVendor=name; } - void set_device_platform(const char * name) { DevicePlatform=name; } - void set_driver_name(const char * name) { DriverName=name; } - void set_driver_vendor(const char * name) { DriverVendor=name; } - void set_driver_version(const char * name) { DriverVersion=name; } - void set_hardware_name(const char * name) { HardwareName=name; } - void set_hardware_vendor(const char * name) { HardwareVendor=name; } - void set_hardware_chipset(const char * name) { HardwareChipset=name; } - - void reset_resolution_list(void) { ResArray.Delete_All(); } - void add_resolution(int w,int h,int bits); - - StringClass DeviceName; - StringClass DeviceVendor; - StringClass DevicePlatform; - - StringClass DriverName; - StringClass DriverVendor; - StringClass DriverVersion; - - StringClass HardwareName; - StringClass HardwareVendor; - StringClass HardwareChipset; - - D3DCAPS8 Caps; - D3DADAPTER_IDENTIFIER8 AdapterIdentifier; - - DynamicVectorClass ResArray; - - friend class WW3D; - friend class DX8Wrapper; -}; - - -inline void RenderDeviceDescClass::add_resolution(int w,int h,int bits) -{ - bool found = false; - for (int i=0; i. -*/ - - /*********************************************************************************************** - *** 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 *** - *********************************************************************************************** - * * - * Project Name : WW3D * - * * - * $Archive:: /Commando/Code/ww3d2/render2dsentence.cpp $* - * * - * $Author:: Patrick $* - * * - * $Modtime:: 8/29/01 11:16a $* - * * - * $Revision:: 13 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#include "render2dsentence.h" -#include "surfaceclass.h" -#include "texture.h" -#include "wwprofile.h" -#include "wwmemlog.h" -#include "dx8wrapper.h" - -#ifdef RTS_INTERNAL -// for occasional debugging... -//#pragma optimize("", off) -//#pragma message("************************************** WARNING, optimization disabled for debugging purposes") -#endif - -//////////////////////////////////////////////////////////////////////////////////// -// Local constants -//////////////////////////////////////////////////////////////////////////////////// -#define no_TEST_PLACEMENT 1 // Shows alignment markers for text. - -#define TEXTURE_OFFSET 2 -//////////////////////////////////////////////////////////////////////////////////// -// -// Render2DSentenceClass -// -//////////////////////////////////////////////////////////////////////////////////// -Render2DSentenceClass::Render2DSentenceClass (void) : - Font (NULL), - Location (0.0F,0.0F), - Cursor (0.0F,0.0F), - TextureOffset (0, 0), - TextureStartX (0), - CurSurface (NULL), - CurrTextureSize (0), - MonoSpaced (false), - IsClippedEnabled (false), - ClipRect (0, 0, 0, 0), - BaseLocation (0, 0), - LockedPtr (NULL), - LockedStride (0), - TextureSizeHint (0), - WrapWidth (0), - Centered (false), - DrawExtents (0, 0, 0, 0), - ParseHotKey( false ), - useHardWordWrap( false) -{ - Shader = Render2DClass::Get_Default_Shader (); - return ; -} - - -//////////////////////////////////////////////////////////////////////////////////// -// -// ~Render2DSentenceClass -// -//////////////////////////////////////////////////////////////////////////////////// -Render2DSentenceClass::~Render2DSentenceClass (void) -{ - REF_PTR_RELEASE (Font); - Reset (); - return ; -} - - -//////////////////////////////////////////////////////////////////////////////////// -// -// Set_Font -// -//////////////////////////////////////////////////////////////////////////////////// -void -Render2DSentenceClass::Set_Font (FontCharsClass *font) -{ - Reset (); - REF_PTR_SET (Font, font); - return ; -} - - -//////////////////////////////////////////////////////////////////////////////////// -// -// Reset_Polys -// -//////////////////////////////////////////////////////////////////////////////////// -void -Render2DSentenceClass::Reset_Polys (void) -{ - for (int index = 0; index < Renderers.Count (); index ++) { - Renderers[index].Renderer->Reset (); - } - - return ; -} - - -//////////////////////////////////////////////////////////////////////////////////// -// -// Reset -// -//////////////////////////////////////////////////////////////////////////////////// -void -Render2DSentenceClass::Reset (void) -{ - // - // Make sure we unlock the current surface (if necessary) - // - if (LockedPtr != NULL) { - CurSurface->Unlock (); - LockedPtr = NULL; - } - - // - // Release our hold on the current surface - // - REF_PTR_RELEASE (CurSurface); - - // - // Free each renderer - // - while (Renderers.Count () > 0) { - delete Renderers[0].Renderer; - Renderers.Delete(0); - } - - Cursor.Set (0, 0); - MonoSpaced = false; - ParseHotKey = false; - - Release_Pending_Surfaces (); - Reset_Sentence_Data (); - return ; -} - - -//////////////////////////////////////////////////////////////////////////////////// -// -// Make_Additive -// -//////////////////////////////////////////////////////////////////////////////////// -void -Render2DSentenceClass::Make_Additive (void) -{ - Shader.Set_Dst_Blend_Func (ShaderClass::DSTBLEND_ONE); - Shader.Set_Src_Blend_Func (ShaderClass::SRCBLEND_ONE); - Shader.Set_Primary_Gradient (ShaderClass::GRADIENT_MODULATE); - Shader.Set_Secondary_Gradient (ShaderClass::SECONDARY_GRADIENT_DISABLE); - - Set_Shader (Shader); - return ; -} - - -//////////////////////////////////////////////////////////////////////////////////// -// -// Make_Additive -// -//////////////////////////////////////////////////////////////////////////////////// -void -Render2DSentenceClass::Set_Shader (ShaderClass shader) -{ - Shader = shader; - - // - // Change each renderer's shader - // - for (int i = 0; i < Renderers.Count (); i ++) { - ShaderClass *curr_shader = Renderers[i].Renderer->Get_Shader (); - (*curr_shader) = Shader; - } - - return ; -} - - -//////////////////////////////////////////////////////////////////////////////////// -// -// Render -// -//////////////////////////////////////////////////////////////////////////////////// -void -Render2DSentenceClass::Render (void) -{ - // - // Build any textures that are pending - // - Build_Textures (); - - // - // Ask each renderer to draw its contents - // - for (int i = 0; i < Renderers.Count (); i ++) { - Renderers[i].Renderer->Render (); - } - - return ; -} - - -//////////////////////////////////////////////////////////////////////////////////// -// -// Set_Base_Location -// -//////////////////////////////////////////////////////////////////////////////////// -void -Render2DSentenceClass::Set_Base_Location (const Vector2 &loc) -{ - Vector2 dif = loc - BaseLocation; - BaseLocation = loc; - for (int i = 0; i < Renderers.Count (); i ++) { - Renderers[i].Renderer->Move (dif); - } - - return ; -} - - -//////////////////////////////////////////////////////////////////////////////////// -// -// Set_Location -// -//////////////////////////////////////////////////////////////////////////////////// -void -Render2DSentenceClass::Set_Location (const Vector2 &loc) -{ - Location = loc; - return ; -} - - -//////////////////////////////////////////////////////////////////////////////////// -// -// Get_Text_Extents -// -//////////////////////////////////////////////////////////////////////////////////// -Vector2 -Render2DSentenceClass::Get_Text_Extents (const WCHAR *text) -{ - Vector2 extent (0, Font->Get_Char_Height()); - - while (*text) { - WCHAR ch = *text++; - - if ( ch != (WCHAR)'\n' ) { - extent.X += Font->Get_Char_Spacing( ch ); - } - } - - return extent; -} - - -//////////////////////////////////////////////////////////////////////////////////// -// -// Get_Formatted_Text_Extents -// -//////////////////////////////////////////////////////////////////////////////////// -Vector2 -Render2DSentenceClass::Get_Formatted_Text_Extents (const WCHAR *text) -{ - return Build_Sentence_Not_Centered(text, NULL, NULL, true); -} - - -//////////////////////////////////////////////////////////////////////////////////// -// -// Reset_Sentence_Data -// -//////////////////////////////////////////////////////////////////////////////////// -void -Render2DSentenceClass::Reset_Sentence_Data (void) -{ - // - // Release our hold on each texture used in the sentence - // - for (int index = 0; index < SentenceData.Count (); index ++) { - REF_PTR_RELEASE (SentenceData[index].Surface); - } - - if (SentenceData.Count()>0) { - SentenceData.Delete_All (); - } - return ; -} - - -//////////////////////////////////////////////////////////////////////////////////// -// -// Release_Pending_Surfaces -// -//////////////////////////////////////////////////////////////////////////////////// -void -Render2DSentenceClass::Release_Pending_Surfaces (void) -{ - // - // Release our hold on each pending surface - // - for (int index = 0; index < PendingSurfaces.Count (); index ++) { - SurfaceClass *curr_surface = PendingSurfaces[index].Surface; - REF_PTR_RELEASE (curr_surface); - } - - if (PendingSurfaces.Count()>0) PendingSurfaces.Delete_All (); - return; -} - - -//////////////////////////////////////////////////////////////////////////////////// -// -// Build_Textures -// -//////////////////////////////////////////////////////////////////////////////////// -void -Render2DSentenceClass::Build_Textures (void) -{ - WWMEMLOG(MEM_TEXTURE); - - // - // Make sure we unlock the current surface - // - if (LockedPtr != NULL) { - CurSurface->Unlock (); - LockedPtr = NULL; - } - - // - // Release our hold on the current surface - // - REF_PTR_RELEASE (CurSurface); - TextureOffset.Set (0, 0); - TextureStartX = 0; - - // - // Convert all pending surfaces to textures - // - for (int index = 0; index < PendingSurfaces.Count (); index ++) { - PendingSurfaceStruct &surface_info = PendingSurfaces[index]; - SurfaceClass *curr_surface = surface_info.Surface; - - // - // Get the dimensions of the surface - // - SurfaceClass::SurfaceDescription desc; - curr_surface->Get_Description (desc); - - // - // Create the new texture - // - TextureClass *new_texture = W3DNEW TextureClass (desc.Width, desc.Width, WW3D_FORMAT_A4R4G4B4, MIP_LEVELS_1); - SurfaceClass *texture_surface = new_texture->Get_Surface_Level (); - - new_texture->Get_Filter().Set_U_Addr_Mode(TextureFilterClass::TEXTURE_ADDRESS_CLAMP); - new_texture->Get_Filter().Set_V_Addr_Mode(TextureFilterClass::TEXTURE_ADDRESS_CLAMP); - new_texture->Get_Filter().Set_Min_Filter(TextureFilterClass::FILTER_TYPE_NONE); - new_texture->Get_Filter().Set_Mag_Filter(TextureFilterClass::FILTER_TYPE_NONE); - new_texture->Get_Filter().Set_Mip_Mapping(TextureFilterClass::FILTER_TYPE_NONE); - - // - // Copy the contents of the texture from the surface - // - DX8Wrapper::_Copy_DX8_Rects (curr_surface->Peek_D3D_Surface (), NULL, 0, texture_surface->Peek_D3D_Surface (), NULL); - REF_PTR_RELEASE (texture_surface); - - // - // Assign this texture to any renderers that need it - // - for (int renderer_index = 0; renderer_index < surface_info.Renderers.Count (); renderer_index ++) { - Render2DClass *renderer = surface_info.Renderers[renderer_index]; - renderer->Set_Texture (new_texture); - } - - // - // Release our hold on the objects - // - REF_PTR_RELEASE (new_texture); - REF_PTR_RELEASE (curr_surface); - } - - // - // Reset the list - // - if (PendingSurfaces.Count()>0) { - PendingSurfaces.Delete_All (); - } - return ; -} - - -//////////////////////////////////////////////////////////////////////////////////// -// -// Draw_Sentence -// -//////////////////////////////////////////////////////////////////////////////////// -void -Render2DSentenceClass::Draw_Sentence (uint32 color) -{ - Render2DClass *curr_renderer = NULL; - SurfaceClass *curr_surface = NULL; - - DrawExtents.Set (0, 0, 0, 0); - - int offset = 0; - // - // Loop over all the parts of the sentence - // - for (int index = 0; index < SentenceData.Count (); index ++) { - SentenceDataStruct &data = SentenceData[index]; - - // - // Has the surface changed? - // - if (data.Surface != curr_surface) { - curr_surface = data.Surface; - - // - // Try to find a renderer that uses the same "texture" - // - bool found = false; - for (int renderer_index = 0; renderer_index < Renderers.Count (); renderer_index ++) { - if (Renderers[renderer_index].Surface == curr_surface) { - found = true; - curr_renderer = Renderers[renderer_index].Renderer; - break; - } - } - - // - // Create a new renderer if we couldn't find an appropriate one - // - if (found == false) { - - // - // Allocate a new renderer - // - curr_renderer = W3DNEW Render2DClass; - curr_renderer->Set_Coordinate_Range (Render2DClass::Get_Screen_Resolution ()); - ShaderClass *curr_shader = curr_renderer->Get_Shader (); - (*curr_shader) = Shader; - - // - // Add it to our list - // - RendererDataStruct render_info; - render_info.Renderer = curr_renderer; - render_info.Surface = curr_surface; - Renderers.Add (render_info); - - // - // Now, add this renderer to the surface pending list - // - for (int surface_index = 0; surface_index < PendingSurfaces.Count (); surface_index ++) { - PendingSurfaceStruct &surface_info = PendingSurfaces[surface_index]; - if (surface_info.Surface == curr_surface) { - surface_info.Renderers.Add (curr_renderer); - } - } - } - } - - // - // Get the dimensions of the surface - // - SurfaceClass::SurfaceDescription desc; - curr_surface->Get_Description (desc); - - // - // Add a quad that contains this sentence chunk - // - RectClass screen_rect = data.ScreenRect; - screen_rect += Location; - RectClass uv_rect = data.UVRect; - - // - // Clip the quad (as necessary) - // - bool add_quad = true; - if (IsClippedEnabled) { - - // - // Check for completely clipped - // - if ( screen_rect.Right <= ClipRect.Left || - screen_rect.Bottom <= ClipRect.Top) - { - add_quad = false; - } else { - - // - // Clip the polygons to the specified area - // - RectClass clipped_rect; - clipped_rect.Left = max (screen_rect.Left, ClipRect.Left); - clipped_rect.Right = min (screen_rect.Right, ClipRect.Right); - clipped_rect.Top = max (screen_rect.Top, ClipRect.Top); - clipped_rect.Bottom = min (screen_rect.Bottom, ClipRect.Bottom); - - // - // Clip the texture to the specified area - // - RectClass clipped_uv_rect; - float percent = ((clipped_rect.Left - screen_rect.Left) / screen_rect.Width ()); - clipped_uv_rect.Left = uv_rect.Left + (uv_rect.Width () * percent); - - percent = ((clipped_rect.Right - screen_rect.Left) / screen_rect.Width ()); - clipped_uv_rect.Right = uv_rect.Left + (uv_rect.Width () * percent); - - percent = ((clipped_rect.Top - screen_rect.Top) / screen_rect.Height ()); - clipped_uv_rect.Top = uv_rect.Top + (uv_rect.Height () * percent); - - percent = ((clipped_rect.Bottom - screen_rect.Top) / screen_rect.Height ()); - clipped_uv_rect.Bottom = uv_rect.Top + (uv_rect.Height () * percent); - - // - // Use the clipped rectangles to render - // - screen_rect = clipped_rect; - uv_rect = clipped_uv_rect; - - if (screen_rect.Right <= screen_rect.Left || - screen_rect.Bottom <= screen_rect.Top) - { - add_quad = false; - } - } - } - - if (add_quad) { - //uv_rect.Bottom += 0.5f; - uv_rect *= 1.0F / ((float)desc.Width); -#ifdef TEST_PLACEMENT - screen_rect.Left += offset*3; - screen_rect.Right += offset*3; -#endif - offset++; - curr_renderer->Add_Quad (screen_rect, uv_rect, color); - - // - // Add this rectangle to the total draw extents - // - if (DrawExtents.Width () == 0) { - DrawExtents = screen_rect; - } else { - DrawExtents += screen_rect; - } - } - } - - return ; -} - - -//////////////////////////////////////////////////////////////////////////////////// -// -// Record_Sentence_Chunk -// -//////////////////////////////////////////////////////////////////////////////////// -void -Render2DSentenceClass::Record_Sentence_Chunk (void) -{ - // - // Do we have anything to store? - // - int width = TextureOffset.I - TextureStartX; - if (width > 0) { - float char_height = Font->Get_Char_Height (); - - // - // Build a structure that contains enough information - // to hold this portion of the sentence - // - SentenceDataStruct sentence_data; - sentence_data.Surface = CurSurface; - sentence_data.Surface->Add_Ref (); - sentence_data.ScreenRect.Left = Cursor.X; - sentence_data.ScreenRect.Right = Cursor.X + width; - sentence_data.ScreenRect.Top = Cursor.Y; - sentence_data.ScreenRect.Bottom = Cursor.Y + char_height; - sentence_data.UVRect.Left = TextureStartX; - sentence_data.UVRect.Top = TextureOffset.J; - sentence_data.UVRect.Right = TextureOffset.I; - sentence_data.UVRect.Bottom = TextureOffset.J + char_height; - - // - // Add this information to our list - // - SentenceData.Add (sentence_data); - } - - return ; -} - - -//////////////////////////////////////////////////////////////////////////////////// -// -// Allocate_New_Surface -// -//////////////////////////////////////////////////////////////////////////////////// -void -Render2DSentenceClass::Allocate_New_Surface (const WCHAR *text, bool justCalcExtents) -{ - if (!justCalcExtents) - { - // - // Unlock the last surface (if necessary) - // - if (LockedPtr != NULL) { - CurSurface->Unlock (); - LockedPtr = NULL; - } - } - - // - // Calculate the width of the text - // - int text_width = 0; - for (int index = 0; text[index] != 0; index ++) { - text_width += Font->Get_Char_Spacing (text[index]); - } - - int char_height = Font->Get_Char_Height (); - - // - // Find the best texture size for the remaining text - // - CurrTextureSize = 256; - int best_tex_mem_usage = 999999999; - for (int pow2 = 6; pow2 <= 8; pow2 ++) { - - int size = 1 << pow2; - int row_count = (text_width / size) + 1; - int rows_per_texture = size / (char_height + 1); - - // - // Can we even fit one character on this texture? - // - if (rows_per_texture > 0) { - - // - // How many textures (at this size) would it take to render - // the remaining text? - // - int texture_count = row_count / rows_per_texture; - texture_count = max (texture_count, 1); - - // - // Is this the best usage of texture memory we've found yet? - // - int texture_mem_usage = (texture_count * size * size); - if (texture_mem_usage < best_tex_mem_usage) { - CurrTextureSize = size; - best_tex_mem_usage = texture_mem_usage; - } - } - } - - // - // Use whichever is larger, the hint or the calculated size - // - CurrTextureSize = max (TextureSizeHint, CurrTextureSize); - - if (!justCalcExtents) - { - // - // Release our extra hold on the old surface - // - REF_PTR_RELEASE (CurSurface); - - // - // Create the new surface - // - CurSurface = NEW_REF (SurfaceClass, (CurrTextureSize, CurrTextureSize, WW3D_FORMAT_A4R4G4B4)); - WWASSERT (CurSurface != NULL); - CurSurface->Add_Ref (); - - // - // Add this surface to our list - // - PendingSurfaceStruct surface_info; - surface_info.Surface = CurSurface; - PendingSurfaces.Add (surface_info); - } - - // - // Reset to the upper left corner - // - TextureOffset.Set (0, 0); - TextureStartX = 0; - return ; -} - -float FindStartingXPos( const WCHAR *text ) -{ - - return 1; -} -//////////////////////////////////////////////////////////////////////////////////// -// -// Build_Sentence_Centered -// -//////////////////////////////////////////////////////////////////////////////////// -void Render2DSentenceClass::Build_Sentence_Centered (const WCHAR *text, int *hkX, int *hkY) -{ - float char_height = Font->Get_Char_Height (); - int wordWidth = 0; - int notCenteredHotkeyX = 0; - int notCenteredHotkeyY = 0; - Vector2 extent = Build_Sentence_Not_Centered(text,¬CenteredHotkeyX, ¬CenteredHotkeyY, TRUE); //Get_Formatted_Text_Extents(text); - - // - // Start fresh - // - Reset_Sentence_Data (); - Cursor.Set (0, 0); - - // - // Ensure we have a surface to start with - // - if (CurSurface == NULL) { - Allocate_New_Surface (text); - } - - - - // - // Loop over all the characters in the string - // - bool end = false; - const WCHAR *word; - int word_width = 0; - int line_width = 0; - int charCount = 0; - int wordCount = 0; - int hotKeyPosX = 0; - int hotKeyPosY = 0; - bool calcHotKeyX = false; - bool dontBlit = false; - while (!end) - { - // - // Re-init everything for the next line - // - word = text; - word_width = 0; - line_width = 0; - charCount = 0; - wordCount = 0; - // - //first find the length of the line till we wrap - // - while ( 1 ) - { - // - // read a word - // - int charWidth = 0; - while ((*word != 0) && (*word > L' ') && (*word != L'\n')) { - if( ParseHotKey && (*word == L'&') && (*word+1 != 0) && (*word+1 > L' ') && (*word+1 != L'\n')) - { - int offset = 0; - //Added By Saad - if (word_width != 0 ) - { - const WCHAR *word_back = word; - *word_back--; - if (*word_back == L' ') - { - line_width -= word_width; - offset =-1; - } - } - // - *word++; - calcHotKeyX = true; - } - - charWidth = Font->Get_Char_Spacing (*word++); - word_width += charWidth; - wordCount++; - - if (WrapWidth > 0 && word_width >= WrapWidth && useHardWordWrap) - break; - } - // - // If this word is unworthy to be on the current line, decrement the space and break - // - if(WrapWidth > 0 && (line_width + word_width >= WrapWidth)) - { - // - //Take care of the case that the word is too big for the allocated space... - //If that's the case, drop out and process the word anyway - // - if(charCount == 0) - { - charCount +=wordCount - 1; - line_width += word_width - charWidth; - if(*word == 0) - end = true; - break; - } - charCount--; - break; - } - // - // if we reached the end of the text, set the values and break, also set the end flag - // - if( *word == 0 ) - { - charCount +=wordCount; - line_width += word_width; - end = true; - break; - } - // - // otherwise, increment the counts - // - charCount +=wordCount + 1; - line_width += word_width; - // - // We were some a new line character break and process - // - if(*word != L' ') - break; - // - // add the space to our width - // - word_width = Font->Get_Char_Spacing (*word++); - wordCount = 0; - //Added By Saad - line_width += word_width; - } - // - // we now hold the length of the line and it's width lets set our cursor position to center it - // - Cursor.X = (int)((extent.X - line_width) / 2); - if(Cursor.X < 0) - Cursor.X = 0; - if(calcHotKeyX) - { - calcHotKeyX = false; - hotKeyPosX = Cursor.X + notCenteredHotkeyX; - } - - for(int i = 0; i <= charCount; i++) { - WCHAR ch = *text++; - dontBlit = false; - // - // Determine how much horizontal space this character requires - // - if(ParseHotKey && (ch == L'&') && (*text != 0) && (*text > L' ') && (*text != L'\n')) - { - ch = *text++; - dontBlit = true; - } - float char_spacing = Font->Get_Char_Spacing (ch); - - bool exceeded_texture_width = ((TextureOffset.I + char_spacing) >= CurrTextureSize); - bool encountered_break_char = (ch == L' ' || ch == L'\n' || ch == 0); - - // - // Do we need to record this portion of the sentence to its own chunk? - // - if (exceeded_texture_width || encountered_break_char) { - Record_Sentence_Chunk (); - - // - // Adjust the positions - // - Cursor.X += (TextureOffset.I - TextureStartX); - TextureStartX = TextureOffset.I; - - // - // Adjust the output coordinates - // - if (ch == L' ') { - Cursor.X += char_spacing; - } else if ((ch == 0 )|| (ch == L'\n')) { - break; - } - - // - // Did the text extend past the edge of the texture? - // - if (exceeded_texture_width) { - TextureStartX = 0; - TextureOffset.I = TextureStartX; - TextureOffset.J += char_height; - - // - // Did the text extent completely off the texture? - // - if ((TextureOffset.J + char_height) >= CurrTextureSize) { - Allocate_New_Surface (text); - } - } - } - // - // Adjust the output coordinates - // - if (ch != L'\n' && ch != L' ') { - - // - // Ensure the surface is locked - // - if (LockedPtr == NULL) { - LockedPtr = (uint16 *)CurSurface->Lock (&LockedStride); - WWASSERT (LockedPtr != NULL); - } - - // - // Check to ensure the text will fit on this texture - // - WWASSERT (((TextureOffset.I + char_spacing) < CurrTextureSize) && ((TextureOffset.J + char_height) < CurrTextureSize)); - - // - // Blit the character to the surface - // - if(!dontBlit) - Font->Blit_Char (ch, LockedPtr, LockedStride, TextureOffset.I, TextureOffset.J); - - if (dontBlit) { - // we don't blit for a hot key character. So add extra spacing. - char_spacing += Font->Get_Extra_Overlap(); - // Brutal hack #27 Gamma - Bolded M's are just a problem. jba. - if (ch=='M') { - char_spacing++; - } - } - - TextureOffset.I += char_spacing; - } - } - // - // reset our cursor and add a line of text to the cursor position - // - Cursor.X = 0; - Cursor.Y += char_height; - line_width = 0; - } - - if(hkX) - *hkX = hotKeyPosX; - if(hkX) - *hkY = hotKeyPosY; - return ; -} -//////////////////////////////////////////////////////////////////////////////////// -// -// Build_Sentence_NotCentered -// -//////////////////////////////////////////////////////////////////////////////////// -Vector2 Render2DSentenceClass::Build_Sentence_Not_Centered (const WCHAR *text, int *hkX, int *hkY, bool justCalcExtents) -{ - Vector2 cursor = Cursor; - int textureStartX = TextureStartX; - float maxX = 0; - - int hotKeyPosX = 0; - int hotKeyPosY = 0; - bool calcHotKeyX = false; - bool dontBlit = false; - Vector2i textureOffset = TextureOffset; - - - // - // Start fresh - // - if (!justCalcExtents) - { - Reset_Sentence_Data (); - } - Cursor.Set (0, 0); - - // - // Ensure we have a surface to start with - // - if (CurSurface == NULL) { - Allocate_New_Surface (text, justCalcExtents); - } - - TextureOffset.Set (TEXTURE_OFFSET, 0); - TextureStartX = TEXTURE_OFFSET; - - float char_height = Font->Get_Char_Height (); - - // - // Loop over all the characters in the string - // - while (text != NULL) { - WCHAR ch = *text++; - dontBlit = false; - // - // Determine how much horizontal space this character requires - // - if(ParseHotKey && (ch == L'&') && (*text != 0) && (*text > L' ') && (*text != L'\n')) - { - hotKeyPosY = Cursor.Y; - if (calcHotKeyX) - hotKeyPosX = 0; - else - hotKeyPosX = Cursor.X + TextureOffset.I -TextureStartX;//TextureOffset.I; - - ch = *text++; - dontBlit = true; - } - float char_spacing = Font->Get_Char_Spacing (ch); - - bool exceeded_texture_width = ((TextureOffset.I + char_spacing) >= CurrTextureSize); - bool encountered_break_char = (ch == L' ' || ch == L'\n' || ch == 0); - bool wordBiggerThenLine = ((useHardWordWrap) && ( WrapWidth != 0 ) &&((Cursor.X + TextureOffset.I -TextureStartX + char_spacing) >= WrapWidth)); - // - // Do we need to record this portion of the sentence to its own chunk? - // - if (exceeded_texture_width || encountered_break_char|| wordBiggerThenLine) { - if (!justCalcExtents) - { - Record_Sentence_Chunk (); - } - - // - // Adjust the positions - // - Cursor.X += (TextureOffset.I - TextureStartX); - maxX = max(maxX, Cursor.X); - TextureStartX = TextureOffset.I; - - // - // Adjust the output coordinates - // - if (ch == L' ') { - //Cursor.X += char_spacing; - //maxX = max(maxX, Cursor.X); - - // - // Check to see if we need to wrap on this word-break - // - if (WrapWidth > 0) { - - // - // Find the length of the next word - // - const WCHAR *word = text; - float word_width = char_spacing; - while ((*word != 0) && (*word > L' ')) { - if(ParseHotKey && (*word == L'&') && (*word+1 != 0) && (*word+1 > L' ') && (*word+1 != L'\n')) - *word++; - word_width += Font->Get_Char_Spacing (*word++); - } - - // - // Should we wrap the next word? - // - if ((Cursor.X + word_width) >= WrapWidth) { - Cursor.X = 0; - Cursor.Y += char_height; - calcHotKeyX = true; - } - } - - } else if (ch == L'\n') { - Cursor.X = 0; - Cursor.Y += char_height; - } else if (ch == 0) { - break; - } else if (wordBiggerThenLine){ // we've entered this loop because we're greater then the wordwrap so we need to force a wordwrap - Cursor.X = 0; - Cursor.Y += char_height; - } - - - // - // Did the text extend past the edge of the texture? - // - if (exceeded_texture_width) { - TextureStartX = TEXTURE_OFFSET; - TextureOffset.I = TextureStartX; - TextureOffset.J += char_height; - - // - // Did the text extent completely off the texture? - // - if ((TextureOffset.J + char_height) >= CurrTextureSize) { - Allocate_New_Surface (text, justCalcExtents); - } - } - } - - if (ch != L'\n' ) { - - // - // Ensure the surface is locked - // - if (!justCalcExtents) - { - if (LockedPtr == NULL) { - LockedPtr = (uint16 *)CurSurface->Lock (&LockedStride); - WWASSERT (LockedPtr != NULL); - } - } - - // - // Check to ensure the text will fit on this texture - // - WWASSERT (((TextureOffset.I + char_spacing) < CurrTextureSize) && ((TextureOffset.J + char_height) < CurrTextureSize)); - - // - // Blit the character to the surface - // - if (!justCalcExtents && !dontBlit ) - { - Font->Blit_Char (ch, LockedPtr, LockedStride, TextureOffset.I, TextureOffset.J); - } - TextureOffset.I += char_spacing; - } - } - - Vector2 extent; - extent.X = maxX + Font->Get_Extra_Overlap(); - extent.Y = Cursor.Y + char_height; - - Cursor = cursor; - TextureOffset = textureOffset; - TextureStartX = textureStartX; - - if(hkX) - *hkX = hotKeyPosX; - if(hkX) - *hkY = hotKeyPosY; - - return extent; -} - - -//////////////////////////////////////////////////////////////////////////////////// -// -// Build_Sentence -// -//////////////////////////////////////////////////////////////////////////////////// -void -Render2DSentenceClass::Build_Sentence (const WCHAR *text, int *hkX, int *hkY) -{ - if (text == NULL) { - return ; - } - - - if(Centered && (WrapWidth > 0 || wcschr(text,L'\n'))) - Build_Sentence_Centered(text, hkX, hkY); - else - Build_Sentence_Not_Centered(text, hkX, hkY); - - return; - -} - - -//////////////////////////////////////////////////////////////////////////////////// -// -// FontCharsClass -// -//////////////////////////////////////////////////////////////////////////////////// -FontCharsClass::FontCharsClass (void) : - OldGDIFont( NULL ), - OldGDIBitmap( NULL ), - GDIFont( NULL ), - GDIBitmap( NULL ), - GDIBitmapBits ( NULL ), - MemDC( NULL ), - CurrPixelOffset( 0 ), - PointSize( 0 ), - CharHeight( 0 ), - UnicodeCharArray( NULL ), - FirstUnicodeChar( 0xFFFF ), - LastUnicodeChar( 0 ), - IsBold (false) -{ - AlternateUnicodeFont = NULL; - ::memset( ASCIICharArray, 0, sizeof (ASCIICharArray) ); - return ; -} - - -//////////////////////////////////////////////////////////////////////////////////// -// -// ~FontCharsClass -// -//////////////////////////////////////////////////////////////////////////////////// -FontCharsClass::~FontCharsClass (void) -{ - while ( BufferList.Count() ) { - delete BufferList[0]; - BufferList.Delete(0); - } - - Free_GDI_Font(); - Free_Character_Arrays(); - return ; -} - - -//////////////////////////////////////////////////////////////////////////////////// -// -// Get_Char_Data -// -//////////////////////////////////////////////////////////////////////////////////// -const FontCharsClassCharDataStruct * -FontCharsClass::Get_Char_Data (WCHAR ch) -{ - const FontCharsClassCharDataStruct *retval = NULL; - - if ( ch < 256 ) - { - retval = ASCIICharArray[ch]; - } - else if ( AlternateUnicodeFont && this != AlternateUnicodeFont ) - { - return AlternateUnicodeFont->Get_Char_Data( ch ); - } - else - { - Grow_Unicode_Array( ch ); - retval = UnicodeCharArray[ch - FirstUnicodeChar]; - } - - // - // If the character wasn't found, then add it to our list - // - if ( retval == NULL ) { - retval = Store_GDI_Char( ch ); - } - - WWASSERT( retval->Value == ch ); - return retval; -} - - -//////////////////////////////////////////////////////////////////////////////////// -// -// Get_Char_Width -// -//////////////////////////////////////////////////////////////////////////////////// -int -FontCharsClass::Get_Char_Width (WCHAR ch) -{ - const FontCharsClassCharDataStruct * data = Get_Char_Data( ch ); - if ( data != NULL ) { - return data->Width; - } - - return 0; -} - - -//////////////////////////////////////////////////////////////////////////////////// -// -// Get_Char_Spacing -// -//////////////////////////////////////////////////////////////////////////////////// -int -FontCharsClass::Get_Char_Spacing (WCHAR ch) -{ - const FontCharsClassCharDataStruct * data = Get_Char_Data( ch ); - if ( data != NULL ) { - if ( data->Width != 0 ) { - return data->Width - PixelOverlap - CharOverhang; - } - } - - return 0; -} - - -//////////////////////////////////////////////////////////////////////////////////// -// -// Blit_Char -// -//////////////////////////////////////////////////////////////////////////////////// -void -FontCharsClass::Blit_Char (WCHAR ch, uint16 *dest_ptr, int dest_stride, int x, int y) -{ - const FontCharsClassCharDataStruct * data = Get_Char_Data( ch ); - if ( data != NULL && data->Width != 0 ) { - - // - // Setup the src and destination pointers - // - int dest_inc = (dest_stride >> 1); - uint16 *src_ptr = data->Buffer; - dest_ptr += (dest_inc * y) + x; - - // - // Simply copy the data from the src buffer to the destination - // - for ( int row = 0; row < CharHeight; row ++ ) { - for ( int col = 0; col < data->Width; col ++ ) { - uint16 curData = *src_ptr; - if (colBuffer; - curr_buffer_p += CurrPixelOffset; - - // - // Copy the BMP contents to the buffer - // - int stride = (((width * 3) + 3) & ~3); - for (int row = 0; row < char_size.cy; row ++) { - - // - // Compute the indices into the BMP and surface - // - int index = (row * stride); - - // - // Loop over each column - // - for (int col = 0; col < char_size.cx; col ++) { - - // - // Get the pixel color at this location - // - uint8 pixel_value = GDIBitmapBits[index]; - index += 3; -#ifdef TEST_PLACEMENT - if (row==CharHeight-1&&col==0) { - pixel_value = 0xff; - } - if (row==CharHeight-2&&col==1) { - pixel_value = 0xff; - } - if (row==0&&col==0) { - pixel_value = 0xff; - } - if (row==1&&col==1) { - pixel_value = 0xff; - } - if (row==CharHeight-1&&col==char_size.cx-1-PixelOverlap) { - pixel_value = 0xff; - } - if (row==CharHeight-2&&col==char_size.cx-2-PixelOverlap) { - pixel_value = 0xff; - } - if (row==0&&col==char_size.cx-1-PixelOverlap) { - pixel_value = 0xff; - } - if (row==1&&col==char_size.cx-2-PixelOverlap) { - pixel_value = 0xff; - } - if (pixel_value == 0x00) { - pixel_value = 0x40; - } -#endif - - uint16 pixel_color = 0; - if (pixel_value != 0) { - pixel_color = 0x0FFF; - } - - // - // Convert the pixel intensity from 8bit to 4bit and - // store it in our buffer - // - uint8 alpha_value = ((pixel_value >> 4) & 0xF); - *curr_buffer_p++ = pixel_color | (alpha_value << 12); - } - } - - // - // Save information about this character in our list - // - FontCharsClassCharDataStruct *char_data = W3DNEW FontCharsClassCharDataStruct; - char_data->Value = ch; - char_data->Width = char_size.cx; - char_data->Buffer = BufferList[BufferList.Count () - 1]->Buffer + CurrPixelOffset; - - // - // Insert this character into our array - // - if ( ch < 256 ) { - ASCIICharArray[ch] = char_data; - } else { - UnicodeCharArray[ch - FirstUnicodeChar] = char_data; - } - - // - // Advance the character position - // - CurrPixelOffset += ((char_size.cx+PixelOverlap) * CharHeight); - - // - // Return the index of the entry we just added - // - return char_data; -} - - -//////////////////////////////////////////////////////////////////////////////////// -// -// Update_Current_Buffer -// -//////////////////////////////////////////////////////////////////////////////////// -void -FontCharsClass::Update_Current_Buffer (int char_width) -{ - // - // Check to see if we need to allocate a new buffer - // - bool needs_new_buffer = (BufferList.Count () == 0); - if (needs_new_buffer == false) { - - // - // Would we extend past this buffer? - // - if ( (CurrPixelOffset + (char_width * CharHeight)) > CHAR_BUFFER_LEN ) { - needs_new_buffer = true; - } - } - - // - // Do we need to create a new surface? - // - if (needs_new_buffer) - { - FontCharsBuffer* new_buffer = W3DNEW FontCharsBuffer; - BufferList.Add( new_buffer ); - CurrPixelOffset = 0; - } - - return ; -} - - -//////////////////////////////////////////////////////////////////////////////////// -// -// Create_GDI_Font -// -//////////////////////////////////////////////////////////////////////////////////// -void -FontCharsClass::Create_GDI_Font (const char *font_name) -{ - HDC screen_dc = ::GetDC ((HWND)WW3D::Get_Window()); - - const char *fontToUseForGenerals = "Arial"; - bool doingGenerals = false; - if (strcmp(font_name, "Generals")==0) { - font_name = fontToUseForGenerals; - doingGenerals = true; - } - - // - // Calculate the height of the font in logical units - // - const int dotsPerInch = 96; // always use 96. jba. - int font_height = -MulDiv (PointSize, dotsPerInch, 72); - - int fontWidth = 0; // use font default. - if (doingGenerals) { - //fontWidth = -font_height*0.35f; //2 pixels tighter. - fontWidth = -font_height*0.40f; // one pixel tighter - } - PixelOverlap = (-font_height)/8; - - // Sanity check in case of perversion. :) - if (PixelOverlap<0) PixelOverlap = 0; - if (PixelOverlap>4) PixelOverlap = 4; - // - // Create the Windows font - // - DWORD bold = IsBold ? FW_BOLD : FW_NORMAL; - DWORD italic = 0; - GDIFont = ::CreateFont (font_height, fontWidth, 0, 0, bold, italic, - FALSE, FALSE, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, - CLIP_DEFAULT_PRECIS, ANTIALIASED_QUALITY, - VARIABLE_PITCH, font_name); - - // - // Set-up the fields of the BITMAPINFOHEADER - // Note: Top-down DIBs use negative height in Win32. - // - BITMAPINFOHEADER bitmap_info = { 0 }; - bitmap_info.biSize = sizeof (BITMAPINFOHEADER); - bitmap_info.biWidth = PointSize * 2; - bitmap_info.biHeight = -(PointSize * 2); - bitmap_info.biPlanes = 1; - bitmap_info.biBitCount = 24; - bitmap_info.biCompression = BI_RGB; - bitmap_info.biSizeImage = ((PointSize * PointSize * 4) * 3); - bitmap_info.biXPelsPerMeter = 0; - bitmap_info.biYPelsPerMeter = 0; - bitmap_info.biClrUsed = 0; - bitmap_info.biClrImportant = 0; - - // - // Create a bitmap that we can access the bits directly of - // - GDIBitmap = ::CreateDIBSection ( screen_dc, - (const BITMAPINFO *)&bitmap_info, - DIB_RGB_COLORS, - (void **)&GDIBitmapBits, - NULL, - 0L); - - // - // Create a device context we can select the font and bitmap into - // - MemDC = ::CreateCompatibleDC (screen_dc); - - // - // Release our temporary screen DC - // - ::ReleaseDC ((HWND)WW3D::Get_Window(), screen_dc); - - // - // Now select the BMP and font into the DC - // - OldGDIBitmap = (HBITMAP)::SelectObject (MemDC, GDIBitmap); - OldGDIFont = (HFONT)::SelectObject (MemDC, GDIFont); - ::SetBkColor (MemDC, RGB (0, 0, 0)); - ::SetTextColor (MemDC, RGB (255, 255, 255)); - - // - // Lookup the pixel height of the font - // - TEXTMETRIC text_metric = { 0 }; - ::GetTextMetrics (MemDC, &text_metric); - CharHeight = text_metric.tmHeight; - CharAscent = text_metric.tmAscent; - CharOverhang = text_metric.tmOverhang; - if (doingGenerals) { - CharOverhang = 0; - } -} - - -//////////////////////////////////////////////////////////////////////////////////// -// -// Free_GDI_Font -// -//////////////////////////////////////////////////////////////////////////////////// -void -FontCharsClass::Free_GDI_Font (void) -{ - // - // Select the old font back into the DC and delete - // our font object - // - if ( GDIFont != NULL ) { - ::SelectObject( MemDC, OldGDIFont ); - ::DeleteObject( GDIFont ); - GDIFont = NULL; - } - - // - // Select the old bitmap back into the DC and delete - // our bitmap object - // - if ( GDIBitmap != NULL ) { - ::SelectObject( MemDC, OldGDIBitmap ); - ::DeleteObject( GDIBitmap ); - GDIBitmap = NULL; - } - - // - // Delete our memory DC - // - if ( MemDC != NULL ) { - ::DeleteDC( MemDC ); - MemDC = NULL; - } - - return ; -} - - -//////////////////////////////////////////////////////////////////////////////////// -// -// Initialize_GDI_Font -// -//////////////////////////////////////////////////////////////////////////////////// -void -FontCharsClass::Initialize_GDI_Font (const char *font_name, int point_size, bool is_bold) -{ - // - // Build a unique name from the font name and its size - // - Name.Format ("%s%d", font_name, point_size); - - // - // Remember these settings - // - GDIFontName = font_name; - PointSize = point_size; - IsBold = is_bold; - - // - // Create the actual font object - // - Create_GDI_Font (font_name); - return ; -} - - -//////////////////////////////////////////////////////////////////////////////////// -// -// Is_Font -// -//////////////////////////////////////////////////////////////////////////////////// -bool -FontCharsClass::Is_Font (const char *font_name, int point_size, bool is_bold) -{ - bool retval = false; - - // - // Check to see if both the name and height matches... - // - if ( (GDIFontName.Compare_No_Case (font_name) == 0) && - (point_size == PointSize) && - (is_bold == IsBold)) - { - retval = true; - } - - return retval; -} - - -//////////////////////////////////////////////////////////////////////////////////// -// -// Grow_Unicode_Array -// -//////////////////////////////////////////////////////////////////////////////////// -void -FontCharsClass::Grow_Unicode_Array (WCHAR ch) -{ - // - // Don't do anything if character is in the ASCII range - // - if ( ch < 256 ) { - return ; - } - - // - // Don't do anything if character is in the currently allocated range - // - if ( ch >= FirstUnicodeChar && ch <= LastUnicodeChar ) { - return ; - } - - uint16 first_index = min( FirstUnicodeChar, static_cast(ch) ); - uint16 last_index = max( LastUnicodeChar, static_cast(ch) ); - uint16 count = (last_index - first_index) + 1; - - // - // Allocate enough memory to hold the new cells - // - FontCharsClassCharDataStruct **new_array = W3DNEWARRAY FontCharsClassCharDataStruct *[count]; - ::memset (new_array, 0, sizeof (FontCharsClassCharDataStruct *) * count); - - // - // Copy the contents of the old array into the new array - // - if ( UnicodeCharArray != NULL ) { - int start_offset = (FirstUnicodeChar - first_index); - int old_count = (LastUnicodeChar - FirstUnicodeChar) + 1; - ::memcpy (&new_array[start_offset], UnicodeCharArray, sizeof (FontCharsClassCharDataStruct *) * old_count); - - // - // Delete the old array - // - delete [] UnicodeCharArray; - UnicodeCharArray = NULL; - } - - FirstUnicodeChar = first_index; - LastUnicodeChar = last_index; - UnicodeCharArray = new_array; - return ; -} - - -//////////////////////////////////////////////////////////////////////////////////// -// -// Free_Character_Arrays -// -//////////////////////////////////////////////////////////////////////////////////// -void -FontCharsClass::Free_Character_Arrays (void) -{ - if ( UnicodeCharArray != NULL ) { - - int count = (LastUnicodeChar - FirstUnicodeChar) + 1; - - // - // Delete each member of the unicode array - // - for (int index = 0; index < count; index ++) { - if ( UnicodeCharArray[index] != NULL ) { - delete UnicodeCharArray[index]; - UnicodeCharArray[index] = NULL; - } - } - - // - // Delete the array itself - // - delete [] UnicodeCharArray; - UnicodeCharArray = NULL; - } - - // - // Delete each member of the ascii character array - // - for (int index = 0; index < 256; index ++) { - if ( ASCIICharArray[index] != NULL ) { - delete ASCIICharArray[index]; - ASCIICharArray[index] = NULL; - } - } - - return ; -} diff --git a/Generals/Code/Libraries/Source/WWVegas/WW3D2/render2dsentence.h b/Generals/Code/Libraries/Source/WWVegas/WW3D2/render2dsentence.h deleted file mode 100644 index 094715d3501..00000000000 --- a/Generals/Code/Libraries/Source/WWVegas/WW3D2/render2dsentence.h +++ /dev/null @@ -1,276 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - - /*********************************************************************************************** - *** 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 *** - *********************************************************************************************** - * * - * Project Name : WW3D * - * * - * $Archive:: /Commando/Code/ww3d2/render2dsentence.h $* - * * - * Author:: Greg Hjelstrom * - * * - * $Modtime:: 8/29/01 10:58a $* - * * - * $Revision:: 6 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#if defined(_MSC_VER) -#pragma once -#endif - -#ifndef RENDER2DSENTENCE_H -#define RENDER2DSENTENCE_H - -#include "render2d.h" -#include "refcount.h" -#include "Vector.H" -#include "vector2i.h" -#include "wwstring.h" -#include "win.h" - -/* -** FontCharsClass -*/ -class SurfaceClass; - -// -// Private data structures -// -class FontCharsClassCharDataStruct : public W3DMPO -{ - W3DMPO_GLUE(FontCharsClassCharDataStruct) -public: - WCHAR Value; - short Width; - uint16 * Buffer; -}; - -enum { CHAR_BUFFER_LEN = 32768 }; - -class FontCharsBuffer : public W3DMPO -{ - W3DMPO_GLUE(FontCharsBuffer) -public: - uint16 Buffer[CHAR_BUFFER_LEN]; -}; - - -class FontCharsClass : public W3DMPO, public RefCountClass -{ - W3DMPO_GLUE(FontCharsClass) - -public: - FontCharsClass( void ); - ~FontCharsClass(); - - // TR: Hack for unicode font support - FontCharsClass *AlternateUnicodeFont; - - - void Initialize_GDI_Font( const char *font_name, int point_size, bool is_bold ); - bool Is_Font( const char *font_name, int point_size, bool is_bold ); - const char * Get_Name( void ) { return Name; } - - int Get_Char_Height( void ) { return CharHeight; } - int Get_Char_Width( WCHAR ch ); - int Get_Char_Spacing( WCHAR ch ); - - int Get_Extra_Overlap(void) {return PixelOverlap;} - - void Blit_Char( WCHAR ch, uint16 *dest_ptr, int dest_stride, int x, int y ); - -private: - - // - // Private methods - // - void Create_GDI_Font( const char *font_name ); - void Free_GDI_Font( void ); - const FontCharsClassCharDataStruct * Store_GDI_Char( WCHAR ch ); - void Update_Current_Buffer( int char_width ); - const FontCharsClassCharDataStruct * Get_Char_Data( WCHAR ch ); - - void Grow_Unicode_Array( WCHAR ch ); - void Free_Character_Arrays( void ); - - // - // Private member data - // - StringClass Name; - DynamicVectorClass BufferList; - int CurrPixelOffset; - int CharHeight; - int CharAscent; - int CharOverhang; - int PixelOverlap; - int PointSize; - StringClass GDIFontName; - HFONT OldGDIFont; - HBITMAP OldGDIBitmap; - HBITMAP GDIBitmap; - HFONT GDIFont; - uint8 * GDIBitmapBits; - HDC MemDC; - FontCharsClassCharDataStruct * ASCIICharArray[256]; - FontCharsClassCharDataStruct ** UnicodeCharArray; - uint16 FirstUnicodeChar; - uint16 LastUnicodeChar; - bool IsBold; -}; - -/* -** Render2DSentenceClass -*/ -class Render2DSentenceClass { -public: - //Render2DSentenceClass( FontCharsClass * font ); - Render2DSentenceClass( void ); - ~Render2DSentenceClass(); - - void Render (void); - virtual void Reset (void); - void Reset_Polys (void); - - FontCharsClass * Peek_Font( void ) { return Font; } - void Set_Font( FontCharsClass *font ); - - void Set_Location( const Vector2 & loc ); - void Set_Base_Location( const Vector2 & loc ); - bool Set_Wrapping_Width (float width) { if(WrapWidth == width) - return false; - WrapWidth = width; - return true; } - bool Set_Word_Wrap_Centered( bool isCentered ) { if(Centered == isCentered) - return false; - Centered = isCentered; - return true;} - void Set_Hot_Key_Parse( bool parseHotKey ){ ParseHotKey = parseHotKey; } - void Set_Use_Hard_Word_Wrap( bool useHardWrap){ useHardWordWrap = useHardWrap; } - // - // Clipping support - // - void Set_Clipping_Rect( const RectClass &rect ) { ClipRect = rect; IsClippedEnabled = true; } - bool Is_Clipping_Enabled( void ) const { return IsClippedEnabled; } - void Enable_Clipping( bool onoff ) { IsClippedEnabled = onoff; } - - // - // Shader modification support - // - void Make_Additive (void); - ShaderClass Get_Shader (void) const { return Shader; } - void Set_Shader (ShaderClass shader); - -// void Draw_Block( const RectClass & screen, unsigned long color = 0xFFFFFFFF ); - - const RectClass & Get_Draw_Extents( void ) { return DrawExtents; } -// const RectClass & Get_Total_Extents( void ) { return TotalExtents; } -// const Vector2 & Get_Cursor( void ) { return Cursor; } - - Vector2 Get_Text_Extents( const WCHAR * text ); - Vector2 Get_Formatted_Text_Extents( const WCHAR * text ); - - // - // Sentence control - // - void Build_Sentence (const WCHAR *text, int *hkX, int *hkY); - void Draw_Sentence (uint32 color = 0xFFFFFFFF); - - // - // Texture hint - // - void Set_Texture_Size_Hint( int hint ) { TextureSizeHint = hint; } - int Get_Texture_Size_Hint( void ) const { return TextureSizeHint; } - - void Set_Mono_Spaced( bool onoff ) { MonoSpaced = onoff; } - -private: - - // - // Private structures - // - struct SentenceDataStruct { - SurfaceClass * Surface; - RectClass ScreenRect; - RectClass UVRect; - - bool operator== (const SentenceDataStruct &src) { return false; } - bool operator!= (const SentenceDataStruct &src) { return true; } - }; - - struct PendingSurfaceStruct { - SurfaceClass * Surface; - DynamicVectorClass Renderers; - - bool operator== (const PendingSurfaceStruct &src) { return false; } - bool operator!= (const PendingSurfaceStruct &src) { return true; } - }; - - struct RendererDataStruct { - Render2DClass * Renderer; - SurfaceClass * Surface; - - bool operator== (const RendererDataStruct &src) { return false; } - bool operator!= (const RendererDataStruct &src) { return true; } - }; - - // - // Private methods - // - void Reset_Sentence_Data (void); - void Build_Textures (void); - void Record_Sentence_Chunk (void); - void Allocate_New_Surface (const WCHAR *text, bool justCalcExtents = false); - void Release_Pending_Surfaces (void); - void Build_Sentence_Centered (const WCHAR *text, int *hkX, int *hkY); - Vector2 Build_Sentence_Not_Centered (const WCHAR *text, int *hkX, int *hkY,bool justCalcExtents = false ); - // - // Private member data - // - DynamicVectorClass SentenceData; - DynamicVectorClass PendingSurfaces; - DynamicVectorClass Renderers; - FontCharsClass * Font; - Vector2 BaseLocation; - Vector2 Location; - Vector2 Cursor; - Vector2i TextureOffset; - int TextureStartX; - int CurrTextureSize; - int TextureSizeHint; - SurfaceClass * CurSurface; - bool MonoSpaced; - float WrapWidth; - bool Centered; // Determines whether or not to center each line - RectClass ClipRect; - RectClass DrawExtents; - bool IsClippedEnabled; - bool ParseHotKey; - bool useHardWordWrap; - - uint16 * LockedPtr; - int LockedStride; - TextureClass * CurTexture; - ShaderClass Shader; -}; - -#endif // RENDER2DSENTENCE_H diff --git a/Generals/Code/Libraries/Source/WWVegas/WW3D2/renderobjectrecycler.cpp b/Generals/Code/Libraries/Source/WWVegas/WW3D2/renderobjectrecycler.cpp deleted file mode 100644 index 6380cb5e0c2..00000000000 --- a/Generals/Code/Libraries/Source/WWVegas/WW3D2/renderobjectrecycler.cpp +++ /dev/null @@ -1,188 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** 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 *** - *********************************************************************************************** - * * - * Project Name : ww3d * - * * - * $Archive:: /Commando/Code/ww3d2/renderobjectrecycler.cpp $* - * * - * Original Author:: Greg Hjelstrom * - * * - * $Author:: Greg_h $* - * * - * $Modtime:: 5/08/01 3:54p $* - * * - * $Revision:: 1 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * RenderObjectRecyclerClass::Reset -- reset the cache * - * RenderObjectRecyclerClass::Get_Render_Object -- Create/Re-use a render object * - * RenderObjectRecyclerClass::Return_Render_Object -- Return a render object to the cache * - * RenderObjectRecyclerClass::Insert_Inactive_Model -- Internally add a render object to the * - * RenderObjectRecyclerClass::Reset_Model -- resets a render object so it can be re-used * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#include "renderobjectrecycler.h" -#include -#include "rendobj.h" -#include "assetmgr.h" -#include "part_emt.h" -#include "matrix3d.h" - - -/*********************************************************************************************** - * RenderObjectRecyclerClass::Reset -- reset the pool * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 4/25/2001 gth : Created. * - *=============================================================================================*/ -void RenderObjectRecyclerClass::Reset(void) -{ - InactiveModels.Reset_List(); -} - - -/*********************************************************************************************** - * RenderObjectRecyclerClass::Get_Render_Object -- Create/Re-use a render object * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 4/25/2001 gth : Created. * - *=============================================================================================*/ -RenderObjClass * RenderObjectRecyclerClass::Get_Render_Object(const char * name,const Matrix3D & tm) -{ - RefRenderObjListIterator it(&InactiveModels); - - RenderObjClass * found = NULL; - while (!it.Is_Done()) { - if (stricmp(it.Peek_Obj()->Get_Name(),name) == 0) { - found = it.Peek_Obj(); - break; - } - it.Next(); - } - - if (found != NULL) { - found->Add_Ref(); - InactiveModels.Remove(found); - found->Set_Transform(tm); - Reset_Model(found); - return found; - - } else { - - RenderObjClass * new_model = WW3DAssetManager::Get_Instance()->Create_Render_Obj(name); - if (new_model != NULL) { - new_model->Set_Transform(tm); - return new_model; - } - } - - return NULL; -} - - -/*********************************************************************************************** - * RenderObjectRecyclerClass::Return_Render_Object -- Return a render object to the pool * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 4/25/2001 gth : Created. * - *=============================================================================================*/ -void RenderObjectRecyclerClass::Return_Render_Object(RenderObjClass * obj) -{ - Insert_Inactive_Model(obj); -} - - -/*********************************************************************************************** - * RenderObjectRecyclerClass::Insert_Inactive_Model -- Internally add a render object to the po* - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 4/25/2001 gth : Created. * - *=============================================================================================*/ -void RenderObjectRecyclerClass::Insert_Inactive_Model(RenderObjClass * obj) -{ - WWASSERT(obj != NULL); - InactiveModels.Add(obj); -} - -/*********************************************************************************************** - * RenderObjectRecyclerClass::Reset_Model -- resets a render object so it can be re-used * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 5/8/2001 gth : Created. * - *=============================================================================================*/ -void RenderObjectRecyclerClass::Reset_Model(RenderObjClass * model) -{ - /* - ** recursively reset all sub-objects (if any) - */ - for (int i=0; iGet_Num_Sub_Objects(); i++) { - RenderObjClass * robj = model->Get_Sub_Object(i); - Reset_Model(robj); - robj->Release_Ref(); - } - - /* - ** particle emitters must be reset (this should release their buffers) - */ - if (model->Class_ID() == RenderObjClass::CLASSID_PARTICLEEMITTER) { - ParticleEmitterClass * emitter = (ParticleEmitterClass *)model; - emitter->Reset(); - } - - /* - ** animated models must have their animation reset (if present) - */ - if (model->Peek_Animation() != NULL) { - model->Set_Animation(model->Peek_Animation(),0.0f,RenderObjClass::ANIM_MODE_ONCE); - } -} diff --git a/Generals/Code/Libraries/Source/WWVegas/WW3D2/renderobjectrecycler.h b/Generals/Code/Libraries/Source/WWVegas/WW3D2/renderobjectrecycler.h deleted file mode 100644 index d07b3120ce1..00000000000 --- a/Generals/Code/Libraries/Source/WWVegas/WW3D2/renderobjectrecycler.h +++ /dev/null @@ -1,84 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** 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 *** - *********************************************************************************************** - * * - * Project Name : ww3d * - * * - * $Archive:: /Commando/Code/ww3d2/renderobjectrecycler.h $* - * * - * Original Author:: Greg Hjelstrom * - * * - * $Author:: Greg_h $* - * * - * $Modtime:: 5/08/01 3:52p $* - * * - * $Revision:: 1 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - - -#ifndef RENDEROBJECTRECYCLER_H -#define RENDEROBJECTRECYCLER_H - -#include "always.h" -#include "robjlist.h" - -class RenderObjClass; -class Matrix3D; - -/** -** RenderObjectRecyclerClass -** This class can be used to eliminate dynamic render object allocation. An example usage would be -** the case where you have a projectile system in a game. Projectiles could be set up to use a -** variety of render objects and would be rapidly created and destroyed as the players and AI's fire -** their weapons. If all of your bullet objects request their models from a RenderObjectCache, and -** return their models to the cache when the bullet is destroyed; the model will get re-used by -** the next bullet that requests that same model type (highly likely in a game situation). -** -** Public member functions: -** Reset - release all of the models in the cache. -** Get_Render_Object - returns either recycles a model or creates a new one through the asset manager -** Return_Render_Object - give your model back to the recycler for re-use later. -*/ -class RenderObjectRecyclerClass -{ -public: - - void Reset(void); - RenderObjClass* Get_Render_Object(const char * name,const Matrix3D & tm); - void Return_Render_Object(RenderObjClass * obj); - -private: - - void Insert_Inactive_Model(RenderObjClass * obj); - void Reset_Model(RenderObjClass * model); - - - RefRenderObjListClass InactiveModels; - -}; - - - - -#endif //RENDEROBJECTRECYCLER_H \ No newline at end of file diff --git a/Generals/Code/Libraries/Source/WWVegas/WW3D2/rendobj.cpp b/Generals/Code/Libraries/Source/WWVegas/WW3D2/rendobj.cpp deleted file mode 100644 index a6237f932ea..00000000000 --- a/Generals/Code/Libraries/Source/WWVegas/WW3D2/rendobj.cpp +++ /dev/null @@ -1,1318 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/* $Header: /Commando/Code/ww3d2/rendobj.cpp 16 12/17/01 8:06p Byon_g $ */ -/*********************************************************************************************** - *** Confidential - Westwood Studios *** - *********************************************************************************************** - * * - * Project Name : Commando / G 3D Engine * - * * - * $Archive:: /Commando/Code/ww3d2/rendobj.cpp $* - * * - * Org Author:: Greg_h * - * * - * Author : Kenny Mitchell * - * * - * $Modtime:: 07/01/02 12:45p $* - * * - * $Revision:: 17 $* - * * - * 07/01/02 KM Coltype enum change to avoid MAX conflicts * - *---------------------------------------------------------------------------------------------* - * Functions: * - * RenderObjClass::RenderObjClass -- constructor * - * RenderObjClass::RenderObjClass -- copy constructor * - * RenderObjClass::operator == -- assignment operator * - * RenderObjClass::Calculate_Texture_Reduction_Factor -- calculate texture reduction factor * - * RenderObjClass::Set_Texture_Reduction_Factor -- set texture reduction factor. * - * RenderObjClass::Get_Screen_Size -- get normalized area of object. * - * RenderObjClass::Get_Scene -- returns the (add_ref'd) scene pointer * - * RenderObjClass::Set_Container -- sets the container pointer * - * RenderObjClass::Get_Container -- returns the container pointer * - * RenderObjClass::Set_Transform -- set the transform for this object * - * RenderObjClass::Set_Position -- Sets the position of this object * - * RenderObjClass::Get_Transform -- returns the transform for the object * - * RenderObjClass::Get_Position -- returns the position of this render object * - * RenderObjClass::Validate_Transform -- If the transform is dirty, this causes it to be re- * - * RenderObjClass::Get_Sub_Object -- returns pointer to first sub-obj with given name * - * RenderObjClass::Add_Sub_Object_To_Bone -- add an object to a named bone * - * RenderObjClass::Prepare_LOD -- prepare object for predictive and texture LOD processing. * - * RenderObjClass::Get_Cost -- get object rendering cost for predictive LOD processing. * - * RenderObjClass::Update_Sub_Object_Bits -- updates our bits according to our sub-objects * - * RenderObjClass::Update_Sub_Object_Transforms -- re-evaluate the transforms my sub-objects * - * RenderObjClass::Add -- Generic add for render objects * - * RenderObjClass::Remove -- Generic Remove for Render Objects * - * RenderObjClass::Notify_Added -- notifies the object that it is in a scene * - * RenderObjClass::Notify_Removed -- notifies an object that it has been removed * - * RenderObjClass::Update_Cached_Bounding_Volumes -- default collision sphere. * - * RenderObjClass::Get_Obj_Space_Bounding_Sphere -- default collision sphere. * - * RenderObjClass::Get_Obj_Space_Bounding_Box -- default collision box. * - * RenderObjClass::Intersect - Returns true if specified intersection object * - * RenderObjClass::Intersect_Sphere -- tests for intersection with the bounding sphere * - * RenderObjClass::Intersect_Sphere_Quick -- tests for intersection with the bounding sphere * - * RenderObjClass::Build_Dependency_List -- Generates a list of files this obj depends on. * - * RenderObjClass::Build_Texture_List -- Builds a list of texture files this obj depends on. * - * RenderObjClass::Add_Dependencies_To_List -- Add dependent files to the list. * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - - -#include "rendobj.h" -#include "assetmgr.h" -#include "win.h" -#include "pot.h" -#include "scene.h" -#include "colmath.h" -#include "coltest.h" -#include "inttest.h" -#include "wwdebug.h" -#include "matinfo.h" -#include "htree.h" -#include "predlod.h" -#include "camera.h" -#include "ww3d.h" -#include "chunkio.h" -#include "persistfactory.h" -#include "saveload.h" -#include "ww3dids.h" -#include "intersec.h" - - -#ifdef RTS_INTERNAL -// for occasional debugging... -//#pragma optimize("", off) -//#pragma MESSAGE("************************************** WARNING, optimization disabled for debugging purposes") -#endif - -// Definitions of static members: -const float RenderObjClass::AT_MIN_LOD = FLT_MAX; -const float RenderObjClass::AT_MAX_LOD = -1.0f; - -// Local inline functions -StringClass -Filename_From_Asset_Name (const char *asset_name) -{ - StringClass filename; - if (asset_name != NULL) { - - // - // Copy the model name into a new filename buffer - // - ::lstrcpy (filename.Get_Buffer (::lstrlen (asset_name) + 5), asset_name); - - // - // Do we need to strip off the model's suffix? - // - char *suffix = ::strchr (filename.Peek_Buffer(), '.'); - if (suffix != NULL) { - suffix[0] = 0; - } - - // - // Concat the w3d file extension - // - filename += ".w3d"; - } - - return filename; -} - -static inline bool Check_Is_Transform_Identity(const Matrix3D& m) -{ - const float zero=0.0f; - const float one=1.0f; - - unsigned d= - ((unsigned&)m[0][0]^(unsigned&)one) | - ((unsigned&)m[0][1]^(unsigned&)zero) | - ((unsigned&)m[0][2]^(unsigned&)zero) | - ((unsigned&)m[0][3]^(unsigned&)zero) | - ((unsigned&)m[1][0]^(unsigned&)zero) | - ((unsigned&)m[1][1]^(unsigned&)one) | - ((unsigned&)m[1][2]^(unsigned&)zero) | - ((unsigned&)m[1][3]^(unsigned&)zero) | - ((unsigned&)m[2][0]^(unsigned&)zero) | - ((unsigned&)m[2][1]^(unsigned&)zero) | - ((unsigned&)m[2][2]^(unsigned&)one) | - ((unsigned&)m[2][3]^(unsigned&)zero); - return !d; -} - - -/*********************************************************************************************** - * RenderObjClass::RenderObjClass -- constructor * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 11/04/1997 GH : Created. * - *=============================================================================================*/ -RenderObjClass::RenderObjClass(void) : - Bits(DEFAULT_BITS), - Transform(1), - NativeScreenSize(WW3D::Get_Default_Native_Screen_Size()), - Scene(NULL), - Container(NULL), - User_Data(NULL), - RenderHook(NULL), - ObjectScale(1.0), - ObjectColor(0), - CachedBoundingSphere(Vector3(0,0,0),1.0f), - CachedBoundingBox(Vector3(0,0,0),Vector3(1,1,1)), - IsTransformIdentity(false) -{ -} - -/*********************************************************************************************** - * RenderObjClass::RenderObjClass -- copy constructor * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 11/5/97 GTH : Created. * - * 1/28/98 EHC : Created. * - *=============================================================================================*/ -RenderObjClass::RenderObjClass(const RenderObjClass & src) : - Bits(src.Bits), - Transform(src.Transform), - NativeScreenSize(src.NativeScreenSize), - Scene(NULL), - Container(NULL), - User_Data(NULL), - RenderHook(NULL), - ObjectScale(1.0), - ObjectColor(0), - CachedBoundingSphere(src.CachedBoundingSphere), - CachedBoundingBox(src.CachedBoundingBox), - IsTransformIdentity(src.IsTransformIdentity) -{ - // Even though we're copying an object which might be in a scene - // this copy won't be so I'm clearing the scene pointer, same logic - // follows for things like the Container pointer. -} - - -/*********************************************************************************************** - * RenderObjClass -- assignment operator * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 11/5/97 GTH : Created. * - * 2/25/99 GTH : Created. * - *=============================================================================================*/ -RenderObjClass & RenderObjClass::operator = (const RenderObjClass & that) -{ - // don't do anything if we're assigning this to this - if (this != &that) { - Set_Hidden(that.Is_Hidden()); - Set_Animation_Hidden(that.Is_Animation_Hidden()); - Set_Force_Visible(that.Is_Force_Visible()); - Set_Collision_Type(that.Get_Collision_Type()); - Set_Native_Screen_Size(that.Get_Native_Screen_Size()); - IsTransformIdentity=false; - } - return *this; -} - - -/*********************************************************************************************** - * RenderObjClass::Calculate_Texture_Reduction_Factor -- calculate texture reduction factor. * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 04/08/99 NH : Created. * - *=============================================================================================*/ -/* -float RenderObjClass::Calculate_Texture_Reduction_Factor(float norm_screensize) -{ - // NOTE: The texture reduction factor represents the number of powers of two that the texture - // must be reduced by in both dimensions. The reason that such an inherently integral quantity - // is represented as a float is for the texture reduction algorithms to incorporate hysteresis - // properly. - float reduction = sqrt(Get_Native_Screen_Size() / norm_screensize); - reduction = MAX(1.0f, reduction); - - // We want to calculate the log base 2. Since the standard libraries have no log-base-2 - // function, we use the following: log-base-2(x) = log(x)/log(2) where log is the natural - // logarithm (which does exist in the stadard libraries). - // We precalculare 1/log(2) as 1.442695f. - return log(reduction) * 1.442695f; -} -*/ - -/*********************************************************************************************** - * RenderObjClass::Set_Texture_Reduction_Factor -- set texture reduction factor. * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 04/08/99 NH : Created. * - *=============================================================================================*/ -/* -void RenderObjClass::Set_Texture_Reduction_Factor(float trf) -{ - WWASSERT(0); // Texture reduction system is broken! Don't call! - MaterialInfoClass *minfo = Get_Material_Info(); - if (minfo) { - minfo->Set_Texture_Reduction_Factor(trf); - minfo->Release_Ref(); - } else { - int num_obj = Get_Num_Sub_Objects(); - RenderObjClass *sub_obj; - - for (int i = 0; i < num_obj; i++) { - sub_obj = Get_Sub_Object(i); - if (sub_obj) { - sub_obj->Set_Texture_Reduction_Factor(trf); - sub_obj->Release_Ref(); - } - } - } -} -*/ - -/*********************************************************************************************** - * RenderObjClass::Get_Screen_Size -- get normalized area of object. * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 3/12/99 NH : Created. * - *=============================================================================================*/ -float RenderObjClass::Get_Screen_Size(CameraClass &camera) -{ - // Currently this works by projecting the bounding sphere to the screen - // (as if the object was at the center) - in future this may be made more - // accurate (perhaps by using the object-space bounding-box) - Vector3 cam = camera.Get_Position(); - - ViewportClass viewport = camera.Get_Viewport(); - Vector2 vpr_min, vpr_max; - camera.Get_View_Plane(vpr_min, vpr_max); - float width_factor = viewport.Width() / (vpr_max.X - vpr_min.X); - float height_factor = viewport.Height() / (vpr_max.Y - vpr_min.Y); - - const SphereClass & sphere = Get_Bounding_Sphere(); - float dist = (sphere.Center - cam).Length(); - float radius = 0.0f; - if (dist) { - radius = sphere.Radius / dist; - } - - // Return area in normalized units. - return WWMATH_PI * radius * radius * width_factor * height_factor; -} - - -/*********************************************************************************************** - * RenderObjClass::Get_Scene -- returns the (add_ref'd) scene pointer * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 3/4/99 GTH : Created. * - *=============================================================================================*/ -SceneClass * RenderObjClass::Get_Scene(void) -{ - if (Scene != NULL) { - Scene->Add_Ref(); - } - return Scene; -} - - -/*********************************************************************************************** - * RenderObjClass::Set_Container -- sets the container pointer * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 3/4/99 GTH : Created. * - *=============================================================================================*/ -void RenderObjClass::Set_Container(RenderObjClass * con) -{ - // Either we arent currently in a container or we are clearing our container, otherwise - // Houston, there is a problem! - WWASSERT((con == NULL) || (Container == NULL)); - Container = con; -} - -#ifdef GET_CONTAINER_INLINE -// nothing -#else -/*********************************************************************************************** - * RenderObjClass::Get_Container -- returns the container pointer * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 3/4/99 GTH : Created. * - *=============================================================================================*/ -RenderObjClass * RenderObjClass::Get_Container(void) const -{ - return Container; -} -#endif - -/*********************************************************************************************** - * RenderObjClass::Set_Transform -- set the transform for this object * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 2/25/99 GTH : Created. * - *=============================================================================================*/ -void RenderObjClass::Set_Transform(const Matrix3D &m) -{ - Transform = m; - IsTransformIdentity=Check_Is_Transform_Identity(m); - Invalidate_Cached_Bounding_Volumes(); -} - - -/*********************************************************************************************** - * RenderObjClass::Set_Position -- Sets the position of this object * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 2/25/99 GTH : Created. * - * 07/14/2001 SKB : Add Check_Is_Transform_Identity * - *=============================================================================================*/ -void RenderObjClass::Set_Position(const Vector3 &v) -{ - Transform.Set_Translation(v); - IsTransformIdentity=Check_Is_Transform_Identity(Transform); - Invalidate_Cached_Bounding_Volumes(); -} - - -/*********************************************************************************************** - * RenderObjClass::Validate_Transform -- If the transform is dirty, this causes it to be re-ca * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 6/15/99 GTH : Created. * - *=============================================================================================*/ -void RenderObjClass::Validate_Transform(void) const -{ - /* - ** Recurse up the tree to see if any of my parents are saying that their sub-object - ** transforms are dirty - */ - RenderObjClass * con = Get_Container(); - bool dirty = false; - if (con != NULL) - { - dirty = con->Are_Sub_Object_Transforms_Dirty(); - - while (con->Get_Container() != NULL) - { - dirty |= con->Are_Sub_Object_Transforms_Dirty(); - con = con->Get_Container(); - } - - /* - ** If the transforms are dirty, update them - */ - if (dirty) - { - con->Update_Sub_Object_Transforms(); - } - } - if (dirty) - IsTransformIdentity = Check_Is_Transform_Identity(Transform); -} - -/*********************************************************************************************** - * RenderObjClass::Get_Position -- returns the position of this render object * - * * - * Similar to Get_Transform but returns only the position. * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 2/25/99 GTH : Created. * - *=============================================================================================*/ -Vector3 RenderObjClass::Get_Position(void) const -{ - Validate_Transform(); - return Transform.Get_Translation(); -} - - -/*********************************************************************************************** - * RenderObjClass::Get_Sub_Object -- returns pointer to first sub-obj with given name * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 3/4/99 GTH : Created. * - *=============================================================================================*/ -RenderObjClass * RenderObjClass::Get_Sub_Object_By_Name(const char * name, int *index) const -{ - int i; - - // first try the un-altered name - for (i=0; iGet_Name(),name) == 0) { - if (index) *index=i; - return robj; - } else { - robj->Release_Ref(); - } - } - } - - // check the given name against the "suffix" names of each sub-object - for (i=0; iGet_Name(),'.'); - if (subobjname == NULL) { - subobjname = robj->Get_Name(); - } else { - // skip past the period. - subobjname = subobjname+1; - } - - if (stricmp(subobjname,name) == 0) { - if (index) *index=i; - return robj; - } else { - robj->Release_Ref(); - } - } - } - - return NULL; -} - - -/*********************************************************************************************** - * RenderObjClass::Add_Sub_Object_To_Bone -- add an object to a named bone * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: If the bone name is unknown then this function will add the the object to the * - * root transform rather than failing. This is due to the fact that GetBoneIndex * - * returns the root tranform for unknown bones. * - * * - * HISTORY: * - * 3/4/99 GTH : Created. * - *=============================================================================================*/ -int RenderObjClass::Add_Sub_Object_To_Bone(RenderObjClass * subobj,const char * bname) -{ - int bindex = Get_Bone_Index(bname); - return Add_Sub_Object_To_Bone(subobj,bindex); -} - - -/*********************************************************************************************** - * RenderObjClass::Remove_Sub_Objects_From_Bone -- remove all objects from a named bone * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 3/1/02 NH : Created. * - *=============================================================================================*/ -int RenderObjClass::Remove_Sub_Objects_From_Bone(int boneindex) -{ - int count = Get_Num_Sub_Objects_On_Bone(boneindex); - int remove_count = 0; - for (int i = count-1; i >= 0; i--) { - RenderObjClass *robj = Get_Sub_Object_On_Bone(i, boneindex); - if ( robj ) { - remove_count += Remove_Sub_Object(robj); - robj->Release_Ref(); - } - } - return remove_count; -} - - -/*********************************************************************************************** - * RenderObjClass::Remove_Sub_Objects_From_Bone -- remove all objects from a named bone * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 3/4/99 NH : Created. * - *=============================================================================================*/ -int RenderObjClass::Remove_Sub_Objects_From_Bone(const char * bname) -{ - return Remove_Sub_Objects_From_Bone(Get_Bone_Index(bname)); -} - - -/*********************************************************************************************** - * RenderObjClass::Prepare_LOD -- prepare object for predictive and texture LOD processing. * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * HISTORY: * - * 3/11/99 NH : Created. * - *=============================================================================================*/ -void RenderObjClass::Prepare_LOD(CameraClass &camera) -{ - // Since most RenderObjClass derivatives are not LOD-capable, the default - // implementation just sets the texture reduction factor and doesn't do any - // predictive LOD preparation (except for adding the objects' cost to the - // total static (nonoptimizeable) cost). - - // Find the maximum screen dimension of the object in pixels -// float norm_area = Get_Screen_Size(camera); - - // Find and set texture reduction factor - // Jani: Don't set tex reduction, it's broken! -// Set_Texture_Reduction_Factor(Calculate_Texture_Reduction_Factor(norm_area)); - - // Since we are not adding this object to the predictive LOD optimizer, - // at least add its cost in. - PredictiveLODOptimizerClass::Add_Cost(Get_Cost()); -} - - -/*********************************************************************************************** - * RenderObjClass::Get_Cost -- get object rendering cost for predictive LOD processing. * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * HISTORY: * - * 3/11/99 NH : Created. * - *=============================================================================================*/ -float RenderObjClass::Get_Cost(void) const -{ - int polycount = Get_Num_Polys(); - // If polycount is zero set Cost to a small nonzero amount to avoid divisions by zero. - float cost = (polycount != 0)? polycount : 0.000001f; - return cost; -} - - -/*********************************************************************************************** - * RenderObjClass::Calculate_Cost_Value_Arrays -- calc arrays for predictive LOD processing. * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNING: This member function assumes that the arrays passed are large enough (# LODs for * - * the cost array and # LODs + 1 for the value array) to contain the desired data. * - * * - * NOTE: This member function is usually only called internally inside LOD objects for * - * initialization purposes, or externally by specialized LOD objects like the G * - * predictive LOD PIP proxy. * - * * - * NOTE: The screen area used is in normalized units. * - * * - * HISTORY: * - * 3/11/99 NH : Created. * - *=============================================================================================*/ -int RenderObjClass::Calculate_Cost_Value_Arrays(float screen_area, float *values, float *costs) const -{ - values[0] = AT_MIN_LOD; - values[1] = AT_MAX_LOD; - costs[0] = Get_Cost(); - - return 0; -} - - -/*********************************************************************************************** - * RenderObjClass::Update_Sub_Object_Bits -- updates our bits according to our sub-objects * - * * - * This should be called by any object that contains other objects whenever a sub object is * - * added or removed. It updates the status of the attribute bits which are supposed to be * - * the union of all of the sub-objects attributes. (I.e. if one of our sub-objects is * - * translucent, then we should be marked as translucent). * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 2/25/99 GTH : Created. * - *=============================================================================================*/ -void RenderObjClass::Update_Sub_Object_Bits(void) -{ - // this doesn't do anything for non-composite objects - if (Get_Num_Sub_Objects() == 0) return; - - // go through all of our sub-objects - int coltype = 0; - int istrans = 0; - int isalpha = 0; - int isadditive = 0; - - for (int ni = 0; ni < Get_Num_Sub_Objects(); ni++) { - RenderObjClass * robj = Get_Sub_Object(ni); - coltype |= robj->Get_Collision_Type(); - istrans |= robj->Is_Translucent(); - isalpha |= robj->Is_Alpha(); - isadditive |= robj->Is_Additive(); - robj->Release_Ref(); - } - - Set_Collision_Type(coltype); - Set_Translucent(istrans); - Set_Alpha(isalpha); - Set_Additive(isadditive); - - // if we are a sub-object, tell our container to do this - if (Container) { - Container->Update_Sub_Object_Bits(); - } -} - - -/*********************************************************************************************** - * RenderObjClass::Update_Sub_Object_Transforms -- re-evaluate the transforms my sub-objects * - * * - * The default implementation is empty, derived classes which have sub-objects should * - * implement it to update the transforms of their sub-objects * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 2/25/99 GTH : Created. * - *=============================================================================================*/ -void RenderObjClass::Update_Sub_Object_Transforms(void) -{ -} - - -/*********************************************************************************************** - * RenderObjClass::Add -- Generic add for render objects * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 11/04/1997 GH : Created. * - * 2/25/99 GTH : Moved to the base RenderObjClass * - *=============================================================================================*/ -void RenderObjClass::Add(SceneClass * scene) -{ - WWASSERT(scene); - WWASSERT(Container == NULL); - Scene = scene; - Scene->Add_Render_Object(this); -} - -/*********************************************************************************************** - * RenderObjClass::Remove -- Generic Remove for Render Objects * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 11/04/1997 GH : Created. * - * 2/25/99 GTH : moved to the base RenderObjClass * - *=============================================================================================*/ -void RenderObjClass::Remove(void) -{ - // All render objects have their scene pointers set. To check if this is a "top level" - // object, (i.e. directly in the scene) you see if its Container pointer is NULL. -#if 1 - if (Container == NULL) { - if (Scene != NULL) { - Scene->Remove_Render_Object(this); - return; - } - } else { - Container->Remove_Sub_Object(this); - return; - } -#else - if (!Scene) return; - Scene->Remove_Render_Object(this); - Scene = NULL; -#endif -} - - -/*********************************************************************************************** - * RenderObjClass::Notify_Added -- notifies the object that it is in a scene * - * * - * This function will be called whenever an object is directly or indirectly added to a scene * - * An example of "indirect" addition would be if you were added as a sub-object to an HModel * - * that was already in a scene. * - * * - * Override this function if you want to register your object for per-frame-updating or * - * as a VertexProcessor. (See the Register method of SceneClass, ParticleBufferClass, etc) * - * * - * Container objects must forward this notification to their sub objects. * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * Due to implementation details of some derived scenes, the SceneClass calls this function. * - * Please dont move the call to this to RenderObjClass::Add * - * Derived classes should also call the base class to ensure that the scene pointer is set * - * * - * HISTORY: * - * 2/25/99 GTH : Created. * - *=============================================================================================*/ -void RenderObjClass::Notify_Added(SceneClass * scene) -{ - Scene = scene; -} - - -/*********************************************************************************************** - * RenderObjClass::Notify_Removed -- notifies an object that it has been removed * - * * - * Works similar to the Notify_Added function. You can override and Unregister yourself from * - * any scene based special processing. Container objects must recurse to their sub objects. * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * Derived classes should also call the base class to ensure that the scene pointer is cleared * - * * - * HISTORY: * - * 2/25/99 GTH : Created. * - *=============================================================================================*/ -void RenderObjClass::Notify_Removed(SceneClass * scene) -{ - Scene = NULL; -} - - -/*********************************************************************************************** - * RenderObjClass::Update_Cached_Bounding_Volumes -- default collision sphere. * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 11/7/97 GTH : Created. * - *=============================================================================================*/ -void RenderObjClass::Update_Cached_Bounding_Volumes(void) const -{ - Get_Obj_Space_Bounding_Box(CachedBoundingBox); - Get_Obj_Space_Bounding_Sphere(CachedBoundingSphere); - -#ifdef ALLOW_TEMPORARIES - CachedBoundingSphere.Center = Get_Transform() * CachedBoundingSphere.Center; -#else - Get_Transform().mulVector3(CachedBoundingSphere.Center); -#endif - CachedBoundingSphere.Radius = ObjectScale * CachedBoundingSphere.Radius; - CachedBoundingBox.Transform(Get_Transform()); - - Validate_Cached_Bounding_Volumes(); -} - - -/*********************************************************************************************** - * RenderObjClass::Get_Obj_Space_Bounding_Sphere -- default collision sphere. * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 28/8/97 NH : Created. * - * 2/25/99 GTH : Moved into RenderObjClass * - *=============================================================================================*/ -void RenderObjClass::Get_Obj_Space_Bounding_Sphere(SphereClass & sphere) const -{ - sphere.Center.Set(0,0,0); - sphere.Radius = 1.0f; -} - - -/*********************************************************************************************** - * RenderObjClass::Get_Obj_Space_Bounding_Box -- default collision box. * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 28/8/97 NH : Created. * - * 2/25/99 GTH : Moved into RenderObjClass * - *=============================================================================================*/ -void RenderObjClass::Get_Obj_Space_Bounding_Box(AABoxClass & box) const -{ - box.Center.Set(0,0,0); - box.Extent.Set(0,0,0); -} - -/*********************************************************************************************** - * RenderObjClass::Intersect - Returns true if specified intersection object * - * intersects this renderobject * - * * - * * - * * - * * - * INPUT: A properly configured Intersection object specifying ray direction & vector * - * * - * OUTPUT: * - * * - * HISTORY: * - * 2/25/99 GTH : Moved into RenderObjClass * - *=============================================================================================*/ -bool RenderObjClass::Intersect(IntersectionClass *Intersection, IntersectionResultClass *Final_Result) -{ - - // do the quick sphere test just to make sure it is worth the more expensive intersection test - if (Intersect_Sphere_Quick(Intersection, Final_Result)) { - - CastResultStruct castresult; - LineSegClass lineseg; - - Vector3 end = *Intersection->RayLocation + *Intersection->RayDirection * Intersection->MaxDistance; - lineseg.Set(* Intersection->RayLocation, end); - - RayCollisionTestClass ray(lineseg, &castresult); - ray.CollisionType = COLL_TYPE_ALL; - - if (Cast_Ray(ray)) { - lineseg.Compute_Point(ray.Result->Fraction,&(Final_Result->Intersection)); - Final_Result->Intersects = true; - Final_Result->IntersectionType = IntersectionResultClass::GENERIC; - if (Intersection->IntersectionNormal) - * Intersection->IntersectionNormal = castresult.Normal; - Final_Result->IntersectedRenderObject = this; - Final_Result->ModelMatrix = Transform; - return true; - } - } - Final_Result->Intersects = false; - return false; -} - - -/*********************************************************************************************** - * RenderObjClass::Intersect_Sphere -- tests for intersection with the bounding sphere * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 2/25/99 GTH : Created. * - *=============================================================================================*/ -bool RenderObjClass::Intersect_Sphere(IntersectionClass *Intersection, IntersectionResultClass *Final_Result) -{ - SphereClass sphere = Get_Bounding_Sphere(); - return Intersection->Intersect_Sphere(sphere, Final_Result); -} - - -/*********************************************************************************************** - * RenderObjClass::Intersect_Sphere_Quick -- tests for intersection with the bounding sphere * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 2/25/99 GTH : Created. * - *=============================================================================================*/ -bool RenderObjClass::Intersect_Sphere_Quick(IntersectionClass *Intersection, IntersectionResultClass *Final_Result) -{ - SphereClass sphere = Get_Bounding_Sphere(); - return Intersection->Intersect_Sphere_Quick(sphere, Final_Result); -} - -/*********************************************************************************************** - * RenderObjClass::Build_Dependency_List -- Generates a list of files this obj depends on. * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 3/18/99 PDS : Created. * - *=============================================================================================*/ -bool RenderObjClass::Build_Dependency_List (DynamicVectorClass &file_list, bool recursive) -{ - if (recursive) - { - // Loop through all this object's subobj's - int subobj_count = Get_Num_Sub_Objects (); - for (int index = 0; index < subobj_count; index ++) { - - // Ask this subobj to add all of its file dependencies to the list - RenderObjClass *psub_obj = Get_Sub_Object (index); - if (psub_obj != NULL) { - psub_obj->Build_Dependency_List (file_list); - psub_obj->Release_Ref (); - } - } - } - - // Now add all of this object's dependencies to the list - Add_Dependencies_To_List (file_list); - - // Return the true/false result code - return (file_list.Count () > 0); -} - - -/*********************************************************************************************** - * RenderObjClass::Build_Texture_List -- Builds a list of texture files this obj depends on. * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 3/18/99 PDS : Created. * - *=============================================================================================*/ -bool RenderObjClass::Build_Texture_List -( - DynamicVectorClass & texture_file_list, - bool recursive -) -{ - if (recursive) { - - // - // Loop through all this object's subobj's - // - int subobj_count = Get_Num_Sub_Objects (); - for (int index = 0; index < subobj_count; index ++) { - - // - // Ask this subobj to add all of its texture file dependencies to the list - // - RenderObjClass *sub_obj = Get_Sub_Object (index); - if (sub_obj != NULL) { - sub_obj->Build_Texture_List (texture_file_list); - sub_obj->Release_Ref (); - } - } - } - - // - // Now add all of this object's texture dependencies to the list - // - Add_Dependencies_To_List (texture_file_list, true); - - // Return the true/false result code - return (texture_file_list.Count () > 0); -} - -/*********************************************************************************************** - * RenderObjClass::Add_Dependencies_To_List -- Add dependent files to the list. * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 3/18/99 PDS : Created. * - *=============================================================================================*/ -void RenderObjClass::Add_Dependencies_To_List -( - DynamicVectorClass &file_list, - bool textures_only -) -{ - // - // Should we add W3D files to the list? - // - if (textures_only == false) { - - // - // Main W3D file - // - const char *model_name = Get_Name (); - file_list.Add (::Filename_From_Asset_Name (model_name)); - - // - // External hierarchy file - // - const HTreeClass *phtree = Get_HTree (); - if (phtree != NULL) { - const char *htree_name = phtree->Get_Name (); - if (::lstrcmpi (htree_name, model_name) != 0) { - - // - // Add this file to the list - // - file_list.Add (::Filename_From_Asset_Name (htree_name)); - } - } - - // - // Original W3D file (if an aggregate) - // - const char *base_model_name = Get_Base_Model_Name (); - if (base_model_name != NULL) { - - // - // Add this file to the list - // - file_list.Add (::Filename_From_Asset_Name (base_model_name)); - } - } - - return; -} - - - -/**************************************************************************************** - - - RenderObjClass - Persistant object support. - - NOTE: For now, the render obj PersistFactory is going to cheat by simply storing - the name of the render object that was saved. At load time, it will ask the - asset manager for that object again. If the asset manager fails to re-create the - object, - - -****************************************************************************************/ - -class RenderObjPersistFactoryClass : public PersistFactoryClass -{ - virtual uint32 Chunk_ID(void) const; - virtual PersistClass * Load(ChunkLoadClass & cload) const; - virtual void Save(ChunkSaveClass & csave,PersistClass * obj) const; - - enum - { - RENDOBJFACTORY_CHUNKID_VARIABLES = 0x00555040, - RENDOBJFACTORY_VARIABLE_OBJPOINTER = 0x00, - RENDOBJFACTORY_VARIABLE_NAME, - RENDOBJFACTORY_VARIABLE_TRANSFORM - }; -}; - -static RenderObjPersistFactoryClass _RenderObjPersistFactory; - -uint32 RenderObjPersistFactoryClass::Chunk_ID(void) const -{ - return WW3D_PERSIST_CHUNKID_RENDEROBJ; -} - -PersistClass * RenderObjPersistFactoryClass::Load(ChunkLoadClass & cload) const -{ - RenderObjClass * old_obj = NULL; - Matrix3D tm(1); - char name[64]; - - while (cload.Open_Chunk()) { - switch (cload.Cur_Chunk_ID()) { - - case RENDOBJFACTORY_CHUNKID_VARIABLES: - - while (cload.Open_Micro_Chunk()) { - switch(cload.Cur_Micro_Chunk_ID()) { - READ_MICRO_CHUNK(cload,RENDOBJFACTORY_VARIABLE_OBJPOINTER,old_obj); - READ_MICRO_CHUNK(cload,RENDOBJFACTORY_VARIABLE_TRANSFORM,tm); - READ_MICRO_CHUNK_STRING(cload,RENDOBJFACTORY_VARIABLE_NAME,name,sizeof(name)); - } - cload.Close_Micro_Chunk(); - } - break; - - default: - WWDEBUG_SAY(("Unhandled Chunk: 0x%X File: %s Line: %d\r\n",__FILE__,__LINE__)); - break; - }; - cload.Close_Chunk(); - } - - // if the object we saved didn't have a name, replace it with null - if (strlen(name) == 0) { - static int count = 0; - if ( ++count < 10 ) { - WWDEBUG_SAY(("RenderObjPersistFactory attempted to load an un-named render object!\r\n")); - WWDEBUG_SAY(("Replacing it with a NULL render object!\r\n")); - } - strcpy(name,"NULL"); - } - - RenderObjClass * new_obj = WW3DAssetManager::Get_Instance()->Create_Render_Obj(name); - - if (new_obj == NULL) { - static int count = 0; - if ( ++count < 10 ) { - WWDEBUG_SAY(("RenderObjPersistFactory failed to create object: %s!!\r\n",name)); - WWDEBUG_SAY(("Either the asset for this object is gone or you tried to save a procedural object.\r\n")); - WWDEBUG_SAY(("Replacing it with a NULL render object!\r\n")); - } - strcpy(name,"NULL"); - new_obj = WW3DAssetManager::Get_Instance()->Create_Render_Obj(name); - } - - WWASSERT(new_obj != NULL); - if (new_obj) { - new_obj->Set_Transform(tm); - } - - SaveLoadSystemClass::Register_Pointer(old_obj,new_obj); - return new_obj; -} - -void RenderObjPersistFactoryClass::Save(ChunkSaveClass & csave,PersistClass * obj) const -{ - RenderObjClass * robj = (RenderObjClass *)obj; - const char * name = robj->Get_Name(); - Matrix3D tm = robj->Get_Transform(); - - csave.Begin_Chunk(RENDOBJFACTORY_CHUNKID_VARIABLES); - WRITE_MICRO_CHUNK(csave,RENDOBJFACTORY_VARIABLE_OBJPOINTER,robj); - WRITE_MICRO_CHUNK_STRING(csave,RENDOBJFACTORY_VARIABLE_NAME,name); - WRITE_MICRO_CHUNK(csave,RENDOBJFACTORY_VARIABLE_TRANSFORM,tm); - csave.End_Chunk(); -} - - -/* -** RenderObj save-load. -*/ -const PersistFactoryClass & RenderObjClass::Get_Factory (void) const -{ - return _RenderObjPersistFactory; -} - -bool RenderObjClass::Save (ChunkSaveClass &csave) -{ - // This should never hit with the persist factory we're using... - // Yes this looks like a design flaw but the way we're saving render objects is - // a "shortcut". We specifically designed this capability into the persistant - // object system so that we could avoid making all render object's save and - // load themselves if possible. - WWASSERT(0); - return true; -} - -bool RenderObjClass::Load (ChunkLoadClass &cload) -{ - WWASSERT(0); // this should never hit with the persist factory we're using. - return true; -} - - diff --git a/Generals/Code/Libraries/Source/WWVegas/WW3D2/rendobj.h b/Generals/Code/Libraries/Source/WWVegas/WW3D2/rendobj.h deleted file mode 100644 index 9560904983b..00000000000 --- a/Generals/Code/Libraries/Source/WWVegas/WW3D2/rendobj.h +++ /dev/null @@ -1,658 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - - /*********************************************************************************************** - *** 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 *** - *********************************************************************************************** - * * - * Project Name : WW3D * - * * - * $Archive:: /Commando/Code/ww3d2/rendobj.h $* - * * - * Org Author:: Greg Hjelstrom * - * * - * Author : Kenny Mitchell * - * * - * $Modtime:: 06/27/02 9:23a $* - * * - * $Revision:: 14 $* - * * - * 06/27/02 KM Shader system classid addition * - * 07/01/02 KM Coltype enum change to avoid MAX conflicts * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - - -#if defined(_MSC_VER) -#pragma once -#endif - -#ifndef RENDOBJ_H -#define RENDOBJ_H - -#include "always.h" -#include "refcount.h" -#include "sphere.h" -#include "coltype.h" -#include "aabox.h" -#include "persist.h" -#include "multilist.h" -#include "robjlist.h" -#include - -class Vector3; -class Matrix3D; -class MaterialInfoClass; -class TextureClass; -class SceneClass; -class HTreeClass; -class HAnimClass; -class HAnimComboClass; -class HCompressedAnimClass; -class RayCollisionTestClass; -class AABoxCollisionTestClass; -class OBBoxCollisionTestClass; -class AABoxIntersectionTestClass; -class OBBoxIntersectionTestClass; -class CameraClass; -class SphereClass; -class AABoxClass; -class RenderInfoClass; -class SpecialRenderInfoClass; -class IntersectionClass; -class IntersectionResultClass; -class DecalGeneratorClass; -class RenderObjProxyClass; -class StringClass; -template class DynamicVectorClass; - -// "unreferenced formal parameter" -#pragma warning(disable : 4100) - -#ifdef DEFINE_W3DANIMMODE_NAMES -static const char* TheAnimModeNames[] = -{ - "MANUAL", - "LOOP", - "ONCE", - "LOOP_PINGPONG", - "LOOP_BACKWARDS", - "ONCE_BACKWARDS", - NULL -}; -#endif - - -////////////////////////////////////////////////////////////////////////////////// -// RenderObjClass -// This is the interface for all objects that get rendered by WW3D. -// -// Render object RTTI: If you really need to typecast a render object -// pointer that you got from the asset manager, the class id mechanism -// can be used to check what you really have. User class id's can come -// after CLASSID_LAST. -// -// Cloning: All RenderObj's need to be able to clone themselves. This function -// should create a new and separate RenderObj of the correct type and return a -// RenderObj pointer to it. The implementation of this function will be -// to simply call your copy constructor; its basically a virtual copy constructor. -// -// Rendering: If the render object is in a scene that is rendered and is determined -// to be visible by that scene, it will receive a Render call. The argument -// to the call will contain both the camera being used and the low level rendering -// interface. In addition, the Special_Render function is for all "non-normal" -// types of rendering. Some examples of this are: G-Buffer rendering (rendering -// object ID's), shadow rendering (just use black, etc) and whatever else we -// come up with. Basically it will be a function with a big switch statement -// to handle all of these extra operations. This means the main render code -// path is not cluttered with these checks while not forcing every object to -// implement millions of separate special render functions. (Many objects just -// pass the render calls onto their sub-objects). -// -// VertexProcessors: Vertex processors are classes that are not actually 'rendered' -// They insert into the system an object that performs operations on all of -// the subsequent vertices that are processed. Lights and Fogs are types of -// vertex processors. -// -// "Scene Graph": A scene is organized as a list of render objects. There is no -// implied hierarchical structure to a scene. RenderObjects can contain other -// render objects (they follow the 'Composite' pattern) which is how hierarchical -// objects are built. Hierarchical models are render objects that just -// contain other render objects and apply hierarchical transforms to them. -// Hierarchical Models can be inserted inside of other hierarchical models. -// -// Predictive LOD: The predictive LOD system selects LODs for the visible objects -// so that the various resources (polys, vertices, etc.) do not pass given -// budgets - the goal is to achieve a constant frame rate. This interface -// includes things that are needed for this optimization process. Objects which -// do not support changing their LOD should report that they have 1 LOD and -// should report their cost to the LOD optimization system. -// -// Dependency Generation: Render objects are composed of one or more W3D and -// texture files. This set of interfaces provides access to that dependency list. -// -////////////////////////////////////////////////////////////////////////////////// - -// This is a small abstract class which a render object may have a pointer to. If present, its -// Pre_Render and Post_Render calls will be called before and after the Render() call of this -// render object. Applications using WW3D may create concrete classes deriving from this for -// application-specific pre- and post- render processing. (the return value from Pre_Render -// determines whether to perform the Render() call - if false, Render() will not be called). -class RenderHookClass -{ -public: - RenderHookClass(void) { } - virtual ~RenderHookClass(void) { } - virtual bool Pre_Render(RenderObjClass *robj, RenderInfoClass &rinfo) = 0; - virtual void Post_Render(RenderObjClass *robj, RenderInfoClass &rinfo) = 0; -private: - // Enforce no-copy semantics, for this and derived classes. This is done by making these - // private and not having definitions for them. - RenderHookClass(const RenderHookClass & src); - RenderHookClass & operator=(const RenderHookClass & src); -}; - -// RenderObjClass definition -class RenderObjClass : public RefCountClass , public PersistClass, public MultiListObjectClass -{ -public: - - //Integer flag placed at the start of structure pointed to by - //User_Data to signal that it points at custom mesh material settings. - //Added for 'Generals' - MW - enum {USER_DATA_MATERIAL_OVERRIDE = 0x01234567}; - - //This strucutre is used to pass custom rendering parameters into the W3D - //mesh renderer so it can override settings which are usually shared across - //all instances of a model - typically material settings like alpha, texture - //animation, texture uv scrolling, etc. Added for 'Generals' -MW - struct Material_Override - { Material_Override(void) : Struct_ID(USER_DATA_MATERIAL_OVERRIDE),customUVOffset(0,0) {} - - int Struct_ID; //ID used to identify this structure from a pointer to it. - Vector2 customUVOffset; - }; - - // - // Note: It is very important that these values NEVER CHANGE. That means - // when adding a new class id, it should be added to the end of the enum. - // - enum - { - CLASSID_UNKNOWN = 0xFFFFFFFF, - CLASSID_MESH = 0, - CLASSID_HMODEL, - CLASSID_DISTLOD, - CLASSID_PREDLODGROUP, - CLASSID_TILEMAP, - CLASSID_IMAGE3D, // Obsolete - CLASSID_LINE3D, - CLASSID_BITMAP2D, // Obsolete - CLASSID_CAMERA, - CLASSID_DYNAMESH, - CLASSID_DYNASCREENMESH, - CLASSID_TEXTDRAW, - CLASSID_FOG, - CLASSID_LAYERFOG, - CLASSID_LIGHT, - CLASSID_PARTICLEEMITTER, - CLASSID_PARTICLEBUFFER, - CLASSID_SCREENPOINTGROUP, - CLASSID_VIEWPOINTGROUP, - CLASSID_WORLDPOINTGROUP, - CLASSID_TEXT2D, - CLASSID_TEXT3D, - CLASSID_NULL, - CLASSID_COLLECTION, - CLASSID_FLARE, - CLASSID_HLOD, - CLASSID_AABOX, - CLASSID_OBBOX, - CLASSID_SEGLINE, - CLASSID_SPHERE, - CLASSID_RING, - CLASSID_BOUNDFOG, - CLASSID_DAZZLE, - CLASSID_SOUND, - CLASSID_SEGLINETRAIL, - CLASSID_LAND, - CLASSID_SHDMESH, // mesh class that uses the scaleable shader system - CLASSID_LAST = 0x0000FFFF - }; - - RenderObjClass(void); - RenderObjClass(const RenderObjClass & src); - RenderObjClass & operator = (const RenderObjClass &); - virtual ~RenderObjClass(void) { if (RenderHook) delete RenderHook; } - - - /////////////////////////////////////////////////////////////////////////////////////////////////////////////// - // Render Object Interface - Cloning and Identification - /////////////////////////////////////////////////////////////////////////////////////////////////////////////// - virtual RenderObjClass * Clone(void) const = 0; - virtual int Class_ID(void) const { return CLASSID_UNKNOWN; } - virtual const char * Get_Name(void) const { return "UNNAMED"; } - virtual void Set_Name(const char * name) { } - virtual const char * Get_Base_Model_Name (void) const { return NULL; } - virtual void Set_Base_Model_Name (const char *name) { } - virtual int Get_Num_Polys(void) const { return 0; } - - - /////////////////////////////////////////////////////////////////////////////////////////////////////////////// - // Render Object Interface - Rendering - // - // Render - this object should render its polygons. Typically called from a SceneClass - // Special_Render - all special-case rendering goes here to avoid polluting the main render pipe (e.g. VIS) - // On_Frame_Update - render objects can register for an On_Frame_Update call; the scene will call this once - // per frame if they do so. - // Restart - This interface is used to facilitate model recycling. If a render object is "Restarted" it should - // put itself back into a state as if it has never been rendered (e.g. particle emitters - // should reset their "emitted particle counts" so they can be re-used.) - /////////////////////////////////////////////////////////////////////////////////////////////////////////////// - virtual void Render(RenderInfoClass & rinfo) = 0; - virtual void Special_Render(SpecialRenderInfoClass & rinfo) { } - virtual void On_Frame_Update() { } - virtual void Restart(void) { } - - - /////////////////////////////////////////////////////////////////////////////////////////////////////////////// - // Render Object Interface - "Scene Graph" - // Some of the functions in this group are non-virtual as they are meant - // to be never overriden or are supposed to be implemented in terms of - // the other virtual functions. We want to keep the virtual interface - // as small as possible - /////////////////////////////////////////////////////////////////////////////////////////////////////////////// - virtual void Add(SceneClass * scene); - virtual void Remove(void); - virtual SceneClass * Get_Scene(void); - virtual SceneClass * Peek_Scene(void) { return Scene; } - virtual void Set_Container(RenderObjClass * con); - virtual void Validate_Transform(void) const; - -#define GET_CONTAINER_INLINE -#ifdef GET_CONTAINER_INLINE - // srj sez: this is called a ton and never overridden, so inline it - inline RenderObjClass * Get_Container(void) const { return Container; } -#else - virtual RenderObjClass * Get_Container(void) const; -#endif - - virtual void Set_Transform(const Matrix3D &m); - virtual void Set_Position(const Vector3 &v); - const Matrix3D & Get_Transform(void) const; - const Matrix3D & Get_Transform(bool& is_transform_identity) const; - const Matrix3D & Get_Transform_No_Validity_Check(void) const; - const Matrix3D & Get_Transform_No_Validity_Check(bool& is_transform_identity) const; - bool Is_Transform_Identity() const; - bool Is_Transform_Identity_No_Validity_Check() const; - Vector3 Get_Position(void) const; - - virtual void Notify_Added(SceneClass * scene); - virtual void Notify_Removed(SceneClass * scene); - - virtual int Get_Num_Sub_Objects(void) const { return 0; } - virtual RenderObjClass * Get_Sub_Object(int index) const { return NULL; } - virtual int Add_Sub_Object(RenderObjClass * subobj) { return 0; } - virtual int Remove_Sub_Object(RenderObjClass * robj) { return 0; } - virtual RenderObjClass * Get_Sub_Object_By_Name(const char * name, int *index=NULL) const; - - virtual int Get_Num_Sub_Objects_On_Bone(int boneindex) const { return 0; } - virtual RenderObjClass * Get_Sub_Object_On_Bone(int index,int boneindex) const { return NULL; } - virtual int Get_Sub_Object_Bone_Index(RenderObjClass * subobj) const { return 0; } - virtual int Get_Sub_Object_Bone_Index(int LodIndex, int ModelIndex) const { return 0; } - virtual int Add_Sub_Object_To_Bone(RenderObjClass * subobj,int bone_index) { return 0; } - virtual int Add_Sub_Object_To_Bone(RenderObjClass * subobj,const char * bname); - virtual int Remove_Sub_Objects_From_Bone(int boneindex); - virtual int Remove_Sub_Objects_From_Bone(const char * bname); - - // This is public only so objects can recursively call this on their sub-objects - virtual void Update_Sub_Object_Transforms(void); - - - /////////////////////////////////////////////////////////////////////////////////////////////////////////////// - // Render Object Interface - Hierarchical Animation - /////////////////////////////////////////////////////////////////////////////////////////////////////////////// - enum AnimMode - { - ANIM_MODE_MANUAL = 0, - ANIM_MODE_LOOP, - ANIM_MODE_ONCE, - ANIM_MODE_LOOP_PINGPONG, - ANIM_MODE_LOOP_BACKWARDS, //make sure only backwards playing animations after this one - ANIM_MODE_ONCE_BACKWARDS, - }; - - virtual void Set_Animation( void ) { } - virtual void Set_Animation( HAnimClass * motion, - float frame, int anim_mode = ANIM_MODE_MANUAL) { } - virtual void Set_Animation( HAnimClass * motion0, - float frame0, - HAnimClass * motion1, - float frame1, - float percentage) { } - virtual void Set_Animation( HAnimComboClass * anim_combo) { } - - virtual HAnimClass * Peek_Animation( void ) { return NULL; } - virtual int Get_Num_Bones(void) { return 0; } - virtual const char * Get_Bone_Name(int bone_index) { return NULL; } - virtual int Get_Bone_Index(const char * bonename) { return 0; } - virtual const Matrix3D & Get_Bone_Transform(const char * bonename) { return Get_Transform(); } - virtual const Matrix3D & Get_Bone_Transform(int boneindex) { return Get_Transform(); } - virtual void Capture_Bone(int bindex) { } - - - virtual void Release_Bone(int bindex) { } - virtual bool Is_Bone_Captured(int bindex) const { return false; } - virtual void Control_Bone(int bindex,const Matrix3D & objtm,bool world_space_translation = false) { } - virtual const HTreeClass * Get_HTree(void) const { return NULL; } - - /////////////////////////////////////////////////////////////////////////////////////////////////////////////// - // Render Object Interface - Collision Detection - // Cast_Ray - intersects a ray with the render object - // Cast_AABox - intersects a swept AABox with the render object - // Cast_OBBox - intersects a swept OBBox with the render object - // Intersect_AABox - boolean test for intersection between an AABox and the renderobj - // Intersect_OBBox - boolean test for intersection between an OBBox and the renderobj - // Intersect - tests a ray for intersection with the render object - // Intersect_Sphere - tests a ray for intersection with the bounding spheres - // Intersect_Sphere_Quick - tests a ray for intersection with bounding spheres - /////////////////////////////////////////////////////////////////////////////////////////////////////////////// - virtual bool Cast_Ray(RayCollisionTestClass & raytest) { return false; } - virtual bool Cast_AABox(AABoxCollisionTestClass & boxtest) { return false; } - virtual bool Cast_OBBox(OBBoxCollisionTestClass & boxtest) { return false; } - - virtual bool Intersect_AABox(AABoxIntersectionTestClass & boxtest) { return false; } - virtual bool Intersect_OBBox(OBBoxIntersectionTestClass & boxtest) { return false; } - - virtual bool Intersect(IntersectionClass *Intersection, IntersectionResultClass *Final_Result); - virtual bool Intersect_Sphere(IntersectionClass *Intersection, IntersectionResultClass *Final_Result); - virtual bool Intersect_Sphere_Quick(IntersectionClass *Intersection, IntersectionResultClass *Final_Result); - - /////////////////////////////////////////////////////////////////////////////////////////////////////////////// - // Render Object Interface - Bounding Volumes - /////////////////////////////////////////////////////////////////////////////////////////////////////////////// - virtual const SphereClass & Get_Bounding_Sphere(void) const; - virtual const AABoxClass & Get_Bounding_Box(void) const; - virtual void Get_Obj_Space_Bounding_Sphere(SphereClass & sphere) const; - virtual void Get_Obj_Space_Bounding_Box(AABoxClass & box) const; - virtual void Update_Obj_Space_Bounding_Volumes(void) { }; - - - /////////////////////////////////////////////////////////////////////////////////////////////////////////////// - // Render Object Interface - Predictive LOD - /////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - // Two constants for Value queries, which are returned instead of the - // current Value in certain cases. They are usually used as sentinels. - // AT_MIN_LOD is a very large positive number, AT_MAX_LOD is negative. - static const float AT_MIN_LOD; - static const float AT_MAX_LOD; - - virtual void Prepare_LOD(CameraClass &camera); - virtual void Recalculate_Static_LOD_Factors(void) { } - virtual void Increment_LOD(void) { } - virtual void Decrement_LOD(void) { } - virtual float Get_Cost(void) const; - virtual float Get_Value(void) const { return AT_MIN_LOD; } - virtual float Get_Post_Increment_Value(void) const { return AT_MAX_LOD; } - virtual void Set_LOD_Level(int lod) { } - virtual int Get_LOD_Level(void) const { return 0; } - virtual int Get_LOD_Count(void) const { return 1; } - virtual void Set_LOD_Bias(float bias) { } - virtual int Calculate_Cost_Value_Arrays(float screen_area, float *values, float *costs) const; - virtual RenderObjClass * Get_Current_LOD(void) { Add_Ref(); return this; } - - - /////////////////////////////////////////////////////////////////////////////////////////////////////////////// - // Render Object Interface - Dependency Generation - /////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - // - // Note: The strings contained in these lists need to be freed by the caller. - // They should be freed using the delete operator. - // - // Be aware, these lists WILL contain duplicate entries. - // - virtual bool Build_Dependency_List (DynamicVectorClass &file_list, bool recursive=true); - virtual bool Build_Texture_List (DynamicVectorClass &texture_file_list, bool recursive=true); - - /////////////////////////////////////////////////////////////////////////////////////////////////////////////// - // Render Object Interface - Decals - /////////////////////////////////////////////////////////////////////////////////////////////////////////////// - virtual void Create_Decal(DecalGeneratorClass * generator) { } - virtual void Delete_Decal(uint32 decal_id) { } - - /////////////////////////////////////////////////////////////////////////////////////////////////////////////// - // Render Object Interface - Attributes, Options, Properties, etc - /////////////////////////////////////////////////////////////////////////////////////////////////////////////// - virtual MaterialInfoClass * Get_Material_Info(void) { return NULL; } - virtual void Set_User_Data(void *value, bool recursive = false) { User_Data = value; }; - virtual void * Get_User_Data() { return User_Data; }; - virtual int Get_Num_Snap_Points(void) { return 0; } - virtual void Get_Snap_Point(int index,Vector3 * set) { } -// virtual float Calculate_Texture_Reduction_Factor(float norm_screensize); -// virtual void Set_Texture_Reduction_Factor(float trf); - virtual float Get_Screen_Size(CameraClass &camera); - virtual void Scale(float scale) { }; - virtual void Scale(float scalex, float scaley, float scalez) { }; - virtual void Set_ObjectScale(float scale) { ObjectScale=scale;} //set's a scale factor that's factored into transform matrix. {ScaleFactor=scale; }; - const float Get_ObjectScale( void ) const { return ObjectScale; }; - void Set_ObjectColor(unsigned int color) { ObjectColor=color;} //the color that was used to modify the asset for player team color (for Generals). -MW - const unsigned int Get_ObjectColor( void ) const { return ObjectColor; }; - - virtual int Get_Sort_Level(void) const { return 0; /* SORT_LEVEL_NONE */ } - virtual void Set_Sort_Level(int level) { } - - virtual int Is_Really_Visible(void) { return ((Bits & IS_REALLY_VISIBLE) == IS_REALLY_VISIBLE); } - virtual int Is_Not_Hidden_At_All(void) { return ((Bits & IS_NOT_HIDDEN_AT_ALL) == IS_NOT_HIDDEN_AT_ALL); } - virtual int Is_Visible(void) const { return (Bits & IS_VISIBLE); } - virtual void Set_Visible(int onoff) { if (onoff) { Bits |= IS_VISIBLE; } else { Bits &= ~IS_VISIBLE; } } - -// The cheatSpy has been put on ice until later... perhaps the next patch? - M Lorenzen - // virtual int Is_VisibleWithCheatSpy(void) const { return ((Bits&=~0x80) & (IS_VISIBLE); } -// virtual void Set_VisibleWithCheatSpy(int onoff) { if (onoff) { Bits |= IS_VISIBLE|0x80; } else { Bits &= ~IS_VISIBLE; } } - - virtual int Is_Hidden(void) const { return !(Bits & IS_NOT_HIDDEN); } - virtual void Set_Hidden(int onoff) { if (onoff) { Bits &= ~IS_NOT_HIDDEN; } else { Bits |= IS_NOT_HIDDEN; } } - virtual int Is_Animation_Hidden(void) const { return !(Bits & IS_NOT_ANIMATION_HIDDEN); } - virtual void Set_Animation_Hidden(int onoff) { if (onoff) { Bits &= ~IS_NOT_ANIMATION_HIDDEN; } else { Bits |= IS_NOT_ANIMATION_HIDDEN; } } - virtual int Is_Force_Visible(void) const { return Bits & IS_FORCE_VISIBLE; } - virtual void Set_Force_Visible(int onoff) { if (onoff) { Bits |= IS_FORCE_VISIBLE; } else { Bits &= ~IS_FORCE_VISIBLE; } } - - virtual int Is_Translucent(void) const { return Bits & IS_TRANSLUCENT; } - virtual void Set_Translucent(int onoff) { if (onoff) { Bits |= IS_TRANSLUCENT; } else { Bits &= ~IS_TRANSLUCENT; } } - virtual int Is_Alpha(void) const { return Bits & IS_ALPHA; } - virtual void Set_Alpha(int onoff) { if (onoff) { Bits |= IS_ALPHA; } else { Bits &= ~IS_ALPHA; } } - virtual int Is_Additive(void) const { return Bits & IS_ADDITIVE; } - virtual void Set_Additive(int onoff) { if (onoff) { Bits |= IS_ADDITIVE; } else { Bits &= ~IS_ADDITIVE; } } - virtual int Get_Collision_Type(void) const { return (Bits & COLL_TYPE_MASK); } - virtual void Set_Collision_Type(int type) { Bits &= ~COLL_TYPE_MASK; Bits |= (type & COLL_TYPE_MASK) | COLL_TYPE_ALL; } - virtual bool Is_Complete(void) { return false; } - virtual bool Is_In_Scene(void) { return Scene != NULL; } - virtual float Get_Native_Screen_Size(void) const { return NativeScreenSize; } - virtual void Set_Native_Screen_Size(float screensize) { NativeScreenSize = screensize; } - - void Set_Sub_Objects_Match_LOD(int onoff) { if (onoff) { Bits |= SUBOBJS_MATCH_LOD; } else { Bits &= ~SUBOBJS_MATCH_LOD; } } - int Is_Sub_Objects_Match_LOD_Enabled(void) { return Bits & SUBOBJS_MATCH_LOD; } - - void Set_Sub_Object_Transforms_Dirty(bool onoff) { if (onoff) { Bits |= SUBOBJ_TRANSFORMS_DIRTY; } else { Bits &= ~SUBOBJ_TRANSFORMS_DIRTY; } } - bool Are_Sub_Object_Transforms_Dirty(void) { return (Bits & SUBOBJ_TRANSFORMS_DIRTY) != 0; } - - void Set_Ignore_LOD_Cost(bool onoff) { if (onoff) { Bits |= IGNORE_LOD_COST; } else { Bits &= ~IGNORE_LOD_COST; } } - bool Is_Ignoring_LOD_Cost(void) { return (Bits & IGNORE_LOD_COST) != 0; } - - void Set_Is_Self_Shadowed() { Bits|=IS_SELF_SHADOWED; } - void Unset_Is_Self_Shadowed() { Bits&=~IS_SELF_SHADOWED; } - int Is_Self_Shadowed() const { return (Bits&IS_SELF_SHADOWED); } - - /////////////////////////////////////////////////////////////////////////////////////////////////////////////// - // Persistant object save-load interface - /////////////////////////////////////////////////////////////////////////////////////////////////////////////// - virtual const PersistFactoryClass & Get_Factory (void) const; - virtual bool Save (ChunkSaveClass &csave); - virtual bool Load (ChunkLoadClass &cload); - - // Application-specific render hook: - RenderHookClass * Get_Render_Hook(void) { return RenderHook; } - void Set_Render_Hook(RenderHookClass *hook) { if (RenderHook) delete RenderHook; RenderHook = hook; } - -protected: - - virtual void Add_Dependencies_To_List (DynamicVectorClass &file_list, bool textures_only = false); - - virtual void Update_Cached_Bounding_Volumes(void) const; - virtual void Update_Sub_Object_Bits(void); - - bool Bounding_Volumes_Valid(void) const { return (Bits & BOUNDING_VOLUMES_VALID) != 0; } - void Invalidate_Cached_Bounding_Volumes(void) const { Bits &= ~BOUNDING_VOLUMES_VALID; } - void Validate_Cached_Bounding_Volumes(void) const { Bits |= BOUNDING_VOLUMES_VALID; } - - enum - { - COLL_TYPE_MASK = 0x000000FF, - - IS_VISIBLE = 0x00000100, - IS_NOT_HIDDEN = 0x00000200, - IS_NOT_ANIMATION_HIDDEN = 0x00000400, - IS_FORCE_VISIBLE = 0x00000800, - BOUNDING_VOLUMES_VALID = 0x00002000, - IS_TRANSLUCENT = 0x00004000, // is additive or alpha blended on any poly - IGNORE_LOD_COST = 0x00008000, // used to define if we should ignore object from LOD calculations - SUBOBJS_MATCH_LOD = 0x00010000, // force sub-objects to have same LOD level - SUBOBJ_TRANSFORMS_DIRTY = 0x00020000, // my sub-objects need me to update their transform - IS_ALPHA = 0x00040000, // added for Generals so we can default these meshes not to cast shadows. -MW - IS_ADDITIVE = 0x00100000, //added for Generals so we quickly determine what type of blending is on the mesh. -MW - IS_SELF_SHADOWED = 0x00080000, // the mesh is self shadowed - IS_CHEATER = 0x00100000,// the new cheat spy code uses these bits, since nothing else now does - IS_REALLY_VISIBLE = IS_VISIBLE | IS_NOT_HIDDEN | IS_NOT_ANIMATION_HIDDEN, - IS_NOT_HIDDEN_AT_ALL = IS_NOT_HIDDEN | IS_NOT_ANIMATION_HIDDEN, - DEFAULT_BITS = COLL_TYPE_ALL | IS_NOT_HIDDEN | IS_NOT_ANIMATION_HIDDEN, - }; - - mutable unsigned long Bits; - Matrix3D Transform; - float ObjectScale; //user applied scaling factor inside Transform matrix. - unsigned int ObjectColor; //user applied coloring to the asset/prototype used to make this robj. - For Generals -MW - mutable SphereClass CachedBoundingSphere; - mutable AABoxClass CachedBoundingBox; - float NativeScreenSize; // The screen size at which the object was designed to be viewed (used in texture resizing). - mutable bool IsTransformIdentity; - - SceneClass * Scene; - RenderObjClass * Container; - void * User_Data; - - RenderHookClass * RenderHook; - - friend class SceneClass; - friend class RenderObjProxyClass; -}; - -WWINLINE const SphereClass & RenderObjClass::Get_Bounding_Sphere(void) const -{ - if (!(Bits & BOUNDING_VOLUMES_VALID)) { - Update_Cached_Bounding_Volumes(); - } - return CachedBoundingSphere; -} - -WWINLINE const AABoxClass & RenderObjClass::Get_Bounding_Box(void) const -{ - if (!(Bits & BOUNDING_VOLUMES_VALID)) { - Update_Cached_Bounding_Volumes(); - } - return CachedBoundingBox; -} - -/************************************************************************** - * Bound_Degrees -- Bounds a degree value between 0 and 360. * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 09/22/1997 PWG : Created. * - *========================================================================*/ -WWINLINE float Bound_Degrees(float angle) -{ - while (angle > 359) angle -= 360; - while (angle < 0) angle += 360; - return angle; -} - -/*********************************************************************************************** - * RenderObjClass::Get_Transform -- returns the transform for the object * - * * - * If the transform is invalid (a container has been moved or animated) then the transform * - * will be recalculated. * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 2/25/99 GTH : Created. * - *=============================================================================================*/ -WWINLINE const Matrix3D & RenderObjClass::Get_Transform(void) const -{ - Validate_Transform(); - return Transform; -} - -WWINLINE const Matrix3D & RenderObjClass::Get_Transform(bool &is_transform_identity) const -{ - Validate_Transform(); - is_transform_identity=IsTransformIdentity; - return Transform; -} - -WWINLINE bool RenderObjClass::Is_Transform_Identity() const -{ - Validate_Transform(); - return IsTransformIdentity; -} - -// Warning: Be sure to call this function only if the transform is known to be valid! -WWINLINE const Matrix3D & RenderObjClass::Get_Transform_No_Validity_Check(void) const -{ - return Transform; -} - -// Warning: Be sure to call this function only if the transform is known to be valid! -WWINLINE const Matrix3D & RenderObjClass::Get_Transform_No_Validity_Check(bool& is_transform_identity) const -{ - is_transform_identity=IsTransformIdentity; - return Transform; -} - -// Warning: Be sure to call this function only if the transform is known to be valid! -WWINLINE bool RenderObjClass::Is_Transform_Identity_No_Validity_Check() const -{ - return IsTransformIdentity; -} - - - - -#endif \ No newline at end of file diff --git a/Generals/Code/Libraries/Source/WWVegas/WW3D2/ringobj.cpp b/Generals/Code/Libraries/Source/WWVegas/WW3D2/ringobj.cpp deleted file mode 100644 index 7f61c168ad3..00000000000 --- a/Generals/Code/Libraries/Source/WWVegas/WW3D2/ringobj.cpp +++ /dev/null @@ -1,1650 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** 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 *** - *********************************************************************************************** - * * - * Project Name : WW3D * - * * - * $Archive:: /Commando/Code/ww3d2/ringobj.cpp $* - * * - * Author:: Greg Hjelstrom * - * * - * $Modtime:: 11/24/01 6:17p $* - * * - * $Revision:: 27 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * RingRenderObjClass::RingRenderObjClass -- Constructor * - * RingRenderObjClass::RingRenderObjClass -- Constructor - init from a definition * - * RingRenderObjClass::RingRenderObjClass -- Copy constructor * - * RingRenderObjClass::~RingRenderObjClass -- destructor * - * RingRenderObjClass::operator -- assignment operator * - * RingRenderObjClass::Get_Num_Polys -- returns number of polygons * - * RingRenderObjClass::Get_Name -- returns name * - * RingRenderObjClass::Set_Name -- sets the name * - * RingRenderObjClass::Set_Color -- Sets the color of the Ring * - * RingRenderObjClass::Init_Ring_Render_System -- global initialization needed for Ring * - * RingRenderObjClass::Shutdown_Ring_Render_System -- cleanup Ring render system * - * RingRenderObjClass::Set_Ring_Display_Mask -- Sets global display mask for all Ringes * - * RingRenderObjClass::Get_Ring_Display_Mask -- returns the display mask * - * RingRenderObjClass::update_mesh_data -- Updates vertex positions, etc * - * RingRenderObjClass::render_Ring -- submits the Ring to the GERD * - * RingRenderObjClass::vis_render_Ring -- submits Ring to the GERD for VIS * - * RingRenderObjClass::RingRenderObjClass -- constructor * - * RingRenderObjClass::RingRenderObjClass -- Constructor - init from a definition * - * RingRenderObjClass::RingRenderObjClass -- copy constructor * - * RingRenderObjClass::RingRenderObjClass -- Constructor from a wwmath aaRing * - * RingRenderObjClass::operator -- assignment operator * - * RingRenderObjClass::Clone -- clones the Ring * - * RingRenderObjClass::Class_ID -- returns the class-id for AARing's * - * RingRenderObjClass::Render -- render this Ring * - * RingRenderObjClass::Special_Render -- special render this Ring (vis) * - * RingRenderObjClass::Set_Transform -- set the transform for this Ring * - * RingRenderObjClass::Set_Position -- Set the position of this Ring * - * RingRenderObjClass::update_cached_Ring -- update the world-space version of this Ring * - * RingRenderObjClass::Cast_Ray -- cast a ray against this Ring * - * RingRenderObjClass::Cast_AARing -- cast an AARing against this Ring * - * RingRenderObjClass::Cast_OBRing -- cast an OBRing against this Ring * - * RingRenderObjClass::Get_Obj_Space_Bounding_Sphere -- return the object-space bounding sper* - * RingRenderObjClass::Get_Obj_Space_Bounding_Box -- returns the obj-space bounding box * - * RingRenderObjClass::Scale -- scales ring uniformly. * - * RingRenderObjClass::Scale -- scales ring non-uniformly. * - * RingRenderObjClass::Update_Cached_Bounding_Volumes -- Updates world-space bounding volum * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - - -#include "ringobj.h" -#include "w3d_util.h" -#include "wwdebug.h" -#include "vertmaterial.h" -#include "ww3d.h" -#include "chunkio.h" -#include "rinfo.h" -#include "coltest.h" -#include "inttest.h" -#include "matrix3.h" -#include "wwmath.h" -#include "assetmgr.h" -#include "wwstring.h" -#include "bound.h" -#include "camera.h" -#include "statistics.h" -#include "predlod.h" -#include "dx8wrapper.h" -#include "dx8indexbuffer.h" -#include "dx8vertexbuffer.h" -#include "sortingrenderer.h" -#include "Vector3i.h" -#include "visrasterizer.h" - - -static bool Ring_Array_Valid = false; - - -/** -** RingMeshClass -** A set of LODs of RingMeshes are re-used by all RingRenderObjClasses. -*/ -class RingMeshClass -{ -friend class RingRenderObjClass; - -public: - // Constructor - RingMeshClass(void); - RingMeshClass(float radius, int slices); - // Destructor - ~RingMeshClass(void); - - void Generate(float radius, int slices); - - int Get_Num_Polys(void) { return face_ct; }; - - void Scale (const Vector2 &inner_scale, const Vector2 &outer_scale); - void Set_Tiling (int count); - -private: - - void Free(void); - - float Radius; - int Slices; - int face_ct; //# of faces - - int TileCount; - Vector2 InnerScale; - Vector2 OuterScale; - - int Vertex_ct; // vertex count - Vector3 *vtx; // array of vertices - Vector2 *orig_vtx; // array of vertices representing a 'unit' ring - Vector3 *vtx_normal; // array of vertex normals - Vector2 *vtx_uv; // array of vertex uv coordinates - - TriIndex *tri_poly; // array of triangle polys, vertex indices (can be discard if switch to fan renderer) -}; - - -RingMeshClass RingMeshArray[RING_NUM_LOD]; -float RingLODCosts[RING_NUM_LOD + 1]; // RING_NUM_LOD doesn't include the null LOD - - - -/* -** RingRenderObjClass Implementation -*/ - - -/*********************************************************************************************** - * RingRenderObjClass::RingRenderObjClass -- Constructor * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 1/19/00 gth : Created. * - *=============================================================================================*/ -RingRenderObjClass::RingRenderObjClass(void) - : anim_time (0.0F), - IsAnimating(false), - LODBias(1.0f), - CurrentLOD(RING_NUM_LOD), // RING_NUM_LOD does not include the null LOD - AnimDuration (0.0F), - RingMaterial (NULL), - RingTexture (NULL), - Color (0.75F,0.75F,0.75F), - InnerScale (1, 1), - OuterScale (1, 1), - Alpha (1.0F), - Flags(0), - TextureTileCount(5), - ObjSpaceCenter (0, 0, 0), - ObjSpaceExtent (1, 1, 1), - InnerExtent (0.5F, 0.5F), - OuterExtent (1.0F, 1.0F) -{ - Generate_Shared_Mesh_Arrays (); - - memset(Name,0,sizeof(Name)); - - Init_Material () ; - - // So that the object is ready for use after construction, we will - // complete its initialization by initializing its value array - // according to a screen area of 1. - calculate_value_array(1.0f, Value); -} - -/*********************************************************************************************** - * RingRenderObjClass::RingRenderObjClass -- Constructor - init from a definition * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 1/19/00 gth : Created. * - *=============================================================================================*/ -RingRenderObjClass::RingRenderObjClass(const W3dRingStruct & def) - : anim_time (0.0F), - IsAnimating(false), - LODBias(1.0f), - CurrentLOD(RING_NUM_LOD), // RING_NUM_LOD does not include the null LOD - AnimDuration (0.0F), - RingMaterial (NULL), - RingTexture (NULL), - Color (0.75F,0.75F,0.75F), - InnerScale (1, 1), - OuterScale (1, 1), - Alpha (1.0F), - Flags(0), - TextureTileCount(5), - ObjSpaceCenter (0, 0, 0), - ObjSpaceExtent (1, 1, 1), - InnerExtent (0.5F, 0.5F), - OuterExtent (1.0F, 1.0F) -{ - Generate_Shared_Mesh_Arrays (); - Init_Material (); - - // - // Initialize from the defintion - // - Set_Name(def.Name); - Set_Local_Center_Extent ( Vector3 (def.Center.X, def.Center.Y, def.Center.Z), - Vector3 (def.Extent.X, def.Extent.Y, def.Extent.Z)); - if (def.TextureName[0] != 0) { - RingTexture = WW3DAssetManager::Get_Instance ()->Get_Texture (def.TextureName); - } - - // So that the object is ready for use after construction, we will - // complete its initialization by initializing its value array - // according to a screen area of 1. - calculate_value_array(1.0f, Value); -} - - -/*********************************************************************************************** - * RingRenderObjClass::RingRenderObjClass -- Copy constructor * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 1/19/00 gth : Created. * - *=============================================================================================*/ -RingRenderObjClass::RingRenderObjClass(const RingRenderObjClass & src) - : anim_time (0.0F), - IsAnimating(false), - LODBias(1.0f), - CurrentLOD(RING_NUM_LOD), // RING_NUM_LOD does not include the null LOD - AnimDuration (0.0F), - RingMaterial (NULL), - RingTexture (NULL), - Color (0.75F,0.75F,0.75F), - InnerScale (1, 1), - OuterScale (1, 1), - Alpha (1.0F), - Flags(0), - TextureTileCount(5), - ObjSpaceCenter (0, 0, 0), - ObjSpaceExtent (1, 1, 1), - InnerExtent (0.5F, 0.5F), - OuterExtent (1.0F, 1.0F) -{ - Generate_Shared_Mesh_Arrays (); - Init_Material (); - - *this = src; - - // So that the object is ready for use after construction, we will - // complete its initialization by initializing its value array - // according to a screen area of 1. - calculate_value_array(1.0f, Value); -} - - -/*********************************************************************************************** - * RingRenderObjClass::~RingRenderObjClass -- destructor * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 2/7/2001 gth : Created. * - *=============================================================================================*/ -RingRenderObjClass::~RingRenderObjClass() -{ - REF_PTR_RELEASE(RingMaterial); - REF_PTR_RELEASE(RingTexture); -} // destructor - - -/*********************************************************************************************** - * RingRenderObjClass::operator -- assignment operator * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 1/19/00 gth : Created. * - *=============================================================================================*/ -RingRenderObjClass & RingRenderObjClass::operator = (const RingRenderObjClass & that) -{ - if (this != &that) { - RenderObjClass::operator = (that); - Set_Name(that.Get_Name()); - Color = that.Color; - Alpha = that.Alpha; - InnerScale = that.InnerScale; - OuterScale = that.OuterScale; - Flags = that.Flags; - RingShader = that.RingShader; - CachedBox = that.CachedBox; - anim_time = that.anim_time; - AnimDuration = that.AnimDuration; - ObjSpaceCenter = that.ObjSpaceCenter; - ObjSpaceExtent = that.ObjSpaceExtent; - ColorChannel = that.ColorChannel; - AlphaChannel = that.AlphaChannel; - InnerScaleChannel = that.InnerScaleChannel; - OuterScaleChannel = that.OuterScaleChannel; - InnerExtent = that.InnerExtent; - OuterExtent = that.OuterExtent; - TextureTileCount = that.TextureTileCount; - - Set_Texture (that.RingTexture); - } - - return *this; -} - - -/*********************************************************************************************** - * RingRenderObjClass::Generate_Shared_Mesh_Arrays -- Generates mesh LOD arrays. * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 03/08/00 pds : Created. * - *=============================================================================================*/ -void RingRenderObjClass::Generate_Shared_Mesh_Arrays (void) -{ - // Generate shared Mesh Arrays - if (!Ring_Array_Valid) { - - float size = RING_LOWEST_LOD; - float step = (RING_HIGHEST_LOD - RING_LOWEST_LOD); - step /= RING_NUM_LOD; - - // For NULL LOD set Cost to a small nonzero amount to avoid divisions by zero. - RingLODCosts[0] = 0.000001f; - for(int i=0; i < RING_NUM_LOD; i++) { - - RingMeshArray[i].Generate(1.0f, size); - RingLODCosts[i + 1] = RingMeshArray[i].Get_Num_Polys(); - - size+=step; - } - - Ring_Array_Valid = true; - } - - return ; -} - - -// This is used both by Prepare_LOD and Calculate_Cost_Value_Arrays. -void RingRenderObjClass::calculate_value_array(float screen_area, float *values) const -{ - values[0] = AT_MIN_LOD; - for (int lod = 1; lod <= RING_NUM_LOD; lod++) { - float polycount = RingLODCosts[lod]; - float benefit_factor = 1 - (0.5f / (polycount * polycount)); - values[lod] = (benefit_factor * screen_area * LODBias) / polycount; - } - values[RING_NUM_LOD + 1] = AT_MAX_LOD; // Post-inc value will flag max LOD. -} - - -/*********************************************************************************************** - * RingRenderObjClass::Init_Material -- Sets up the material and default shader for the Ring.* - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 03/08/00 pds : Created. * - *=============================================================================================*/ -void RingRenderObjClass::Init_Material (void) -{ - REF_PTR_RELEASE (RingMaterial); - - RingMaterial = NEW_REF(VertexMaterialClass,()); - RingMaterial->Set_Ambient(0,0,0); - RingMaterial->Set_Diffuse(0,0,0); - RingMaterial->Set_Specular(0,0,0); - RingMaterial->Set_Emissive(1,1,1); - RingMaterial->Set_Opacity(0.25f); - RingMaterial->Set_Shininess(0.0f); - - // Texturing, zbuffer, primary gradient, alpha blending - RingShader = ShaderClass::_PresetAlphaShader; - -} // Init_Material - - - -/*********************************************************************************************** - * RingRenderObjClass::Get_Num_Polys -- returns number of polygons * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 1/19/00 gth : Created. * - *=============================================================================================*/ -int RingRenderObjClass::Get_Num_Polys(void) const -{ - return RingLODCosts[CurrentLOD]; -} - -/*********************************************************************************************** - * RingRenderObjClass::Set_Texture * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 1/19/00 gth : Created. * - *=============================================================================================*/ -void RingRenderObjClass::Set_Texture(TextureClass *tf) -{ - REF_PTR_SET(RingTexture,tf); -} - - -/*********************************************************************************************** - * RingRenderObjClass::Get_Name -- returns name * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 1/19/00 gth : Created. * - *=============================================================================================*/ -const char * RingRenderObjClass::Get_Name(void) const -{ - return Name; -} - - -/*********************************************************************************************** - * RingRenderObjClass::Set_Name -- sets the name * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 1/19/00 gth : Created. * - *=============================================================================================*/ -void RingRenderObjClass::Set_Name(const char * name) -{ - WWASSERT(name != NULL); - WWASSERT(strlen(name) < 2*W3D_NAME_LEN); - strcpy(Name,name); -} - -/*********************************************************************************************** - * RingRenderObjClass::render_ring -- submits the box to the GERD * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 1/19/00 gth : Created. * - *=============================================================================================*/ -void RingRenderObjClass::render_ring(RenderInfoClass & rinfo,const Vector3 & center,const Vector3 & extent) -{ - // Should never get here with NULL LOD - if (CurrentLOD == 0) { - WWASSERT(0); - return; - } - - RingMeshClass & ring = RingMeshArray[CurrentLOD - 1]; - - if (RingTexture) { - RingShader.Set_Texturing (ShaderClass::TEXTURING_ENABLE); - } else { - RingShader.Set_Texturing (ShaderClass::TEXTURING_DISABLE); - } - DX8Wrapper::Set_Shader(RingShader); - DX8Wrapper::Set_Texture(0,RingTexture); - DX8Wrapper::Set_Material(RingMaterial); - - // Enable sorting if the primitive is translucent, alpha testing is not enabled, and sorting is enabled globally. - const bool sort = (RingShader.Get_Dst_Blend_Func() != ShaderClass::DSTBLEND_ZERO) && (RingShader.Get_Alpha_Test() == ShaderClass::ALPHATEST_DISABLE) && (WW3D::Is_Sorting_Enabled()); - const unsigned int buffer_type = sort ? BUFFER_TYPE_DYNAMIC_SORTING : BUFFER_TYPE_DYNAMIC_DX8; - - DynamicVBAccessClass vb(buffer_type, dynamic_fvf_type, ring.Vertex_ct); - { - DynamicVBAccessClass::WriteLockClass Lock(&vb); - VertexFormatXYZNDUV2 *vb = Lock.Get_Formatted_Vertex_Array(); - - // - // set up the vertex color+alpha - // - unsigned color; - if (RingShader.Get_Dst_Blend_Func () == ShaderClass::DSTBLEND_ONE) { - color = DX8Wrapper::Convert_Color(Alpha * Color,1.0f); - } else { - color = DX8Wrapper::Convert_Color(Color,Alpha); - } - - for (int i=0; ix = ring.vtx[i].X; - vb->y = ring.vtx[i].Y; - vb->z = ring.vtx[i].Z; - - vb->nx = ring.vtx_normal[i].X; // may not need this! - vb->ny = ring.vtx_normal[i].Y; - vb->nz = ring.vtx_normal[i].Z; - - vb->diffuse = color; - - if (RingTexture) { - vb->u1 = ring.vtx_uv[i].X; - vb->v1 = ring.vtx_uv[i].Y; - } - vb++; - } - } - - DynamicIBAccessClass ib(buffer_type, ring.face_ct * 3); - { - DynamicIBAccessClass::WriteLockClass Lock(&ib); - unsigned short *mem=Lock.Get_Index_Array(); - for (int i=0; iProcess_Reduction(); - - Matrix3D temp = Transform; - - // Do Time Based Animation - animate (); - - // - // Scale the inner and outer parts of the ring. - // - Vector2 inner_scale (InnerExtent.X * InnerScale.X, InnerExtent.Y * InnerScale.Y); - Vector2 outer_scale (OuterExtent.X * OuterScale.X, OuterExtent.Y * OuterScale.Y); - RingMeshArray[CurrentLOD - 1].Scale(inner_scale, outer_scale); - - // - // Make sure this mesh uses the correct UV tiling - // - if (RingTexture != NULL) { - RingMeshArray[CurrentLOD - 1].Set_Tiling (TextureTileCount); - } - - // - // Should we force the ring to be camera aligned? - // (this will cause the ring to be parallel to the screen) - // - if (Flags & USE_CAMERA_ALIGN) { - Vector3 obj_position; - Vector3 camera_z_vector; - - rinfo.Camera.Get_Transform().Get_Z_Vector(&camera_z_vector); - Transform.Get_Translation(&obj_position); - - Matrix3D temp; - temp.Look_At(obj_position, obj_position + camera_z_vector, 0.0f); - DX8Wrapper::Set_Transform(D3DTS_WORLD, temp); - } else { - DX8Wrapper::Set_Transform(D3DTS_WORLD, Transform); - } - - // - // Pass the geometry on to DX8 - // - render_ring (rinfo, ObjSpaceCenter, ObjSpaceExtent); - } -} // Render - - -/*********************************************************************************************** - * RingRenderObjClass::Get_Default_Color - get the default (or first frame) value * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 3/13/2000 pds : Created. * - *=============================================================================================*/ -Vector3 RingRenderObjClass::Get_Default_Color(void) const -{ - Vector3 value; - - if (ColorChannel.Get_Key_Count () > 0) { - value = ColorChannel.Get_Key (0).Get_Value (); - } else { - value = Color; - } - - return value; -} - - -/*********************************************************************************************** - * RingRenderObjClass::Get_Default_Alpha - get the default (or first frame) value * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 3/13/2000 pds : Created. * - *=============================================================================================*/ -float RingRenderObjClass::Get_Default_Alpha(void) const -{ - float value; - - if (AlphaChannel.Get_Key_Count () > 0) { - value = AlphaChannel.Get_Key (0).Get_Value (); - } else { - value = Alpha; - } - - return value; -} - - -/*********************************************************************************************** - * RingRenderObjClass::Get_Default_Inner_Scale - get the default (or first frame) value * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 3/13/2000 pds : Created. * - *=============================================================================================*/ -Vector2 RingRenderObjClass::Get_Default_Inner_Scale(void) const -{ - Vector2 value; - - if (InnerScaleChannel.Get_Key_Count () > 0) { - value = InnerScaleChannel.Get_Key (0).Get_Value (); - } else { - value = InnerScale; - } - - return value; -} - - -/*********************************************************************************************** - * RingRenderObjClass::Get_Default_Outer_Scale - get the default (or first frame) value * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 3/13/2000 pds : Created. * - *=============================================================================================*/ -Vector2 RingRenderObjClass::Get_Default_Outer_Scale(void) const -{ - Vector2 value; - - if (OuterScaleChannel.Get_Key_Count () > 0) { - value = OuterScaleChannel.Get_Key (0).Get_Value (); - } else { - value = OuterScale; - } - - return value; -} - - -/*********************************************************************************************** - * RingRenderObjClass::Special_Render -- special render this box (vis) * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * -, * * - * HISTORY: * - * 1/19/00 gth : Created. * - *=============================================================================================*/ -void RingRenderObjClass::Special_Render(SpecialRenderInfoClass & rinfo) -{ - Matrix3D temp(1); - temp.Translate(Transform.Get_Translation()); - - if (rinfo.RenderType == SpecialRenderInfoClass::RENDER_VIS) { - WWASSERT(rinfo.VisRasterizer != NULL); - rinfo.VisRasterizer->Set_Model_Transform(temp); - vis_render_ring(rinfo,ObjSpaceCenter,ObjSpaceExtent); - } -} - - -/*********************************************************************************************** - * RingRenderObjClass::Set_Transform -- set the transform for this box * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 1/19/00 gth : Created. * - *=============================================================================================*/ -void RingRenderObjClass::Set_Transform(const Matrix3D &m) -{ - RenderObjClass::Set_Transform(m); - update_cached_box(); -} - - -/*********************************************************************************************** - * RingRenderObjClass::Set_Position -- Set the position of this box * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 1/19/00 gth : Created. * - *=============================================================================================*/ -void RingRenderObjClass::Set_Position(const Vector3 &v) -{ - RenderObjClass::Set_Position(v); - update_cached_box(); -} - - -/*********************************************************************************************** - * RingRenderObjClass::update_cached_box -- update the world-space version of this box * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 1/19/00 gth : Created. * - *=============================================================================================*/ -void RingRenderObjClass::update_cached_box(void) -{ - CachedBox.Center = Transform.Get_Translation() + ObjSpaceCenter; - CachedBox.Extent = ObjSpaceExtent; -} - - -/*********************************************************************************************** - * RingRenderObjClass::Get_Obj_Space_Bounding_Ring -- return the object-space bounding sphe * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 1/19/00 gth : Created. * - *=============================================================================================*/ -void RingRenderObjClass::Get_Obj_Space_Bounding_Sphere(SphereClass & sphere) const -{ - sphere.Center = ObjSpaceCenter; - sphere.Radius = ObjSpaceExtent.Length(); -} - - -/*********************************************************************************************** - * RingRenderObjClass::Get_Obj_Space_Bounding_Box -- returns the obj-space bounding box * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 1/19/00 gth : Created. * - *=============================================================================================*/ -void RingRenderObjClass::Get_Obj_Space_Bounding_Box(AABoxClass & box) const -{ - box.Center = ObjSpaceCenter; - box.Extent = ObjSpaceExtent; -} - - -void RingRenderObjClass::Prepare_LOD(CameraClass &camera) -{ - if (Is_Not_Hidden_At_All() == false) { - return; - } - - calculate_value_array(Get_Screen_Size(camera), Value); - - PredictiveLODOptimizerClass::Add_Object(this); -} - -void RingRenderObjClass::Increment_LOD(void) -{ - if (CurrentLOD < RING_NUM_LOD) CurrentLOD++; -} - -void RingRenderObjClass::Decrement_LOD(void) -{ - if (CurrentLOD > 0) CurrentLOD--; -} - -float RingRenderObjClass::Get_Cost(void) const -{ - return Get_Num_Polys(); // Currently cost == polys -} - -float RingRenderObjClass::Get_Value(void) const -{ - return Value[CurrentLOD]; -} - -float RingRenderObjClass::Get_Post_Increment_Value(void) const -{ - return Value[CurrentLOD + 1]; -} - -void RingRenderObjClass::Set_LOD_Level(int lod) -{ - CurrentLOD = Bound(lod, 0, RING_NUM_LOD); // RING_NUM_LOD doesn't include the null LOD -} - -int RingRenderObjClass::Get_LOD_Level(void) const -{ - return CurrentLOD; -} - -int RingRenderObjClass::Get_LOD_Count(void) const -{ - return RING_NUM_LOD + 1; // RING_NUM_LOD doesn't include the null LOD -} - -int RingRenderObjClass::Calculate_Cost_Value_Arrays(float screen_area, float *values, float *costs) const -{ - calculate_value_array(screen_area, values); - for (int lod = 0; lod <= RING_NUM_LOD; lod++) { - costs[lod] = RingLODCosts[lod]; - } - - // We currently don't support max screen size or minimum LOD clamping for ring objects - return 0; -} - - -/*********************************************************************************************** - * RingRenderObjClass::Scale -- scales ring uniformly. * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 7/01/02 NH : Created. * - *=============================================================================================*/ -void RingRenderObjClass::Scale(float scale) -{ - if (scale == 1.0f) return; - - // Scale default values - InnerScale *= scale; - OuterScale *= scale; - - // Loop over all keys in inner and outer scale channel and scale values. - int i; - int inner_count = InnerScaleChannel.Get_Key_Count(); - for (i = 0; i < inner_count; i++) { - const PrimitiveAnimationChannelClass::KeyClass &key = InnerScaleChannel.Get_Key(i); - InnerScaleChannel.Set_Key_Value(i, key.Get_Value() * scale); - } - int outer_count = OuterScaleChannel.Get_Key_Count(); - for (i = 0; i < outer_count; i++) { - const PrimitiveAnimationChannelClass::KeyClass &key = OuterScaleChannel.Get_Key(i); - OuterScaleChannel.Set_Key_Value(i, key.Get_Value() * scale); - } -} - - -/*********************************************************************************************** - * RingRenderObjClass::Scale -- scales ring non-uniformly. * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 7/01/02 NH : Created. * - *=============================================================================================*/ -void RingRenderObjClass::Scale(float scalex, float scaley, float scalez) -{ - // Scale default values - InnerScale.X *= scalex; - InnerScale.Y *= scaley; - OuterScale.X *= scalex; - OuterScale.Y *= scaley; - - // Loop over all keys in inner and outer scale channel and scale values. - int i; - int inner_count = InnerScaleChannel.Get_Key_Count(); - for (i = 0; i < inner_count; i++) { - const PrimitiveAnimationChannelClass::KeyClass &key = InnerScaleChannel.Get_Key(i); - Vector2 key_val = key.Get_Value(); - key_val.X *= scalex; - key_val.Y *= scaley; - InnerScaleChannel.Set_Key_Value(i, key_val); - } - int outer_count = OuterScaleChannel.Get_Key_Count(); - for (i = 0; i < outer_count; i++) { - const PrimitiveAnimationChannelClass::KeyClass &key = OuterScaleChannel.Get_Key(i); - Vector2 key_val = key.Get_Value(); - key_val.X *= scalex; - key_val.Y *= scaley; - OuterScaleChannel.Set_Key_Value(i, key_val); - } -} - - -/*********************************************************************************************** - * RingRenderObjClass::Update_On_Visibilty -- Either starts or stops the animation based on vis* - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 4/04/00 pds : Created. * - *=============================================================================================*/ -void RingRenderObjClass::Update_On_Visibilty(void) -{ - // Simply start or stop the animation based on - // the visibility state of the primitive. - if (Is_Not_Hidden_At_All () && Is_Animating () == false) { - Start_Animating (); - } else if ((Is_Not_Hidden_At_All () == false) && Is_Animating ()) { - Stop_Animating (); - } - - return ; -} - -/*********************************************************************************************** - * RingRenderObjClass::animate -- Update Current Display state * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 3/07/00 jga : Created. * - *=============================================================================================*/ -void RingRenderObjClass::animate() -{ - if (Is_Animating ()) { - - if ( ColorChannel.Get_Key_Count () > 0 || - AlphaChannel.Get_Key_Count () > 0 || - InnerScaleChannel.Get_Key_Count () > 0 || - OuterScaleChannel.Get_Key_Count () > 0) - { - // - // Convert from milliseconds to seconds and normalize the time - // - if (AnimDuration > 0) { - float frametime = WW3D::Get_Frame_Time(); - frametime = (frametime * 0.001F) / AnimDuration; - anim_time += frametime; - } else { - anim_time = 1.0F; - } - WWASSERT (anim_time >= 0.0F); - - if ((Flags & USE_ANIMATION_LOOP) && anim_time > 1.0F) { - anim_time -= 1.0F; - } - - if (ColorChannel.Get_Key_Count () > 0) { - Color = ColorChannel.Evaluate (anim_time); - } - - if (AlphaChannel.Get_Key_Count () > 0) { - Alpha = AlphaChannel.Evaluate (anim_time); - } - - if (InnerScaleChannel.Get_Key_Count () > 0) { - InnerScale = InnerScaleChannel.Evaluate (anim_time); - } - - if (OuterScaleChannel.Get_Key_Count () > 0) { - OuterScale = OuterScaleChannel.Evaluate (anim_time); - ObjSpaceExtent.X = OuterScale.X * OuterExtent.X; - ObjSpaceExtent.Y = OuterScale.Y * OuterExtent.Y; - ObjSpaceExtent.Z = 0; - Update_Cached_Bounding_Volumes (); - } - } - } - - return ; -} // animate - - -/* -** RingLoaderClass Implementation -*/ -PrototypeClass * RingLoaderClass::Load_W3D(ChunkLoadClass & cload) -{ - RingPrototypeClass *prototype = W3DNEW RingPrototypeClass (); - prototype->Load (cload); - return prototype; -} - -/* -** RingPrototypeClass Implementation -*/ -RingPrototypeClass::RingPrototypeClass (void) -{ - ::memset (&Definition, 0, sizeof (Definition)); - return ; -} - -RingPrototypeClass::RingPrototypeClass(RingRenderObjClass *ring) -{ - ::memset (&Definition, 0, sizeof (Definition)); - ::strcpy (Definition.Name, ring->Get_Name ()); - - Definition.AnimDuration = ring->AnimDuration; - Definition.Attributes = ring->Get_Flags (); - Definition.DefaultAlpha = ring->Get_Default_Alpha (); - Definition.DefaultInnerScale = ring->Get_Default_Inner_Scale (); - Definition.DefaultOuterScale = ring->Get_Default_Outer_Scale (); - Definition.TextureTileCount = ring->Get_Texture_Tiling (); - - Definition.InnerExtent = ring->Get_Inner_Extent (); - Definition.OuterExtent = ring->Get_Outer_Extent (); - - Vector3 def_color = ring->Get_Default_Color (); - W3dUtilityClass::Convert_Vector (def_color, &Definition.DefaultColor); - - W3dUtilityClass::Convert_Vector (ring->Get_Box ().Center, &Definition.Center); - W3dUtilityClass::Convert_Vector (ring->Get_Box ().Extent, &Definition.Extent); - W3dUtilityClass::Convert_Shader (ring->RingShader, &Definition.Shader); - - // - // Determine the texture name for this ring - // - if (ring->RingTexture != NULL) { - StringClass name = ring->RingTexture->Get_Full_Path(); - const char *filename = ::strrchr (name, '\\'); - if (filename != NULL) { - filename ++; - } else { - filename = name; - } - - ::strcpy (Definition.TextureName, filename); - } - - // - // Save the animateable channels - // - ColorChannel = ring->Peek_Color_Channel (); - AlphaChannel = ring->Peek_Alpha_Channel (); - InnerScaleChannel = ring->Peek_Inner_Scale_Channel (); - OuterScaleChannel = ring->Peek_Outer_Scale_Channel (); - return ; -} - -RingPrototypeClass::~RingPrototypeClass (void) -{ - return ; -} - -const char * RingPrototypeClass::Get_Name(void) const -{ - return Definition.Name; -} - -int RingPrototypeClass::Get_Class_ID(void) const -{ - return RenderObjClass::CLASSID_RING; -} - -enum -{ - CHUNKID_RING_DEF = 1, - CHUNKID_COLOR_CHANNEL, - CHUNKID_ALPHA_CHANNEL, - CHUNKID_INNER_SCALE_CHANNEL, - CHUNKID_OUTER_SCALE_CHANNEL -}; - -bool RingPrototypeClass::Load (ChunkLoadClass &cload) -{ - ColorChannel.Reset (); - AlphaChannel.Reset (); - InnerScaleChannel.Reset (); - OuterScaleChannel.Reset (); - - while (cload.Open_Chunk ()) { - switch (cload.Cur_Chunk_ID ()) { - - case CHUNKID_RING_DEF: - cload.Read (&Definition, sizeof (Definition)); - break; - - case CHUNKID_COLOR_CHANNEL: - ColorChannel.Load (cload); - break; - - case CHUNKID_ALPHA_CHANNEL: - AlphaChannel.Load (cload); - break; - - case CHUNKID_INNER_SCALE_CHANNEL: - InnerScaleChannel.Load (cload); - break; - - case CHUNKID_OUTER_SCALE_CHANNEL: - OuterScaleChannel.Load (cload); - break; - } - - cload.Close_Chunk (); - } - - return true; -} - -bool RingPrototypeClass::Save (ChunkSaveClass &csave) -{ - csave.Begin_Chunk (W3D_CHUNK_RING); - - csave.Begin_Chunk (CHUNKID_RING_DEF); - csave.Write (&Definition, sizeof (Definition)); - csave.End_Chunk (); - - if (ColorChannel.Get_Key_Count () > 0) { - csave.Begin_Chunk (CHUNKID_COLOR_CHANNEL); - ColorChannel.Save (csave); - csave.End_Chunk (); - } - - if (AlphaChannel.Get_Key_Count () > 0) { - csave.Begin_Chunk (CHUNKID_ALPHA_CHANNEL); - AlphaChannel.Save (csave); - csave.End_Chunk (); - } - - if (InnerScaleChannel.Get_Key_Count () > 0) { - csave.Begin_Chunk (CHUNKID_INNER_SCALE_CHANNEL); - InnerScaleChannel.Save (csave); - csave.End_Chunk (); - } - - if (OuterScaleChannel.Get_Key_Count () > 0) { - csave.Begin_Chunk (CHUNKID_OUTER_SCALE_CHANNEL); - OuterScaleChannel.Save (csave); - csave.End_Chunk (); - } - - csave.End_Chunk (); - return true; -} - -RenderObjClass * RingPrototypeClass::Create(void) -{ - // - // Create the new render object - // - RingRenderObjClass *ring = W3DNEW RingRenderObjClass (Definition); - - // - // Configure the ring - // - W3dUtilityClass::Convert_Shader (Definition.Shader, &ring->RingShader); - if (WW3DAssetManager::Get_Instance()->Get_Activate_Fog_On_Load()) { - ring->RingShader.Enable_Fog ("RingPrototypeClass"); - ring->RingShader.Set_Cull_Mode(ShaderClass::CULL_MODE_DISABLE); - } - W3dUtilityClass::Convert_Vector (Definition.DefaultColor, &ring->Color); - ring->InnerScale = Definition.DefaultInnerScale; - ring->OuterScale = Definition.DefaultOuterScale; - ring->Set_Animation_Duration (Definition.AnimDuration); - ring->Alpha = Definition.DefaultAlpha; - ring->Set_Flags (Definition.Attributes); - ring->Set_Inner_Extent (Definition.InnerExtent); - ring->Set_Outer_Extent (Definition.OuterExtent); - ring->Set_Texture_Tiling (Definition.TextureTileCount); - - // - // Initialize the render object with the keyframe arrays - // - ring->Set_Color_Channel (ColorChannel); - ring->Set_Alpha_Channel (AlphaChannel); - ring->Set_Inner_Scale_Channel (InnerScaleChannel); - ring->Set_Outer_Scale_Channel (OuterScaleChannel); - return ring; -} - -/* -** Global instance of the box loader -*/ -RingLoaderClass _RingLoader; - - -// -// Vertices are ordered as such -// center, followed by outer ring -// -/*********************************************************************************************** - * RingMeshClass::RingMeshClass -- Constructor * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 3/07/00 jga : Created. * - *=============================================================================================*/ -RingMeshClass::RingMeshClass(float radius, int slices): -Radius(radius), -Slices(slices), -Vertex_ct(0), // 1 vertex minimum, for center -vtx(NULL), -orig_vtx(NULL), -vtx_normal(NULL), -vtx_uv(NULL), -face_ct(0), -tri_poly(NULL), -TileCount (5), -InnerScale (1.0F, 1.0F), -OuterScale (1.0F, 1.0F) -{ - Generate(radius, slices); -} - -/*********************************************************************************************** - * RingMeshClass::RingMeshClass -- Constructor * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 3/07/00 jga : Created. * - *=============================================================================================*/ -RingMeshClass::RingMeshClass(void): -Radius(0.0f), -Slices(0), -Vertex_ct(0), // 1 vertex minimum, for center -vtx(NULL), -orig_vtx(NULL), -vtx_normal(NULL), -vtx_uv(NULL), -face_ct(0), -tri_poly(NULL), -TileCount (5), -InnerScale (1.0F, 1.0F), -OuterScale (1.0F, 1.0F) -{ -} // empty ringmesh Constructor - - -void RingMeshClass::Set_Tiling (int count) -{ - if (TileCount != count) { - TileCount = count; - - // - // Calculate the increment 'u' increment value (as in UV). - // - float u_inc = ((float)TileCount) / ((float)(Slices)); - float u_value = 0.0F; - - // - // Reassign the UVs - // - for (int index = 0; index < Vertex_ct; index += 2) { - vtx_uv[index].Set (u_value, 0.0F); - vtx_uv[index + 1].Set (u_value, 1.0F); - u_value += u_inc; - } - } - - return ; -} - - -void RingMeshClass::Scale (const Vector2 &inner_scale, const Vector2 &outer_scale) -{ - bool do_inner = (inner_scale != InnerScale); - bool do_outer = (outer_scale != OuterScale); - - // - // Only scale the inner ring if necessary - // - if (do_inner) { - - for (int index = 0; index < Vertex_ct; index += 2) { - vtx[index].X = orig_vtx[index].X * inner_scale.X; - vtx[index].Y = orig_vtx[index].Y * inner_scale.Y; - vtx[index].Z = 0; - } - - InnerScale = inner_scale; - } - - // - // Only scale the outer ring if necessary - // - if (do_outer) { - - for (int index = 1; index < Vertex_ct; index += 2) { - vtx[index].X = orig_vtx[index].X * outer_scale.X; - vtx[index].Y = orig_vtx[index].Y * outer_scale.Y; - vtx[index].Z = 0; - } - - OuterScale = outer_scale; - } - - return ; -} - - -/*********************************************************************************************** - * RingMeshClass::Generate - Create Ring Geometry * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 3/07/00 jga : Created. * - *=============================================================================================*/ -void RingMeshClass::Generate(float radius, int slices) -{ - Free (); - - Slices = slices; - Radius = radius; - - face_ct = (Slices * 2); - Vertex_ct = (Slices * 2) + 2; - - vtx = W3DNEWARRAY Vector3[Vertex_ct]; - orig_vtx = W3DNEWARRAY Vector2[Vertex_ct]; - vtx_normal = W3DNEWARRAY Vector3[Vertex_ct]; - vtx_uv = W3DNEWARRAY Vector2[Vertex_ct]; - tri_poly = W3DNEWARRAY TriIndex[face_ct]; - - // - // Generate vertices, normals, and uv's - // - float angle_inc = DEG_TO_RADF (360) / ((float)Slices); - float u_inc = ((float)TileCount) / ((float)(Slices)); - float u_value = 0.0F; - float angle = 0; - int index = 0; - - for (index = 0; index < Vertex_ct; index += 2) { - - float x_pos = -WWMath::Sin (angle); - float y_pos = WWMath::Cos (angle); - - // - // Place the inner index - // - vtx[index].X = orig_vtx[index].X = x_pos; - vtx[index].Y = orig_vtx[index].Y = y_pos; - vtx[index].Z = 0; - - // - // Place the outer index - // - vtx[index+1].X = orig_vtx[index+1].X = x_pos; - vtx[index+1].Y = orig_vtx[index+1].Y = y_pos; - vtx[index+1].Z = 0; - - // - // Normals will just point straight up from the ring... - // - vtx_normal[index].Set (0, 0, 1); - vtx_normal[index + 1].Set (0, 0, 1); - - // - // Assign the UVs - // - vtx_uv[index].Set (u_value, 0.0F); - vtx_uv[index + 1].Set (u_value, 1.0F); - u_value += u_inc; - - angle += angle_inc; - } - - // - // Make the triangle strip... - // - for (index = 0; index < face_ct; index ++) { - tri_poly[index].I = index; - tri_poly[index].J = index+1; - tri_poly[index].K = index+2; - } - - return ; -} - - -/*********************************************************************************************** - * RingMeshClass::~RingMeshClass -- Destructor * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 3/07/00 jga : Created. * - *=============================================================================================*/ -RingMeshClass::~RingMeshClass(void) -{ - Free(); -} - -/*********************************************************************************************** - * RingMeshClass::Free - Release Memory, that the ring mesh is using * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 3/07/00 jga : Created. * - *=============================================================================================*/ -void RingMeshClass::Free(void) -{ - - if (vtx) delete vtx; - if (orig_vtx) delete orig_vtx; - if (vtx_normal) delete vtx_normal; - if (vtx_uv) delete vtx_uv; - if (tri_poly) delete tri_poly; - - vtx = NULL; - orig_vtx = NULL; - vtx_normal = NULL; - vtx_uv = NULL; - tri_poly = NULL; - -} // Free - -// EOF - ringobj.cpp diff --git a/Generals/Code/Libraries/Source/WWVegas/WW3D2/ringobj.h b/Generals/Code/Libraries/Source/WWVegas/WW3D2/ringobj.h deleted file mode 100644 index 7085e6c7ba6..00000000000 --- a/Generals/Code/Libraries/Source/WWVegas/WW3D2/ringobj.h +++ /dev/null @@ -1,370 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** 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 *** - *********************************************************************************************** - * * - * Project Name : WW3D * - * * - * $Archive:: /Commando/Code/ww3d2/ringobj.h $* - * * - * Author:: Jason Andersen * - * * - * $Modtime:: 3/23/01 7:02p $* - * * - * $Revision:: 5 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#if defined(_MSC_VER) -#pragma once -#endif - -#ifndef RINGOBJ_H -#define RINGOBJ_H - -#include "always.h" -#include "rendobj.h" -#include "w3d_file.h" -#include "shader.h" -#include "proto.h" -#include "obbox.h" -#include "quat.h" -#include "vector3.h" -#include "vector2.h" -#include "prim_anim.h" - -class VertexMaterialClass; - -typedef LERPAnimationChannelClass RingColorChannelClass; -typedef LERPAnimationChannelClass RingAlphaChannelClass; -typedef LERPAnimationChannelClass RingScaleChannelClass; - - -/** -** W3dRingStruct -** This structure is used to define a ring object in the W3D file format. -*/ -struct W3dRingStruct -{ - uint32 Version; // file format version - uint32 Attributes; // box attributes (above #define's) - char Name[2*W3D_NAME_LEN]; // name is in the form . - - W3dVectorStruct Center; // center of the box - W3dVectorStruct Extent; // extent of the box - - float AnimDuration; // Animation time (in seconds) - - W3dVectorStruct DefaultColor; - float DefaultAlpha; - Vector2 DefaultInnerScale; - Vector2 DefaultOuterScale; - - Vector2 InnerExtent; - Vector2 OuterExtent; - - char TextureName[2*W3D_NAME_LEN]; - W3dShaderStruct Shader; - int TextureTileCount; - - // - // Note this structure is followed by a series of - // W3dRingKeyArrayStruct structures which define the - // variable set of keyframes for each channel -}; - -// Note: RING_NUM_LOD does not include the NULL LOD. -#define RING_NUM_LOD (20) -#define RING_LOWEST_LOD (10) -#define RING_HIGHEST_LOD (50) - -/* -** RingRenderObjClass: Procedurally generated render rings -** -*/ -class RingRenderObjClass : public RenderObjClass -{ - -public: - - // These are bit masks, so they should enum 1,2,4,8,10,20,40 etc... - enum RingFlags { - USE_CAMERA_ALIGN = 0x00000001, - USE_ANIMATION_LOOP= 0x00000002, - }; - - RingRenderObjClass(void); - RingRenderObjClass(const W3dRingStruct & def); - RingRenderObjClass(const RingRenderObjClass & src); - RingRenderObjClass & operator = (const RingRenderObjClass &); - ~RingRenderObjClass(void); - - ///////////////////////////////////////////////////////////////////////////// - // Render Object Interface - ///////////////////////////////////////////////////////////////////////////// - virtual RenderObjClass * Clone(void) const; - virtual int Class_ID(void) const; - virtual void Render(RenderInfoClass & rinfo); - virtual void Special_Render(SpecialRenderInfoClass & rinfo); - virtual void Set_Transform(const Matrix3D &m); - virtual void Set_Position(const Vector3 &v); - virtual void Get_Obj_Space_Bounding_Sphere(SphereClass & sphere) const; - virtual void Get_Obj_Space_Bounding_Box(AABoxClass & box) const; - - virtual void Prepare_LOD(CameraClass &camera); - virtual void Increment_LOD(void); - virtual void Decrement_LOD(void); - virtual float Get_Cost(void) const; - virtual float Get_Value(void) const; - virtual float Get_Post_Increment_Value(void) const; - virtual void Set_LOD_Level(int lod); - virtual int Get_LOD_Level(void) const; - virtual int Get_LOD_Count(void) const; - virtual void Set_LOD_Bias(float bias) { LODBias = MAX(bias, 0.0f); } - virtual int Calculate_Cost_Value_Arrays(float screen_area, float *values, float *costs) const; - - virtual void Scale(float scale); - virtual void Scale(float scalex, float scaley, float scalez); - - virtual void Set_Hidden(int onoff) { RenderObjClass::Set_Hidden (onoff); Update_On_Visibilty (); } - virtual void Set_Visible(int onoff) { RenderObjClass::Set_Visible (onoff); Update_On_Visibilty (); } - virtual void Set_Animation_Hidden(int onoff) { RenderObjClass::Set_Animation_Hidden (onoff); Update_On_Visibilty (); } - virtual void Set_Force_Visible(int onoff) { RenderObjClass::Set_Force_Visible (onoff); Update_On_Visibilty (); } - - const AABoxClass & Get_Box(void); - - virtual int Get_Num_Polys(void) const; - virtual const char *Get_Name(void) const; - virtual void Set_Name(const char * name); - - unsigned int Get_Flags(void) {return Flags;} - void Set_Flags(unsigned int flags) { Flags = flags; } - void Set_Flag(unsigned int flag, bool onoff) { Flags &= (~flag); if (onoff) Flags |= flag; } - - // Animation access - bool Is_Animating (void) { return IsAnimating; } - void Start_Animating (void) { IsAnimating = true; anim_time = 0; } - void Stop_Animating (void) { IsAnimating = false; anim_time = 0; } - - // Texture tiling access - int Get_Texture_Tiling (void) const { return TextureTileCount; } - void Set_Texture_Tiling (int count) { TextureTileCount = count; } - - // Current state access - void Set_Color(const Vector3 & color) { Color = color; } - void Set_Alpha(float alpha) { Alpha = alpha; } - void Set_Inner_Scale(const Vector2 & scale) { InnerScale = scale; } - void Set_Outer_Scale(const Vector2 & scale) { OuterScale = scale; } - - const Vector3 & Get_Color(void) const { return Color; } - float Get_Alpha(void) const { return Alpha; } - const Vector2 & Get_Inner_Scale(void) const { return InnerScale; } - const Vector2 & Get_Outer_Scale(void) const { return OuterScale; } - - Vector3 Get_Default_Color(void) const; - float Get_Default_Alpha(void) const; - Vector2 Get_Default_Inner_Scale(void) const; - Vector2 Get_Default_Outer_Scale(void) const; - - // Size/position methods - const Vector2 & Get_Inner_Extent (void) const { return InnerExtent; } - const Vector2 & Get_Outer_Extent (void) const { return OuterExtent; } - void Set_Inner_Extent (const Vector2 &extent); - void Set_Outer_Extent (const Vector2 &extent); - void Set_Local_Center_Extent(const Vector3 & center,const Vector3 & extent); - void Set_Local_Min_Max(const Vector3 & min,const Vector3 & max); - - // Texture access - void Set_Texture(TextureClass *tf); - TextureClass * Peek_Texture(void) { return RingTexture; } - ShaderClass & Get_Shader(void) { return RingShader; } - void Set_Shader(ShaderClass &shader) { RingShader = shader; } - - // Animation Control - float Get_Animation_Duration(void) const { return AnimDuration; } - void Set_Animation_Duration(float time) { AnimDuration = time; Restart_Animation(); } - void Restart_Animation (void) { anim_time = 0; } - - // Animatable channel access - RingColorChannelClass & Get_Color_Channel (void) { return ColorChannel; } - const RingColorChannelClass & Peek_Color_Channel (void) { return ColorChannel; } - - RingAlphaChannelClass & Get_Alpha_Channel (void) { return AlphaChannel; } - const RingAlphaChannelClass & Peek_Alpha_Channel (void) { return AlphaChannel; } - - RingScaleChannelClass & Get_Inner_Scale_Channel (void) { return InnerScaleChannel; } - const RingScaleChannelClass & Peek_Inner_Scale_Channel (void) { return InnerScaleChannel; } - - RingScaleChannelClass & Get_Outer_Scale_Channel (void) { return OuterScaleChannel; } - const RingScaleChannelClass & Peek_Outer_Scale_Channel (void) { return OuterScaleChannel; } - - void Set_Color_Channel (const RingColorChannelClass &data) { ColorChannel = data; } - void Set_Alpha_Channel (const RingAlphaChannelClass &data) { AlphaChannel = data; } - void Set_Inner_Scale_Channel (const RingScaleChannelClass &data) { InnerScaleChannel = data; } - void Set_Outer_Scale_Channel (const RingScaleChannelClass &data) { OuterScaleChannel = data; } - -protected: - - virtual void update_cached_box(void); - void Update_On_Visibilty(void); - - // Initialization stuff - void Init_Material (void); - static void Generate_Shared_Mesh_Arrays (void); - - - // Animation Stuff - void animate(void); // animation update function - float anim_time; // what time in seconds are we in the animation - float AnimDuration; - bool IsAnimating; - - // LOD Stuff - void calculate_value_array(float screen_area, float *values) const; - float LODBias; - int CurrentLOD; - float Value[RING_NUM_LOD + 2];// Value array needs # of LODs + 1 (RING_NUM_LOD doesn't include null LOD) - - RingColorChannelClass ColorChannel; - RingAlphaChannelClass AlphaChannel; - RingScaleChannelClass InnerScaleChannel; - RingScaleChannelClass OuterScaleChannel; - - void update_mesh_data(const Vector3 & center,const Vector3 & extent); - void render_ring(RenderInfoClass & rinfo,const Vector3 & center,const Vector3 & extent); - void vis_render_ring(SpecialRenderInfoClass & rinfo,const Vector3 & center,const Vector3 & extent); - - char Name[2*W3D_NAME_LEN]; - Vector3 ObjSpaceCenter; - Vector3 ObjSpaceExtent; - - Vector2 InnerExtent; - Vector2 OuterExtent; - - int TextureTileCount; - - // Current State - Vector3 Color; - float Alpha; - Vector2 InnerScale; - Vector2 OuterScale; - - // Flags - unsigned int Flags; - - VertexMaterialClass *RingMaterial; - ShaderClass RingShader; - TextureClass *RingTexture; - - AABoxClass CachedBox; - - // Friend classes - friend class RingPrototypeClass; -}; - -inline void RingRenderObjClass::Set_Inner_Extent (const Vector2 &extent) -{ - InnerExtent = extent; -} - -inline void RingRenderObjClass::Set_Outer_Extent (const Vector2 &extent) -{ - OuterExtent = extent; - ObjSpaceExtent.X = extent.X; - ObjSpaceExtent.Y = extent.Y; - ObjSpaceExtent.Z = 0; - update_cached_box(); -} - -inline void RingRenderObjClass::Set_Local_Center_Extent(const Vector3 & center,const Vector3 & extent) -{ - ObjSpaceCenter = center; - ObjSpaceExtent = extent; - update_cached_box(); -} - -inline void RingRenderObjClass::Set_Local_Min_Max(const Vector3 & min,const Vector3 & max) -{ - ObjSpaceCenter = (max + min) / 2.0f; - ObjSpaceExtent = (max - min) / 2.0f; - update_cached_box(); -} - -inline const AABoxClass & RingRenderObjClass::Get_Box(void) -{ - Validate_Transform(); - update_cached_box(); - return CachedBox; -} - -/* -** Loader for rings -*/ -class RingLoaderClass : public PrototypeLoaderClass -{ -public: - virtual int Chunk_Type (void) { return W3D_CHUNK_RING; } - virtual PrototypeClass * Load_W3D(ChunkLoadClass & cload); -}; - -/* -** Prototype for Ring objects -*/ -class RingPrototypeClass : public W3DMPO, public PrototypeClass -{ - W3DMPO_GLUE(RingPrototypeClass) - -public: - RingPrototypeClass (void); - RingPrototypeClass (RingRenderObjClass *ring); - - virtual const char * Get_Name(void) const; - virtual int Get_Class_ID(void) const; - virtual RenderObjClass * Create(void); - virtual void DeleteSelf() { delete this; } - - bool Load (ChunkLoadClass &cload); - bool Save (ChunkSaveClass &csave); - -protected: - ~RingPrototypeClass (void); - -private: - W3dRingStruct Definition; - - RingColorChannelClass ColorChannel; - RingAlphaChannelClass AlphaChannel; - RingScaleChannelClass InnerScaleChannel; - RingScaleChannelClass OuterScaleChannel; -}; - -/* -** Instance of the loader which the asset manager installs -*/ -extern RingLoaderClass _RingLoader; - - -#endif // RINGOBJ_H - -// EOF - ringobj,h - - diff --git a/Generals/Code/Libraries/Source/WWVegas/WW3D2/robjlist.h b/Generals/Code/Libraries/Source/WWVegas/WW3D2/robjlist.h deleted file mode 100644 index 54b49a72d22..00000000000 --- a/Generals/Code/Libraries/Source/WWVegas/WW3D2/robjlist.h +++ /dev/null @@ -1,67 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** 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 *** - *********************************************************************************************** - * * - * Project Name : WW3D * - * * - * $Archive:: /Commando/Code/ww3d2/robjlist.h $* - * * - * Author:: Greg Hjelstrom * - * * - * $Modtime:: 1/08/01 10:04a $* - * * - * $Revision:: 1 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - - -#if defined(_MSC_VER) -#pragma once -#endif - -#ifndef ROBJLIST_H -#define ROBJLIST_H - -#ifndef ALWAYS_H -#include "always.h" -#endif - -#ifndef MULTILIST_H -#include "multilist.h" -#endif - -#ifndef WWDEBUG_H -#include "wwdebug.h" -#endif - -class RenderObjClass; - -typedef RefMultiListClass RefRenderObjListClass; -typedef RefMultiListIterator RefRenderObjListIterator; - -typedef MultiListClass NonRefRenderObjListClass; -typedef MultiListIterator NonRefRenderObjListIterator; - -#endif - - diff --git a/Generals/Code/Libraries/Source/WWVegas/WW3D2/segline.cpp b/Generals/Code/Libraries/Source/WWVegas/WW3D2/segline.cpp deleted file mode 100644 index 413d3e86cf2..00000000000 --- a/Generals/Code/Libraries/Source/WWVegas/WW3D2/segline.cpp +++ /dev/null @@ -1,591 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** 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 *** - *********************************************************************************************** - * * - * Project Name : G * - * * - * $Archive:: /VSS_Sync/ww3d2/segline.cpp $* - * * - * $Author:: Vss_sync $* - * * - * $Modtime:: 8/29/01 7:29p $* - * * - * $Revision:: 23 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#include "segline.h" -#include "ww3d.h" -#include "rinfo.h" -#include "predlod.h" -#include "v3_rnd.h" -#include "texture.h" -#include "coltest.h" -#include "w3d_file.h" -#include "texture.h" -#include "dx8wrapper.h" -#include "vp.h" -#include "Vector3i.h" -#include "sortingrenderer.h" - -static SegLineRendererClass _LineRenderer; - - -/* -** SegmentedLineClass implementation: -*/ - -SegmentedLineClass::SegmentedLineClass(void) : - MaxSubdivisionLevels(0), - NormalizedScreenArea(0.0f) -{ -} - -SegmentedLineClass::SegmentedLineClass(const SegmentedLineClass & src) : - MaxSubdivisionLevels(src.MaxSubdivisionLevels), - NormalizedScreenArea(src.NormalizedScreenArea), - PointLocations(src.PointLocations), - LineRenderer(src.LineRenderer) -{ -} - -SegmentedLineClass & SegmentedLineClass::operator = (const SegmentedLineClass &that) -{ - RenderObjClass::operator = (that); - - if (this != &that) { - - MaxSubdivisionLevels = that.MaxSubdivisionLevels; - NormalizedScreenArea = that.NormalizedScreenArea; - PointLocations = that.PointLocations; - LineRenderer = that.LineRenderer; - } - - return * this; -} - -SegmentedLineClass::~SegmentedLineClass(void) -{ -} - -void SegmentedLineClass::Reset_Line(void) -{ - LineRenderer.Reset_Line(); -} - - -// These are segment points, and include the start and end point of the -// entire line. Therefore there must be at least two. -void SegmentedLineClass::Set_Points(unsigned int num_points, Vector3 *locs) -{ - if (num_points < 2 || !locs) { - WWASSERT(0); - return; - } - - PointLocations.Delete_All(); - for (unsigned int i=0; iProcess_Reduction(); - - unsigned int sort_level = SORT_LEVEL_NONE; - - if (!WW3D::Is_Sorting_Enabled()) - sort_level=Get_Shader().Guess_Sort_Level(); - - if (WW3D::Are_Static_Sort_Lists_Enabled() && sort_level!=SORT_LEVEL_NONE) { - - WW3D::Add_To_Static_Sort_List(this, sort_level); - - } else - Render_Seg_Line(rinfo); -} - -void SegmentedLineClass::Get_Obj_Space_Bounding_Sphere(SphereClass & sphere) const -{ - // Get object-space bounding box and create bounding sphere from it - AABoxClass box; - Get_Obj_Space_Bounding_Box(box); - - // Create object-space bounding sphere from the bounding box: - sphere.Center = box.Center; - sphere.Radius = box.Extent.Length(); -} - -void SegmentedLineClass::Get_Obj_Space_Bounding_Box(AABoxClass & box) const -{ - unsigned int num_points = PointLocations.Count(); - - // Line must have at least two points to be valid - - if (num_points >= 2) { - - // Find object-space axis-aligned bounding box - Vector3 max_coords; - Vector3 min_coords; - unsigned int i; - - // We create two bounding boxes; one from the points, and if we have random noise - // subdivision we create another one from the midpoints and factor the noise amplitude - // into the second box, and then combine the two. - - // First bounding box: - max_coords = PointLocations[0]; - min_coords = PointLocations[0]; - for (i = 1; i < num_points; i++) { - max_coords.Update_Max(PointLocations[i]); - min_coords.Update_Min(PointLocations[i]); - } - // Enlarge bounding box by half the width - float enlarge_factor = LineRenderer.Get_Width() * 0.5f; - Vector3 enlarge_offset; - enlarge_offset.Set(enlarge_factor, enlarge_factor, enlarge_factor); - max_coords += enlarge_offset; - min_coords -= enlarge_offset; - - if (MaxSubdivisionLevels > 0) { - // Second bounding box: - Vector3 max_coords2; - Vector3 min_coords2; - Vector3 midpoint = (PointLocations[0] + PointLocations[1]) * 0.5f; - max_coords2 = midpoint; - min_coords2 = midpoint; - for (i = 1; i < num_points - 1; i++) { - midpoint = (PointLocations[i] + PointLocations[i + 1]) * 0.5f; - max_coords2.Update_Max(midpoint); - min_coords2.Update_Min(midpoint); - } - - // We ignore the actual number of subdivision levels: we multiply the random noise - // amplitude by 2, which is the limit as the number of subdivision levels goes to - // infinity. - enlarge_factor += (2 * LineRenderer.Get_Noise_Amplitude()); - enlarge_offset.Set(enlarge_factor, enlarge_factor, enlarge_factor); - max_coords2 += enlarge_offset; - min_coords2 -= enlarge_offset; - - // Combine the two: - max_coords.Update_Max(max_coords2); - min_coords.Update_Min(min_coords2); - } - - box.Init_Min_Max(min_coords, max_coords); - - } else { - // Invalid line - return something - box.Init(Vector3(0,0,0),Vector3(1,1,1)); - } -} - -void SegmentedLineClass::Prepare_LOD(CameraClass &camera) -{ - // Find the maximum screen dimension of the object in pixels - NormalizedScreenArea = Get_Screen_Size(camera); - -// // Find and set texture reduction factor -// Set_Texture_Reduction_Factor(Calculate_Texture_Reduction_Factor(NormalizedScreenArea)); - - // Ensure subdivision level is legal - unsigned int lvl = LineRenderer.Get_Current_Subdivision_Level(); - lvl = MIN(lvl, MaxSubdivisionLevels); - LineRenderer.Set_Current_Subdivision_Level(lvl); - - // Prepare LOD processing if the line has subdivision enabled: - if (MaxSubdivisionLevels > 0) { - // Add myself to the LOD optimizer: - PredictiveLODOptimizerClass::Add_Object(this); - } else { - // Not added to optimizer, need to add cost - PredictiveLODOptimizerClass::Add_Cost(Get_Cost()); - } -} - -void SegmentedLineClass::Increment_LOD(void) -{ - unsigned int lvl = LineRenderer.Get_Current_Subdivision_Level(); - - lvl = MIN(lvl+1,MaxSubdivisionLevels); - - LineRenderer.Set_Current_Subdivision_Level(lvl); -} - -void SegmentedLineClass::Decrement_LOD(void) -{ - int lvl = LineRenderer.Get_Current_Subdivision_Level(); - if (lvl == 0) return; - LineRenderer.Set_Current_Subdivision_Level(lvl-1); -} - -float SegmentedLineClass::Get_Cost(void) const -{ - return Get_Num_Polys(); -} - -float SegmentedLineClass::Get_Value(void) const -{ - // If we are at the minimum LOD, we must return AT_MIN_LOD. - if (LineRenderer.Get_Current_Subdivision_Level() == 0) { - return AT_MIN_LOD; - } else { - float polycount = (float)Get_Num_Polys(); - float benefit_factor = 1.0f - (0.5f / (polycount * polycount)); - return (benefit_factor * NormalizedScreenArea) / Get_Cost(); - } -} - -float SegmentedLineClass::Get_Post_Increment_Value(void) const -{ - // If we are at the maximum LOD, we must return AT_MIN_LOD. - if (LineRenderer.Get_Current_Subdivision_Level() == MaxSubdivisionLevels) { - return AT_MAX_LOD; - } else { - // Assumption: each subdivision level doubles polycount - float polycount = 2.0f * (float)Get_Num_Polys(); - float benefit_factor = 1.0f - (0.5f / (polycount * polycount)); - // Assumption: Cost() == polycount - return (benefit_factor * NormalizedScreenArea) / polycount; - } -} - -void SegmentedLineClass::Set_LOD_Level(int lod) -{ - lod = MAX(0, lod); - lod = MIN(lod, (int)MaxSubdivisionLevels); - - LineRenderer.Set_Current_Subdivision_Level((unsigned int)lod); -} - -int SegmentedLineClass::Get_LOD_Level(void) const -{ - return (int) LineRenderer.Get_Current_Subdivision_Level(); -} - -int SegmentedLineClass::Get_LOD_Count(void) const -{ - return (int)MaxSubdivisionLevels; -} -/* -void SegmentedLineClass::Set_Texture_Reduction_Factor(float trf) -{ - if (LineRenderer.Peek_Texture()) LineRenderer.Peek_Texture()->Set_Reduction_Factor(trf); -}*/ - - - -void SegmentedLineClass::Render_Seg_Line(RenderInfoClass & rinfo) -{ - // Line must have at least two points to be valid - if (PointLocations.Count() < 2) return; - - SphereClass bounding_sphere; - Get_Obj_Space_Bounding_Sphere(bounding_sphere); - - LineRenderer.Render( - rinfo, - Transform, - PointLocations.Count(), - &(PointLocations[0]), - bounding_sphere - ); -} - - -bool SegmentedLineClass::Cast_Ray(RayCollisionTestClass & raytest) -{ - if ((Get_Collision_Type() & raytest.CollisionType) == 0) return false; - - bool retval = false; - - // - // Check each line segment against the ray - // - float fraction = 1.0F; - for (uint32 index = 1; index < (unsigned int)PointLocations.Count(); index ++) - { -#ifdef ALLOW_TEMPORARIES - Vector3 curr_start = Transform * PointLocations[index-1]; - Vector3 curr_end = Transform * PointLocations[index]; - LineSegClass line_seg (curr_start, curr_end); -#else - Vector3 curr[2]; - Transform.mulVector3Array(&PointLocations[index-1], curr, 2); - LineSegClass line_seg(curr[0], curr[1]); -#endif - - Vector3 p0; - Vector3 p1; - if (raytest.Ray.Find_Intersection (line_seg, &p0, &fraction, &p1, NULL)) { - - // - // Determine if the ray was close enough to this line to be - // considered intersecting - // - float dist = (p0 - p1).Length (); - if (dist <= LineRenderer.Get_Width() && fraction >= 0 && fraction < raytest.Result->Fraction) { - //if (dist <= Width && fraction < raytest.Result->Fraction) { - retval = true; - break; - } - } - } - - // - // Fill in the raytest structure if we were successfull - // - if (retval) { - raytest.Result->Fraction = fraction; - raytest.Result->SurfaceType = SURFACE_TYPE_DEFAULT; - raytest.CollidedRenderObj = this; - } - - return retval; -} - - diff --git a/Generals/Code/Libraries/Source/WWVegas/WW3D2/segline.h b/Generals/Code/Libraries/Source/WWVegas/WW3D2/segline.h deleted file mode 100644 index cda5703123e..00000000000 --- a/Generals/Code/Libraries/Source/WWVegas/WW3D2/segline.h +++ /dev/null @@ -1,182 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** 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 *** - *********************************************************************************************** - * * - * Project Name : G * - * * - * $Archive:: /Commando/Code/ww3d2/segline.h $* - * * - * $Author:: Greg_h $* - * * - * $Modtime:: 6/13/01 4:09p $* - * * - * $Revision:: 12 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#if defined(_MSC_VER) -#pragma once -#endif - -#ifndef SEGLINE_H -#define SEGLINE_H - -#include "rendobj.h" -#include "shader.h" -#include "simplevec.h" -#include "seglinerenderer.h" - - -class TextureClass; - -/* -** SegmentedLineClass -- a render object for rendering thick segmented lines. -*/ -class SegmentedLineClass : public RenderObjClass -{ - public: - - SegmentedLineClass(void); - SegmentedLineClass(const SegmentedLineClass & src); - SegmentedLineClass & operator = (const SegmentedLineClass &that); - virtual ~SegmentedLineClass(void); - - void Reset_Line(void); - - /* - ** SegmentedLineClass interface: - */ - - // These are segment points, and include the start and end point of the - // entire line. Therefore there must be at least two. - void Set_Points(unsigned int num_points, Vector3 *locs); - int Get_Num_Points(void); - - // Set object-space location for a given point. - // NOTE: If given position beyond end of point list, do nothing. - void Set_Point_Location(unsigned int point_idx, const Vector3 &location); - - // Get object-space location for a given point. - void Get_Point_Location(unsigned int point_idx, Vector3 &loc); - - // Modify the line by adding and removing points - void Add_Point(const Vector3 & location); - void Delete_Point(unsigned int point_idx); - - // Get/set global properties (which affect all line segments) - TextureClass * Get_Texture(void); - ShaderClass Get_Shader(void); - - float Get_Width(void); - void Get_Color(Vector3 &color); - float Get_Opacity(void); - float Get_Noise_Amplitude(void); - float Get_Merge_Abort_Factor(void); - unsigned int Get_Subdivision_Levels(void); - SegLineRendererClass::TextureMapMode Get_Texture_Mapping_Mode(void); - float Get_Texture_Tile_Factor(void); - Vector2 Get_UV_Offset_Rate(void); - int Is_Merge_Intersections(void); - int Is_Freeze_Random(void); - int Is_Sorting_Disabled(void); - int Are_End_Caps_Enabled(void); - - void Set_Texture(TextureClass *texture); - void Set_Shader(ShaderClass shader); - void Set_Width(float width); - void Set_Color(const Vector3 &color); - void Set_Opacity(float opacity); - void Set_Noise_Amplitude(float amplitude); - void Set_Merge_Abort_Factor(float factor); - void Set_Subdivision_Levels(unsigned int levels); - void Set_Texture_Mapping_Mode(SegLineRendererClass::TextureMapMode mode); - // WARNING! Do NOT set the tile factor to be too high (should be less than 8) or negative - //performance impact will result! - void Set_Texture_Tile_Factor(float factor); - void Set_UV_Offset_Rate(const Vector2 &rate); - void Set_Merge_Intersections(int onoff); - void Set_Freeze_Random(int onoff); - void Set_Disable_Sorting(int onoff); - void Set_End_Caps(int onoff); - - ///////////////////////////////////////////////////////////////////////////// - // Render Object Interface - Cloning and Identification - ///////////////////////////////////////////////////////////////////////////// - virtual RenderObjClass * Clone(void) const; - virtual int Class_ID(void) const { return CLASSID_SEGLINE; } - virtual int Get_Num_Polys(void) const; - - ///////////////////////////////////////////////////////////////////////////// - // Render Object Interface - Rendering - ///////////////////////////////////////////////////////////////////////////// - virtual void Render(RenderInfoClass & rinfo); - - ///////////////////////////////////////////////////////////////////////////// - // Render Object Interface - Bounding Volumes - ///////////////////////////////////////////////////////////////////////////// - virtual void Get_Obj_Space_Bounding_Sphere(SphereClass & sphere) const; - virtual void Get_Obj_Space_Bounding_Box(AABoxClass & box) const; - - ///////////////////////////////////////////////////////////////////////////// - // Render Object Interface - Predictive LOD - ///////////////////////////////////////////////////////////////////////////// - virtual void Prepare_LOD(CameraClass &camera); - virtual void Increment_LOD(void); - virtual void Decrement_LOD(void); - virtual float Get_Cost(void) const; - virtual float Get_Value(void) const; - virtual float Get_Post_Increment_Value(void) const; - virtual void Set_LOD_Level(int lod); - virtual int Get_LOD_Level(void) const; - virtual int Get_LOD_Count(void) const; - - ///////////////////////////////////////////////////////////////////////////// - // Render Object Interface - Attributes, Options, Properties, etc - ///////////////////////////////////////////////////////////////////////////// -// virtual void Set_Texture_Reduction_Factor(float trf); - - /////////////////////////////////////////////////////////////////////////////////////////////////////////////// - // Render Object Interface - Collision Detection - /////////////////////////////////////////////////////////////////////////////////////////////////////////////// - virtual bool Cast_Ray(RayCollisionTestClass & raytest); - - protected: - - void Render_Seg_Line(RenderInfoClass & rinfo); - - private: - - // Subdivision properties - unsigned int MaxSubdivisionLevels; - - // Normalized screen area - used for LOD purposes - float NormalizedScreenArea; - - // Per-point location array - SimpleDynVecClass PointLocations; - - // LineRenderer, contains most of the line settings. - SegLineRendererClass LineRenderer; -}; - -#endif // SEGLINE_H diff --git a/Generals/Code/Libraries/Source/WWVegas/WW3D2/seglinerenderer.cpp b/Generals/Code/Libraries/Source/WWVegas/WW3D2/seglinerenderer.cpp deleted file mode 100644 index 019091b0a1a..00000000000 --- a/Generals/Code/Libraries/Source/WWVegas/WW3D2/seglinerenderer.cpp +++ /dev/null @@ -1,1320 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** 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 *** - *********************************************************************************************** - * * - * Project Name : ww3d * - * * - * $Archive:: /Commando/Code/ww3d2/seglinerenderer.cpp $* - * * - * Original Author:: Greg Hjelstrom * - * * - * $Author:: Kenny Mitchell * - * * - * $Modtime:: 06/26/02 4:04p $* - * * - * $Revision:: 5 $* - * * - * 06/26/02 KM Matrix name change to avoid MAX conflicts * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#include "seglinerenderer.h" -#include "ww3d.h" -#include "rinfo.h" -#include "dx8wrapper.h" -#include "sortingrenderer.h" -#include "vp.h" -#include "Vector3i.h" -#include "RANDOM.H" -#include "v3_rnd.h" -#include "meshgeometry.h" - - -/* We have chunking logic which handles N segments at a time. To simplify the subdivision logic, -** we will ensure that N is a power of two and that N >= 2^MAX_SEGLINE_SUBDIV_LEVELS, so that the -** subdivision logic can be inside the chunking loop. -*/ - -#if MAX_SEGLINE_SUBDIV_LEVELS > 7 -#define SEGLINE_CHUNK_SIZE (1 << MAX_SEGLINE_SUBDIV_LEVELS) -#else -#define SEGLINE_CHUNK_SIZE (128) -#endif - -#ifdef RTS_INTERNAL -// for occasional debugging... -//#pragma optimize("", off) -//#pragma MESSAGE("************************************** WARNING, optimization disabled for debugging purposes") -#endif - -#define MAX_SEGLINE_POINT_BUFFER_SIZE (1 + SEGLINE_CHUNK_SIZE) -// This macro depends on the assumption that each line segment is two polys. -#define MAX_SEGLINE_POLY_BUFFER_SIZE (SEGLINE_CHUNK_SIZE * 2) - - - - -SegLineRendererClass::SegLineRendererClass(void) : - Texture(NULL), - Shader(ShaderClass::_PresetAdditiveSpriteShader), - Width(0.0f), - Color(Vector3(1,1,1)), - Opacity(1.0f), - SubdivisionLevel(0), - NoiseAmplitude(0.0f), - MergeAbortFactor(1.5f), - TextureTileFactor(1.0f), - LastUsedSyncTime(WW3D::Get_Sync_Time()), - CurrentUVOffset(0.0f,0.0f), - UVOffsetDeltaPerMS(0.0f, 0.0f), - Bits(DEFAULT_BITS), - m_vertexBufferSize(0), - m_vertexBuffer(NULL) -{ - // EMPTY -} - -SegLineRendererClass::SegLineRendererClass(const SegLineRendererClass & that) : - Texture(NULL), - Shader(ShaderClass::_PresetAdditiveSpriteShader), - Width(0.0f), - Color(Vector3(1,1,1)), - Opacity(1.0f), - SubdivisionLevel(0), - NoiseAmplitude(0.0f), - MergeAbortFactor(1.5f), - TextureTileFactor(1.0f), - LastUsedSyncTime(that.LastUsedSyncTime), - CurrentUVOffset(0.0f,0.0f), - UVOffsetDeltaPerMS(0.0f, 0.0f), - Bits(DEFAULT_BITS), - m_vertexBufferSize(0), - m_vertexBuffer(NULL) -{ - *this = that; -} - -SegLineRendererClass & SegLineRendererClass::operator = (const SegLineRendererClass & that) -{ - if (this != &that) { - REF_PTR_SET(Texture,that.Texture); - Shader = that.Shader; - Width = that.Width; - Color = that.Color; - Opacity = that.Opacity; - SubdivisionLevel = that.SubdivisionLevel; - NoiseAmplitude = that.NoiseAmplitude; - MergeAbortFactor = that.MergeAbortFactor; - TextureTileFactor = that.TextureTileFactor; - LastUsedSyncTime = that.LastUsedSyncTime; - CurrentUVOffset = that.CurrentUVOffset; - UVOffsetDeltaPerMS = that.UVOffsetDeltaPerMS; - Bits = that.Bits; - // Don't modify m_vertexBufferSize and m_vertexBuffer - } - return *this; -} - -SegLineRendererClass::~SegLineRendererClass(void) -{ - REF_PTR_RELEASE(Texture); - delete [] m_vertexBuffer; -} - -void SegLineRendererClass::Init(const W3dEmitterLinePropertiesStruct & props) -{ - // translate the flags - Set_Merge_Intersections(props.Flags & W3D_ELINE_MERGE_INTERSECTIONS); - Set_Freeze_Random(props.Flags & W3D_ELINE_FREEZE_RANDOM); - Set_Disable_Sorting(props.Flags & W3D_ELINE_DISABLE_SORTING); - Set_End_Caps(props.Flags & W3D_ELINE_END_CAPS); - - int texture_mode = ((props.Flags & W3D_ELINE_TEXTURE_MAP_MODE_MASK) >> W3D_ELINE_TEXTURE_MAP_MODE_OFFSET); - switch (texture_mode) - { - case W3D_ELINE_UNIFORM_WIDTH_TEXTURE_MAP: - Set_Texture_Mapping_Mode(UNIFORM_WIDTH_TEXTURE_MAP); - break; - case W3D_ELINE_UNIFORM_LENGTH_TEXTURE_MAP: - Set_Texture_Mapping_Mode(UNIFORM_LENGTH_TEXTURE_MAP); - break; - case W3D_ELINE_TILED_TEXTURE_MAP: - Set_Texture_Mapping_Mode(TILED_TEXTURE_MAP); - break; - }; - - // install all other settings - Set_Current_Subdivision_Level(props.SubdivisionLevel); - Set_Noise_Amplitude(props.NoiseAmplitude); - Set_Merge_Abort_Factor(props.MergeAbortFactor); - Set_Texture_Tile_Factor(props.TextureTileFactor); - Set_UV_Offset_Rate(Vector2(props.UPerSec,props.VPerSec)); -} - - -void SegLineRendererClass::Set_Texture(TextureClass *texture) -{ - REF_PTR_SET(Texture,texture); -} - -TextureClass * SegLineRendererClass::Get_Texture(void) const -{ - if (Texture != NULL) { - Texture->Add_Ref(); - } - return Texture; -} - -void SegLineRendererClass::Set_Current_UV_Offset(const Vector2 & offset) -{ - CurrentUVOffset = offset; -} - -void SegLineRendererClass::Set_Texture_Tile_Factor(float factor) -{ - // Care should be taken to avoid tiling a texture too many times over a single polygon; - // otherwise performance may be adversely affected. - ///@todo: I raised this number and didn't see much difference on our min-spec. -MW - const static float MAX_LINE_TILING_FACTOR = 50.0f; - if (factor > MAX_LINE_TILING_FACTOR) { - WWDEBUG_SAY(("Texture (%s) Tile Factor (%.2f) too large in SegLineRendererClass!\r\n", Get_Texture()->Get_Texture_Name(), TextureTileFactor)); - factor = MAX_LINE_TILING_FACTOR; - } else { - factor = MAX(factor, 0.0f); - } - TextureTileFactor = factor; -} - -void SegLineRendererClass::Reset_Line(void) -{ - LastUsedSyncTime = WW3D::Get_Sync_Time(); - CurrentUVOffset.Set(0.0f,0.0f); -} - - - -void SegLineRendererClass::Render -( - RenderInfoClass & rinfo, - const Matrix3D & transform, - unsigned int num_points, - Vector3 * points, - const SphereClass & obj_sphere, - Vector4 * rgbas -) -{ - Matrix4x4 view; - DX8Wrapper::Get_Transform(D3DTS_VIEW,view); - - Matrix4x4 identity(true); - DX8Wrapper::Set_Transform(D3DTS_WORLD,identity); - DX8Wrapper::Set_Transform(D3DTS_VIEW,identity); - - /* - ** Handle texture UV offset animation (done once for entire line). - */ - unsigned int delta = WW3D::Get_Sync_Time() - LastUsedSyncTime; - float del = (float)delta; - Vector2 uv_offset = CurrentUVOffset + UVOffsetDeltaPerMS * del; - - // ensure offsets are in [0, 1] range: - uv_offset.X = uv_offset.X - floorf(uv_offset.X); - uv_offset.Y = uv_offset.Y - floorf(uv_offset.Y); - - // Update state - CurrentUVOffset = uv_offset; - LastUsedSyncTime = WW3D::Get_Sync_Time(); - - // Used later - TextureMapMode map_mode = Get_Texture_Mapping_Mode(); - - /* - ** Process line geometry: - */ - - // This has been tweaked to produce empirically good results. - const float parallel_factor = 0.9f; - - // We reduce the chunk size to take account of subdivision levels (so that the # of points - // after subdivision will be no higher than the allowed maximum). We know this will not reduce - // the chunk size below 2, since the chunk size must be at least two to the power of the - // maximum allowable number of subdivisions. The plus 1 is because #points = #segments + 1. - unsigned int chunk_size = (SEGLINE_CHUNK_SIZE >> SubdivisionLevel) + 1; - if (chunk_size > num_points) chunk_size = num_points; - - // Chunk through the points (we increment by chunk_size - 1 because the last point of this - // chunk must be reused as the first point of the next chunk. This is also the reason we stop - // when chidx = NumPoints - 1: the last point has already been processed in the previous - // iteration so we don't need another one). - for (unsigned int chidx = 0; chidx < num_points - 1; chidx += (chunk_size - 1)) { - unsigned int point_cnt = num_points - chidx; - point_cnt = MIN(point_cnt, chunk_size); - - // We use these different loop indices (which loop INSIDE a chunk) to improve readability: - unsigned int pidx; // Point index - unsigned int sidx; // Segment index - unsigned int iidx; // Intersection index - - - /* - ** Transform points in chunk from objectspace to eyespace: - */ - - Vector3 xformed_pts[MAX_SEGLINE_POINT_BUFFER_SIZE]; - - Matrix3D view2( view[0].X,view[0].Y,view[0].Z,view[0].W, - view[1].X,view[1].Y,view[1].Z,view[1].W, - view[2].X,view[2].Y,view[2].Z,view[2].W); - -#ifdef ALLOW_TEMPORARIES - Matrix3D modelview=view2*transform; -#else - Matrix3D modelview; - modelview.mul(view2, transform); -#endif - - VectorProcessorClass::Transform(&xformed_pts[0], - &points[chidx], modelview, point_cnt); - - - /* - ** Prepare v parameter per point - used for texture mapping (esp. tiled mapping mode) - */ - - float base_tex_v[MAX_SEGLINE_POINT_BUFFER_SIZE]; - float u_values[2]; - switch (map_mode) { - case UNIFORM_WIDTH_TEXTURE_MAP: - for (pidx = 0; pidx < point_cnt; pidx++) { - // All 0 - base_tex_v[pidx] = 0.0f; - } - u_values[0] = 0.0f; - u_values[1] = 1.0f; - break; - case UNIFORM_LENGTH_TEXTURE_MAP: - for (pidx = 0; pidx < point_cnt; pidx++) { - // Increasing V - base_tex_v[pidx] = (float)(pidx + chidx) * TextureTileFactor; - } - u_values[0] = 0.0f; - u_values[1] = 0.0f; - break; - case TILED_TEXTURE_MAP: - for (pidx = 0; pidx < point_cnt; pidx++) { - // Increasing V - base_tex_v[pidx] = (float)(pidx + chidx) * TextureTileFactor; - } - u_values[0] = 0.0f; - u_values[1] = 1.0f; - break; - } - - - /* - ** Fractal noise recursive subdivision: - ** We find the midpoint for each section, apply a random offset, and recurse. We also find - ** the average V coordinate of the endpoints which is the midpoint V (for tiled texture - ** mapping). - */ - - Vector3 xformed_subdiv_pts[MAX_SEGLINE_POINT_BUFFER_SIZE]; - float subdiv_tex_v[MAX_SEGLINE_POINT_BUFFER_SIZE]; - Vector4 subdiv_rgbas[MAX_SEGLINE_POINT_BUFFER_SIZE]; - unsigned int sub_point_cnt; - - Vector4 *rgbasPointer = rgbas ? &rgbas[ chidx ] : NULL; - - subdivision_util(point_cnt, xformed_pts, base_tex_v, &sub_point_cnt, xformed_subdiv_pts, subdiv_tex_v, rgbasPointer, subdiv_rgbas); - - // Start using subdivided points from now on - Vector3 *points = xformed_subdiv_pts; - float *tex_v = subdiv_tex_v; - Vector4 *diffuse = subdiv_rgbas; - point_cnt = sub_point_cnt; - - - /* - ** Calculate line segment edge planes: - */ - - // For each line segment find the two silhouette planes from eyepoint to the line segment - // cylinder. To simplify we do not find the tangent planes but intersect the cylinder with a - // plane passing through its axis and perpendicular to the eye vector, find the edges of the - // resulting rectangle, and create planes through these edges and the eyepoint. - // Note that these planes are represented as a single normal rather than a normal and a - // distance; this is because they pass through the origin (eyepoint) so their distance is - // always zero. - - // Since the line has thickness, each segment has two edges. We name these 'top' and - // 'bottom' - note however that the top/bottom distinction does not relate to screen - // up/down and remains consistent throughout the segmented line. - enum SegmentEdge { - FIRST_EDGE = 0, // For loop conditions - TOP_EDGE = 0, // Top Edge - BOTTOM_EDGE = 1, // Bottom Edge - MAX_EDGE = 1, // For loop conditions - NUM_EDGES = 2 // For array allocations - }; - - bool switch_edges = false; - - // We have dummy segments for "before the first point" and "after the last point" - in these - // segments the top and bottom edge are the same - they are a perpendicular plane defined by - // the endpoint vertices. This is so we can merge intersections properly for the first and - // last points. - - struct LineSegment { - Vector3 StartPlane; - Vector3 EdgePlane[NUM_EDGES]; - }; - - // # segments = numpoints + 1 (numpoints - 1, plus two dummy segments) - LineSegment segment[MAX_SEGLINE_POINT_BUFFER_SIZE + 1]; - - // Intersections. This has data for two edges (top or bottom) intersecting. - struct LineSegmentIntersection { - unsigned int PointCount; // How many points does this intersection represent - unsigned int NextSegmentID; // ID of segment after this intersection - Vector3 Direction; // Calculated intersection direction line - Vector3 Point; // Averaged 3D point on the line which this represents - float TexV; // Averaged texture V coordinate of points - Vector4 RGBA; // Averaged RGBA of the points - bool Fold; // Does the line fold over at this intersection? - bool Parallel; // Edges at this intersection are parallel (or almost-) - }; - - // Used to calculate the edge planes - float radius = Width * 0.5f; - - // The number of intersections is the number of points minus 2. However, we store - // intersection records for the first and last point, even though they are not really - // intersections. The reason we do this is for the intersection merging - the vertices for - // the first and last points can get merged just like any other intersection. Also, we have - // a dummy intersection record before the first point - this is because we want "previous - // segments" for the first point and each intersection only has an index for the next - // segment. - LineSegmentIntersection intersection[MAX_SEGLINE_POINT_BUFFER_SIZE + 1][NUM_EDGES]; - - for (sidx = 1; sidx < point_cnt; sidx++) { // #segments = #points - 1 (+ 2 dummy segments) - - Vector3 &curr_point = points[sidx - 1]; - Vector3 &next_point = points[sidx]; - if (Equal_Within_Epsilon(curr_point, next_point, 0.0001f)) - { - next_point.X += 0.001f; - } - - // We temporarily store the segment direction in the segment's StartPlane (since it is - // used to calculate the StartPlane later). - Vector3 &segdir = segment[sidx].StartPlane; - segdir = next_point - curr_point; - segdir.Normalize(); - - // Find nearest point on infinite line to eye (origin) - Vector3 nearest = curr_point + segdir * -Vector3::Dot_Product(segdir, curr_point); - - // Find top and bottom points on cylinder - Vector3 offset; - Vector3::Cross_Product(segdir, nearest, &offset); - offset.Normalize(); - Vector3 top = curr_point + offset * radius; - Vector3 bottom = curr_point + offset * -radius; - - // Find planes through top/bottom points and eyepoint. In addition to the two points, we - // know that the planes are parallel to the line segment. - Vector3 top_normal; - Vector3::Cross_Product(top, segdir, &top_normal); - top_normal.Normalize(); - segment[sidx].EdgePlane[TOP_EDGE] = top_normal; - - Vector3 bottom_normal; - Vector3::Cross_Product(segdir, bottom, &bottom_normal); - bottom_normal.Normalize(); - segment[sidx].EdgePlane[BOTTOM_EDGE] = bottom_normal; - - // If the visual angle between the previous and current line segments (we use the angle - // between the planes defined by each line segment and the eyepoint) is less than 90 - // degrees, switch the top and bottom edges for the current and subsequent segments and - // mark the intersection as having a fold - if (sidx > 1) { - - Vector3 prev_plane; - Vector3::Cross_Product(points[sidx - 2], curr_point, &prev_plane); - prev_plane.Normalize(); - - Vector3 curr_plane; - Vector3::Cross_Product(curr_point, next_point, &curr_plane); - curr_plane.Normalize(); - - if (Vector3::Dot_Product(prev_plane, curr_plane) < 0.0f) { - switch_edges = !switch_edges; - intersection[sidx][TOP_EDGE].Fold = true; - intersection[sidx][BOTTOM_EDGE].Fold = true; - } else { - intersection[sidx][TOP_EDGE].Fold = false; - intersection[sidx][BOTTOM_EDGE].Fold = false; - } - } - - if (switch_edges) { - // We switch signs so the normals will always point inwards - segment[sidx].EdgePlane[TOP_EDGE] = -bottom_normal; - segment[sidx].EdgePlane[BOTTOM_EDGE] = -top_normal; - } - - } - - // The two dummy segments for the clipping edges of the first and last real segments will be - // defined later, with the first and last intersections. - - - /* - ** Calculate segment edge intersections: - */ - - unsigned int numsegs = point_cnt - 1; // Doesn't include the two dummy segments - unsigned int num_intersections[NUM_EDGES]; - - // These include the 1st, last point "intersections", not the pre-first dummy intersection - num_intersections[TOP_EDGE] = point_cnt; - num_intersections[BOTTOM_EDGE] = point_cnt; - - // Initialize pre-first point dummy intersection record (only NextSegmentID will be used). - intersection[0][TOP_EDGE].PointCount = 0; // Should never be used - intersection[0][TOP_EDGE].NextSegmentID = 0; // Points to first dummy segment - intersection[0][TOP_EDGE].Direction.Set(1,0,0); // Should never be used - intersection[0][TOP_EDGE].Point.Set(0,0,0); // Should never be used - intersection[0][TOP_EDGE].TexV = 0.0f; // Should never be used - intersection[0][TOP_EDGE].RGBA.Set(0, 0, 0, 0); // Should never be used - intersection[0][TOP_EDGE].Fold = true; // Should never be used - intersection[0][TOP_EDGE].Parallel = false; // Should never be used - intersection[0][BOTTOM_EDGE].PointCount = 0; // Should never be used - intersection[0][BOTTOM_EDGE].NextSegmentID = 0; // Points to first dummy segment - intersection[0][BOTTOM_EDGE].Point.Set(0,0,0); // Should never be used - intersection[0][BOTTOM_EDGE].TexV = 0.0f; // Should never be used - intersection[0][BOTTOM_EDGE].RGBA.Set(0, 0, 0, 0); // Should never be used - intersection[0][BOTTOM_EDGE].Direction.Set(1,0,0); // Should never be used - intersection[0][BOTTOM_EDGE].Fold = true; // Should never be used - intersection[0][BOTTOM_EDGE].Parallel = false; // Should never be used - - // Initialize first point "intersection" record. - intersection[1][TOP_EDGE].PointCount = 1; - intersection[1][TOP_EDGE].NextSegmentID = 1; - intersection[1][TOP_EDGE].Point = points[0]; - intersection[1][TOP_EDGE].TexV = tex_v[0]; - intersection[1][TOP_EDGE].RGBA = diffuse[0]; - intersection[1][TOP_EDGE].Fold = true; - intersection[1][TOP_EDGE].Parallel = false; - intersection[1][BOTTOM_EDGE].PointCount = 1; - intersection[1][BOTTOM_EDGE].NextSegmentID = 1; - intersection[1][BOTTOM_EDGE].Point = points[0]; - intersection[1][BOTTOM_EDGE].TexV = tex_v[0]; - intersection[1][BOTTOM_EDGE].RGBA = diffuse[0]; - intersection[1][BOTTOM_EDGE].Fold = true; - intersection[1][BOTTOM_EDGE].Parallel = false; - - // Find closest point to 1st top/bottom segment edge plane, and convert to direction vector - // and dummy segment edge plane. - - Vector3 top; - Vector3 bottom; - - Vector3 &first_point = points[0]; - Vector3 *first_plane = &(segment[1].EdgePlane[0]); - top = first_point - first_plane[TOP_EDGE] * Vector3::Dot_Product(first_plane[TOP_EDGE], first_point); - top.Normalize(); - intersection[1][TOP_EDGE].Direction = top; - bottom = first_point - first_plane[BOTTOM_EDGE] * Vector3::Dot_Product(first_plane[BOTTOM_EDGE], first_point); - bottom.Normalize(); - intersection[1][BOTTOM_EDGE].Direction = bottom; - - Vector3 segdir = points[1] - points[0]; - segdir.Normalize(); // Is this needed? Probably not - remove later when all works - Vector3 start_pl; - Vector3::Cross_Product(top, bottom, &start_pl); - start_pl.Normalize(); - float dp = Vector3::Dot_Product(segdir, start_pl); - if (dp > 0.0f) { - segment[0].StartPlane = segment[0].EdgePlane[TOP_EDGE] = segment[0].EdgePlane[BOTTOM_EDGE] = start_pl; - } else { - segment[0].StartPlane = segment[0].EdgePlane[TOP_EDGE] = segment[0].EdgePlane[BOTTOM_EDGE] = -start_pl; - } - - // Initialize StartPlane for the first "real" segment - segment[1].StartPlane = segment[0].StartPlane; - - // Initialize last point "intersection" record. - unsigned int last_isec = num_intersections[TOP_EDGE]; // Same # top, bottom intersections - - intersection[last_isec][TOP_EDGE].PointCount = 1; - intersection[last_isec][TOP_EDGE].NextSegmentID = numsegs + 1; // Last dummy segment - intersection[last_isec][TOP_EDGE].Point = points[point_cnt - 1]; - intersection[last_isec][TOP_EDGE].TexV = tex_v[point_cnt - 1]; - intersection[last_isec][TOP_EDGE].RGBA = diffuse[point_cnt - 1]; - intersection[last_isec][TOP_EDGE].Fold = true; - intersection[last_isec][TOP_EDGE].Parallel = false; - intersection[last_isec][BOTTOM_EDGE].PointCount = 1; - intersection[last_isec][BOTTOM_EDGE].NextSegmentID = numsegs + 1;// Last dummy segment - intersection[last_isec][BOTTOM_EDGE].Point = points[point_cnt - 1]; - intersection[last_isec][BOTTOM_EDGE].TexV = tex_v[point_cnt - 1]; - intersection[last_isec][BOTTOM_EDGE].RGBA = diffuse[point_cnt - 1]; - intersection[last_isec][BOTTOM_EDGE].Fold = true; - intersection[last_isec][BOTTOM_EDGE].Parallel = false; - - // Find closest point to last top/bottom segment edge plane, and convert to direction vector - // and dummy segment edge vector - - Vector3 &last_point = points[point_cnt - 1]; - Vector3 *last_plane = &(segment[numsegs].EdgePlane[0]); - top = last_point - last_plane[TOP_EDGE] * Vector3::Dot_Product(last_plane[TOP_EDGE], last_point); - top.Normalize(); - intersection[last_isec][TOP_EDGE].Direction = top; - bottom = last_point - last_plane[BOTTOM_EDGE] * Vector3::Dot_Product(last_plane[BOTTOM_EDGE], last_point); - bottom.Normalize(); - intersection[last_isec][BOTTOM_EDGE].Direction = bottom; - - segdir = points[point_cnt - 1] - points[point_cnt - 2]; - segdir.Normalize(); // Is this needed? Probably not - remove later when all works - Vector3::Cross_Product(top, bottom, &start_pl); - start_pl.Normalize(); - dp = Vector3::Dot_Product(segdir, start_pl); - if (dp > 0.0f) { - segment[numsegs + 1].StartPlane = segment[numsegs + 1].EdgePlane[TOP_EDGE] = - segment[numsegs + 1].EdgePlane[BOTTOM_EDGE] = start_pl; - } else { - segment[numsegs + 1].StartPlane = segment[numsegs + 1].EdgePlane[TOP_EDGE] = - segment[numsegs + 1].EdgePlane[BOTTOM_EDGE] = -start_pl; - } - - // Calculate midpoint segment intersections. There are 2 segment intersections for each - // point: top and bottom (due to the fact that the segments have width, so they have a top - // edge and a bottom edge). Note that the top/bottom distinction does not relate to screen - // up/down. Since each segment edge is represented by a plane passing through the origin - // (eyepoint), the intersection of two such is a line passing through the origin, which is - // represented as a normalized direction vector. - // We use both segment intersections to define the startplane for the segment which begins - // at that intersection. - - float vdp; - - for (iidx = 2; iidx < num_intersections[TOP_EDGE]; iidx++) { - - // Relevant midpoint: - Vector3 &midpoint = points[iidx - 1]; - float mid_tex_v = tex_v[iidx - 1]; - Vector4 mid_diffuse = diffuse[iidx - 1]; - - // Initialize misc. fields - intersection[iidx][TOP_EDGE].PointCount = 1; - intersection[iidx][TOP_EDGE].NextSegmentID = iidx; - intersection[iidx][TOP_EDGE].Point = midpoint; - intersection[iidx][TOP_EDGE].TexV = mid_tex_v; - intersection[iidx][TOP_EDGE].RGBA = mid_diffuse; - intersection[iidx][BOTTOM_EDGE].PointCount = 1; - intersection[iidx][BOTTOM_EDGE].NextSegmentID = iidx; - intersection[iidx][BOTTOM_EDGE].Point = midpoint; - intersection[iidx][BOTTOM_EDGE].TexV = mid_tex_v; - intersection[iidx][BOTTOM_EDGE].RGBA = mid_diffuse; - - // Intersection calculation: if the top/bottom planes of both adjoining segments are not - // very close to being parallel, intersect them to get top/bottom intersection lines. If - // the planes are almost parallel, pick one, find the point on the plane closest to the - // midpoint, and convert that point to a line direction vector. - - // Top: - vdp = Vector3::Dot_Product(segment[iidx - 1].EdgePlane[TOP_EDGE], segment[iidx].EdgePlane[TOP_EDGE]); - if (fabs(vdp) < parallel_factor) { - - // Not parallel - intersect planes to get line (get vector, normalize it, ensure it is - // pointing towards the midpoint) - Vector3::Cross_Product(segment[iidx - 1].EdgePlane[TOP_EDGE], segment[iidx].EdgePlane[TOP_EDGE], - &(intersection[iidx][TOP_EDGE].Direction)); - intersection[iidx][TOP_EDGE].Direction.Normalize(); - if (Vector3::Dot_Product(intersection[iidx][TOP_EDGE].Direction, midpoint) < 0.0f) { - intersection[iidx][TOP_EDGE].Direction = -intersection[iidx][TOP_EDGE].Direction; - } - - intersection[iidx][TOP_EDGE].Parallel = false; - - } else { - - // Parallel (or almost): find point on av. plane closest to midpoint, convert to line - - // Ensure average calculation is numerically stable: - Vector3 pl; - if (vdp > 0.0f) { - pl = segment[iidx - 1].EdgePlane[TOP_EDGE] + segment[iidx].EdgePlane[TOP_EDGE]; - } else { - pl = segment[iidx - 1].EdgePlane[TOP_EDGE] - segment[iidx].EdgePlane[TOP_EDGE]; - } - pl.Normalize(); - - intersection[iidx][TOP_EDGE].Direction = midpoint - pl * Vector3::Dot_Product(pl, midpoint); - intersection[iidx][TOP_EDGE].Direction.Normalize(); - - intersection[iidx][TOP_EDGE].Parallel = true; - } - - // Bottom: - vdp = Vector3::Dot_Product(segment[iidx - 1].EdgePlane[BOTTOM_EDGE], segment[iidx].EdgePlane[BOTTOM_EDGE]); - if (fabs(vdp) < parallel_factor) { - - // Not parallel - intersect planes to get line (get vector, normalize it, ensure it is - // pointing towards the midpoint) - Vector3::Cross_Product(segment[iidx - 1].EdgePlane[BOTTOM_EDGE], segment[iidx].EdgePlane[BOTTOM_EDGE], - &(intersection[iidx][BOTTOM_EDGE].Direction)); - intersection[iidx][BOTTOM_EDGE].Direction.Normalize(); - if (Vector3::Dot_Product(intersection[iidx][BOTTOM_EDGE].Direction, midpoint) < 0.0f) { - intersection[iidx][BOTTOM_EDGE].Direction = -intersection[iidx][BOTTOM_EDGE].Direction; - } - - intersection[iidx][BOTTOM_EDGE].Parallel = false; - - } else { - - // Parallel (or almost): find point on av. plane closest to midpoint, convert to line - - // Ensure average calculation is numerically stable: - Vector3 pl; - if (vdp > 0.0f) { - pl = segment[iidx - 1].EdgePlane[BOTTOM_EDGE] + segment[iidx].EdgePlane[BOTTOM_EDGE]; - } else { - pl = segment[iidx - 1].EdgePlane[BOTTOM_EDGE] - segment[iidx].EdgePlane[BOTTOM_EDGE]; - } - pl.Normalize(); - - intersection[iidx][BOTTOM_EDGE].Direction = midpoint - pl * Vector3::Dot_Product(pl, midpoint); - intersection[iidx][BOTTOM_EDGE].Direction.Normalize(); - - intersection[iidx][BOTTOM_EDGE].Parallel = true; - } - - // Find StartPlane: - Vector3::Cross_Product(intersection[iidx][TOP_EDGE].Direction, intersection[iidx][BOTTOM_EDGE].Direction, &start_pl); - start_pl.Normalize(); - dp = Vector3::Dot_Product(segment[iidx].StartPlane, start_pl); - if (dp > 0.0f) { - segment[iidx].StartPlane = start_pl; - } else { - segment[iidx].StartPlane = -start_pl; - } - - } // for iidx - - - /* - ** Intersection merging: when an intersection is inside an adjacent segment and certain - ** other conditions hold true, we need to merge intersections to avoid visual glitches - ** caused by the polys folding over on themselves. - */ - - if (Is_Merge_Intersections()) { - - // Since we are merging the intersections in-place, we have two index variables, a "read - // index" and a "write index". - unsigned int iidx_r; - unsigned int iidx_w; - - // The merges will be repeated in multiple passes until none are performed. The reason - // for this is that one merge may cause the need for another merge elsewhere. - bool merged = true; - - while (merged) { - - merged = false; - - SegmentEdge edge; - for (edge = FIRST_EDGE; edge <= MAX_EDGE; edge = (SegmentEdge)((int)edge + 1)) { - // Merge top and bottom edge intersections: loop through the intersections from the - // first intersection to the penultimate intersection, for each intersection check - // if it needs to be merged with the next one (which is why the loop doesn't go all - // the way to the last intersection). We start at 1 because 0 is the dummy - // "pre-first-point" intersection. - unsigned int num_isects = num_intersections[edge]; // Capture here because will change inside loop - for (iidx_r = 1, iidx_w = 1; iidx_r < num_isects; iidx_r++, iidx_w++) { - - // Check for either of two possible reasons to merge this intersection with the - // next: either the segment on the far side of the next intersection overlaps - // this intersection, or the previous segment overlaps the next intersection. - // Note that some other conditions need to be true as well. - - // Note: iidx_r is used for anything at or after the current position, iidx_w is - // used for anything before the current position (previous positions have - // potentially already been merged). - // Note: iidx_r is used for anything at or after the current position, iidx_w is - // used for anything before the current position (previous positions have - // potentially already been merged). - LineSegmentIntersection *curr_int = &(intersection[iidx_r][edge]); - LineSegmentIntersection *next_int = &(intersection[iidx_r + 1][edge]); - LineSegmentIntersection *write_int = &(intersection[iidx_w][edge]); - LineSegmentIntersection *prev_int = &(intersection[iidx_w - 1][edge]); - LineSegment *next_seg = &(segment[next_int->NextSegmentID]); - LineSegment *curr_seg = &(segment[curr_int->NextSegmentID]); - LineSegment *prev_seg = &(segment[prev_int->NextSegmentID]); - - // If this intersection is inside both the start plane and the segment edge - // plane of the segment after the next intersection, merge this edge - // intersection and the next. We repeat merging until no longer needed. - // NOTE - we do not merge across a fold. - while ( (!next_int->Fold && - (Vector3::Dot_Product(curr_int->Direction, next_seg->StartPlane) > 0.0f) && - (Vector3::Dot_Product(curr_int->Direction, next_seg->EdgePlane[edge]) > 0.0f )) || - (!curr_int->Fold && - (Vector3::Dot_Product(next_int->Direction, -curr_seg->StartPlane) > 0.0f) && - (Vector3::Dot_Product(next_int->Direction, prev_seg->EdgePlane[edge]) > 0.0f )) ) { - - // First calculate location of merged intersection - this is so we can abort - // the merge if it yields funky results. - - // Find mean point (weighted so all points have same weighting) - unsigned int new_count = curr_int->PointCount + next_int->PointCount; - float oo_new_count = 1.0f / (float)new_count; - float curr_factor = oo_new_count * (float)curr_int->PointCount; - float next_factor = oo_new_count * (float)curr_int->PointCount; - Vector3 new_point = curr_int->Point * curr_factor + next_int->Point * next_factor; - float new_tex_v = curr_int->TexV * curr_factor + next_int->TexV * next_factor; - Vector4 new_diffuse = curr_int->RGBA * curr_factor + next_int->RGBA * next_factor; - - // Calculate new intersection direction by intersecting prev_seg with next_seg - bool new_parallel; - Vector3 new_direction; - vdp = Vector3::Dot_Product(prev_seg->EdgePlane[edge], next_seg->EdgePlane[edge]); - if (fabs(vdp) < parallel_factor) { - - // Not parallel - intersect planes to get line (get vector, normalize it, - // ensure it is pointing towards the current point) - Vector3::Cross_Product(prev_seg->EdgePlane[edge], next_seg->EdgePlane[edge], &new_direction); - new_direction.Normalize(); - if (Vector3::Dot_Product(new_direction, new_point) < 0.0f) { - new_direction = -new_direction; - } - - new_parallel = false; - - } else { - - // Parallel (or almost). If the current intersection is not parallel, take - // the average plane and intersect it with the skipped plane. If the - // current intersection is parallel, find the average plane, and find the - // direction vector on it closest to the current intersections direction - // vector. - - // Ensure average calculation is numerically stable: - Vector3 pl; - if (vdp > 0.0f) { - pl = prev_seg->EdgePlane[edge] + next_seg->EdgePlane[edge]; - } else { - pl = prev_seg->EdgePlane[edge] - next_seg->EdgePlane[edge]; - } - pl.Normalize(); - - if (curr_int->Parallel) { - new_direction = new_direction - pl * Vector3::Dot_Product(pl, new_direction); - new_direction.Normalize(); - } else { - Vector3::Cross_Product(curr_seg->EdgePlane[edge], pl, &new_direction); - new_direction.Normalize(); - } - - new_parallel = true; - } - - // Now check to see if the merge caused any funky results - if so abort it. - // Currently we check to see if the distance of the direction from the two - // points is larger than the radius times the merge_abort factor. - if (MergeAbortFactor > 0.0f) { - float abort_dist = radius * MergeAbortFactor; - float abort_dist2 = abort_dist * abort_dist; - Vector3 diff_curr = curr_int->Point - - new_direction * Vector3::Dot_Product(curr_int->Point, new_direction); - if (diff_curr.Length2() > abort_dist2) break; - Vector3 next_curr = next_int->Point - - new_direction * Vector3::Dot_Product(next_int->Point, new_direction); - if (next_curr.Length2() > abort_dist2) break; - } - - // Merge edge intersections (curr_int and next_int) into curr_int - merged = true; - - curr_int->Direction = new_direction; - curr_int->Parallel = new_parallel; - curr_int->Point = new_point; - curr_int->TexV = new_tex_v; - curr_int->RGBA = new_diffuse; - curr_int->PointCount = new_count; - curr_int->NextSegmentID = next_int->NextSegmentID; - curr_int->Fold = curr_int->Fold || next_int->Fold; - - // Decrement number of edge intersections - num_intersections[edge]--; - - // Advance iidx_r to shift subsequent entries backwards in result. - iidx_r++; - - // If we are at the end then break: - if (iidx_r == num_isects) { - break; - } - - // Advance next_int and next_seg. - next_int = &(intersection[iidx_r + 1][edge]); - next_seg = &(segment[next_int->NextSegmentID]); - - } // while - - // Copy from "read index" to "write index" - write_int->PointCount = curr_int->PointCount; - write_int->NextSegmentID = curr_int->NextSegmentID; - write_int->Point = curr_int->Point; - write_int->TexV = curr_int->TexV; - write_int->RGBA = curr_int->RGBA; - write_int->Direction = curr_int->Direction; - write_int->Fold = curr_int->Fold; - - } // for iidx - - // If iidx_r is exactly equal to num_isects (rather than being larger by one) at this - // point, this means that the last intersection was not merged with the previous one. In - // this case, we need to do one last copy: - if (iidx_r == num_isects) { - LineSegmentIntersection *write_int = &(intersection[iidx_w][edge]); - LineSegmentIntersection *curr_int = &(intersection[iidx_r][edge]); - write_int->PointCount = curr_int->PointCount; - write_int->NextSegmentID = curr_int->NextSegmentID; - write_int->Point = curr_int->Point; - write_int->TexV = curr_int->TexV; - write_int->RGBA = curr_int->RGBA; - write_int->Direction = curr_int->Direction; - write_int->Fold = curr_int->Fold; - } - -#ifdef ENABLE_WWDEBUGGING - // Testing code - ensure total PointCount fits the number of points - unsigned int total_cnt = 0; - for (unsigned int nidx = 0; nidx <= num_intersections[edge]; nidx++) { - total_cnt += intersection[nidx][edge].PointCount; - } - assert(total_cnt == point_cnt); -#endif - - } // for edge - } // while (merged) - } // if (Is_Merge_Intersections()) - - /* - ** Find vertex positions, generate vertices and triangles: - ** Since we can have top/bottom intersections merged, we need to skip points if both the top - ** and bottom intersections are merged, generate triangle fans if one of the sides is merged - ** and the other isnt, and generate triangle strips otherwise. - */ - - // Configure vertex array and setup renderer. - unsigned int vnum = num_intersections[TOP_EDGE] + num_intersections[BOTTOM_EDGE]; - VertexFormatXYZDUV1 *vArray = getVertexBuffer(vnum); - TriIndex v_index_array[MAX_SEGLINE_POLY_BUFFER_SIZE]; - - // Vertex and triangle indices - unsigned int vidx = 0; - unsigned int tidx = 0; - -// GENERALIZE FOR WHEN NO TEXTURE (DO NOT SET UV IN THESE CASES? NEED TO GENERALIZE FOR DIFFERENT TEXTURING MODES ANYWAY). - - // "Prime the pump" with two vertices (pick nearest point on each direction line): - Vector3 &top_dir = intersection[1][TOP_EDGE].Direction; - top = top_dir * Vector3::Dot_Product(points[0], top_dir); - Vector3 &bottom_dir = intersection[1][BOTTOM_EDGE].Direction; - bottom = bottom_dir * Vector3::Dot_Product(points[0], bottom_dir); - vArray[vidx].x = top.X; - vArray[vidx].y = top.Y; - vArray[vidx].z = top.Z; - vArray[vidx].diffuse = DX8Wrapper::Convert_Color(intersection[1][TOP_EDGE].RGBA); - vArray[vidx].u1 = u_values[0] + uv_offset.X; - vArray[vidx].v1 = intersection[1][TOP_EDGE].TexV + uv_offset.Y; - vidx++; - vArray[vidx].x = bottom.X; - vArray[vidx].y = bottom.Y; - vArray[vidx].z = bottom.Z; - vArray[vidx].diffuse = DX8Wrapper::Convert_Color(intersection[1][BOTTOM_EDGE].RGBA); - vArray[vidx].u1 = u_values[1] + uv_offset.X; - vArray[vidx].v1 = intersection[1][BOTTOM_EDGE].TexV + uv_offset.Y; - vidx++; - - unsigned int last_top_vidx = 0; - unsigned int last_bottom_vidx = 1; - - // Loop over intersections, create new vertices and triangles. - unsigned int top_int_idx = 1; // Skip "pre-first-point" dummy intersection - unsigned int bottom_int_idx = 1; // Skip "pre-first-point" dummy intersection - pidx = 0; - unsigned int residual_top_points = intersection[1][TOP_EDGE].PointCount; - unsigned int residual_bottom_points = intersection[1][BOTTOM_EDGE].PointCount; - - // Reduce both pointcounts by the same amount so the smaller one is 1 (skip points) - unsigned int delta = MIN(residual_top_points, residual_bottom_points) - 1; - residual_top_points -= delta; - residual_bottom_points -= delta; - pidx += delta; - - for (; ; ) { - - if (residual_top_points == 1 && residual_bottom_points == 1) { - // Advance both intersections, creating a tristrip segment - v_index_array[tidx].I = last_top_vidx; - v_index_array[tidx].J = last_bottom_vidx; - v_index_array[tidx].K = vidx; - tidx++; - v_index_array[tidx].I = last_bottom_vidx; - v_index_array[tidx].J = vidx + 1; - v_index_array[tidx].K = vidx; - tidx++; - last_top_vidx = vidx; - last_bottom_vidx = vidx + 1; - - // Advance both intersections. - top_int_idx++; - bottom_int_idx++; - residual_top_points = intersection[top_int_idx][TOP_EDGE].PointCount; - residual_bottom_points = intersection[bottom_int_idx][BOTTOM_EDGE].PointCount; - - // Advance point index (must do here because the new point index is used below): - pidx++; - - // Generate two vertices for next point by picking nearest point on each direction line - Vector3 &top_dir = intersection[top_int_idx][TOP_EDGE].Direction; - top = top_dir * Vector3::Dot_Product(points[pidx], top_dir); - Vector3 &bottom_dir = intersection[bottom_int_idx][BOTTOM_EDGE].Direction; - bottom = bottom_dir * Vector3::Dot_Product(points[pidx], bottom_dir); - - vArray[vidx].x = top.X; - vArray[vidx].y = top.Y; - vArray[vidx].z = top.Z; - vArray[vidx].diffuse = DX8Wrapper::Convert_Color(intersection[top_int_idx][TOP_EDGE].RGBA); - vArray[vidx].u1 = u_values[0] + uv_offset.X; - vArray[vidx].v1 = intersection[top_int_idx][TOP_EDGE].TexV + uv_offset.Y; - vidx++; - vArray[vidx].x = bottom.X; - vArray[vidx].y = bottom.Y; - vArray[vidx].z = bottom.Z; - vArray[vidx].diffuse = DX8Wrapper::Convert_Color(intersection[bottom_int_idx][BOTTOM_EDGE].RGBA); - vArray[vidx].u1 = u_values[1] + uv_offset.X; - vArray[vidx].v1 = intersection[bottom_int_idx][BOTTOM_EDGE].TexV + uv_offset.Y; - vidx++; - } else { - // Exactly one of the pointcounts is greater than one - advance it and draw one triangle - if (residual_top_points > 1) { - // Draw one triangle (fan segment) - v_index_array[tidx].I = last_top_vidx; - v_index_array[tidx].J = last_bottom_vidx; - v_index_array[tidx].K = vidx; - tidx++; - last_bottom_vidx = vidx; - - // Advance bottom intersection only - residual_top_points--; - bottom_int_idx++; - residual_bottom_points = intersection[bottom_int_idx][BOTTOM_EDGE].PointCount; - - // Advance point index (must do here because the new point index is used below): - pidx++; - - // Generate bottom vertex by picking nearest point on bottom direction line - Vector3 &bottom_dir = intersection[bottom_int_idx][BOTTOM_EDGE].Direction; - bottom = bottom_dir * Vector3::Dot_Product(points[pidx], bottom_dir); - - vArray[vidx].x = bottom.X; - vArray[vidx].y = bottom.Y; - vArray[vidx].z = bottom.Z; - vArray[vidx].diffuse = DX8Wrapper::Convert_Color(intersection[bottom_int_idx][BOTTOM_EDGE].RGBA); - vArray[vidx].u1 = u_values[1] + uv_offset.X; - vArray[vidx].v1 = intersection[bottom_int_idx][BOTTOM_EDGE].TexV + uv_offset.Y; - vidx++; - } else { - - // residual_bottom_points > 1 - - // Draw one triangle (fan segment) - v_index_array[tidx].I = last_top_vidx; - v_index_array[tidx].J = last_bottom_vidx; - v_index_array[tidx].K = vidx; - tidx++; - last_top_vidx = vidx; - - // Advance top intersection only - residual_bottom_points--; - top_int_idx++; - residual_top_points = intersection[top_int_idx][TOP_EDGE].PointCount; - - // Advance point index (must do here because the new point index is used below): - pidx++; - - // Generate top vertex by picking nearest point on top direction line - Vector3 &top_dir = intersection[top_int_idx][TOP_EDGE].Direction; - top = top_dir * Vector3::Dot_Product(points[pidx], top_dir); - vArray[vidx].x = top.X; - vArray[vidx].y = top.Y; - vArray[vidx].z = top.Z; - vArray[vidx].diffuse = DX8Wrapper::Convert_Color(intersection[top_int_idx][TOP_EDGE].RGBA); - vArray[vidx].u1 = u_values[0] + uv_offset.X; - vArray[vidx].v1 = intersection[top_int_idx][TOP_EDGE].TexV + uv_offset.Y; - vidx++; - } - } - - // Reduce both pointcounts by the same amount so the smaller one is 1 (skip points) - delta = MIN(residual_top_points, residual_bottom_points) - 1; - residual_top_points -= delta; - residual_bottom_points -= delta; - pidx += delta; - - // Exit conditions - if ( (top_int_idx >= num_intersections[TOP_EDGE] && residual_top_points == 1) || - (bottom_int_idx >= num_intersections[BOTTOM_EDGE] && residual_bottom_points == 1)) { - // Debugging check - if either intersection index is before end, both of them should be - // and the points should be before the end. - assert(top_int_idx == num_intersections[TOP_EDGE]); - assert(bottom_int_idx == num_intersections[BOTTOM_EDGE]); - assert(pidx == point_cnt - 1); - break; - } - } - - /* - ** Set color, opacity, vertex flags: - */ - - // If color is not white or opacity not 100%, enable gradient in shader and in renderer - otherwise disable. - unsigned int rgba; - rgba=DX8Wrapper::Convert_Color(Color,Opacity); - bool rgba_all=(rgba==0xFFFFFFFF); - - // Enable sorting if sorting has not been disabled and line is translucent and alpha testing is not enabled. - bool sorting = (!Is_Sorting_Disabled()) && (Shader.Get_Dst_Blend_Func() != ShaderClass::DSTBLEND_ZERO && Shader.Get_Alpha_Test() == ShaderClass::ALPHATEST_DISABLE); - - ShaderClass shader = Shader; - shader.Set_Cull_Mode(ShaderClass::CULL_MODE_DISABLE); - - VertexMaterialClass *mat; - - // if there's a default color or an rgba array modulate - if (!rgba_all || (rgba != 0) ) { - shader.Set_Primary_Gradient(ShaderClass::GRADIENT_MODULATE); - mat=VertexMaterialClass::Get_Preset(VertexMaterialClass::PRELIT_DIFFUSE); - } else { - // othewise it's texture only - shader.Set_Primary_Gradient(ShaderClass::GRADIENT_DISABLE); - mat=VertexMaterialClass::Get_Preset(VertexMaterialClass::PRELIT_NODIFFUSE); - } - - // If Texture is non-NULL enable texturing in shader - otherwise disable. - if (Texture) { - shader.Set_Texturing(ShaderClass::TEXTURING_ENABLE); - } else { - shader.Set_Texturing(ShaderClass::TEXTURING_DISABLE); - } - - - /* - ** Render - */ - - DynamicVBAccessClass Verts((sorting?BUFFER_TYPE_DYNAMIC_SORTING:BUFFER_TYPE_DYNAMIC_DX8),dynamic_fvf_type,vnum); - // Copy in the data to the VB - { - DynamicVBAccessClass::WriteLockClass Lock(&Verts); - unsigned int i; - unsigned char *vb=(unsigned char*)Lock.Get_Formatted_Vertex_Array(); - const FVFInfoClass& fvfinfo=Verts.FVF_Info(); - - const unsigned int verticesOffset = fvfinfo.Get_Location_Offset(); - const unsigned diffuseOffset = fvfinfo.Get_Diffuse_Offset(); - const unsigned textureOffset = fvfinfo.Get_Tex_Offset(0); - const unsigned vbSize = fvfinfo.Get_FVF_Size(); - - for (i=0; i(vb + verticesOffset); - vertex->X = vArray[i].x; - vertex->Y = vArray[i].y; - vertex->Z = vArray[i].z; - *reinterpret_cast(vb + diffuseOffset) = vArray[i].diffuse; - Vector2 *texture = reinterpret_cast(vb + textureOffset); - texture->U = vArray[i].u1; - texture->V = vArray[i].v1; - vb += vbSize; - } - } // copy - - DynamicIBAccessClass ib_access((sorting?BUFFER_TYPE_DYNAMIC_SORTING:BUFFER_TYPE_DYNAMIC_DX8),tidx*3); - { - unsigned int i; - DynamicIBAccessClass::WriteLockClass lock(&ib_access); - unsigned short* inds=lock.Get_Index_Array(); - - for (i=0; i= 0;) { - if (stack[tos].Level == SubdivisionLevel) { - // Generate point location and texture V coordinate - xformed_subdiv_pts[sub_pidx] = stack[tos].StartPos; - subdiv_tex_v[sub_pidx] = stack[tos].StartTexV; - subdiv_diffuse[sub_pidx] = stack[tos].StartDiffuse; - - sub_pidx = sub_pidx + 1; - - // Pop - tos--; - } else { - // Recurse down: pop existing entry and push two subdivided ones. - if (freeze_random) { - randvec.Set(randomize * oo_int_max, randomize * oo_int_max, randomize * oo_int_max); - } else { - randomizer.Get_Vector(randvec); - } - stack[tos + 1].StartPos = stack[tos].StartPos; - stack[tos + 1].EndPos = (stack[tos].StartPos + stack[tos].EndPos) * 0.5f + randvec * stack[tos].Rand; - stack[tos + 1].StartTexV = stack[tos].StartTexV; - stack[tos + 1].EndTexV = (stack[tos].StartTexV + stack[tos].EndTexV) * 0.5f; - stack[tos + 1].StartDiffuse = stack[tos].StartDiffuse; - stack[tos + 1].EndDiffuse = (stack[tos].StartDiffuse + stack[tos].EndDiffuse) * 0.5f; - stack[tos + 1].Rand = stack[tos].Rand * 0.5f; - stack[tos + 1].Level = stack[tos].Level + 1; - stack[tos].StartPos = stack[tos + 1].EndPos; - // stack[tos].EndPos already has the right value - stack[tos].StartTexV = stack[tos + 1].EndTexV; - // stack[tos].EndTexV already has the right value - stack[tos].Rand = stack[tos + 1].Rand; - stack[tos].Level = stack[tos + 1].Level; - tos++; - } - } - } - // Last point - xformed_subdiv_pts[sub_pidx] = xformed_pts[point_cnt - 1]; - subdiv_tex_v[sub_pidx] = base_tex_v[point_cnt - 1]; - if (base_diffuse) { - subdiv_diffuse[sub_pidx] = base_diffuse[point_cnt - 1]; - } else { - subdiv_diffuse[sub_pidx].Set(Color.X, Color.Y, Color.Z, Opacity); - } - - sub_pidx = sub_pidx + 1; - - // Output: - *p_sub_point_cnt = sub_pidx; -} - -void SegLineRendererClass::Scale(float scale) -{ - Width *= scale; - NoiseAmplitude *= scale; -} - -VertexFormatXYZDUV1 *SegLineRendererClass::getVertexBuffer(unsigned int number) -{ - // TODO: use a stl vector instead of our own array. - if (number > m_vertexBufferSize) - { - unsigned int numberToAlloc = number + (number >> 1); - delete [] m_vertexBuffer; - m_vertexBuffer = W3DNEWARRAY VertexFormatXYZDUV1[numberToAlloc]; - m_vertexBufferSize = numberToAlloc; - } - - return m_vertexBuffer; -} diff --git a/Generals/Code/Libraries/Source/WWVegas/WW3D2/seglinerenderer.h b/Generals/Code/Libraries/Source/WWVegas/WW3D2/seglinerenderer.h deleted file mode 100644 index 0db6ecb7edd..00000000000 --- a/Generals/Code/Libraries/Source/WWVegas/WW3D2/seglinerenderer.h +++ /dev/null @@ -1,212 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** 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 *** - *********************************************************************************************** - * * - * Project Name : ww3d * - * * - * $Archive:: /Commando/Code/ww3d2/seglinerenderer.h $* - * * - * Original Author:: Greg Hjelstrom * - * * - * $Author:: Greg_h $* - * * - * $Modtime:: 6/08/01 5:23p $* - * * - * $Revision:: 1 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#ifndef SEGLINERENDERER_H -#define SEGLINERENDERER_H - -#include "always.h" -#include "shader.h" -#include "texture.h" -#include "matrix3d.h" -#include "vector2.h" - -class RenderInfoClass; -class SphereClass; -struct W3dEmitterLinePropertiesStruct; -struct VertexFormatXYZDUV1; - - -// The maximum allowable level of subdivision. This should be no more than 7 to avoid increasing -// the chunk buffer size too much -#define MAX_SEGLINE_SUBDIV_LEVELS 7 - - - -/** -** SegLineRendererClass -** This class implements the low-level line rendering functionality used by both SegmentedLineClass -** and ParticleBufferClass -*/ -class SegLineRendererClass -{ -public: - - SegLineRendererClass(void); - SegLineRendererClass(const SegLineRendererClass & that); - SegLineRendererClass & operator = (const SegLineRendererClass & that); - ~SegLineRendererClass(void); - - enum TextureMapMode { - UNIFORM_WIDTH_TEXTURE_MAP = 0x00000000, // Entire line uses one row of texture (constant V) - UNIFORM_LENGTH_TEXTURE_MAP = 0x00000001, // Entire line uses one row of texture stretched length-wise - TILED_TEXTURE_MAP = 0x00000002 // Tiled continuously over line - }; - - void Init(const W3dEmitterLinePropertiesStruct & props); - - // Get properties used to render this line segment - TextureClass * Get_Texture(void) const; - TextureClass * Peek_Texture(void) const { return Texture; } - ShaderClass Get_Shader(void) const { return Shader; } - float Get_Width(void) const { return Width; } - const Vector3 & Get_Color(void) const { return Color; } - float Get_Opacity(void) const { return Opacity; } - float Get_Noise_Amplitude(void) const { return NoiseAmplitude; } - float Get_Merge_Abort_Factor(void) const { return MergeAbortFactor; } - unsigned int Get_Current_Subdivision_Level(void) const { return SubdivisionLevel; } - TextureMapMode Get_Texture_Mapping_Mode(void) const; - float Get_Texture_Tile_Factor(void) const { return TextureTileFactor; } - Vector2 Get_UV_Offset_Rate(void) const; - int Is_Merge_Intersections(void) const { return Bits & MERGE_INTERSECTIONS; } - int Is_Freeze_Random(void) const { return Bits & FREEZE_RANDOM; } - int Is_Sorting_Disabled(void) const { return Bits & DISABLE_SORTING; } - int Are_End_Caps_Enabled(void) const { return Bits & END_CAPS; } - - // Set properties used to render this line segment - void Set_Texture(TextureClass *texture); - void Set_Shader(ShaderClass shader) { Shader = shader; } - void Set_Width(float width) { Width = width; } - void Set_Color(const Vector3 &color) { Color = color; } - void Set_Opacity(float opacity) { Opacity = opacity; } - void Set_Noise_Amplitude(float amplitude) { NoiseAmplitude = amplitude; } - void Set_Merge_Abort_Factor(float factor) { MergeAbortFactor = factor; } - void Set_Current_Subdivision_Level(unsigned int lv) { SubdivisionLevel = lv; } - void Set_Texture_Mapping_Mode(TextureMapMode mode); - void Set_Texture_Tile_Factor(float factor); // Might be clamped if too high - void Set_Current_UV_Offset(const Vector2 & offset); - void Set_UV_Offset_Rate(const Vector2 &rate); - void Set_Merge_Intersections(int onoff) { if (onoff) { Bits |= MERGE_INTERSECTIONS; } else { Bits &= ~MERGE_INTERSECTIONS; }; } - void Set_Freeze_Random(int onoff) { if (onoff) { Bits |= FREEZE_RANDOM; } else { Bits &= ~FREEZE_RANDOM; }; } - void Set_Disable_Sorting(int onoff) { if (onoff) { Bits |= DISABLE_SORTING; } else { Bits &= ~DISABLE_SORTING; }; } - void Set_End_Caps(int onoff) { if (onoff) { Bits |= END_CAPS; } else { Bits &= ~END_CAPS; }; } - - - void Render( RenderInfoClass & rinfo, - const Matrix3D & transform, - unsigned int point_count, - Vector3 * points, - const SphereClass & obj_sphere, - Vector4 * rgbas = 0); - - void Reset_Line(void); - void Scale(float scale); - -private: - - // Utility functions - void subdivision_util(unsigned int point_cnt, const Vector3 *xformed_pts, - const float *base_tex_v, unsigned int *p_sub_point_cnt, - Vector3 *xformed_subdiv_pts, float *subdiv_tex_v, - Vector4 *base_diffuse, Vector4 *subdiv_diffuse); - - // Global properties - TextureClass * Texture; - ShaderClass Shader; - float Width; - Vector3 Color; - float Opacity; - - // Subdivision properties - unsigned int SubdivisionLevel; - float NoiseAmplitude; - - // If >0, will abort a merge which causes an intersection to move - // farther away than this factor * line radius from the line point. - // (defaults to 1.5, has no affect if intersection merging is disabled). - float MergeAbortFactor; - - // Affects tiled texture mapping mode only. If this is set too high, performance (and - // possibly visual) problems will result from excessive tiling over a single polygon, over - // the entire line, or both. - float TextureTileFactor; - - // Used for texture coordinate animation - unsigned int LastUsedSyncTime; // Last sync time used - Vector2 CurrentUVOffset; // Current UV offset - Vector2 UVOffsetDeltaPerMS; // Amount to increase offset each millisec - - // Various flags - enum BitShiftOffsets { - TEXTURE_MAP_MODE_OFFSET = 24 // By how many bits do I need to shift the texture mapping mode? - }; - enum { - MERGE_INTERSECTIONS = 0x00000001, // Merge intersections - FREEZE_RANDOM = 0x00000002, // Freeze random (note: offsets are in camera space) - DISABLE_SORTING = 0x00000004, // Disable sorting (even if shader has alpha-blending) - END_CAPS = 0x00000008, // Draw end caps on the line - - // Some bits are used to select the texture mapping mode: - TEXTURE_MAP_MODE_MASK = 0xFF000000, // Must cover all possible TextureMapMode values - - DEFAULT_BITS = MERGE_INTERSECTIONS | (UNIFORM_WIDTH_TEXTURE_MAP << TEXTURE_MAP_MODE_OFFSET) - }; - unsigned int Bits; - - friend class SegmentedLineClass; - - VertexFormatXYZDUV1 *getVertexBuffer(unsigned int number); - unsigned int m_vertexBufferSize; - VertexFormatXYZDUV1 *m_vertexBuffer; -}; - - - -inline SegLineRendererClass::TextureMapMode SegLineRendererClass::Get_Texture_Mapping_Mode(void) const -{ - return (TextureMapMode)((Bits & TEXTURE_MAP_MODE_MASK) >> TEXTURE_MAP_MODE_OFFSET); -} - -inline void SegLineRendererClass::Set_Texture_Mapping_Mode(SegLineRendererClass::TextureMapMode mode) -{ - Bits &= ~TEXTURE_MAP_MODE_MASK; - Bits |= ((mode << TEXTURE_MAP_MODE_OFFSET) & TEXTURE_MAP_MODE_MASK); -} - -inline Vector2 SegLineRendererClass::Get_UV_Offset_Rate(void) const -{ - return UVOffsetDeltaPerMS * 1000.0f; -} - -inline void SegLineRendererClass::Set_UV_Offset_Rate(const Vector2 &rate) -{ - UVOffsetDeltaPerMS = rate * 0.001f; -} - - -#endif //SEGLINERENDERER_H - diff --git a/Generals/Code/Libraries/Source/WWVegas/WW3D2/shattersystem.cpp b/Generals/Code/Libraries/Source/WWVegas/WW3D2/shattersystem.cpp deleted file mode 100644 index 09283effa43..00000000000 --- a/Generals/Code/Libraries/Source/WWVegas/WW3D2/shattersystem.cpp +++ /dev/null @@ -1,1268 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** 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 *** - *********************************************************************************************** - * * - * Project Name : WWPhys * - * * - * $Archive:: /Commando/Code/ww3d2/shattersystem.cpp $* - * * - * Original Author:: Greg Hjelstrom * - * * - * $Author:: Greg_h $* - * * - * $Modtime:: 12/03/01 4:57p $* - * * - * $Revision:: 11 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#include "shattersystem.h" -#include "assetmgr.h" -#include "mesh.h" -#include "meshmdl.h" -#include "dynamesh.h" -#include "htree.h" -#include "plane.h" -#include "simplevec.h" -#include "wwstring.h" -#include "vp.h" -#include "meshmatdesc.h" -#include - -/* -** Debug logging for the shatter system -*/ -#define SHATTER_DEBUG_LOG_ENABLED 0 -#if (SHATTER_DEBUG_LOG_ENABLED) -#define SHATTER_DEBUG_SAY(x) WWDEBUG_SAY(x) -#else -#define SHATTER_DEBUG_SAY(x) -#endif - - - -#define SHATTER_PATTERN_FORMAT "ShatterPlanes%d" - -#define BPT_FRONT 0x01 -#define BPT_BACK 0x02 -#define BPT_ON 0x04 -#define BPT_BOTH 0x08 -#define BPT_EPSILON 0.0001f -#define BPT_COINCIDENCE_EPSILON 0.000001f - - -/** -** Mesh Material Parameters -*/ -class MeshMtlParamsClass -{ -public: - MeshMtlParamsClass(MeshModelClass * model); - ~MeshMtlParamsClass(void); - - int PassCount; - - /* - ** NOTE: currently I do not fully support stage 1 textures or texture arrays in any pass. - ** The uv coordinates will be computed but the textures will not be set up. - */ - unsigned * DCG[MeshMatDescClass::MAX_PASSES]; - unsigned * DIG[MeshMatDescClass::MAX_PASSES]; - Vector2 * UV[MeshMatDescClass::MAX_PASSES][MeshMatDescClass::MAX_TEX_STAGES]; -// Vector3i * UVIndexArray[MeshMatDescClass::MAX_PASSES]; -}; - - - -/** -** VertexClass -** Temporary representation of vertices as they are being clipped -*/ -class VertexClass -{ -public: - - VertexClass(void); - VertexClass(const VertexClass & that); - VertexClass & operator = (const VertexClass & that); - - int Which_Side(const PlaneClass & plane) const; - - Vector3 Position; - Vector3 Normal; - - int PassCount; - unsigned DCG[MeshMatDescClass::MAX_PASSES]; - unsigned DIG[MeshMatDescClass::MAX_PASSES]; - Vector2 TexCoord[MeshMatDescClass::MAX_PASSES][MeshMatDescClass::MAX_TEX_STAGES]; - - static void Lerp(const VertexClass & v0,const VertexClass & v1,float lerp,VertexClass * res); - static void Intersect_Plane(const VertexClass & v0,const VertexClass & v1,const PlaneClass & plane,VertexClass * res); -}; - -/** -** PolygonClass -** Temporary representation of polygons as they are being clipped -*/ -class PolygonClass -{ -public: - - enum { BPT_POLY_MAX_VERTS = 24 }; - - PolygonClass(void); - PolygonClass(const PolygonClass & that); - PolygonClass(const VertexClass * points, int num); - PolygonClass & operator = (const PolygonClass & that); - - // Accessors - const VertexClass & operator[] (int i) const { return Verts[i]; } - VertexClass & operator[] (int i) { return Verts[i]; } - - int Get_Vertex_Count(void) const { return NumVerts; } - int Get_Material_ID(void) const { return MaterialId; } - const PlaneClass & Get_Plane(void) const { return Plane; } - - void Set_Vertex_Count(int count) { NumVerts = count; } - void Set_Material_Id(int id) { MaterialId = id; } - void Set_Plane(const PlaneClass & plane) { Plane = plane; } - - // Operations - void Compute_Plane(void); - int Which_Side(const PlaneClass & plane) const; - void Split(const PlaneClass & plane,PolygonClass & front,PolygonClass & back) const; - bool Is_Degenerate(void); - bool Salvage_Degenerate(void); - -public: - - int MaterialId; - int NumVerts; - VertexClass Verts[BPT_POLY_MAX_VERTS]; - - PlaneClass Plane; - -}; - -/** -** BSPClass -** Representation of a node in a BSP clipping tree in the shatter system -** Meshes are "shattered" by clipping them with a fixed BSP tree. -** The resulting leaf polygons are turned into separate dynamic objects -** which are thrown around in the world. The BSP tree is constructed -** using an HTree where each transform in the tree is used as a clipping -** plane. The plane is defined by the x-y plane of the coordinate system -** (i.e. z-axis is the normal of the plane, origin is a point on the plane). -** Leaf nodes of this tree will have two indices. These are indices into -** the MeshFragments array where they put the polygons in thier front and -** back half-spaces. -*/ -class BSPClass -{ -public: - BSPClass(HTreeClass * tree,int bone_index,int & leaf_index); - ~BSPClass(void); - - const PlaneClass & Get_Plane(void) { return Plane; } - BSPClass * Get_Front_Child(void) { return Front; } - BSPClass * Get_Back_Child(void) { return Back; } - - void Clip_Polygon(const PolygonClass & poly); - -protected: - - void Set_Plane_From_Transform(const Matrix3D & tm); - - PlaneClass Plane; // plane equation - BSPClass * Front; // pointers to child clipping planes - BSPClass * Back; - int FrontLeafIndex; // if a leaf node, has two mesh fragment indices - int BackLeafIndex; -}; - - -/*********************************************************************************************** -** -** Static Variables -** ShatterPatterns - Array of BSP-trees for clipping (shattering) messhes -** ClippedPolygonPool - Array of polygon arrays, one per leaf. -** MeshFragments - Array of resultant clipped meshes, one per leaf -** TmpVertPositions - Workspace for transforming vertex positions -** TmpVertNormals - Workspace for transforming vertex normals -** -***********************************************************************************************/ - -enum { MAX_MESH_FRAGMENTS = 32 }; -static SimpleDynVecClass ShatterPatterns; -static SimpleDynVecClass ClipPools[MAX_MESH_FRAGMENTS]; -static SimpleDynVecClass MeshFragments(MAX_MESH_FRAGMENTS); -static SimpleVecClass TmpVertPositions(256); -static SimpleVecClass TmpVertNormals(256); - - -/*********************************************************************************************** -** -** Local static utility functions -** -***********************************************************************************************/ -static Vector3 * _get_temp_vertex_position_array(int count) -{ - if (TmpVertPositions.Length() < count) { - TmpVertPositions.Resize(count); - } - return &(TmpVertPositions[0]); -} - -static Vector3 * _get_temp_vertex_normal_array(int count) -{ - if (TmpVertNormals.Length() < count) { - TmpVertNormals.Resize(count); - } - return &(TmpVertNormals[0]); -} - -/*********************************************************************************************** -** -** MeshMtlParamsClass Implementation -** -***********************************************************************************************/ -MeshMtlParamsClass::MeshMtlParamsClass(MeshModelClass * model) -{ - PassCount = model->Get_Pass_Count(); - - for (int ipass=0; ipassGet_DCG_Array(ipass); - DIG[ipass] = model->Get_DIG_Array(ipass); -// UVIndexArray[ipass] = model->Get_UVIndex_Array(ipass,false); - for (int istage=0; istage(model->Get_UV_Array(ipass,istage)); - } - } -} - -MeshMtlParamsClass::~MeshMtlParamsClass(void) -{ -} - - -/*********************************************************************************************** -** -** VertexClass Implementation -** -***********************************************************************************************/ -VertexClass::VertexClass(void) : - Position(0,0,0), - Normal(0,0,1), - PassCount(0) -{ - for (int ipass=0; ipass= -BPT_EPSILON); - assert(lerp <= 1.0 + BPT_EPSILON); - assert(v0.PassCount==v1.PassCount); - res->PassCount = v0.PassCount; - - // interpolate position - Vector3::Lerp(v0.Position,v1.Position,lerp,&(res->Position)); - - // interpolate normal, renormalize - Vector3::Lerp(v0.Normal,v1.Normal,lerp,&(res->Normal)); - res->Normal.Normalize(); - - // interpolate material properies - for (int ipass=0; ipassDCG[ipass]); - Vector4::Lerp(dig_v0,dig_v1,res->DIG[ipass]); -// Vector4::Lerp(v0.DCG[ipass],v1.DCG[ipass],lerp,&(res->DCG[ipass])); -// Vector4::Lerp(v0.DIG[ipass],v1.DIG[ipass],lerp,&(res->DIG[ipass])); - for (int istage=0; istageTexCoord[ipass][istage])); - } - } -} - -int VertexClass::Which_Side(const PlaneClass & plane) const -{ - float d = Vector3::Dot_Product(plane.N,Position); - d -= plane.D; - - if (d > BPT_EPSILON) { - return BPT_FRONT; - } - - if (d < -BPT_EPSILON) { - return BPT_BACK; - } - - return BPT_ON; -} - -void VertexClass::Intersect_Plane -( - const VertexClass & p0, - const VertexClass & p1, - const PlaneClass & plane, - VertexClass * res -) -{ - float alpha = 0.0f; - plane.Compute_Intersection(p0.Position,p1.Position,&alpha); - VertexClass::Lerp(p0,p1,alpha,res); -} - - - -/*********************************************************************************************** -** -** PolygonClass Implementation -** -***********************************************************************************************/ -PolygonClass::PolygonClass(void) : - NumVerts(0) -{ -} - -PolygonClass::PolygonClass(const PolygonClass & that) -{ - NumVerts = that.NumVerts; - for (int i=0;iGet_Transform(bone_index)); - int front = -1; - int back = -1; - - // search for a front and back child of this bone - for (int ibone=0; ibone < tree->Num_Pivots(); ibone++) { - if (tree->Get_Parent_Index(ibone) == bone_index) { - - // found a child, now see if it is the front or back child - Vector3 point = tree->Get_Transform(ibone).Get_Translation(); - if (Plane.In_Front(point)) { - front = ibone; - } else { - back = ibone; - } - - } - } - - // Recurse if we have children, otherwise assign leaf indices - if (front != -1) { - Front = W3DNEW BSPClass(tree,front,leaf_index); - } else { - FrontLeafIndex = leaf_index++; - } - - if (back != -1) { - Back = W3DNEW BSPClass(tree,back,leaf_index); - } else { - BackLeafIndex = leaf_index++; - } -} - -BSPClass::~BSPClass(void) -{ - if (Front != NULL) { - delete Front; - } - if (Back != NULL) { - delete Back; - } - Front = Back = NULL; -} - -void BSPClass::Set_Plane_From_Transform(const Matrix3D & tm) -{ - Plane.Set(tm.Get_Z_Vector(),tm.Get_Translation()); -} - -void BSPClass::Clip_Polygon(const PolygonClass & polygon) -{ - PolygonClass front_poly,back_poly; - front_poly.Set_Vertex_Count(0); - back_poly.Set_Vertex_Count(0); - - switch(polygon.Which_Side(Plane)) - { - case BPT_FRONT: case BPT_ON: - front_poly = polygon; - break; - case BPT_BACK: - back_poly = polygon; - break; - default: - polygon.Split(Plane,front_poly,back_poly); - break; - }; - - // Process the front halfspace: Recurse if we have a child clipping plane, - // otherwise add our polygons to our assigned clipping pool - if (Front == NULL) { - // We're a leaf node so put the polygons into the mesh fragment arrays - if (front_poly.Get_Vertex_Count() >= 3) { - ClipPools[FrontLeafIndex].Add(front_poly); - } - } else { - // Pass the polygons to our child for further clipping - if (front_poly.Get_Vertex_Count() >= 3) { - Front->Clip_Polygon(front_poly); - } - } - - // Process the back halfspace: - if (Back==NULL) { - if (back_poly.Get_Vertex_Count() >= 3) { - ClipPools[BackLeafIndex].Add(back_poly); - } - } else { - if (back_poly.Get_Vertex_Count() >= 3) { - Back->Clip_Polygon(back_poly); - } - } -} - - - - -/*********************************************************************************************** -** -** ShatterSystem Implementation - this is the interface with the outside world -** -** Transform meshes into space needed for shattering: -** Vshatter = Mscale-to-unit * Mworld-shatterview * Mobj-world * Vobj -** -***********************************************************************************************/ -void ShatterSystem::Init(void) -{ - /* - ** Resize the Mesh Fragment pointer array to handle the maximum number - ** of mesh fragments. - */ - MeshFragments.Resize(MAX_MESH_FRAGMENTS); - - /* - ** Search for ShatterPattern hierarchy tree objects, beginning with ShatterPattern00 - ** Create a BSP structure for each one. - */ - StringClass htree_name; - htree_name.Format(SHATTER_PATTERN_FORMAT,0); - - if (WW3DAssetManager::Get_Instance()==NULL) - return; // WorldBuilderTool doesn't initialize the asset manager. jba. -#if 1 - HTreeClass *htree = NULL; -#else - HTreeClass * htree = WW3DAssetManager::Get_Instance()->Get_HTree(htree_name); -#endif - while (htree != NULL) { - if ((htree->Num_Pivots() > 1) && (htree->Num_Pivots() < MAX_MESH_FRAGMENTS)) { - int leaf_counter = 0; - htree->Base_Update(Matrix3D(1)); - ShatterPatterns.Add(W3DNEW BSPClass(htree,1,leaf_counter)); - } - - /* - ** Try to load the next tree - */ - htree_name.Format(SHATTER_PATTERN_FORMAT,ShatterPatterns.Count()); - htree = WW3DAssetManager::Get_Instance()->Get_HTree(htree_name); - } -} - -void ShatterSystem::Shutdown(void) -{ - /* - ** Release all mesh fragments - */ - Release_Fragments(); - - /* - ** Release any loaded BSP trees - */ - for (int i=0; iGet_Model(); - if (model->Get_Pass_Count() > MeshMatDescClass::MAX_PASSES) { - WWDEBUG_SAY(("Failed to shatter model: %s. Too many passes (%d)\n",model->Get_Name(),model->Get_Pass_Count())); - REF_PTR_RELEASE(model); - return; - } - for (ipass=0; ipassGet_Pass_Count(); ipass++) { - if (model->Has_Material_Array(ipass) || model->Has_Shader_Array(ipass)) { - WWDEBUG_SAY(("Failed to shatter model: %s. It has shader or material arrays\n",model->Get_Name())); - REF_PTR_RELEASE(model); - return; - } - - for (istage=0; istageHas_Texture_Array(ipass,istage)) { - WWDEBUG_SAY(("Failed to shatter model: %s. Texture array in pass: %d stage: %d\n",model->Get_Name(),ipass,istage)); - REF_PTR_RELEASE(model); - return; - } - } - } - - /* - ** Grab a random shatter pattern - */ - BSPClass * clipper = ShatterPatterns[rand() % ShatterPatterns.Count()]; - - /* - ** Compute transforms which take vertices from mesh-space to shatter-space - ** and back again. Transform polygons into "shatter-space", clip, then - ** transform the results back out - ** - ** Take vertices from obj-space to shatter space: - ** Vshatter = Mscale-to-unit * Mworld-shatterview * Mobj-world * Vobj - ** - ** Clip the polygons to the BSP - ** Vclipped = BSP_CLIP(Vshatter) - ** - ** Next, take the verts back to object space: - ** Vobjclip = Inverse(Mscale-to-unit * Mworld-shatter * Mobj-world) * Vclipped - ** = Inv(Mobj-world)*Inv(Mworld-shatter)*Inv(Mscl-to-unit) * Vclipped - ** - ** Next, create separate, re-centered meshes - ** Vnewobj = Mold-obj-to-new-obj * Vobjclip - */ - - /* - ** Object-space to world-space transform - */ - Matrix3D Mobj_to_world = mesh->Get_Transform(); - - /* - ** World-space to shatter-space transform - */ - Matrix3D Mshatter_to_world; - Matrix3D Mworld_to_shatter; - Mshatter_to_world.Look_At(point,point+direction,0.0f); // TODO: could put random roll - Mshatter_to_world.Get_Orthogonal_Inverse(Mworld_to_shatter); - - /* - ** Final pair of matrices - */ - Matrix3D Mobj_to_shatter; - Matrix3D Mshatter_to_obj; - - Matrix3D::Multiply(Mworld_to_shatter,Mobj_to_world,&Mobj_to_shatter); - Mobj_to_shatter.Get_Orthogonal_Inverse(Mshatter_to_obj); - - /* - ** Scaling matrices. This could be simpler if Matrix3D had a full inverse function. - */ - SphereClass sphere; - model->Get_Bounding_Sphere(&sphere); - - float scale_factor = 5.0f / sphere.Radius; // mesh scales to 5x shatter pattern. - Matrix3D Mscale_to_shatter(1); - Matrix3D Mscale_from_shatter(1); - Mscale_to_shatter.Scale(scale_factor); - Mscale_from_shatter.Scale(1.0f / scale_factor); - - Matrix3D::Multiply(Mscale_to_shatter,Mobj_to_shatter,&Mobj_to_shatter); - Matrix3D::Multiply(Mshatter_to_obj,Mscale_from_shatter,&Mshatter_to_obj); - - /* - ** Grab the arrays out of the mesh and transform verts and vnorms - ** into "shatter-space" - */ - const TriIndex * polys = model->Get_Polygon_Array(); - const Vector3 * src_verts = model->Get_Vertex_Array(); - const Vector3 * src_vnorms = model->Get_Vertex_Normal_Array(); - - Vector3 * verts = _get_temp_vertex_position_array(model->Get_Vertex_Count()); - VectorProcessorClass::Transform(verts,src_verts,Mobj_to_shatter,model->Get_Vertex_Count()); - - /* - ** Build a description of the material parameters for the mesh - */ - MeshMtlParamsClass mtl_params(model); - - - SHATTER_DEBUG_SAY(("****************************************************\n")); - SHATTER_DEBUG_SAY((" Clipping model: %s\n",model->Get_Name())); - SHATTER_DEBUG_SAY(("****************************************************\n")); - - /* - ** Pass each polygon of the source model through the BSP clipper - */ - for (ipoly=0; ipolyGet_Polygon_Count(); ipoly++) { - - /* - ** Set up a PolygonClass for polygon 'i' in the mesh - */ - SHATTER_DEBUG_SAY(("Passing polygon %d to clipper.\n",ipoly)); - PolygonClass polygon; - for (ivert=0; ivert<3; ivert++) { - - int vert_index = polys[ipoly][ivert]; - polygon.Verts[ivert].PassCount = mtl_params.PassCount; - polygon.Verts[ivert].Position = verts[vert_index]; - polygon.Verts[ivert].Normal = src_vnorms[vert_index]; - SHATTER_DEBUG_SAY(("position: %f %f %f\n",verts[vert_index].X,verts[vert_index].Y,verts[vert_index].Z)); - SHATTER_DEBUG_SAY(("normal: %f %f %f\n",src_vnorms[vert_index].X,src_vnorms[vert_index].Y,src_vnorms[vert_index].Z)); - - for (ipass=0; ipassClip_Polygon(polygon); - } - - /* - ** convert the clipped polygons into meshes - */ - Process_Clip_Pools(Mshatter_to_obj,mesh,mtl_params); - - /* - ** release resources - */ - REF_PTR_RELEASE(model); -} - -int ShatterSystem::Get_Fragment_Count(void) -{ - return MeshFragments.Count(); -} - -RenderObjClass * ShatterSystem::Get_Fragment(int fragment_index) -{ - if (MeshFragments[fragment_index] != NULL) { - MeshFragments[fragment_index]->Add_Ref(); - } - return MeshFragments[fragment_index]; -} - -RenderObjClass * ShatterSystem::Peek_Fragment(int fragment_index) -{ - return MeshFragments[fragment_index]; -} - -void ShatterSystem::Release_Fragments(void) -{ - // release any ref's to render objects - for (int i=0; iGet_Model(); - WWASSERT(model != NULL); - - /* - ** Loop over all ClipPools and build a mesh for any that contain polygons - */ - for (int ipool=0; ipool 0) { - - int ivert,ipoly,ipass,istage; - - /* - ** Count the verts and polys - */ - int pcount = 0; - int vcount = 0; - for (ipoly=0;ipolyGet_Name())); - SHATTER_DEBUG_SAY((" polycount = %d vertexcount = %d\n",pcount,vcount)); - SHATTER_DEBUG_SAY(("****************************************************\n")); - - /* - ** Create the new mesh, install materials - */ - DynamicMeshClass * new_mesh = NEW_REF(DynamicMeshClass,(pcount,vcount)); - MaterialInfoClass * matinfo = NEW_REF(MaterialInfoClass,()); - - if (model->Get_Flag(MeshModelClass::SORT)) { - new_mesh->Enable_Sort(); - } - new_mesh->Set_Pass_Count(mtl_params.PassCount); - - bool has_textures = false; - for (ipass=0; ipassGet_Pass_Count(); ipass++) { - if (model->Peek_Single_Material(ipass) != NULL) { - matinfo->Add_Vertex_Material(model->Peek_Single_Material(ipass)); - } - for (int istage=0; istagePeek_Single_Texture(ipass,istage) != NULL) { - matinfo->Add_Texture(model->Peek_Single_Texture(ipass,istage)); - has_textures = true; - } - } - } - new_mesh->Set_Material_Info(matinfo); - - for (ipass=0; ipassGet_Pass_Count(); ipass++) { - new_mesh->Set_Vertex_Material(model->Peek_Single_Material(ipass),false,ipass); - new_mesh->Set_Shader(model->Get_Single_Shader(ipass),ipass); - - for (istage=0; istagePeek_Single_Texture(ipass,istage); - if (tex != NULL) { - new_mesh->Peek_Model()->Set_Single_Texture(tex,ipass,istage); - } - } - } - - REF_PTR_RELEASE(matinfo); - - - /* - ** Add the polygons and vertices to the mesh, transform the vertices - ** back into the original mesh's coordinate system as we do this - */ - for (ipoly=0; ipolyBegin_Tri_Fan(); - SHATTER_DEBUG_SAY(("Begin Tri Fan\n")); - - for(ivert=0; ivertBegin_Vertex(); - SHATTER_DEBUG_SAY(("postion: %f %f %f\n",pos.X,pos.Y,pos.Z)); - new_mesh->Location_Inline(pos); - new_mesh->Normal(norm); - - for (ipass=0; ipassDCG(Vector3(vert.DCG[ipass].X,vert.DCG[ipass].Y,vert.DCG[ipass].Z),ipass); - new_mesh->Alpha(vert.DCG[ipass].W,ipass); - */ - mycolor=vert.DCG[ipass]; - } - - // HY- Multiplying DIG with DCG as in meshmdlio - if (mtl_params.DIG[ipass] != NULL) { - SHATTER_DEBUG_SAY(("DIG: pass:%d: %f %f %f\n",ipass,vert.DIG[ipass].X,vert.DIG[ipass].Y,vert.DIG[ipass].Z)); - Vector4 mc=DX8Wrapper::Convert_Color(mycolor); - Vector4 dc=DX8Wrapper::Convert_Color(vert.DIG[ipass]); - mc=Vector4(mc.X*dc.X,mc.Y*dc.Y,mc.Z*dc.Z,mc.W); - mycolor=DX8Wrapper::Convert_Color(mc); - } - - new_mesh->Color(mycolor); - - /* - ** If there were UV coordinates in the original mesh for either stage, - ** then copy the vertex's uv's into into the new mesh. - */ -// #pragma MESSAGE("HY- Naty, will dynamesh support multiple stages of UV?") - for (istage=0; istageUV(vert.TexCoord[ipass][istage],istage); - } - } - } - - new_mesh->End_Vertex(); - - } - new_mesh->End_Tri_Fan(); - } - - /* - ** Offset all vertices so that the bounding box center is 0,0,0 and - ** record that offset into the transform of the mesh - */ - new_mesh->Set_Dirty_Bounds(); - Vector3 center = new_mesh->Get_Bounding_Box().Center; - - new_mesh->Translate_Vertices(-center); - - Matrix3D tm(1);// = mesh->Get_Transform(); - tm.Translate(center); - Matrix3D::Multiply(tm,mesh->Get_Transform(),&tm); - new_mesh->Set_Transform(tm); - - /* - ** We gave it good vertex normals so clear their dirty flag - */ - new_mesh->Set_Dirty_Bounds(); - new_mesh->Set_Dirty_Planes(); - new_mesh->Clear_Dirty_Vertex_Normals(); - - /* - ** Install it in the mesh fragment pool, transferring our reference - ** to the fragment array... - */ - MeshFragments.Add(new_mesh); - } - } - REF_PTR_RELEASE(model); -} diff --git a/Generals/Code/Libraries/Source/WWVegas/WW3D2/shattersystem.h b/Generals/Code/Libraries/Source/WWVegas/WW3D2/shattersystem.h deleted file mode 100644 index 14b1e7ba19c..00000000000 --- a/Generals/Code/Libraries/Source/WWVegas/WW3D2/shattersystem.h +++ /dev/null @@ -1,103 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** 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 *** - *********************************************************************************************** - * * - * Project Name : WWPhys * - * * - * $Archive:: /Commando/Code/ww3d2/shattersystem.h $* - * * - * Original Author:: Greg Hjelstrom * - * * - * $Author:: Greg_h $* - * * - * $Modtime:: 1/08/01 10:04a $* - * * - * $Revision:: 1 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#if defined(_MSC_VER) -#pragma once -#endif - -#ifndef SHATTERSYSTEM_H -#define SHATTERSYSTEM_H - -#include "always.h" - - -class MeshClass; -class PhysicsSceneClass; -class RenderObjClass; -class Vector3; -class Matrix3D; -class MeshMtlParamsClass; - - -/** -** ShatterSystem -** This collection of static functions is used to "shatter" a mesh into fragments and -** create projectile objects which use the generated fragments as their render object. -*/ -class ShatterSystem -{ -public: - - /* - ** Init and Shutdown, these are called from the main physics system init and - ** shutdown. The BSP shatter planes are loaded up and initialized in Init - ** and released in Shutdown. - */ - static void Init(void); - static void Shutdown(void); - - /* - ** Pass in the mesh you want shattered and the scene that you want - ** the shards to be placed in. - */ - static void Shatter_Mesh(MeshClass * mesh,const Vector3 & point,const Vector3 & velocity); - - /* - ** Use these methods to get access to the resultant mesh fragments - ** Get_Fragment_Count - returns the number of meshes created - ** Get_Fragment - returns a pointer (ref-counted!) to the 'n'th mesh - ** Relese_Fragments - call this when you are done, it causes the ShatterSystem - ** to release its references to the fragments. - */ - static int Get_Fragment_Count(void); - static RenderObjClass * Get_Fragment(int fragment_index); - static RenderObjClass * Peek_Fragment(int fragment_index); - static void Release_Fragments(void); - -protected: - - static void Reset_Clip_Pools(void); - static void Process_Clip_Pools(const Matrix3D &Mshatter_to_mesh,MeshClass * mesh,MeshMtlParamsClass & mtl_params); - - -}; - - -#endif - - diff --git a/Generals/Code/Libraries/Source/WWVegas/WW3D2/snapPts.h b/Generals/Code/Libraries/Source/WWVegas/WW3D2/snapPts.h deleted file mode 100644 index d9eb37942bc..00000000000 --- a/Generals/Code/Libraries/Source/WWVegas/WW3D2/snapPts.h +++ /dev/null @@ -1,64 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** 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 *** - *********************************************************************************************** - * * - * Project Name : WW3D * - * * - * $Archive:: /Commando/Code/ww3d2/snappts.h $* - * * - * Author:: Greg Hjelstrom * - * * - * $Modtime:: 1/08/01 10:04a $* - * * - * $Revision:: 1 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#if defined(_MSC_VER) -#pragma once -#endif - -#ifndef SNAPPTS_H -#define SNAPPTS_H - -#include "refcount.h" -#include "Vector.H" -#include "vector3.h" -#include "w3derr.h" - - -class ChunkLoadClass; - -class SnapPointsClass : public DynamicVectorClass, public RefCountClass -{ -public: - - WW3DErrorType Load_W3D(ChunkLoadClass & cload); - -protected: - - ~SnapPointsClass(void) {} - -}; - -#endif diff --git a/Generals/Code/Libraries/Source/WWVegas/WW3D2/snappts.cpp b/Generals/Code/Libraries/Source/WWVegas/WW3D2/snappts.cpp deleted file mode 100644 index c9dfe9c01bb..00000000000 --- a/Generals/Code/Libraries/Source/WWVegas/WW3D2/snappts.cpp +++ /dev/null @@ -1,65 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** 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 *** - *********************************************************************************************** - * * - * Project Name : WW3D * - * * - * $Archive:: /Commando/Code/ww3d2/snappts.cpp $* - * * - * Author:: Greg Hjelstrom * - * * - * $Modtime:: 1/08/01 10:04a $* - * * - * $Revision:: 1 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#include "snapPts.h" -#include "chunkio.h" -#include "w3d_file.h" -#include "w3derr.h" - -WW3DErrorType SnapPointsClass::Load_W3D(ChunkLoadClass & cload) -{ - // this function assumes that a W3D_CHUNK_POINTS has been opened - int size = cload.Cur_Chunk_Length(); - int count = size / sizeof (W3dVectorStruct); - - Resize(count); - for (int i=0; i. -*/ - - /*********************************************************************************************** - *** 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 *** - *********************************************************************************************** - * - * Project name : Earth and Beyond - * - * File name : soundlibrarybridge.h - * - * Programmer : Mike Lytle - * - * Start date : 6/21/2002 - * - * Last update : 10/23/2002 MBL - * - *--------------------------------------------------------------------------------------------- - * Functions: - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#ifndef SOUNDLIBRARYBRIDGE_H -#define SOUNDLIBRARYBRIDGE_H - -// Forward declarations. -class Matrix3D; - -class SoundLibraryBridgeClass { - public: - virtual void Play_3D_Audio(const char * name, const Matrix3D & tm) = 0; - virtual void Play_2D_Audio(const char * name) = 0; - virtual void Stop_Playing_Audio(const char * name) = 0; -}; - -#endif //SOUNDLIBRARYBRIDGE_H diff --git a/Generals/Code/Libraries/Source/WWVegas/WW3D2/soundrobj.cpp b/Generals/Code/Libraries/Source/WWVegas/WW3D2/soundrobj.cpp deleted file mode 100644 index 989c98140f7..00000000000 --- a/Generals/Code/Libraries/Source/WWVegas/WW3D2/soundrobj.cpp +++ /dev/null @@ -1,772 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** 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 *** - *********************************************************************************************** - * * - * Project Name : WW3D * - * * - * $Archive:: /Commando/Code/ww3d2/soundrobj.cpp $* - * * - * Author:: Patrick Smith * - * * - * $Modtime:: 1/16/02 10:21a $* - * * - * $Revision:: 4 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#include "soundrobj.h" - -#if noWWAUDIO //(gth) removing dependency on wwaudio - -#include "AudibleSound.h" -#include "Sound3D.h" -#include "WWAudio.h" -#include "ffactory.h" -#include "WWFILE.H" -#include "chunkio.h" -#include "scene.h" - - -////////////////////////////////////////////////////////////////////////////////// -// Global variables -////////////////////////////////////////////////////////////////////////////////// -SoundRenderObjLoaderClass _SoundRenderObjLoader; - - -////////////////////////////////////////////////////////////////////////////////// -// -// SoundRenderObjClass -// -////////////////////////////////////////////////////////////////////////////////// -SoundRenderObjClass::SoundRenderObjClass (void) - : Flags (FLAG_STOP_WHEN_HIDDEN), - Sound (NULL), - IsInitialized (false) -{ - return ; -} - - -////////////////////////////////////////////////////////////////////////////////// -// -// SoundRenderObjClass -// -////////////////////////////////////////////////////////////////////////////////// -SoundRenderObjClass::SoundRenderObjClass (const SoundRenderObjClass &src) - : Flags (FLAG_STOP_WHEN_HIDDEN), - Sound (NULL), - IsInitialized (false) -{ - (*this) = src; - return ; -} - - -////////////////////////////////////////////////////////////////////////////////// -// -// ~SoundRenderObjClass -// -////////////////////////////////////////////////////////////////////////////////// -SoundRenderObjClass::~SoundRenderObjClass (void) -{ - // - // Remove the old sound from the world (if necessary) - // - if (Sound != NULL) { - Sound->Attach_To_Object (NULL); - Sound->Remove_From_Scene (); - REF_PTR_RELEASE (Sound); - } - - return ; -} - - -////////////////////////////////////////////////////////////////////////////////// -// -// operator= -// -////////////////////////////////////////////////////////////////////////////////// -const SoundRenderObjClass & -SoundRenderObjClass::operator= (const SoundRenderObjClass &src) -{ - // - // Create a definition from the src sound object - // - AudibleSoundDefinitionClass definition; - definition.Initialize_From_Sound (src.Sound); - - // - // Create the internal sound object from the definition - // - Set_Sound (&definition); - - // - // Copy the other misc settings - // - Name = src.Name; - return *this; -} - - -////////////////////////////////////////////////////////////////////////////////// -// -// Set_Sound -// -////////////////////////////////////////////////////////////////////////////////// -void -SoundRenderObjClass::Set_Sound (AudibleSoundDefinitionClass *definition) -{ - // - // Remove the old sound from the world (if necessary) - // - if (Sound != NULL) { - Sound->Remove_From_Scene (); - REF_PTR_RELEASE (Sound); - } - - // - // Create the sound object from its definition - // - if (definition != NULL) { - Sound = (AudibleSoundClass *)definition->Create (); - } - - return ; -} - - -////////////////////////////////////////////////////////////////////////////////// -// -// On_Frame_Update -// -////////////////////////////////////////////////////////////////////////////////// -void -SoundRenderObjClass::On_Frame_Update (void) -{ - // - // Stop the sound from playing (if necessary) - // - if ( Sound != NULL && - Sound->Is_In_Scene () && - Sound->Is_Playing () == false) - { - Sound->Attach_To_Object (NULL); - Sound->Remove_From_Scene (); - } - - return ; -} - - -////////////////////////////////////////////////////////////////////////////////// -// -// Set_Hidden -// -////////////////////////////////////////////////////////////////////////////////// -void -SoundRenderObjClass::Set_Hidden (int onoff) -{ - int before = Is_Not_Hidden_At_All (); - RenderObjClass::Set_Hidden (onoff); - - // - // If we've changed state, then update the visibility - // - if (IsInitialized == false || Is_Not_Hidden_At_All () != before) { - IsInitialized = true; - Update_On_Visibilty (); - } - - return ; -} - - -////////////////////////////////////////////////////////////////////////////////// -// -// Set_Visible -// -////////////////////////////////////////////////////////////////////////////////// -void -SoundRenderObjClass::Set_Visible (int onoff) -{ - int before = Is_Not_Hidden_At_All (); - RenderObjClass::Set_Visible (onoff); - - // - // If we've changed state, then update the visibility - // - if (IsInitialized == false || Is_Not_Hidden_At_All () != before) { - IsInitialized = true; - Update_On_Visibilty (); - } - - return ; -} - - -////////////////////////////////////////////////////////////////////////////////// -// -// Set_Animation_Hidden -// -////////////////////////////////////////////////////////////////////////////////// -void -SoundRenderObjClass::Set_Animation_Hidden (int onoff) -{ - int before = Is_Not_Hidden_At_All (); - RenderObjClass::Set_Animation_Hidden (onoff); - - // - // If we've changed state, then update the visibility - // - if (IsInitialized == false || Is_Not_Hidden_At_All () != before) { - IsInitialized = true; - Update_On_Visibilty (); - } - - return ; -} - - -////////////////////////////////////////////////////////////////////////////////// -// -// Set_Force_Visible -// -////////////////////////////////////////////////////////////////////////////////// -void -SoundRenderObjClass::Set_Force_Visible (int onoff) -{ - int before = Is_Not_Hidden_At_All (); - RenderObjClass::Set_Force_Visible (onoff); - - // - // If we've changed state, then update the visibility - // - if (IsInitialized == false || Is_Not_Hidden_At_All () != before) { - IsInitialized = true; - Update_On_Visibilty (); - } - - return ; -} - - -////////////////////////////////////////////////////////////////////////////////// -// -// Update_On_Visibilty -// -////////////////////////////////////////////////////////////////////////////////// -void -SoundRenderObjClass::Update_On_Visibilty (void) -{ - if (Sound == NULL) { - return ; - } - - // - // Ensure our transform is correct - // - Validate_Transform (); - - // - // Either add the sound object to the sound scene - // or remove it from the sound scene depending - // on the visibility state of the render object. - // - if ( Is_Not_Hidden_At_All () && - Sound->Is_In_Scene () == false && - Peek_Scene () != NULL) - { - // - // Make sure the sound is properly attached to this render - // object and then add it to the scene - // - Sound->Attach_To_Object (this); - Sound->Add_To_Scene (true); - - } else if ((Is_Not_Hidden_At_All () == false) || (Peek_Scene () == NULL)) { - - // - // Remove the sound from the scene (it will stop playing) - // - if ((Flags & FLAG_STOP_WHEN_HIDDEN) != 0 || (Peek_Scene () == NULL)) { - Sound->Attach_To_Object (NULL); - Sound->Remove_From_Scene (); - } - } - - return ; -} - - -////////////////////////////////////////////////////////////////////////////////// -// -// Get_Sound -// -////////////////////////////////////////////////////////////////////////////////// -AudibleSoundClass * -SoundRenderObjClass::Get_Sound (void) const -{ - if (Sound != NULL) { - Sound->Add_Ref (); - } - - return Sound; -} - - -////////////////////////////////////////////////////////////////////////////// -// -// Set_Flag -// -////////////////////////////////////////////////////////////////////////////// -void -SoundRenderObjClass::Set_Flag (uint32 flag, bool onoff) -{ - Flags &= ~flag; - if (onoff) { - Flags |= flag; - } - - return ; -} - - -////////////////////////////////////////////////////////////////////////////////// -// -// Notify_Added -// -////////////////////////////////////////////////////////////////////////////////// -void -SoundRenderObjClass::Notify_Added (SceneClass *scene) -{ - RenderObjClass::Notify_Added (scene); - scene->Register (this, SceneClass::ON_FRAME_UPDATE); - - Update_On_Visibilty (); - return ; -} - - -////////////////////////////////////////////////////////////////////////////////// -// -// Notify_Removed -// -////////////////////////////////////////////////////////////////////////////////// -void -SoundRenderObjClass::Notify_Removed (SceneClass *scene) -{ - scene->Unregister (this, SceneClass::ON_FRAME_UPDATE); - RenderObjClass::Notify_Removed (scene); - - Update_On_Visibilty (); - return ; -} - - -////////////////////////////////////////////////////////////////////////////////// -// -// Set_Transform -// -////////////////////////////////////////////////////////////////////////////////// -void -SoundRenderObjClass::Set_Transform (const Matrix3D &tm) -{ - RenderObjClass::Set_Transform (tm); - - if (IsInitialized == false) { - IsInitialized = true; - Update_On_Visibilty (); - } - - return ; -} - - -////////////////////////////////////////////////////////////////////////////////// -// -// Set_Position -// -////////////////////////////////////////////////////////////////////////////////// -void -SoundRenderObjClass::Set_Position (const Vector3 &pos) -{ - RenderObjClass::Set_Position (pos); - - if (IsInitialized == false) { - IsInitialized = true; - Update_On_Visibilty (); - } - - return ; -} - - -//********************************************************************************* -// -// Start of SoundRenderObjDefClass -// -//********************************************************************************* - - -////////////////////////////////////////////////////////////////////////////////// -// -// SoundRenderObjDefClass -// -////////////////////////////////////////////////////////////////////////////////// -SoundRenderObjDefClass::SoundRenderObjDefClass (void) - : Version (W3D_CURRENT_SOUNDROBJ_VERSION), - Flags (SoundRenderObjClass::FLAG_STOP_WHEN_HIDDEN) -{ - return ; -} - - -////////////////////////////////////////////////////////////////////////////////// -// -// SoundRenderObjDefClass -// -////////////////////////////////////////////////////////////////////////////////// -SoundRenderObjDefClass::SoundRenderObjDefClass (SoundRenderObjClass &render_obj) - : Version (W3D_CURRENT_SOUNDROBJ_VERSION), - Flags (SoundRenderObjClass::FLAG_STOP_WHEN_HIDDEN) -{ - Initialize (render_obj); - return ; -} - - -////////////////////////////////////////////////////////////////////////////////// -// -// SoundRenderObjDefClass -// -////////////////////////////////////////////////////////////////////////////////// -SoundRenderObjDefClass::SoundRenderObjDefClass (const SoundRenderObjDefClass &src) - : Version (W3D_CURRENT_SOUNDROBJ_VERSION), - Flags (SoundRenderObjClass::FLAG_STOP_WHEN_HIDDEN) -{ - (*this) = src; - return ; -} - - -////////////////////////////////////////////////////////////////////////////////// -// -// ~SoundRenderObjDefClass -// -////////////////////////////////////////////////////////////////////////////////// -SoundRenderObjDefClass::~SoundRenderObjDefClass (void) -{ - return ; -} - - -////////////////////////////////////////////////////////////////////////////////// -// -// operator= -// -////////////////////////////////////////////////////////////////////////////////// -const SoundRenderObjDefClass & -SoundRenderObjDefClass::operator= (const SoundRenderObjDefClass &src) -{ - Definition = src.Definition; - Version = src.Version; - Name = src.Name; - return (*this); -} - - -////////////////////////////////////////////////////////////////////////////////// -// -// Create -// -////////////////////////////////////////////////////////////////////////////////// -RenderObjClass * -SoundRenderObjDefClass::Create (void) -{ - // - // Allocate and initialize a new instance - // - SoundRenderObjClass *render_obj = W3DNEW SoundRenderObjClass; - render_obj->Set_Name (Name); - render_obj->Set_Sound (&Definition); - render_obj->Set_Flags (Flags); - - return render_obj; -} - - -////////////////////////////////////////////////////////////////////////////////// -// -// Initialize -// -////////////////////////////////////////////////////////////////////////////////// -void -SoundRenderObjDefClass::Initialize (SoundRenderObjClass &render_obj) -{ - // - // Copy the settings from the sound object into our definition - // - Definition.Initialize_From_Sound (render_obj.Peek_Sound ()); - - // - // Copy the flags from the render object - // - Flags = (SoundRenderObjClass::FLAGS)render_obj.Get_Flags (); - - // - // Copy the name - // - Name = render_obj.Get_Name (); - return ; -} - - -/////////////////////////////////////////////////////////////////////////////////// -// -// Load -// -/////////////////////////////////////////////////////////////////////////////////// -WW3DErrorType -SoundRenderObjDefClass::Load_W3D (ChunkLoadClass &cload) -{ - WW3DErrorType retval = WW3D_ERROR_LOAD_FAILED; - - // - // Attempt to read the different sections of the definition - // - if ((Read_Header (cload) == WW3D_ERROR_OK) && - (Read_Definition (cload) == WW3D_ERROR_OK)) - { - retval = WW3D_ERROR_OK; - } - - return retval; -} - - -////////////////////////////////////////////////////////////////////////////////// -// -// Save_W3D -// -////////////////////////////////////////////////////////////////////////////////// -WW3DErrorType -SoundRenderObjDefClass::Save_W3D (ChunkSaveClass &csave) -{ - WW3DErrorType retval = WW3D_ERROR_SAVE_FAILED; - - // - // Begin a chunk that identifies a sound render object - // - if (csave.Begin_Chunk (W3D_CHUNK_SOUNDROBJ) == TRUE) { - - // - // Attempt to save the different sections of the aggregate definition - // - if ((Write_Header (csave) == WW3D_ERROR_OK) && - (Write_Definition (csave) == WW3D_ERROR_OK)) - { - retval = WW3D_ERROR_OK; - } - - csave.End_Chunk (); - } - - return retval; -} - - -/////////////////////////////////////////////////////////////////////////////////// -// -// Read_Header -// -/////////////////////////////////////////////////////////////////////////////////// -WW3DErrorType -SoundRenderObjDefClass::Read_Header (ChunkLoadClass &cload) -{ - WW3DErrorType retval = WW3D_ERROR_LOAD_FAILED; - - // - // Is this the header chunk? - // - if (cload.Open_Chunk () && - (cload.Cur_Chunk_ID () == W3D_CHUNK_SOUNDROBJ_HEADER)) - { - // - // Read the header from the chunk - // - W3dSoundRObjHeaderStruct header = { 0 }; - if (cload.Read (&header, sizeof (header)) == sizeof (header)) { - - // - // Copy the names from the header structure - // - Name = header.Name; - Version = header.Version; - Flags = (SoundRenderObjClass::FLAGS)header.Flags; - retval = WW3D_ERROR_OK; - } - - cload.Close_Chunk (); - } - - return retval; -} - - -/////////////////////////////////////////////////////////////////////////////////// -// -// Read_Definition -// -/////////////////////////////////////////////////////////////////////////////////// -WW3DErrorType -SoundRenderObjDefClass::Read_Definition (ChunkLoadClass &cload) -{ - WW3DErrorType retval = WW3D_ERROR_LOAD_FAILED; - - // - // Is this the right chunk? - // - if (cload.Open_Chunk () && - (cload.Cur_Chunk_ID () == W3D_CHUNK_SOUNDROBJ_DEFINITION)) - { - // - // Ask the definition to load its settings from the chunk - // - if (Definition.Load (cload)) { - retval = WW3D_ERROR_OK; - } - - cload.Close_Chunk (); - } - - return retval; -} - - -/////////////////////////////////////////////////////////////////////////////////// -// -// Write_Header -// -/////////////////////////////////////////////////////////////////////////////////// -WW3DErrorType -SoundRenderObjDefClass::Write_Header (ChunkSaveClass &csave) -{ - WW3DErrorType retval = WW3D_ERROR_SAVE_FAILED; - - // - // Begin a chunk that identifies the aggregate - // - if (csave.Begin_Chunk (W3D_CHUNK_SOUNDROBJ_HEADER) == TRUE) { - - // - // Fill the header structure - // - W3dSoundRObjHeaderStruct header = { 0 }; - header.Version = W3D_CURRENT_AGGREGATE_VERSION; - header.Flags = Flags; - ::lstrcpyn (header.Name, (const char *)Name, sizeof (header.Name)); - header.Name[sizeof (header.Name) - 1] = 0; - - // - // Write the header out to the chunk - // - if (csave.Write (&header, sizeof (header)) == sizeof (header)) { - retval = WW3D_ERROR_OK; - } - - // End the header chunk - csave.End_Chunk (); - } - - return retval; -} - - -/////////////////////////////////////////////////////////////////////////////////// -// -// Write_Definition -// -/////////////////////////////////////////////////////////////////////////////////// -WW3DErrorType -SoundRenderObjDefClass::Write_Definition (ChunkSaveClass &csave) -{ - WW3DErrorType retval = WW3D_ERROR_SAVE_FAILED; - - // - // Save the definition to its own chunk - // - if (csave.Begin_Chunk (W3D_CHUNK_SOUNDROBJ_DEFINITION) == TRUE) { - if (Definition.Save (csave)) { - retval = WW3D_ERROR_OK; - } - csave.End_Chunk (); - } - - return retval; -} - - -//********************************************************************************* -// -// Start of SoundRenderObjDefClass -// -//********************************************************************************* - - -/////////////////////////////////////////////////////////////////////////////////// -// -// Load_W3D -// -/////////////////////////////////////////////////////////////////////////////////// -PrototypeClass * -SoundRenderObjLoaderClass::Load_W3D (ChunkLoadClass &cload) -{ - SoundRenderObjPrototypeClass *prototype = NULL; - - // - // Create a definition object - // - SoundRenderObjDefClass *definition = W3DNEW SoundRenderObjDefClass; - if (definition != NULL) { - - // - // Ask the definition object to load the sound data - // - if (definition->Load_W3D (cload) == WW3D_ERROR_OK) { - - // - // Success! Create a prototype from the definition - // - prototype = W3DNEW SoundRenderObjPrototypeClass (definition); - } - - REF_PTR_RELEASE (definition); - } - - return prototype; -} - -#endif // noWWAUDIO - - diff --git a/Generals/Code/Libraries/Source/WWVegas/WW3D2/soundrobj.h b/Generals/Code/Libraries/Source/WWVegas/WW3D2/soundrobj.h deleted file mode 100644 index a57ba7beb11..00000000000 --- a/Generals/Code/Libraries/Source/WWVegas/WW3D2/soundrobj.h +++ /dev/null @@ -1,285 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** 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 *** - *********************************************************************************************** - * * - * Project Name : WW3D * - * * - * $Archive:: /Commando/Code/ww3d2/soundrobj.h $* - * * - * Author:: Patrick Smith * - * * - * $Modtime:: 1/15/02 5:57p $* - * * - * $Revision:: 4 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#if defined(_MSC_VER) -#pragma once -#endif - -#ifndef __SOUNDROBJ_H -#define __SOUNDROBJ_H - -// TheSuperHackers @compile xezon 05/04/2025 Compile in WWAUDIO for Renegade's w3dview tool. -#define noWWAUDIO 1 - -#if noWWAUDIO // (gth) removing dependency on WWAUDIO - -#include "rendobj.h" -#include "wwstring.h" -#include "proto.h" -#include "w3d_file.h" -#include "w3derr.h" -#include "AudibleSound.h" - - -////////////////////////////////////////////////////////////////////////////////// -// Forward declarations -////////////////////////////////////////////////////////////////////////////////// -class ChunkSaveClass; -class ChunkLoadClass; - - -////////////////////////////////////////////////////////////////////////////////// -// -// SoundRenderObjClass -// -// This object is used to trigger a sound effect in the world. When the object -// is shown, its associated sound is added to the world and played, when the object -// is hidden, the associated sound is stopped and removed from the world. -// -// This is handy when used in conjunction with the aggregate system for creating -// complex animations. -// -////////////////////////////////////////////////////////////////////////////////// -class SoundRenderObjClass : public RenderObjClass -{ -public: - - //////////////////////////////////////////////////////////////// - // Public flags - //////////////////////////////////////////////////////////////// - typedef enum - { - FLAG_STOP_WHEN_HIDDEN = 0x00000001, - - } FLAGS; - - /////////////////////////////////////////////////////////// - // Public constructors/destructors - /////////////////////////////////////////////////////////// - SoundRenderObjClass (void); - SoundRenderObjClass (const SoundRenderObjClass &src); - virtual ~SoundRenderObjClass (void); - - /////////////////////////////////////////////////////////// - // Public operators - /////////////////////////////////////////////////////////// - const SoundRenderObjClass &operator= (const SoundRenderObjClass &src); - - /////////////////////////////////////////////////////////// - // Public methods - /////////////////////////////////////////////////////////// - - // - // From RenderObjClass - // - RenderObjClass * Clone (void) const { return W3DNEW SoundRenderObjClass (*this); } - int Class_ID (void) const { return CLASSID_SOUND; } - const char * Get_Name (void) const { return Name; } - void Set_Name (const char *name) { Name = name; } - void Render (RenderInfoClass &rinfo) { } - void On_Frame_Update (void); - void Set_Hidden (int onoff); - void Set_Visible (int onoff); - void Set_Animation_Hidden (int onoff); - void Set_Force_Visible (int onoff); - void Notify_Added (SceneClass *scene); - void Notify_Removed (SceneClass *scene); - void Set_Transform(const Matrix3D &m); - void Set_Position(const Vector3 &v); - - // - // SoundRenderObjClass specific - // - virtual void Set_Sound (AudibleSoundDefinitionClass *definition); - virtual AudibleSoundClass * Get_Sound (void) const; - virtual AudibleSoundClass * Peek_Sound (void) const { return Sound; } - - // - // Flag support - // - uint32 Get_Flags (void) const { return Flags; } - void Set_Flags (uint32 flags) { Flags = flags; } - bool Get_Flag (uint32 flag) { return bool((Flags & flag) == flag); } - void Set_Flag (uint32 flag, bool onoff); - - -protected: - - /////////////////////////////////////////////////////////// - // Protected methods - /////////////////////////////////////////////////////////// - virtual void Update_On_Visibilty (void); - -private: - - /////////////////////////////////////////////////////////// - // Private member data - /////////////////////////////////////////////////////////// - bool IsInitialized; - StringClass Name; - AudibleSoundClass * Sound; - uint32 Flags; -}; - - -////////////////////////////////////////////////////////////////////////////////// -// -// SoundRenderObjDefClass -// -////////////////////////////////////////////////////////////////////////////////// -class SoundRenderObjDefClass : public RefCountClass -{ -public: - - /////////////////////////////////////////////////////////// - // Public constructors/destructors - /////////////////////////////////////////////////////////// - SoundRenderObjDefClass (void); - SoundRenderObjDefClass (SoundRenderObjClass &render_obj); - SoundRenderObjDefClass (const SoundRenderObjDefClass &src); - virtual ~SoundRenderObjDefClass (void); - - /////////////////////////////////////////////////////////// - // Public operators - /////////////////////////////////////////////////////////// - const SoundRenderObjDefClass &operator= (const SoundRenderObjDefClass &src); - - /////////////////////////////////////////////////////////// - // Public methods - /////////////////////////////////////////////////////////// - RenderObjClass * Create (void); - WW3DErrorType Load_W3D (ChunkLoadClass &cload); - WW3DErrorType Save_W3D (ChunkSaveClass &csave); - const char * Get_Name (void) const { return Name; } - void Set_Name (const char *name) { Name = name; } - SoundRenderObjDefClass * Clone (void) const { return NEW_REF( SoundRenderObjDefClass, (*this) ); } - - // - // Initialization - // - void Initialize (SoundRenderObjClass &render_obj); - -protected: - - /////////////////////////////////////////////////////////// - // Protected methods - /////////////////////////////////////////////////////////// - - // - // Loading methods - // - WW3DErrorType Read_Header (ChunkLoadClass &cload); - WW3DErrorType Read_Definition (ChunkLoadClass &cload); - - // - // Saving methods - // - WW3DErrorType Write_Header (ChunkSaveClass &csave); - WW3DErrorType Write_Definition (ChunkSaveClass &csave); - -private: - - /////////////////////////////////////////////////////////// - // Private member data - /////////////////////////////////////////////////////////// - uint32 Version; - StringClass Name; - AudibleSoundDefinitionClass Definition; - SoundRenderObjClass::FLAGS Flags; -}; - - -/////////////////////////////////////////////////////////////////////////////////// -// -// SoundRenderObjPrototypeClass -// -/////////////////////////////////////////////////////////////////////////////////// -class SoundRenderObjPrototypeClass : public W3DMPO, public PrototypeClass -{ - W3DMPO_GLUE(SoundRenderObjPrototypeClass) -public: - - /////////////////////////////////////////////////////////// - // Public constructors/destructors - /////////////////////////////////////////////////////////// - SoundRenderObjPrototypeClass (SoundRenderObjDefClass *def) - : Definition (NULL) { Set_Definition (def); } - - /////////////////////////////////////////////////////////// - // Public methods - /////////////////////////////////////////////////////////// - const char * Get_Name(void) const { return Definition->Get_Name (); } - int Get_Class_ID(void) const { return RenderObjClass::CLASSID_SOUND; } - RenderObjClass * Create (void) { return Definition->Create (); } - virtual void DeleteSelf() { delete this; } - - SoundRenderObjDefClass * Peek_Definition (void) const { return Definition; } - void Set_Definition (SoundRenderObjDefClass *def) { REF_PTR_SET (Definition, def); } - -protected: - virtual ~SoundRenderObjPrototypeClass (void) { REF_PTR_RELEASE (Definition); } - -private: - - /////////////////////////////////////////////////////////// - // Private member data - /////////////////////////////////////////////////////////// - SoundRenderObjDefClass * Definition; -}; - - -/////////////////////////////////////////////////////////////////////////////////// -// -// SoundRenderObjLoaderClass -// -/////////////////////////////////////////////////////////////////////////////////// -class SoundRenderObjLoaderClass : public PrototypeLoaderClass -{ -public: - virtual int Chunk_Type (void) { return W3D_CHUNK_SOUNDROBJ; } - virtual PrototypeClass * Load_W3D (ChunkLoadClass &cload); -}; - - -/////////////////////////////////////////////////////////////////////////////////// -// Global variables -/////////////////////////////////////////////////////////////////////////////////// -extern SoundRenderObjLoaderClass _SoundRenderObjLoader; - -#endif //noWWAUDIO (gth) removing dependency on wwaudio - -#endif //__SOUNDROBJ_H - diff --git a/Generals/Code/Libraries/Source/WWVegas/WW3D2/sphereobj.cpp b/Generals/Code/Libraries/Source/WWVegas/WW3D2/sphereobj.cpp deleted file mode 100644 index f293b75e197..00000000000 --- a/Generals/Code/Libraries/Source/WWVegas/WW3D2/sphereobj.cpp +++ /dev/null @@ -1,1754 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** 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 *** - *********************************************************************************************** - * * - * Project Name : WW3D * - * * - * $Archive:: /Commando/Code/ww3d2/sphereobj.cpp $* - * * - * Org Author:: Greg Hjelstrom * - * * - * $Author:: Kenny Mitchell * - * * - * $Modtime:: 06/26/02 4:04p $* - * * - * $Revision:: 24 $* - * * - * 06/26/02 KM Matrix name change to avoid MAX conflicts * - *---------------------------------------------------------------------------------------------* - * Functions: * - * SphereRenderObjClass::SphereRenderObjClass -- Constructor * - * SphereRenderObjClass::SphereRenderObjClass -- Constructor - init from a definition * - * SphereRenderObjClass::SphereRenderObjClass -- Copy constructor * - * SphereRenderObjClass::operator -- assignment operator * - * SphereRenderObjClass::Get_Num_Polys -- returns number of polygons * - * SphereRenderObjClass::Get_Name -- returns name * - * SphereRenderObjClass::Set_Name -- sets the name * - * SphereRenderObjClass::render_Sphere -- submits the Sphere to the GERD * - * SphereRenderObjClass::vis_render_Sphere -- submits Sphere to the GERD for VIS * - * SphereRenderObjClass::SphereRenderObjClass -- constructor * - * SphereRenderObjClass::SphereRenderObjClass -- Constructor - init from a definition * - * SphereRenderObjClass::SphereRenderObjClass -- copy constructor * - * SphereRenderObjClass::SphereRenderObjClass -- Constructor from a wwmath aaSphere * - * SphereRenderObjClass::operator -- assignment operator * - * SphereRenderObjClass::Clone -- clones the Sphere * - * SphereRenderObjClass::Class_ID -- returns the class-id for AASphere's * - * SphereRenderObjClass::Render -- render this Sphere * - * SphereRenderObjClass::Special_Render -- special render this Sphere (vis) * - * SphereRenderObjClass::Set_Transform -- set the transform for this Sphere * - * SphereRenderObjClass::Set_Position -- Set the position of this Sphere * - * SphereRenderObjClass::update_cached_Sphere -- update the world-space version of this Spher* - * SphereRenderObjClass::Cast_Ray -- cast a ray against this Sphere * - * SphereRenderObjClass::Cast_AASphere -- cast an AASphere against this Sphere * - * SphereRenderObjClass::Cast_OBSphere -- cast an OBSphere against this Sphere * - * SphereRenderObjClass::Intersect_AASphere -- intersect this Sphere with an AASphere * - * SphereRenderObjClass::Intersect_OBSphere -- Intersect this Sphere with an OBSphere * - * SphereRenderObjClass::Get_Obj_Space_Bounding_Sphere -- return the object-space bounding sp* - * SphereRenderObjClass::Get_Obj_Space_Bounding_Sphere -- returns the obj-space bounding Sphe* - * SphereRenderObjClass::Scale -- scales sphere uniformly. * - * SphereRenderObjClass::Scale -- scales sphere non-uniformly. * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - - -#include "sphereobj.h" -#include "w3d_util.h" -#include "wwdebug.h" -#include "vertmaterial.h" -#include "ww3d.h" -#include "chunkio.h" -#include "rinfo.h" -#include "coltest.h" -#include "bound.h" -#include "inttest.h" -#include "predlod.h" -#include "matrix3.h" -#include "wwmath.h" -#include "assetmgr.h" -#include "wwstring.h" -#include "camera.h" -#include "statistics.h" -#include "dx8wrapper.h" -#include "dx8vertexbuffer.h" -#include "dx8indexbuffer.h" -#include "sortingrenderer.h" -#include "visrasterizer.h" - -static bool Sphere_Array_Valid = false; - -SphereMeshClass SphereMeshArray[SPHERE_NUM_LOD]; -float SphereLODCosts[SPHERE_NUM_LOD + 1]; // SPHERE_NUM_LOD doesn't include the null LOD - - -/* -** SphereRenderObjClass Implementation -*/ - -/*********************************************************************************************** - * SphereRenderObjClass::SphereRenderObjClass -- Constructor * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 1/19/00 gth : Created. * - *=============================================================================================*/ -SphereRenderObjClass::SphereRenderObjClass(void) - : anim_time (0.0F), - IsAnimating (true), - LODBias(1.0f), - CurrentLOD(SPHERE_NUM_LOD), // SPHERE_NUM_LOD does not include the null LOD - AnimDuration (0.0F), - SphereMaterial (NULL), - SphereTexture (NULL), - CurrentColor(0.75f, 0.75f, 0.75F), - CurrentAlpha(1.0f), - CurrentScale(1.0f, 1.0f, 1.0f), - CurrentVector(), - Flags(USE_ALPHA_VECTOR), - ObjSpaceCenter (0, 0, 0), - ObjSpaceExtent (1, 1, 1) -{ - Generate_Shared_Mesh_Arrays ( CurrentVector ); - - Orientation.Make_Identity(); - memset(Name,0,sizeof(Name)); - - Init_Material (); - - // So that the object is ready for use after construction, we will - // complete its initialization by initializing its value array - // according to a screen area of 1. - calculate_value_array(1.0f, Value); -} - - -/*********************************************************************************************** - * SphereRenderObjClass::SphereRenderObjClass -- Constructor - init from a definition * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 1/19/00 gth : Created. * - *=============================================================================================*/ -SphereRenderObjClass::SphereRenderObjClass(const W3dSphereStruct & def) - : anim_time (0.0F), - IsAnimating (true), - LODBias(1.0f), - CurrentLOD(SPHERE_NUM_LOD), // SPHERE_NUM_LOD does not include the null LOD - AnimDuration (0.0F), - SphereMaterial (NULL), - SphereTexture (NULL), - CurrentColor(0.75f, 0.75f, 0.75F), - CurrentAlpha(1.0f), - CurrentScale(1.0f, 1.0f, 1.0f), - CurrentVector(), - Flags(USE_ALPHA_VECTOR), - ObjSpaceCenter (0, 0, 0), - ObjSpaceExtent (1, 1, 1) -{ - Generate_Shared_Mesh_Arrays ( CurrentVector ); - Init_Material (); - Orientation.Make_Identity(); - - // - // Initialize from the defintion - // - Set_Name(def.Name); - Set_Local_Center_Extent ( Vector3 (def.Center.X, def.Center.Y, def.Center.Z), - Vector3 (def.Extent.X, def.Extent.Y, def.Extent.Z)); - - if (def.TextureName[0] != 0) { - SphereTexture = WW3DAssetManager::Get_Instance ()->Get_Texture (def.TextureName); - } - - // So that the object is ready for use after construction, we will - // complete its initialization by initializing its value array - // according to a screen area of 1. - calculate_value_array(1.0f, Value); -} - - -/*********************************************************************************************** - * SphereRenderObjClass::SphereRenderObjClass -- Copy constructor * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 1/19/00 gth : Created. * - *=============================================================================================*/ -SphereRenderObjClass::SphereRenderObjClass(const SphereRenderObjClass & src) - : anim_time (0.0F), - IsAnimating (true), - LODBias(1.0f), - CurrentLOD(SPHERE_NUM_LOD), // SPHERE_NUM_LOD does not include the null LOD - AnimDuration (0.0F), - SphereMaterial (NULL), - SphereTexture (NULL), - CurrentColor(0.75f, 0.75f, 0.75F), - CurrentAlpha(1.0f), - CurrentScale(1.0f, 1.0f, 1.0f), - CurrentVector(), - Flags(USE_ALPHA_VECTOR), - ObjSpaceCenter (0, 0, 0), - ObjSpaceExtent (1, 1, 1) -{ - Generate_Shared_Mesh_Arrays ( CurrentVector ); - Init_Material (); - Orientation.Make_Identity(); - - *this = src; - - // So that the object is ready for use after construction, we will - // complete its initialization by initializing its value array - // according to a screen area of 1. - calculate_value_array(1.0f, Value); -} - -SphereRenderObjClass::~SphereRenderObjClass() -{ - REF_PTR_RELEASE(SphereMaterial); -} // destructor - -/*********************************************************************************************** - * SphereRenderObjClass::operator -- assignment operator * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 1/19/00 gth : Created. * - *=============================================================================================*/ -SphereRenderObjClass & SphereRenderObjClass::operator = (const SphereRenderObjClass & that) -{ - if (this != &that) { - RenderObjClass::operator = (that); - Set_Name(that.Get_Name()); - CurrentColor = that.CurrentColor; - CurrentAlpha = that.CurrentAlpha; - CurrentScale = that.CurrentScale; - CurrentVector = that.CurrentVector; - Flags = that.Flags; - Orientation = that.Orientation; - SphereShader = that.SphereShader; - CachedBox = that.CachedBox; - anim_time = that.anim_time; - AnimDuration = that.AnimDuration; - ObjSpaceCenter = that.ObjSpaceCenter; - ObjSpaceExtent = that.ObjSpaceExtent; - ColorChannel = that.ColorChannel; - AlphaChannel = that.AlphaChannel; - ScaleChannel = that.ScaleChannel; - VectorChannel = that.VectorChannel; - - Set_Texture (that.SphereTexture); - } - - return *this; -} - - -/*********************************************************************************************** - * SphereRenderObjClass::Generate_Shared_Mesh_Arrays -- Generates mesh LOD arrays. * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 03/08/00 pds : Created. * - *=============================================================================================*/ -void SphereRenderObjClass::Generate_Shared_Mesh_Arrays (const AlphaVectorStruct &alphavector) -{ - // Generate shared Mesh Arrays - if (!Sphere_Array_Valid) { - - float size = SPHERE_LOWEST_LOD; - float step = (SPHERE_HIGHEST_LOD - SPHERE_LOWEST_LOD); - step /= SPHERE_NUM_LOD; - - // For NULL LOD set Cost to a small nonzero amount to avoid divisions by zero. - SphereLODCosts[0] = 0.000001f; - for(int i=0; i < SPHERE_NUM_LOD; i++) { - - SphereMeshArray[i].Generate(1.0f, size, size); - SphereLODCosts[i + 1] = SphereMeshArray[i].Get_Num_Polys(); - - size+=step; - - SphereMeshArray[i].Set_Alpha_Vector( alphavector, false, false ); - - } - - Sphere_Array_Valid = true; - } - - return ; -} - - -// This is used both by Prepare_LOD and Calculate_Cost_Value_Arrays. -void SphereRenderObjClass::calculate_value_array(float screen_area, float *values) const -{ - values[0] = AT_MIN_LOD; - for (int lod = 1; lod <= SPHERE_NUM_LOD; lod++) { - float polycount = SphereLODCosts[lod]; - float benefit_factor = 1 - (0.5f / (polycount * polycount)); - values[lod] = (benefit_factor * screen_area * LODBias) / polycount; - } - values[SPHERE_NUM_LOD + 1] = AT_MAX_LOD; // Post-inc value will flag max LOD. -} - - -/*********************************************************************************************** - * SphereRenderObjClass::Init_Material -- Sets up the material and default shader for the sphere.* - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 03/08/00 pds : Created. * - *=============================================================================================*/ -void SphereRenderObjClass::Init_Material (void) -{ - REF_PTR_RELEASE (SphereMaterial); - - SphereMaterial = NEW_REF(VertexMaterialClass,()); - SphereMaterial->Set_Ambient(0,0,0); - SphereMaterial->Set_Diffuse(0,0,0); - SphereMaterial->Set_Specular(0,0,0); - SphereMaterial->Set_Emissive(1,1,1); - SphereMaterial->Set_Opacity(0.25f); - SphereMaterial->Set_Shininess(0.0f); - SphereMaterial->Set_Lighting(true); - - // Texturing, zbuffer, primary gradient, alpha blending - SphereShader = ShaderClass::_PresetAlphaShader; - - // (gth) Looks like sphere's were coded with backwards normals! Quick fix (though expensive) - // is to turn off backface culling... ug... - SphereShader.Set_Cull_Mode(ShaderClass::CULL_MODE_DISABLE); - -} // Init_Material - - -/*********************************************************************************************** - * SphereRenderObjClass::Get_Num_Polys -- returns number of polygons * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 1/19/00 gth : Created. * - *=============================================================================================*/ -int SphereRenderObjClass::Get_Num_Polys(void) const -{ - return SphereLODCosts[CurrentLOD]; -} - - -/*********************************************************************************************** - * SphereRenderObjClass::Set_Texture * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 1/19/00 gth : Created. * - *=============================================================================================*/ -void SphereRenderObjClass::Set_Texture(TextureClass *tf) -{ - REF_PTR_SET(SphereTexture,tf); -} - - -/*********************************************************************************************** - * SphereRenderObjClass::Get_Name -- returns name * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 1/19/00 gth : Created. * - *=============================================================================================*/ -const char * SphereRenderObjClass::Get_Name(void) const -{ - return Name; -} - - -/*********************************************************************************************** - * SphereRenderObjClass::Set_Name -- sets the name * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 1/19/00 gth : Created. * - *=============================================================================================*/ -void SphereRenderObjClass::Set_Name(const char * name) -{ - WWASSERT(name != NULL); - WWASSERT(strlen(name) < 2*W3D_NAME_LEN); - strcpy(Name,name); -} - - -/*********************************************************************************************** - * SphereRenderObjClass::render_sphere * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 3/01/00 jga : Created. * - * 2/19/01 HY : upgraded to DX8 * - *=============================================================================================*/ -void SphereRenderObjClass::render_sphere() -{ - // Should never get here with NULL LOD - if (CurrentLOD == 0) { - WWASSERT(0); - return; - } - - SphereMeshClass & mesh = SphereMeshArray[CurrentLOD - 1]; - - if (SphereTexture) { - SphereShader.Set_Texturing (ShaderClass::TEXTURING_ENABLE); - } else { - SphereShader.Set_Texturing (ShaderClass::TEXTURING_DISABLE); - } - DX8Wrapper::Set_Shader(SphereShader); - DX8Wrapper::Set_Texture(0,SphereTexture); - DX8Wrapper::Set_Material(SphereMaterial); - - // Enable sorting if the primitive is translucent, alpha testing is not enabled, and sorting is enabled globally. - const bool sort = (SphereShader.Get_Dst_Blend_Func() != ShaderClass::DSTBLEND_ZERO) && (SphereShader.Get_Alpha_Test() == ShaderClass::ALPHATEST_DISABLE) && (WW3D::Is_Sorting_Enabled()); - const unsigned int buffer_type = sort ? BUFFER_TYPE_DYNAMIC_SORTING : BUFFER_TYPE_DYNAMIC_DX8; - - DynamicVBAccessClass vb(buffer_type, dynamic_fvf_type, mesh.Vertex_ct); - { - DynamicVBAccessClass::WriteLockClass Lock(&vb); - VertexFormatXYZNDUV2 *vb = Lock.Get_Formatted_Vertex_Array(); - - for (int i=0; ix = mesh.vtx[i].X; - vb->y = mesh.vtx[i].Y; - vb->z = mesh.vtx[i].Z; - - vb->nx = mesh.vtx_normal[i].X; // may not need this! - vb->ny = mesh.vtx_normal[i].Y; - vb->nz = mesh.vtx_normal[i].Z; - - if (Flags & USE_ALPHA_VECTOR) { - vb->diffuse = DX8Wrapper::Convert_Color(mesh.dcg[i]); - } else { - vb->diffuse = 0xFFFFFFFF; // TODO could combine the material color with this and turn off lighting - } - - if (SphereTexture) { - vb->u1 = mesh.vtx_uv[i].X; - vb->v1 = mesh.vtx_uv[i].Y; - } - vb++; - } - } - - DynamicIBAccessClass ib(buffer_type, mesh.face_ct*3); - { - DynamicIBAccessClass::WriteLockClass Lock(&ib); - unsigned short *mem=Lock.Get_Index_Array(); - for (int i=0; iProcess_Reduction(); - - Matrix3D temp = Transform; - - // Do Time Based Animation - animate(); - - // Scale - - Vector3 real_scale; - real_scale.X = ObjSpaceExtent.X * CurrentScale.X; - real_scale.Y = ObjSpaceExtent.Y * CurrentScale.Y; - real_scale.Z = ObjSpaceExtent.Z * CurrentScale.Z; - temp.Scale(real_scale); - - // - // Configure the alpha - // - bool is_additive = (SphereShader.Get_Dst_Blend_Func () == ShaderClass::DSTBLEND_ONE); - if (is_additive) { - SphereMaterial->Set_Emissive (CurrentAlpha * CurrentColor); - } else { - SphereMaterial->Set_Opacity (CurrentAlpha); - SphereMaterial->Set_Emissive (CurrentColor); - } - - // If using Alpha Vector, check to see if it needs updated - if (Flags & USE_ALPHA_VECTOR) { - - bool use_inverse = false; - - if (Flags & USE_INVERSE_ALPHA) { - use_inverse = true; - } - - SphereMeshArray[CurrentLOD - 1].Set_Alpha_Vector( CurrentVector, use_inverse, is_additive ); - } - - // Camera Align - if (Flags & USE_CAMERA_ALIGN) { - Matrix4x4 view,ident(true); - DX8Wrapper::Get_Transform(D3DTS_VIEW,view); - - Vector4 wpos(Transform[0][3],Transform[1][3],Transform[2][3],1); - Vector4 cpos; - - Matrix4x4::Transform_Vector(view,wpos,&cpos); - Matrix3D tm(0.0f, 1.0f, 0.0f, cpos.X, - 0.0f, 0.0f, 1.0f, cpos.Y, - 1.0f, 0.0f, 0.0f, cpos.Z); - - tm.Scale(real_scale); - DX8Wrapper::Set_Transform(D3DTS_WORLD,ident); - DX8Wrapper::Set_Transform(D3DTS_VIEW,tm); - render_sphere(); - DX8Wrapper::Set_Transform(D3DTS_VIEW,view); - } else { - DX8Wrapper::Set_Transform(D3DTS_WORLD,temp); - render_sphere(); - } - } -} - - -/*********************************************************************************************** - * SphereRenderObjClass::Special_Render -- special render this box (vis) * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 1/19/00 gth : Created. * - *=============================================================================================*/ -void SphereRenderObjClass::Special_Render(SpecialRenderInfoClass & rinfo) -{ - Matrix3D temp(1); - temp.Translate(Transform.Get_Translation()); - - if (rinfo.RenderType == SpecialRenderInfoClass::RENDER_VIS) { - WWASSERT(rinfo.VisRasterizer != NULL); - rinfo.VisRasterizer->Set_Model_Transform(temp); - vis_render_sphere(rinfo,ObjSpaceCenter,ObjSpaceExtent); - } -} - - -/*********************************************************************************************** - * SphereRenderObjClass::Set_Transform -- set the transform for this box * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 1/19/00 gth : Created. * - *=============================================================================================*/ -void SphereRenderObjClass::Set_Transform(const Matrix3D &m) -{ - RenderObjClass::Set_Transform(m); - update_cached_box(); -} - - -/*********************************************************************************************** - * SphereRenderObjClass::Set_Position -- Set the position of this box * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 1/19/00 gth : Created. * - *=============================================================================================*/ -void SphereRenderObjClass::Set_Position(const Vector3 &v) -{ - RenderObjClass::Set_Position(v); - update_cached_box(); -} - - -/*********************************************************************************************** - * SphereRenderObjClass::update_cached_box -- update the world-space version of this box * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 1/19/00 gth : Created. * - *=============================================================================================*/ -void SphereRenderObjClass::update_cached_box(void) -{ - CachedBox.Center = Transform.Get_Translation() + ObjSpaceCenter; - CachedBox.Extent = ObjSpaceExtent; -} - - -/*********************************************************************************************** - * SphereRenderObjClass::Get_Obj_Space_Bounding_Sphere -- return the object-space bounding sphe * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 1/19/00 gth : Created. * - *=============================================================================================*/ -void SphereRenderObjClass::Get_Obj_Space_Bounding_Sphere(SphereClass & sphere) const -{ - sphere.Init(ObjSpaceCenter,ObjSpaceExtent.Length()); -} - - -/*********************************************************************************************** - * SphereRenderObjClass::Get_Obj_Space_Bounding_Box -- returns the obj-space bounding box * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 1/19/00 gth : Created. * - *=============================================================================================*/ -void SphereRenderObjClass::Get_Obj_Space_Bounding_Box(AABoxClass & box) const -{ - box.Init(ObjSpaceCenter,ObjSpaceExtent); -} - - -void SphereRenderObjClass::Prepare_LOD(CameraClass &camera) -{ - if (Is_Not_Hidden_At_All() == false) { - return; - } - - calculate_value_array(Get_Screen_Size(camera), Value); - - PredictiveLODOptimizerClass::Add_Object(this); -} - -void SphereRenderObjClass::Increment_LOD(void) -{ - if (CurrentLOD < SPHERE_NUM_LOD) CurrentLOD++; -} - -void SphereRenderObjClass::Decrement_LOD(void) -{ - if (CurrentLOD > 0) CurrentLOD--; -} - -float SphereRenderObjClass::Get_Cost(void) const -{ - return Get_Num_Polys(); // Currently cost == polys -} - -float SphereRenderObjClass::Get_Value(void) const -{ - return Value[CurrentLOD]; -} - -float SphereRenderObjClass::Get_Post_Increment_Value(void) const -{ - return Value[CurrentLOD + 1]; -} - -void SphereRenderObjClass::Set_LOD_Level(int lod) -{ - CurrentLOD = Bound(lod, 0, SPHERE_NUM_LOD); // SPHERE_NUM_LOD doesn't include the null LOD -} - -int SphereRenderObjClass::Get_LOD_Level(void) const -{ - return CurrentLOD; -} - -int SphereRenderObjClass::Get_LOD_Count(void) const -{ - return SPHERE_NUM_LOD + 1; // SPHERE_NUM_LOD doesn't include the null LOD -} - -int SphereRenderObjClass::Calculate_Cost_Value_Arrays(float screen_area, float *values, float *costs) const -{ - calculate_value_array(screen_area, values); - for (int lod = 0; lod <= SPHERE_NUM_LOD; lod++) { - costs[lod] = SphereLODCosts[lod]; - } - - // We currently don't support max screen size or minimum LOD clamping for sphere objects - return 0; -} - - -/*********************************************************************************************** - * SphereRenderObjClass::Scale -- scales sphere uniformly. * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 7/01/02 NH : Created. * - *=============================================================================================*/ -void SphereRenderObjClass::Scale(float scale) -{ - if (scale == 1.0f) return; - - // Scale default value - CurrentScale *= scale; - - // Loop over all keys in scale channel and scale values. - int i; - int count = ScaleChannel.Get_Key_Count(); - for (i = 0; i < count; i++) { - const PrimitiveAnimationChannelClass::KeyClass &key = ScaleChannel.Get_Key(i); - ScaleChannel.Set_Key_Value(i, key.Get_Value() * scale); - } -} - - -/*********************************************************************************************** - * SphereRenderObjClass::Scale -- scales sphere non-uniformly. * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 7/01/02 NH : Created. * - *=============================================================================================*/ -void SphereRenderObjClass::Scale(float scalex, float scaley, float scalez) -{ - // Scale default value - CurrentScale.X *= scalex; - CurrentScale.Y *= scaley; - CurrentScale.Z *= scalez; - - // Loop over all keys in scale channel and scale values. - int i; - int count = ScaleChannel.Get_Key_Count(); - for (i = 0; i < count; i++) { - const PrimitiveAnimationChannelClass::KeyClass &key = ScaleChannel.Get_Key(i); - Vector3 key_val = key.Get_Value(); - key_val.X *= scalex; - key_val.Y *= scaley; - key_val.Z *= scalez; - ScaleChannel.Set_Key_Value(i, key_val); - } -} - - - -/*********************************************************************************************** - * SphereRenderObjClass::Update_Cached_Bounding_Volumes -- Updates world-space bounding volumes * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 1/19/00 gth : Created. * - *=============================================================================================*/ -void SphereRenderObjClass::Update_Cached_Bounding_Volumes(void) const -{ - CachedBoundingBox.Extent.X = ObjSpaceExtent.X * CurrentScale.X; - CachedBoundingBox.Extent.Y = ObjSpaceExtent.Y * CurrentScale.Y; - CachedBoundingBox.Extent.Z = ObjSpaceExtent.Z * CurrentScale.Z; - - CachedBoundingSphere.Center = CachedBoundingBox.Center = Get_Position() + ObjSpaceCenter; - CachedBoundingSphere.Radius = CachedBoundingBox.Extent.Length(); - - Validate_Cached_Bounding_Volumes(); -} - - -/*********************************************************************************************** - * SphereRenderObjClass::Get_Default_Color - get the default (or first frame) value * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 3/13/2000 pds : Created. * - *=============================================================================================*/ -Vector3 SphereRenderObjClass::Get_Default_Color(void) const -{ - Vector3 value; - - if (ColorChannel.Get_Key_Count () > 0) { - value = ColorChannel.Get_Key (0).Get_Value (); - } else { - value = CurrentColor; - } - - return value; -} - - -/*********************************************************************************************** - * SphereRenderObjClass::Get_Default_Alpha - get the default (or first frame) value * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 3/13/2000 pds : Created. * - *=============================================================================================*/ -float SphereRenderObjClass::Get_Default_Alpha(void) const -{ - float value; - - if (AlphaChannel.Get_Key_Count () > 0) { - value = AlphaChannel.Get_Key (0).Get_Value (); - } else { - value = CurrentAlpha; - } - - return value; -} - - -/*********************************************************************************************** - * SphereRenderObjClass::Get_Default_Scale - get the default (or first frame) value * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 3/13/2000 pds : Created. * - *=============================================================================================*/ -Vector3 SphereRenderObjClass::Get_Default_Scale(void) const -{ - Vector3 value; - - if (ScaleChannel.Get_Key_Count () > 0) { - value = ScaleChannel.Get_Key (0).Get_Value (); - } else { - value = CurrentScale; - } - - return value; -} - - -/*********************************************************************************************** - * SphereRenderObjClass::Get_Default_Vector - get the default (or first frame) value * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 3/13/2000 pds : Created. * - *=============================================================================================*/ -AlphaVectorStruct SphereRenderObjClass::Get_Default_Vector(void) const -{ - AlphaVectorStruct value; - - if (VectorChannel.Get_Key_Count () > 0) { - value = VectorChannel.Get_Key (0).Get_Value (); - } else { - value = CurrentVector; - } - - return value; -} - - -/*********************************************************************************************** - * SphereRenderObjClass::Update_On_Visibilty -- Either starts or stops the animation based on visibility* - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 4/04/00 pds : Created. * - *=============================================================================================*/ -void SphereRenderObjClass::Update_On_Visibilty(void) -{ - // Simply start or stop the animation based on - // the visibility state of the primitive. - if (Is_Not_Hidden_At_All () && Is_Animating () == false) { - Start_Animating (); - } else if ((Is_Not_Hidden_At_All () == false) && Is_Animating ()) { - Stop_Animating (); - } - - return ; -} - - -/*********************************************************************************************** - * SphereRenderObjClass::animate -- Update Current Display state * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 3/07/00 jga : Created. * - *=============================================================================================*/ -void SphereRenderObjClass::animate (void) -{ - if (Is_Animating ()) { - - if ( ColorChannel.Get_Key_Count () > 0 || - AlphaChannel.Get_Key_Count () > 0 || - ScaleChannel.Get_Key_Count () > 0 || - VectorChannel.Get_Key_Count () > 0) - { - // - // Convert from milliseconds to seconds and normalize the time - // - if (AnimDuration > 0) { - float frametime = WW3D::Get_Frame_Time(); - frametime = (frametime * 0.001F) / AnimDuration; - anim_time += frametime; - } else { - anim_time = 1.0F; - } - WWASSERT (anim_time >= 0.0F); - - if ((Flags & USE_ANIMATION_LOOP) && anim_time > 1.0F) { - anim_time -= 1.0F; - } - - if (ColorChannel.Get_Key_Count () > 0) { - CurrentColor = ColorChannel.Evaluate (anim_time); - } - - if (AlphaChannel.Get_Key_Count () > 0) { - CurrentAlpha = AlphaChannel.Evaluate (anim_time); - } - - if (ScaleChannel.Get_Key_Count () > 0) { - CurrentScale = ScaleChannel.Evaluate (anim_time); - Update_Cached_Bounding_Volumes (); - } - - if (VectorChannel.Get_Key_Count () > 0) { - CurrentVector = VectorChannel.Evaluate (anim_time); - } - } - } - - return ; - -} // animate - - -/* -** SphereLoaderClass Implementation -*/ -PrototypeClass * SphereLoaderClass::Load_W3D(ChunkLoadClass & cload) -{ - SpherePrototypeClass *prototype = W3DNEW SpherePrototypeClass; - prototype->Load (cload); - return prototype; -} - -/* -** SpherePrototypeClass Implementation -*/ -SpherePrototypeClass::SpherePrototypeClass (void) -{ - ::memset (&Definition, 0, sizeof (Definition)); - return ; -} - -SpherePrototypeClass::SpherePrototypeClass(SphereRenderObjClass *sphere) -{ - ::memset (&Definition, 0, sizeof (Definition)); - ::strcpy (Definition.Name, sphere->Get_Name ()); - - Definition.DefaultAlpha = sphere->Get_Default_Alpha (); - Definition.AnimDuration = sphere->AnimDuration; - Definition.Attributes = sphere->Get_Flags (); - Definition.DefaultVector = sphere->Get_Default_Vector (); - - Vector3 def_color = sphere->Get_Default_Color (); - Vector3 def_scale = sphere->Get_Default_Scale (); - W3dUtilityClass::Convert_Vector (def_color, &Definition.DefaultColor); - W3dUtilityClass::Convert_Vector (def_scale, &Definition.DefaultScale); - - W3dUtilityClass::Convert_Vector (sphere->Get_Box ().Center, &Definition.Center); - W3dUtilityClass::Convert_Vector (sphere->Get_Box ().Extent, &Definition.Extent); - W3dUtilityClass::Convert_Shader (sphere->SphereShader, &Definition.Shader); - - // - // Determine the texture name for this sphere - // - if (sphere->SphereTexture != NULL) { - StringClass name = sphere->SphereTexture->Get_Full_Path(); - const char *filename = ::strrchr (name, '\\'); - if (filename != NULL) { - filename ++; - } else { - filename = name; - } - - ::strcpy (Definition.TextureName, filename); - - } - - // - // Save the animateable channels - // - ColorChannel = sphere->Peek_Color_Channel (); - AlphaChannel = sphere->Peek_Alpha_Channel (); - ScaleChannel = sphere->Peek_Scale_Channel (); - VectorChannel = sphere->Peek_Vector_Channel (); - return ; -} - -SpherePrototypeClass::~SpherePrototypeClass (void) -{ - return ; -} - -enum -{ - CHUNKID_SPHERE_DEF = 1, - CHUNKID_COLOR_CHANNEL, - CHUNKID_ALPHA_CHANNEL, - CHUNKID_SCALE_CHANNEL, - CHUNKID_VECTOR_CHANNEL -}; - -bool SpherePrototypeClass::Load (ChunkLoadClass &cload) -{ - ColorChannel.Reset (); - AlphaChannel.Reset (); - ScaleChannel.Reset (); - VectorChannel.Reset (); - - while (cload.Open_Chunk ()) { - switch (cload.Cur_Chunk_ID ()) { - - case CHUNKID_SPHERE_DEF: - cload.Read (&Definition, sizeof (Definition)); - break; - - case CHUNKID_COLOR_CHANNEL: - ColorChannel.Load (cload); - break; - - case CHUNKID_ALPHA_CHANNEL: - AlphaChannel.Load (cload); - break; - - case CHUNKID_SCALE_CHANNEL: - ScaleChannel.Load (cload); - break; - - case CHUNKID_VECTOR_CHANNEL: - VectorChannel.Load (cload); - break; - } - - cload.Close_Chunk (); - } - - return true; -} - -bool SpherePrototypeClass::Save (ChunkSaveClass &csave) -{ - csave.Begin_Chunk (W3D_CHUNK_SPHERE); - - csave.Begin_Chunk (CHUNKID_SPHERE_DEF); - csave.Write (&Definition, sizeof (Definition)); - csave.End_Chunk (); - - if (ColorChannel.Get_Key_Count () > 0) { - csave.Begin_Chunk (CHUNKID_COLOR_CHANNEL); - ColorChannel.Save (csave); - csave.End_Chunk (); - } - - if (AlphaChannel.Get_Key_Count () > 0) { - csave.Begin_Chunk (CHUNKID_ALPHA_CHANNEL); - AlphaChannel.Save (csave); - csave.End_Chunk (); - } - - - if (ScaleChannel.Get_Key_Count () > 0) { - csave.Begin_Chunk (CHUNKID_SCALE_CHANNEL); - ScaleChannel.Save (csave); - csave.End_Chunk (); - } - - if (VectorChannel.Get_Key_Count () > 0) { - csave.Begin_Chunk (CHUNKID_VECTOR_CHANNEL); - VectorChannel.Save (csave); - csave.End_Chunk (); - } - - csave.End_Chunk (); - return true; -} - -const char * SpherePrototypeClass::Get_Name(void) const -{ - return Definition.Name; -} - -int SpherePrototypeClass::Get_Class_ID(void) const -{ - return RenderObjClass::CLASSID_SPHERE; -} - -RenderObjClass * SpherePrototypeClass::Create(void) -{ - // - // Create the new render object - // - SphereRenderObjClass *sphere = W3DNEW SphereRenderObjClass (Definition); - - // - // Configure the sphere - // - W3dUtilityClass::Convert_Shader (Definition.Shader, &sphere->SphereShader); - if (WW3DAssetManager::Get_Instance()->Get_Activate_Fog_On_Load()) { - sphere->SphereShader.Enable_Fog ("SpherePrototypeClass"); - } - W3dUtilityClass::Convert_Vector (Definition.DefaultColor, &sphere->CurrentColor); - W3dUtilityClass::Convert_Vector (Definition.DefaultScale, &sphere->CurrentScale); - sphere->CurrentVector = Definition.DefaultVector; - sphere->Set_Animation_Duration (Definition.AnimDuration); - sphere->CurrentAlpha = Definition.DefaultAlpha; - sphere->Set_Flags (Definition.Attributes); - - // - // Initialize the render object with the keyframe arrays - // - sphere->Set_Color_Channel (ColorChannel); - sphere->Set_Alpha_Channel (AlphaChannel); - sphere->Set_Scale_Channel (ScaleChannel); - sphere->Set_Vector_Channel (VectorChannel); - return sphere; -} - -/* -** Global instance of the box loader -*/ -SphereLoaderClass _SphereLoader; - - -// -// Vertices are ordered as such -// North Pole, stack 1, stack 2, stack x..., SouthPole -// -/*********************************************************************************************** - * SphereMeshClass::SphereMeshClass -- Constructor for SphereMesh Geometry * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 3/07/00 jga : Created. * - *=============================================================================================*/ -SphereMeshClass::SphereMeshClass(float radius, int slices, int stacks): -Radius(radius), -Slices(slices), -Stacks(stacks), -Vertex_ct(0), -vtx(NULL), -vtx_normal(NULL), -vtx_uv(NULL), -strip_ct(0), -strip_size(0), -strips(NULL), -fan_ct(0), -fan_size(0), -fans(NULL), -face_ct(0), -tri_poly(NULL), -inverse_alpha(false) -{ - // compute # of vertices - // 1st 2 vertices, represent, north, and south pole (Y - axis) - - Generate(radius, slices, stacks); - -} // SphereMesh Constructor - -/*********************************************************************************************** - * SphereMeshClass::SphereMeshClass -- Constructor for SphereMesh Geometry * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 3/07/00 jga : Created. * - *=============================================================================================*/ -SphereMeshClass::SphereMeshClass(void): -Radius(0.0f), -Slices(0), -Stacks(0), -Vertex_ct(0), -vtx(NULL), -vtx_normal(NULL), -vtx_uv(NULL), -strip_ct(0), -strip_size(0), -strips(NULL), -fan_ct(0), -fan_size(0), -fans(NULL), -face_ct(0), -tri_poly(NULL), -inverse_alpha(false) -{ - -} // Empty SphereMesh Constructor - - - -/*********************************************************************************************** - * SphereMeshClass::Set_Alpha_Vector -- Unit Direction Vector, for Alpha hole effects * - * * - * INPUT: vector4 v ; Unit Vector pointing into the sphere in object space * - * .W = Intensity ; Percent Effect * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 3/07/00 jga : Created. * - *=============================================================================================*/ -void SphereMeshClass::Set_Alpha_Vector (const AlphaVectorStruct &v, bool inverse, bool is_additive, bool force) -{ - // - // Exit if there is nothing to do... - // - if ( alpha_vector == v && - inverse == inverse_alpha && - is_additive == IsAdditive && - !force) - { - return ; - } - - inverse_alpha = inverse; - alpha_vector = v; - - float Intensity = v.intensity; - assert(Intensity >= 0.0f); - - Vector3 vec = alpha_vector.angle.Rotate_Vector (Vector3 (1, 0, 0)); - - if (inverse_alpha) { - for (int idx=0; idx < Vertex_ct; idx++) { - - float temp; - temp = Vector3::Dot_Product(vec, vtx_normal[idx]); - temp*= Intensity; - - temp = fabs(temp); - - if (temp > 1.0f) temp = 1.0f; - - Set_DCG (is_additive, idx, temp); - } - - } else { - - for (int idx=0; idx < Vertex_ct; idx++) { - - float temp; - temp = Vector3::Dot_Product(vec, vtx_normal[idx]); - temp*= Intensity; - - temp = fabs(temp); - - if (temp > 1.0f) temp = 1.0f; - - Set_DCG (is_additive, idx, 1.0F - temp); - } - } - - return ; -} // Set_Alpha_Vector - - -/*********************************************************************************************** - * SphereMeshClass::Generate -- Alloc Memory, and Generate Geometry, for the SphereMesh * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 3/07/00 jga : Created. * - *=============================================================================================*/ -void SphereMeshClass::Generate(float radius, int slices, int stacks) -{ - // compute # of vertices - // 1st 2 vertices, represent, north, and south pole (Y - axis) - - Free(); - - Slices = slices; - Stacks = stacks; - Radius = radius; - - face_ct = (Slices * Stacks * 2); - - Vertex_ct = ((Slices+1) * Stacks) + 2; - - vtx = W3DNEWARRAY Vector3[Vertex_ct]; - vtx_normal = W3DNEWARRAY Vector3[Vertex_ct]; - vtx_uv = W3DNEWARRAY Vector2[Vertex_ct]; - dcg = W3DNEWARRAY Vector4[Vertex_ct]; - - Matrix3x3 mat; - Vector3 vec(0.0f, 0.0f, radius); - - Vector3 *veclist = vtx; - Vector2 *uv = vtx_uv; - - *veclist = vec; // assign north pole - veclist++; - - // Generate Vertex UV coordinates - // - // 0,0 _____ 1,0 - // Texture maps UV's look something like this |_____| - // 0,1 1,1 - // - // - - uv->U = 0.5f; uv->V = 0.0f; // assign uv for north pole - uv++; - - for (stacks = 0; stacks < Stacks; stacks++) { - - float stackstep = ((float)stacks + 1) / ((float) Stacks+1); - float XAxisAngle = WWMATH_PI * stackstep; - - for (slices = 0; slices <= Slices; slices++) { - - float slicestep = ((float)slices) / ((float)Slices); - float YAxisAngle = (WWMATH_PI * 2.0f) * slicestep; - - - mat.Make_Identity(); - mat.Rotate_Z( YAxisAngle ); - mat.Rotate_X( XAxisAngle ); - *veclist = mat * vec; - - veclist++; - - // update UV - - uv->U = slicestep; - uv->V = stackstep; - uv++; - - } // for slices - } // for stacks - - // Assign vertex for south pole; - *veclist = -1.0f * vec; - uv->U = 0.5f; uv->V = 1.0f; // uv for south pole - - // Generate Vertex Normals - - Vector3 *src = vtx; - Vector3 *dst = vtx_normal; - - for(int idx = 0; idx < Vertex_ct; idx++) { - - Vector3 temp; - - temp = src[idx]; - temp.Normalize(); - dst[idx] = temp; - } - - - // Generate Fans for North + south pole - fan_ct = 2; - fan_size = Slices+2; - fans = W3DNEWARRAY int[fan_size * fan_ct]; - - // Do Fan #1 - int ct = 0; - for (; ct < fan_size; ct++) { - fans[ct] = ct; - } - //fans[ct] = 1; - - // Do Fan #2 - int vtx_idx = Vertex_ct - 1; - for (ct = fan_size; ct < (fan_size * 2); ct++) { - fans[ct] = vtx_idx; - vtx_idx--; - } - //fans[ct] = Vertex_ct - 2; - - // Generate Strips, for the inbetween stacks - - strip_size = ((Slices+1) * 2); - strip_ct = Stacks - 1; - if (strip_ct) { - strips = W3DNEWARRAY int[strip_size * strip_ct]; - for (stacks = 0; stacks < strip_ct; stacks++) { - // outer loop for each stack - int store_idx = stacks * strip_size; - int base_vtx = 1 + (stacks * (Slices+1)); - int cur_vtx = base_vtx; - - for(ct = 0; ct <= Slices; ct++) { - - strips[store_idx] = cur_vtx + (Slices+1); - strips[store_idx+1] = cur_vtx; - - cur_vtx++; - store_idx+=2; - - } - - // Last, special case +2 - //strips[store_idx] = base_vtx + Slices; - //strips[store_idx+1] = base_vtx; - } - } - - // Generate Tri-Poly Indices - - tri_poly = W3DNEWARRAY TriIndex[face_ct]; // 3 indices per triangle - - TriIndex *out = tri_poly; - int *in; - - for (stacks = 0; stacks < strip_ct; stacks++) { - - in = &strips[strip_size * stacks]; - - // Strip to Poly Function - // IJK - for(int fidx=0; fidx < (strip_size - 2); fidx++) { - - out->I = in[0]; - out->J = in[1]; - out->K = in[2]; - - out++; - in++; - - fidx++; - if (fidx >= (strip_size-2)) break; - - out->I = in[0]; - out->J = in[2]; - out->K = in[1]; - out++; - in++; - - } - - // End Strip to Poly Function - } - - - // Fans to Poly Function - - for(slices = 0; slices < fan_ct; slices++) { - - in = &fans[fan_size * slices]; - int *base_idx = in; - - for (int fidx=0; fidx < (fan_size - 2); fidx++) { - - out->I = base_idx[0]; - out->J = in[2]; - out->K = in[1]; - - in++; - out++; - } - - } - - // Make Sure ptr is where I expect it to be - WWASSERT(((int)out) == ((int)(tri_poly + face_ct))); - - // - // Fill in the DCG array - // - Set_Alpha_Vector (alpha_vector, inverse_alpha, IsAdditive, true); - return ; - -} // Generate - - - -/*********************************************************************************************** - * SphereMeshClass::~SphereMeshClass -- Destructor * - * * - * WARNINGS: * - * * - * HISTORY: * - * 3/07/00 jga : Created. * - *=============================================================================================*/ -SphereMeshClass::~SphereMeshClass(void) -{ - - Free(); - -} // Destructor - - -/*********************************************************************************************** - * SphereMeshClass::Free Memory used by geometry for the SphereMesh * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 3/07/00 jga : Created. * - *=============================================================================================*/ -void SphereMeshClass::Free(void) -{ - if (vtx) delete [] vtx; - if (vtx_normal) delete [] vtx_normal; - if (vtx_uv) delete [] vtx_uv; - if (dcg) delete [] dcg; - if (strips) delete [] strips; - if (fans) delete [] fans; - if (tri_poly) delete [] tri_poly; - - vtx = NULL; - vtx_normal = NULL; - vtx_uv = NULL; - dcg = NULL; - strips = NULL; - fans = NULL; - tri_poly = NULL; - -} - -// EOF - sphereobj.cpp - diff --git a/Generals/Code/Libraries/Source/WWVegas/WW3D2/sphereobj.h b/Generals/Code/Libraries/Source/WWVegas/WW3D2/sphereobj.h deleted file mode 100644 index 4620509efa2..00000000000 --- a/Generals/Code/Libraries/Source/WWVegas/WW3D2/sphereobj.h +++ /dev/null @@ -1,479 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** 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 *** - *********************************************************************************************** - * * - * Project Name : WW3D * - * * - * $Archive:: /Commando/Code/ww3d2/sphereobj.h $* - * * - * Author:: Jason Andersen * - * * - * $Modtime:: 11/24/01 6:21p $* - * * - * $Revision:: 7 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#if defined(_MSC_VER) -#pragma once -#endif - -#ifndef SPHEREOBJ_H -#define SPHEREOBJ_H - -#include "always.h" -#include "rendobj.h" -#include "w3d_file.h" -#include "shader.h" -#include "proto.h" -#include "obbox.h" -#include "Vector3i.h" -#include "quat.h" -#include "prim_anim.h" -#include "meshgeometry.h" - -class TextureClass; - -struct AlphaVectorStruct -{ - AlphaVectorStruct (void) - : angle (true), - intensity (1.0F) { } - AlphaVectorStruct (const AlphaVectorStruct &src) { *this = src; } - - bool operator== (const AlphaVectorStruct &src) { return (angle.X == src.angle.X) && (angle.Y == src.angle.Y) && (angle.Z == src.angle.Z) && (intensity == src.intensity); } - bool operator!= (const AlphaVectorStruct &src) { return ! operator== (src); } - - const AlphaVectorStruct & operator= (const AlphaVectorStruct &src) { angle = src.angle; intensity = src.intensity; return *this; } - - Quaternion angle; - float intensity; -}; - -class AlphaVectorChannel : public PrimitiveAnimationChannelClass -{ -public: - AlphaVectorStruct Evaluate (float time) - { - int key_count = m_Data.Count (); - AlphaVectorStruct value = m_Data[key_count - 1].Get_Value (); - - // - // Don't interpolate past the last keyframe - // - if (time < m_Data[key_count - 1].Get_Time ()) { - - // Check to see if the last key index is valid - if (time < m_Data[m_LastIndex].Get_Time ()) { - m_LastIndex = 0; - } - - KeyClass *key1 = &m_Data[m_LastIndex]; - KeyClass *key2 = &m_Data[key_count - 1]; - - // - // Search, using last_key as our starting point - // - for (int keyidx = m_LastIndex; keyidx < (key_count - 1); keyidx ++) { - - if (time < m_Data[keyidx+1].Get_Time ()) { - key1 = &m_Data[keyidx]; - key2 = &m_Data[keyidx+1]; - m_LastIndex = keyidx; - break; - } - } - - // Calculate the linear percent between the two keys - float percent = (time - key1->Get_Time ()) / (key2->Get_Time () - key1->Get_Time ()); - - // Slerp the quaternions and lerp the intensities - value.intensity = (key1->Get_Value ().intensity + (key2->Get_Value ().intensity - key1->Get_Value ().intensity) * percent); - Fast_Slerp (value.angle, key1->Get_Value ().angle, key2->Get_Value ().angle, percent); - } - - return value; - } -}; - -struct W3dSphereStruct -{ - uint32 Version; // file format version - uint32 Attributes; // sphere attributes (above #define's) - char Name[2*W3D_NAME_LEN]; // name is in the form . - - W3dVectorStruct Center; // center of the sphere - W3dVectorStruct Extent; // extent of the sphere - - float AnimDuration; // Animation time (in seconds) - - W3dVectorStruct DefaultColor; - float DefaultAlpha; - W3dVectorStruct DefaultScale; - AlphaVectorStruct DefaultVector; - - char TextureName[2*W3D_NAME_LEN]; - W3dShaderStruct Shader; - - // - // Note this structure is followed by a series of - // W3dSphereKeyArrayStruct structures which define the - // variable set of keyframes for each channel. - // -}; - -typedef LERPAnimationChannelClass SphereColorChannelClass; -typedef LERPAnimationChannelClass SphereAlphaChannelClass; -typedef LERPAnimationChannelClass SphereScaleChannelClass; -typedef AlphaVectorChannel SphereVectorChannelClass; -//typedef AlphaVectorChannel ; - -class VertexMaterialClass; - - -class SphereMeshClass -{ -friend class SphereRenderObjClass; - -public: - // Constructor - SphereMeshClass(void); - SphereMeshClass(float radius, int slices, int stacks); - // Destructor - ~SphereMeshClass(void); - - void Generate (float radius, int slices, int stacks); - int Get_Num_Polys (void) { return face_ct; }; - void Set_Alpha_Vector (const AlphaVectorStruct &v, bool inverse, bool is_additive, bool force = false); - -private: - - void Set_DCG (bool is_additive, int index, float value); - - void Free(void); - - float Radius; - int Slices; - int Stacks; - int face_ct; // # of faces - - int Vertex_ct; // vertex count - Vector3 *vtx; // array of vertices - Vector3 *vtx_normal; // array of vertex normals - Vector2 *vtx_uv; // array of vertex uv coordinates - Vector4 *dcg; - - AlphaVectorStruct alpha_vector; // vector last used to computer vtx_alpha array - bool inverse_alpha; // inverse alpha, or not - bool IsAdditive; - - int strip_ct; // number of strips - int strip_size; // size of each strip - int *strips; // array of vertex indices for each strip (# stripbs x sizeof strip) - - int fan_ct; // number of fans - int fan_size; // size of each fan - int *fans; // array of vertex indices for each fan (# of fans by fan_size) - - TriIndex *tri_poly; // array of triangle poly's, vertex indices (can be discard if switched to strips + fans) - -}; - -inline void -SphereMeshClass::Set_DCG (bool is_additive, int index, float value) -{ - if (is_additive) { - dcg[index].X = value; - dcg[index].Y = value; - dcg[index].Z = value; - dcg[index].W = 0; - } else { - dcg[index].X = 1.0F; - dcg[index].Y = 1.0F; - dcg[index].Z = 1.0F; - dcg[index].W = value; - } - - return ; -} - -// Note: SPHERE_NUM_LOD does not include the NULL LOD. -#define SPHERE_NUM_LOD (10) -#define SPHERE_LOWEST_LOD (7) -#define SPHERE_HIGHEST_LOD (17) - -/* -** SphereRenderObjClass: Procedurally generated render spheres -** -*/ -class SphereRenderObjClass : public RenderObjClass -{ - -public: - - // These are bit masks, so they should enum 1,2,4,8,10,20,40 etc... - enum SphereFlags { - USE_ALPHA_VECTOR = 0x00000001, - USE_CAMERA_ALIGN = 0x00000002, - USE_INVERSE_ALPHA = 0x00000004, - USE_ANIMATION_LOOP= 0x00000008, - }; - - SphereRenderObjClass(void); - SphereRenderObjClass(const W3dSphereStruct & def); - SphereRenderObjClass(const SphereRenderObjClass & src); - SphereRenderObjClass & operator = (const SphereRenderObjClass &); - ~SphereRenderObjClass(void); - - ///////////////////////////////////////////////////////////////////////////// - // Render Object Interface - ///////////////////////////////////////////////////////////////////////////// - virtual RenderObjClass * Clone(void) const; - virtual int Class_ID(void) const; - virtual void Render(RenderInfoClass & rinfo); - virtual void Special_Render(SpecialRenderInfoClass & rinfo); - virtual void Set_Transform(const Matrix3D &m); - virtual void Set_Position(const Vector3 &v); - virtual void Get_Obj_Space_Bounding_Sphere(SphereClass & sphere) const; - virtual void Get_Obj_Space_Bounding_Box(AABoxClass & aabox) const; - - virtual void Prepare_LOD(CameraClass &camera); - virtual void Increment_LOD(void); - virtual void Decrement_LOD(void); - virtual float Get_Cost(void) const; - virtual float Get_Value(void) const; - virtual float Get_Post_Increment_Value(void) const; - virtual void Set_LOD_Level(int lod); - virtual int Get_LOD_Level(void) const; - virtual int Get_LOD_Count(void) const; - virtual void Set_LOD_Bias(float bias) { LODBias = MAX(bias, 0.0f); } - virtual int Calculate_Cost_Value_Arrays(float screen_area, float *values, float *costs) const; - - virtual void Scale(float scale); - virtual void Scale(float scalex, float scaley, float scalez); - virtual void Set_Hidden(int onoff) { RenderObjClass::Set_Hidden (onoff); Update_On_Visibilty (); } - virtual void Set_Visible(int onoff) { RenderObjClass::Set_Visible (onoff); Update_On_Visibilty (); } - virtual void Set_Animation_Hidden(int onoff) { RenderObjClass::Set_Animation_Hidden (onoff); Update_On_Visibilty (); } - virtual void Set_Force_Visible(int onoff) { RenderObjClass::Set_Force_Visible (onoff); Update_On_Visibilty (); } - - - const AABoxClass & Get_Box(void); - - virtual int Get_Num_Polys(void) const; - virtual const char * Get_Name(void) const; - virtual void Set_Name(const char * name); - - unsigned int Get_Flags(void) { return Flags; } - void Set_Flags(unsigned int flags) { Flags = flags; } - void Set_Flag(unsigned int flag, bool onoff) { Flags &= (~flag); if (onoff) Flags |= flag; } - - // Animation access - bool Is_Animating (void) { return IsAnimating; } - void Start_Animating (void) { IsAnimating = true; anim_time = 0; } - void Stop_Animating (void) { IsAnimating = false; anim_time = 0; } - - // Current state access - void Set_Color(const Vector3 & color) { CurrentColor = color; } - void Set_Alpha(float alpha) { CurrentAlpha = alpha; } - void Set_Scale(const Vector3 & scale) { CurrentScale = scale; } - void Set_Vector(const AlphaVectorStruct &v) { CurrentVector = v; } - - const Vector3 & Get_Color(void) const { return CurrentColor; } - float Get_Alpha(void) const { return CurrentAlpha; } - const Vector3 & Get_Scale(void) const { return CurrentScale; } - const AlphaVectorStruct & Get_Vector(void) const { return CurrentVector; } - - Vector3 Get_Default_Color(void) const; - float Get_Default_Alpha(void) const; - Vector3 Get_Default_Scale(void) const; - AlphaVectorStruct Get_Default_Vector(void) const; - - // Size/position methods - void Set_Extent (const Vector3 &extent); - void Set_Local_Center_Extent(const Vector3 & center,const Vector3 & extent); - void Set_Local_Min_Max(const Vector3 & min,const Vector3 & max); - - // Texture access - void Set_Texture(TextureClass *tf); - TextureClass * Peek_Texture(void) {return SphereTexture;} - ShaderClass & Get_Shader(void) {return SphereShader;} - void Set_Shader(ShaderClass &shader) {SphereShader=shader;} - - // Animation control - float Get_Animation_Duration (void) const { return AnimDuration; } - void Set_Animation_Duration (float time) { AnimDuration = time; Restart_Animation (); } - void Restart_Animation (void) { anim_time = 0; } - - // Animatable channel access - SphereColorChannelClass & Get_Color_Channel (void) { return ColorChannel; } - const SphereColorChannelClass & Peek_Color_Channel (void) { return ColorChannel; } - - SphereAlphaChannelClass & Get_Alpha_Channel (void) { return AlphaChannel; } - const SphereAlphaChannelClass & Peek_Alpha_Channel (void) { return AlphaChannel; } - - SphereScaleChannelClass & Get_Scale_Channel (void) { return ScaleChannel; } - const SphereScaleChannelClass & Peek_Scale_Channel (void) { return ScaleChannel; } - - SphereVectorChannelClass & Get_Vector_Channel (void) { return VectorChannel; } - const SphereVectorChannelClass & Peek_Vector_Channel (void) { return VectorChannel; } - - void Set_Color_Channel (const SphereColorChannelClass &data) { ColorChannel = data; } - void Set_Alpha_Channel (const SphereAlphaChannelClass &data) { AlphaChannel = data; } - void Set_Scale_Channel (const SphereScaleChannelClass &data) { ScaleChannel = data; } - void Set_Vector_Channel (const SphereVectorChannelClass &data) { VectorChannel = data; } - -protected: - - virtual void update_cached_box(void); - virtual void Update_Cached_Bounding_Volumes(void) const; - void Update_On_Visibilty(void); - - // Initialization stuff - void Init_Material (void); - static void Generate_Shared_Mesh_Arrays (const AlphaVectorStruct &alphavector); - - // Animation Stuff - void animate(void); // animation update function - float anim_time; // what time in seconds are we in the animation - float AnimDuration; - bool IsAnimating; - - // LOD Stuff - void calculate_value_array(float screen_area, float *values) const; - float LODBias; - int CurrentLOD; - float Value[SPHERE_NUM_LOD + 2];// Value array needs # of LODs + 1 (RING_NUM_LOD doesn't include null LOD) - - SphereColorChannelClass ColorChannel; - SphereAlphaChannelClass AlphaChannel; - SphereScaleChannelClass ScaleChannel; - SphereVectorChannelClass VectorChannel; - - void update_mesh_data(const Vector3 & center,const Vector3 & extent); - void render_sphere(); - void vis_render_sphere(SpecialRenderInfoClass & rinfo,const Vector3 & center,const Vector3 & extent); - - char Name[2*W3D_NAME_LEN]; - Vector3 ObjSpaceCenter; - Vector3 ObjSpaceExtent; - - // Current State - Vector3 CurrentColor; - float CurrentAlpha; - Vector3 CurrentScale; - AlphaVectorStruct CurrentVector; - - Quaternion Orientation; - - // Flags - unsigned int Flags; - - VertexMaterialClass *SphereMaterial; - ShaderClass SphereShader; - TextureClass *SphereTexture; - - AABoxClass CachedBox; - - // Friend classes - friend class SpherePrototypeClass; -}; - -inline void SphereRenderObjClass::Set_Extent (const Vector3 &extent) -{ - ObjSpaceExtent = extent; - update_cached_box(); - Update_Cached_Bounding_Volumes(); -} - -inline void SphereRenderObjClass::Set_Local_Center_Extent(const Vector3 & center,const Vector3 & extent) -{ - ObjSpaceCenter = center; - ObjSpaceExtent = extent; - update_cached_box(); -} - -inline void SphereRenderObjClass::Set_Local_Min_Max(const Vector3 & min,const Vector3 & max) -{ - ObjSpaceCenter = (max + min) / 2.0f; - ObjSpaceExtent = (max - min) / 2.0f; - update_cached_box(); -} - - -inline const AABoxClass & SphereRenderObjClass::Get_Box(void) -{ - Validate_Transform(); - update_cached_box(); - return CachedBox; -} - -/* -** Loader for spheres -*/ -class SphereLoaderClass : public PrototypeLoaderClass -{ -public: - virtual int Chunk_Type (void) { return W3D_CHUNK_SPHERE; } - virtual PrototypeClass * Load_W3D(ChunkLoadClass & cload); -}; - -/* -** Prototype for Sphere objects -*/ -class SpherePrototypeClass : public W3DMPO, public PrototypeClass -{ - W3DMPO_GLUE(SpherePrototypeClass) -public: - SpherePrototypeClass (void); - SpherePrototypeClass (SphereRenderObjClass *sphere); - - virtual const char * Get_Name(void) const; - virtual int Get_Class_ID(void) const; - virtual RenderObjClass * Create(void); - virtual void DeleteSelf() { delete this; } - - bool Load (ChunkLoadClass &cload); - bool Save (ChunkSaveClass &csave); - -protected: - ~SpherePrototypeClass (void); - -private: - W3dSphereStruct Definition; - - SphereColorChannelClass ColorChannel; - SphereAlphaChannelClass AlphaChannel; - SphereScaleChannelClass ScaleChannel; - SphereVectorChannelClass VectorChannel; -}; - -/* -** Instance of the loader which the asset manager installs -*/ -extern SphereLoaderClass _SphereLoader; - -#endif // SPHEREOBJ_H - -// EOF - sphereobj,h - - diff --git a/Generals/Code/Libraries/Source/WWVegas/WW3D2/static_sort_list.cpp b/Generals/Code/Libraries/Source/WWVegas/WW3D2/static_sort_list.cpp deleted file mode 100644 index 25f8f55d672..00000000000 --- a/Generals/Code/Libraries/Source/WWVegas/WW3D2/static_sort_list.cpp +++ /dev/null @@ -1,97 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*************************************************************************************************** - *** 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 *** - *************************************************************************************************** - * * - * Project Name : G * - * * - * $Archive:: $* - * * - * Creator::Scott K. Bowen - 7/15/2002 * - * * - * $Author:: $* - * * - * $Modtime:: $* - * * - * $Revision:: $* - * * - *-------------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -//////////////////////////////////////////////////////////////////////////////////////////////////// -// Include files /////////////////////////////////////////////////////////////////////////////////// - -#include "static_sort_list.h" - -#include "rendobj.h" -#include "dx8renderer.h" - -//////////////////////////////////////////////////////////////////////////////////////////////////// -// Initialization Functions //////////////////////////////////////////////////////////////////////// - -DefaultStaticSortListClass::DefaultStaticSortListClass(void) : - StaticSortListClass(), - SortLists(), - MinSort(1), - MaxSort(MAX_SORT_LEVEL) -{ -} - -DefaultStaticSortListClass::~DefaultStaticSortListClass(void) -{ -} - -//////////////////////////////////////////////////////////////////////////////////////////////////// -// Virtual functions /////////////////////////////////////////////////////////////////////////////// - -void DefaultStaticSortListClass::Add_To_List(RenderObjClass * robj, unsigned int sort_level) -{ - if(sort_level < 1 || sort_level > MAX_SORT_LEVEL) { - WWASSERT(0); - return; - } - SortLists[sort_level].Add_Tail(robj, false); -} - -void DefaultStaticSortListClass::Render_And_Clear(RenderInfoClass & rinfo) -{ - // We go from higher sort level to lower, since lower sort level means higher priority (in - // front), so lower sort level meshes need to be rendered later. - for(unsigned int sort_level = MaxSort; sort_level >= MinSort; sort_level--) { - bool render=false; - for ( RenderObjClass *robj = SortLists[sort_level].Remove_Head(); robj; - robj->Release_Ref(), robj = SortLists[sort_level].Remove_Head()) - { - if (robj->Get_Render_Hook()) { - if (robj->Get_Render_Hook()->Pre_Render(robj, rinfo)) { - robj->Render(rinfo); - render = true; - } - robj->Get_Render_Hook()->Post_Render(robj, rinfo); - } else { - robj->Render(rinfo); - render = true; - } - } - if (render) TheDX8MeshRenderer.Flush(); - } -} - diff --git a/Generals/Code/Libraries/Source/WWVegas/WW3D2/static_sort_list.h b/Generals/Code/Libraries/Source/WWVegas/WW3D2/static_sort_list.h deleted file mode 100644 index 127ee0c46f5..00000000000 --- a/Generals/Code/Libraries/Source/WWVegas/WW3D2/static_sort_list.h +++ /dev/null @@ -1,99 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/***************************************************************************************************************** - *** 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 *** - ***************************************************************************************************************** - * * - * Project Name : G * - * * - * $Archive:: $* - * * - * Creator::Scott K. Bowen - 7/15/2002 * - * * - * $Author:: $* - * * - * $Modtime:: $* - * * - * $Revision:: $* - * * - *---------------------------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#if defined(_MSC_VER) -#pragma once -#endif - -#ifndef STATIC_SORT_LIST_H -#define STATIC_SORT_LIST_H - -#include "robjlist.h" -#include "w3d_file.h" - -class RenderInfoClass; - -// Just defines the interface for the class as used by WW3D.. -class StaticSortListClass -{ - public: - /////////////////////////////////////////////////////////////////////////////////// - // Construction. - StaticSortListClass(void) {} - virtual ~StaticSortListClass(void) {} - - virtual void Add_To_List(RenderObjClass * robj, unsigned int sort_level) = 0; - virtual void Render_And_Clear(RenderInfoClass & rinfo) = 0; - -}; // end StaticSortListClass - -// The actual implementation for the standard ww3d StaticSortList. -class DefaultStaticSortListClass : public StaticSortListClass -{ - public: - /////////////////////////////////////////////////////////////////////////////////// - // Construction. - DefaultStaticSortListClass(void); - virtual ~DefaultStaticSortListClass(void); - - virtual void Add_To_List(RenderObjClass * robj, unsigned int sort_level); - virtual void Render_And_Clear(RenderInfoClass & rinfo); - - - unsigned int Get_Min_Sort(void) const {return MinSort;}; - unsigned int Get_Max_Sort(void) const {return MaxSort;}; - - void Set_Min_Sort(unsigned int value) {MinSort = (value > MAX_SORT_LEVEL) ? MAX_SORT_LEVEL : value;} - void Set_Max_Sort(unsigned int value) {MaxSort = (value > MAX_SORT_LEVEL) ? MAX_SORT_LEVEL : value;} - - private: - // These are for use by controlling classes to allow control of what levels - // to render when Render_And_Clear() is called. As for this class, the values - // are set to 1..MAX_SORT_LEVEL and then never changed. - unsigned int MinSort; - unsigned int MaxSort; - - // An array of lists - each object in a given list has same SortLevel. - RefRenderObjListClass SortLists[MAX_SORT_LEVEL + 1]; - -}; // end StaticSortListClass - - - - -#endif //STATIC_SORT_LIST_H - diff --git a/Generals/Code/Libraries/Source/WWVegas/WW3D2/statistics.cpp b/Generals/Code/Libraries/Source/WWVegas/WW3D2/statistics.cpp deleted file mode 100644 index 04fe233f529..00000000000 --- a/Generals/Code/Libraries/Source/WWVegas/WW3D2/statistics.cpp +++ /dev/null @@ -1,394 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -#include "statistics.h" -#include "wwstring.h" -#include "simplevec.h" -#include "dx8renderer.h" -#include "dx8wrapper.h" -#include "dx8caps.h" -#include "textureloader.h" -#include "texture.h" -#include - -#include -#ifdef _UNIX -#include "osdep.h" -#endif - -// ---------------------------------------------------------------------------- -// -// Texture memory tracking system -// -// ---------------------------------------------------------------------------- - -static int texture_memory; -static int texture_count; -static int lightmap_texture_memory; -static int lightmap_texture_count; -static int procedural_texture_memory; -static int procedural_texture_count; -static int record_count; -static int texture_change_count; -static int last_frame_texture_memory; -static int last_frame_texture_count; -static int last_frame_lightmap_texture_memory; -static int last_frame_lightmap_texture_count; -static int last_frame_procedural_texture_memory; -static int last_frame_procedural_texture_count; -static int last_frame_record_count; -static int last_frame_texture_change_count; -static TextureClass* latest_texture; -static Debug_Statistics::RecordTextureMode record_texture_mode; -static StringClass texture_statistics_string; - -struct TextureStatisticsStruct -{ - TextureClass* tex; - int usage_count; - int change_count; -}; - -static SimpleDynVecClass texture_statistics; - -static void Record_Texture_Begin() -{ - texture_memory=0; - texture_count=0; - lightmap_texture_memory=0; - lightmap_texture_count=0; - procedural_texture_memory=0; - procedural_texture_count=0; - record_count=0; - texture_change_count=0; - latest_texture=NULL; - texture_statistics.Resize(0); -} - -static void Record_Texture_End() -{ - last_frame_texture_memory=texture_memory; - last_frame_texture_count=texture_count; - last_frame_lightmap_texture_memory=lightmap_texture_memory; - last_frame_lightmap_texture_count=lightmap_texture_count; - last_frame_procedural_texture_memory=procedural_texture_memory; - last_frame_procedural_texture_count=procedural_texture_count; - last_frame_record_count=record_count; - last_frame_texture_change_count=texture_change_count; - - texture_statistics_string=""; - if (record_texture_mode==Debug_Statistics::RECORD_TEXTURE_DETAILS) { - char tmp_text[1024]; - _snprintf(tmp_text,sizeof(tmp_text), - "Set_DX8_Texture count: %d\nactual changes: %d\n\n" - "id refs changes size name\n" - "--------------------------------------\n", - - last_frame_record_count,last_frame_texture_change_count); - texture_statistics_string+=tmp_text; - for (int a=0;agetClassID() == ID_TEXTURE_FILE_CLASS) { -// TextureFileClass* tfc=static_cast(t); -// id=tfc->ID(); -// if (tfc->Get_Texture_Flash()) flash="F"; -// } - - working_string.Format("%4.4d %3.3d %3.3d %s ",id,texture_statistics[a].usage_count,texture_statistics[a].change_count,flash.Peek_Buffer()); - texture_statistics_string+=working_string; - - StringClass error=""; - if (t) { -// int red_factor=t->Get_Current_Reduction_Factor(); - unsigned bytes=t->Get_Texture_Memory_Usage(); -// unsigned non_red_bytes=t->Get_Non_Reduced_Texture_Memory_Usage(); - if (!t->Is_Initialized()) { -// non_red_bytes=bytes; - texture_statistics_string+="*"; - } - else { - texture_statistics_string+=" "; - } -// if (!non_red_bytes) non_red_bytes=1; -// int percents=100-100*bytes/non_red_bytes; - working_string.Format("%4.4dkb ",bytes/1024); - texture_statistics_string+=working_string; - } - else { - texture_statistics_string+="N/A "; - } - texture_statistics_string+=t->Get_Texture_Name();//getTextureName(); - texture_statistics_string+=error; - texture_statistics_string+="\n"; - } - texture_statistics_string+="\nid = id of texture. Use with command 'flash_texture [id]'\n"; - texture_statistics_string+="refs = # of times texture is used when rendering\n"; - texture_statistics_string+="changes = # of times texture change needed - BAD IF HIGH!\n"; - texture_statistics_string+="red = texture reduction factor\n"; - texture_statistics_string+="size = amount of memory needed for texture\n"; - texture_statistics_string+="(w/o red) = size of reduction not used\n"; - texture_statistics_string+="percent = savings of reduction system, in percents\n"; - texture_statistics_string+="\n* = thumbnail used\n"; - texture_statistics_string+="\n"; -// texture_statistics_string+=TextureFileClass::List_Missing_Files(); - - } - -} - -void Debug_Statistics::Record_Texture_Mode(RecordTextureMode mode) -{ - record_texture_mode=mode; -} - -Debug_Statistics::RecordTextureMode Debug_Statistics::Get_Record_Texture_Mode() -{ - return record_texture_mode; -} - -static bool Find_Record_Texture(TextureClass* t) -{ - for (int a=0;aIs_Lightmap()) lightmap_texture_count++; - if (t->Is_Procedural()) procedural_texture_count++; -} - -void Debug_Statistics::Record_Texture(TextureClass* t) -{ - record_count++; - if (t!=latest_texture) { - texture_change_count++; - } - - if (record_texture_mode==RECORD_TEXTURE_NONE) { - latest_texture=t; - return; - } - if (!t) { - latest_texture=t; - return; - } - - if (Find_Record_Texture(t)) { - latest_texture=t; - return; - } - Add_Record_Texture(t); - - texture_memory+=t->Get_Texture_Memory_Usage(); - latest_texture=t; - if (t->Is_Lightmap()) lightmap_texture_memory+=t->Get_Texture_Memory_Usage(); - if (t->Is_Procedural()) procedural_texture_memory+=t->Get_Texture_Memory_Usage(); - -} - -int Debug_Statistics::Get_Record_Texture_Size() // Return total textures used during latest frame, in bytes -{ - return last_frame_texture_memory; -} - -int Debug_Statistics::Get_Record_Texture_Count() // Return total textures used during latest frame, in bytes -{ - return last_frame_texture_count; -} - -int Debug_Statistics::Get_Record_Texture_Change_Count() -{ - return last_frame_texture_change_count; -} - -int Debug_Statistics::Get_Record_Lightmap_Texture_Size() // Return total lightmap textures used during latest frame, in bytes -{ - return last_frame_lightmap_texture_memory; -} - -int Debug_Statistics::Get_Record_Lightmap_Texture_Count() // Return total lightmap textures used during latest frame, in bytes -{ - return last_frame_lightmap_texture_count; -} - -int Debug_Statistics::Get_Record_Procedural_Texture_Size() // Return total procedural textures used during latest frame, in bytes -{ - return last_frame_procedural_texture_memory; -} - -int Debug_Statistics::Get_Record_Procedural_Texture_Count() // Return total procedural textures used during latest frame, in bytes -{ - return last_frame_procedural_texture_count; -} - -const StringClass& Debug_Statistics::Get_Record_Texture_String() -{ - return texture_statistics_string; -} - -// ---------------------------------------------------------------------------- - -static int dx8_skin_renders; -static int last_frame_dx8_skin_renders; -static int dx8_skin_polygons; -static int last_frame_dx8_skin_polygons; -static int dx8_skin_vertices; -static int last_frame_dx8_skin_vertices; -static int dx8_polygons; -static int last_frame_dx8_polygons; -static int dx8_vertices; -static int last_frame_dx8_vertices; -static int sorting_polygons; -static int last_frame_sorting_polygons; -static int sorting_vertices; -static int last_frame_sorting_vertices; -static int draw_calls; -static int last_frame_draw_calls; - -void Debug_Statistics::Record_DX8_Skin_Polys_And_Vertices(int pcount,int vcount) -{ - dx8_skin_polygons+=pcount; - dx8_skin_vertices+=vcount; - dx8_skin_renders++; - draw_calls++; -} - -void Debug_Statistics::Record_DX8_Polys_And_Vertices(int pcount,int vcount,const ShaderClass& shader) -{ - if (shader.Get_NPatch_Enable()==ShaderClass::NPATCH_ENABLE && DX8Wrapper::Get_Current_Caps()->Support_NPatches()) { - unsigned level=WW3D::Get_NPatches_Level(); - level*=level; - pcount*=level; - } - dx8_polygons+=pcount; - dx8_vertices+=vcount; - draw_calls++; -} - -int Debug_Statistics::Get_DX8_Skin_Renders() -{ - return last_frame_dx8_skin_renders; -} - -int Debug_Statistics::Get_DX8_Skin_Polygons() -{ - return last_frame_dx8_skin_polygons; -} - -int Debug_Statistics::Get_DX8_Skin_Vertices() -{ - return last_frame_dx8_skin_vertices; -} - -int Debug_Statistics::Get_DX8_Polygons() -{ - return last_frame_dx8_polygons; -} - -int Debug_Statistics::Get_DX8_Vertices() -{ - return last_frame_dx8_vertices; -} - -void Debug_Statistics::Record_Sorting_Polys_And_Vertices(int pcount,int vcount) -{ - sorting_polygons+=pcount; - sorting_vertices+=vcount; - draw_calls++; -} - -int Debug_Statistics::Get_Sorting_Polygons() -{ - return last_frame_sorting_polygons; -} - -int Debug_Statistics::Get_Sorting_Vertices() -{ - return last_frame_sorting_vertices; -} - -int Debug_Statistics::Get_Draw_Calls() -{ - return last_frame_draw_calls; -} - -// ---------------------------------------------------------------------------- -// -// -// -// ---------------------------------------------------------------------------- - -void Debug_Statistics::Begin_Statistics() -{ - dx8_polygons=0; - dx8_vertices=0; - dx8_skin_polygons=0; - dx8_skin_vertices=0; - dx8_skin_renders=0; - sorting_polygons=0; - sorting_vertices=0; - draw_calls=0; - Record_Texture_Begin(); - DX8Wrapper::Begin_Statistics(); -// DX8MeshRendererClass::Begin_Statistics(); -} - -void Debug_Statistics::End_Statistics() -{ - Record_Texture_End(); - last_frame_dx8_skin_polygons=dx8_skin_polygons; - last_frame_dx8_skin_vertices=dx8_skin_vertices; - last_frame_dx8_skin_renders=dx8_skin_renders; - last_frame_dx8_polygons=dx8_polygons; - last_frame_dx8_vertices=dx8_vertices; - last_frame_sorting_polygons=sorting_polygons; - last_frame_sorting_vertices=sorting_vertices; - last_frame_draw_calls=draw_calls; -// DX8MeshRendererClass::End_Statistics(); - DX8Wrapper::End_Statistics(); -} - -void Debug_Statistics::Shutdown_Statistics() -{ - texture_statistics_string.Release_Resources(); -} -// ---------------------------------------------------------------------------- - diff --git a/Generals/Code/Libraries/Source/WWVegas/WW3D2/statistics.h b/Generals/Code/Libraries/Source/WWVegas/WW3D2/statistics.h deleted file mode 100644 index a50e5de60e5..00000000000 --- a/Generals/Code/Libraries/Source/WWVegas/WW3D2/statistics.h +++ /dev/null @@ -1,80 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -#ifndef WW3D_STATISTICS_H -#define WW3D_STATISTICS_H - -#if defined(_MSC_VER) -#pragma once -#endif - -#include "always.h" -//#include "wwstring.h" - -class TextureClass; -class StringClass; -class ShaderClass; - -namespace Debug_Statistics -{ - enum RecordTextureMode - { - RECORD_TEXTURE_NONE, - RECORD_TEXTURE_SIMPLE, - RECORD_TEXTURE_DETAILS - }; - - // Texture memory tracking system - void Record_Texture_Mode(RecordTextureMode m); - RecordTextureMode Get_Record_Texture_Mode(); - - void Record_Texture(TextureClass* t); - int Get_Record_Texture_Size(); // Return total size of textures used during latest frame, in bytes - int Get_Record_Lightmap_Texture_Size(); // Return total size of lightmap textures used during latest frame, in bytes - int Get_Record_Procedural_Texture_Size(); // Return total size of procedural textures used during latest frame, in bytes - int Get_Record_Texture_Count(); // Return total number of textures used during latest frame - int Get_Record_Texture_Change_Count(); - int Get_Record_Lightmap_Texture_Count(); // Return total number of lightmap textures used during latest frame - int Get_Record_Procedural_Texture_Count(); // Return total number of procedutal textures used during latest frame - const StringClass& Get_Record_Texture_String(); - - void Record_DX8_Skin_Polys_And_Vertices(int pcount,int vcount); - void Record_DX8_Polys_And_Vertices(int pcount,int vcount,const ShaderClass& shader); - void Record_Sorting_Polys_And_Vertices(int pcount,int vcount); - int Get_DX8_Polygons(); - int Get_DX8_Vertices(); - int Get_DX8_Skin_Renders(); - int Get_DX8_Skin_Polygons(); - int Get_DX8_Skin_Vertices(); - int Get_Sorting_Polygons(); - int Get_Sorting_Vertices(); - int Get_Draw_Calls(); - - void Begin_Statistics(); - void End_Statistics(); - void Shutdown_Statistics(); -}; - -#define ADD_STATISTICS_VERTEX_PROCESSOR_PUSH Debug_Statistics::Add_Vertex_Processor() -#define DX8_RECORD_TEXTURE(t) Debug_Statistics::Record_Texture(t) -#define DX8_RECORD_TEXTURE_ARRAY(t,c) Debug_Statistics::Record_Texture_Array(t,c) -#define DX8_RECORD_RENDER(polys,verts,shader) Debug_Statistics::Record_DX8_Polys_And_Vertices(polys,verts,shader) -#define DX8_RECORD_SORTING_RENDER(polys,verts) Debug_Statistics::Record_Sorting_Polys_And_Vertices(polys,verts) -#define DX8_RECORD_SKIN_RENDER(polys,verts) Debug_Statistics::Record_DX8_Skin_Polys_And_Vertices(polys,verts) - -#endif diff --git a/Generals/Code/Libraries/Source/WWVegas/WW3D2/streak.cpp b/Generals/Code/Libraries/Source/WWVegas/WW3D2/streak.cpp deleted file mode 100644 index 3a9fe42c6d4..00000000000 --- a/Generals/Code/Libraries/Source/WWVegas/WW3D2/streak.cpp +++ /dev/null @@ -1,745 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** 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 *** - *********************************************************************************************** - * * - * Project Name : G * - * * - * $Archive:: /VSS_Sync/ww3d2/segline.cpp $* - * * - * $Author:: Vss_sync $* - * * - * $Modtime:: 8/29/01 7:29p $* - * * - * $Revision:: 23 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#include "streak.h" -#include "ww3d.h" -#include "rinfo.h" -#include "predlod.h" -#include "v3_rnd.h" -#include "texture.h" -#include "coltest.h" -#include "w3d_file.h" -#include "texture.h" -#include "dx8wrapper.h" -#include "vp.h" -#include "Vector3i.h" -#include "sortingrenderer.h" - -static SegLineRendererClass _LineRenderer; - - -/* -** StreakLineClass implementation: -*/ - -StreakLineClass::StreakLineClass(void) : - MaxSubdivisionLevels(0), - NormalizedScreenArea(0.0f) -{ - Personalities = NULL; - -} - -StreakLineClass::StreakLineClass(const StreakLineClass & src) : - MaxSubdivisionLevels(src.MaxSubdivisionLevels), - NormalizedScreenArea(src.NormalizedScreenArea), - PointLocations(src.PointLocations), - PointColors(src.PointColors), - PointWidths(src.PointWidths), - LineRenderer(src.LineRenderer), - StreakRenderer(src.StreakRenderer), - Personalities(src.Personalities) -{ -} - -StreakLineClass & StreakLineClass::operator = (const StreakLineClass &that) -{ - RenderObjClass::operator = (that); - - if (this != &that) { - - MaxSubdivisionLevels = that.MaxSubdivisionLevels; - NormalizedScreenArea = that.NormalizedScreenArea; - PointLocations = that.PointLocations; - PointColors = that.PointColors; - PointWidths = that.PointWidths; - LineRenderer = that.LineRenderer; - StreakRenderer = that.StreakRenderer; - Personalities = that.Personalities; - } - - return * this; -} - -//StreakLineClass::~StreakLineClass(void) -//{ -//} - - - - - -void StreakLineClass::Reset_Line(void) -{ - LineRenderer.Reset_Line(); - StreakRenderer.Reset_Line(); -} - - - - - -//////////////////////////////////////////////////////////////////////////// -//////////////////////////////////////////////////////////////////////////// -//////////////////////////////////////////////////////////////////////////// -// These are segment points, and include the start and end point of the -// entire line. Therefore there must be at least two. -void StreakLineClass::Set_Locs( unsigned int num_points, Vector3 *locs ) -{ - if (num_points < 2 || !locs) { - WWASSERT(0); - return; - } - - PointLocations.Delete_All(); - for (unsigned int i=0; iProcess_Reduction(); - - unsigned int sort_level = SORT_LEVEL_NONE; - - if (!WW3D::Is_Sorting_Enabled()) - sort_level=Get_Shader().Guess_Sort_Level(); - - if (WW3D::Are_Static_Sort_Lists_Enabled() && sort_level!=SORT_LEVEL_NONE) { - - WW3D::Add_To_Static_Sort_List(this, sort_level); - - } - else - { - if ( !PointColors.Count() || !PointWidths.Count() ) - { - Render_Seg_Line(rinfo); - } - else - { - Render_Streak_Line(rinfo); - } - } -} - -void StreakLineClass::Get_Obj_Space_Bounding_Sphere(SphereClass & sphere) const -{ - // Get object-space bounding box and create bounding sphere from it - AABoxClass box; - Get_Obj_Space_Bounding_Box(box); - - // Create object-space bounding sphere from the bounding box: - sphere.Center = box.Center; - sphere.Radius = box.Extent.Length(); -} - -void StreakLineClass::Get_Obj_Space_Bounding_Box(AABoxClass & box) const -{ - unsigned int num_points = PointLocations.Count(); - - // Line must have at least two points to be valid - - if (num_points >= 2) { - - // Find object-space axis-aligned bounding box - Vector3 max_coords; - Vector3 min_coords; - unsigned int i; - - // We create two bounding boxes; one from the points, and if we have random noise - // subdivision we create another one from the midpoints and factor the noise amplitude - // into the second box, and then combine the two. - - // First bounding box: - max_coords = PointLocations[0]; - min_coords = PointLocations[0]; - for (i = 1; i < num_points; i++) { - max_coords.Update_Max(PointLocations[i]); - min_coords.Update_Min(PointLocations[i]); - } - // Enlarge bounding box by half the width - float enlarge_factor = LineRenderer.Get_Width() * 0.5f; - Vector3 enlarge_offset; - enlarge_offset.Set(enlarge_factor, enlarge_factor, enlarge_factor); - max_coords += enlarge_offset; - min_coords -= enlarge_offset; - - if (MaxSubdivisionLevels > 0) { - // Second bounding box: - Vector3 max_coords2; - Vector3 min_coords2; - Vector3 midpoint = (PointLocations[0] + PointLocations[1]) * 0.5f; - max_coords2 = midpoint; - min_coords2 = midpoint; - for (i = 1; i < num_points - 1; i++) { - midpoint = (PointLocations[i] + PointLocations[i + 1]) * 0.5f; - max_coords2.Update_Max(midpoint); - min_coords2.Update_Min(midpoint); - } - - // We ignore the actual number of subdivision levels: we multiply the random noise - // amplitude by 2, which is the limit as the number of subdivision levels goes to - // infinity. - enlarge_factor += (2 * LineRenderer.Get_Noise_Amplitude()); - enlarge_offset.Set(enlarge_factor, enlarge_factor, enlarge_factor); - max_coords2 += enlarge_offset; - min_coords2 -= enlarge_offset; - - // Combine the two: - max_coords.Update_Max(max_coords2); - min_coords.Update_Min(min_coords2); - } - - box.Init_Min_Max(min_coords, max_coords); - - } else { - // Invalid line - return something - box.Init(Vector3(0,0,0),Vector3(1,1,1)); - } -} - -void StreakLineClass::Prepare_LOD(CameraClass &camera) -{ - // Find the maximum screen dimension of the object in pixels - NormalizedScreenArea = Get_Screen_Size(camera); - -// // Find and set texture reduction factor -// Set_Texture_Reduction_Factor(Calculate_Texture_Reduction_Factor(NormalizedScreenArea)); - - // Ensure subdivision level is legal - unsigned int lvl = LineRenderer.Get_Current_Subdivision_Level(); - lvl = MIN(lvl, MaxSubdivisionLevels); - LineRenderer.Set_Current_Subdivision_Level(lvl); - - // Prepare LOD processing if the line has subdivision enabled: - if (MaxSubdivisionLevels > 0) { - // Add myself to the LOD optimizer: - PredictiveLODOptimizerClass::Add_Object(this); - } else { - // Not added to optimizer, need to add cost - PredictiveLODOptimizerClass::Add_Cost(Get_Cost()); - } -} - -void StreakLineClass::Increment_LOD(void) -{ - unsigned int lvl = LineRenderer.Get_Current_Subdivision_Level(); - - lvl = MIN(lvl+1,MaxSubdivisionLevels); - - LineRenderer.Set_Current_Subdivision_Level(lvl); -} - -void StreakLineClass::Decrement_LOD(void) -{ - int lvl = LineRenderer.Get_Current_Subdivision_Level(); - if (lvl == 0) return; - LineRenderer.Set_Current_Subdivision_Level(lvl-1); -} - -float StreakLineClass::Get_Cost(void) const -{ - return Get_Num_Polys(); -} - -float StreakLineClass::Get_Value(void) const -{ - // If we are at the minimum LOD, we must return AT_MIN_LOD. - if (LineRenderer.Get_Current_Subdivision_Level() == 0) { - return AT_MIN_LOD; - } else { - float polycount = (float)Get_Num_Polys(); - float benefit_factor = 1.0f - (0.5f / (polycount * polycount)); - return (benefit_factor * NormalizedScreenArea) / Get_Cost(); - } -} - -float StreakLineClass::Get_Post_Increment_Value(void) const -{ - // If we are at the maximum LOD, we must return AT_MIN_LOD. - if (LineRenderer.Get_Current_Subdivision_Level() == MaxSubdivisionLevels) { - return AT_MAX_LOD; - } else { - // Assumption: each subdivision level doubles polycount - float polycount = 2.0f * (float)Get_Num_Polys(); - float benefit_factor = 1.0f - (0.5f / (polycount * polycount)); - // Assumption: Cost() == polycount - return (benefit_factor * NormalizedScreenArea) / polycount; - } -} - -void StreakLineClass::Set_LOD_Level(int lod) -{ - lod = MAX(0, lod); - lod = MIN(lod, (int)MaxSubdivisionLevels); - - LineRenderer.Set_Current_Subdivision_Level((unsigned int)lod); -} - -int StreakLineClass::Get_LOD_Level(void) const -{ - return (int) LineRenderer.Get_Current_Subdivision_Level(); -} - -int StreakLineClass::Get_LOD_Count(void) const -{ - return (int)MaxSubdivisionLevels; -} -/* -void StreakLineClass::Set_Texture_Reduction_Factor(float trf) -{ - if (LineRenderer.Peek_Texture()) LineRenderer.Peek_Texture()->Set_Reduction_Factor(trf); -}*/ - - - -void StreakLineClass::Render_Seg_Line(RenderInfoClass & rinfo) -{ - // Line must have at least two points to be valid - if (PointLocations.Count() < 2) return; - - SphereClass bounding_sphere; - Get_Obj_Space_Bounding_Sphere(bounding_sphere); - -// LineRenderer.Set_Width(rand()%3); - - LineRenderer.Render( - rinfo, - Transform, - PointLocations.Count(), - &(PointLocations[0]), - bounding_sphere - ); -} - - -void StreakLineClass::Render_Streak_Line(RenderInfoClass & rinfo) -{ - - WWASSERT(PointLocations.Count() == PointColors.Count()); - WWASSERT(PointLocations.Count() == PointWidths.Count()); - - // Line must have at least two points to be valid - if (PointLocations.Count() < 2) return; - if (PointColors.Count() < 2) return; - if (PointWidths.Count() < 2) return; - - if(PointLocations.Count() != PointColors.Count()) return; - if(PointLocations.Count() != PointWidths.Count()) return; - - SphereClass bounding_sphere; - Get_Obj_Space_Bounding_Sphere(bounding_sphere); - - -// StreakRenderer.Render( -// rinfo, -// Transform, -// PointLocations.Count(), -// &(PointLocations[0]), -// bounding_sphere -// ); - StreakRenderer.RenderStreak( - rinfo, - Transform, - PointLocations.Count(), - &(PointLocations[0]), - &(PointColors[0]), - &(PointWidths[0]), - bounding_sphere, - Personalities - ); -} - - -bool StreakLineClass::Cast_Ray(RayCollisionTestClass & raytest) -{ - if ((Get_Collision_Type() & raytest.CollisionType) == 0) return false; - - bool retval = false; - - // - // Check each line segment against the ray - // - float fraction = 1.0F; - for (uint32 index = 1; index < (unsigned int)PointLocations.Count(); index ++) - { -#ifdef ALLOW_TEMPORARIES - Vector3 curr_start = Transform * PointLocations[index-1]; - Vector3 curr_end = Transform * PointLocations[index]; - LineSegClass line_seg (curr_start, curr_end); -#else - Vector3 curr[2]; - Transform.mulVector3Array(&PointLocations[index-1], curr, 2); - LineSegClass line_seg(curr[0], curr[1]); -#endif - - Vector3 p0; - Vector3 p1; - if (raytest.Ray.Find_Intersection (line_seg, &p0, &fraction, &p1, NULL)) { - - // - // Determine if the ray was close enough to this line to be - // considered intersecting - // - float dist = (p0 - p1).Length (); - if (dist <= LineRenderer.Get_Width() && fraction >= 0 && fraction < raytest.Result->Fraction) { - //if (dist <= Width && fraction < raytest.Result->Fraction) { - retval = true; - break; - } - } - } - - // - // Fill in the raytest structure if we were successfull - // - if (retval) { - raytest.Result->Fraction = fraction; - raytest.Result->SurfaceType = SURFACE_TYPE_DEFAULT; - raytest.CollidedRenderObj = this; - } - - return retval; -} - - diff --git a/Generals/Code/Libraries/Source/WWVegas/WW3D2/streak.h b/Generals/Code/Libraries/Source/WWVegas/WW3D2/streak.h deleted file mode 100644 index 962362ba2de..00000000000 --- a/Generals/Code/Libraries/Source/WWVegas/WW3D2/streak.h +++ /dev/null @@ -1,220 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/********************************************************************************* - *** C O N F I D E N T I A L --- E A P A C I F I C *** - ********************************************************************************* - * * - * Project Name : G * - * * - * $Archive:: ww3d2/streak.h $* - * * - * $Author:: Mark Lorenzen $* - * * - * $Modtime:: 8/6/02 4:09p $* - * * - * $Revision:: 1 $* - * * - *-------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#if defined(_MSC_VER) -#pragma once -#endif - -#ifndef STREAK_H -#define STREAK_H - -#include "rendobj.h" -#include "shader.h" -#include "simplevec.h" -#include "seglinerenderer.h" -#include "streakRender.h" - -class TextureClass; - -/* -** StreakLineClass -- a render object for rendering thick segmented lines. -** essentially it is segmentedlineclass++ -** with added characteristics, such as varying thickness, opacity -** color and precise texture tiling... -** The reason this does not descend from segmentedlineclass, is to streamline -** the upcoming merge with the LasVegas code (to keep our changes out of their code) -*/ - -class StreakLineClass : public RenderObjClass -{ - public: - - StreakLineClass(void); - StreakLineClass(const StreakLineClass & src); - StreakLineClass & operator = (const StreakLineClass &that); -// virtual ~StreakLineClass(void); - - void Reset_Line(void); - - /* - ** StreakLineClass interface: - */ - - // These are segment points, and include the start and end point of the - // entire line. Therefore there must be at least two. - int Get_Num_Points(void); - - - // Set object-space location for a given point. - // NOTE: If given position beyond end of point list, do nothing. - void Set_Point_Location(unsigned int point_idx, const Vector3 &location); - - // Get object-space location for a given point. - void Get_Point_Location(unsigned int point_idx, Vector3 &loc); - - // Modify the line by adding and removing points - void Add_Point(const Vector3 & location); - void Delete_Point(unsigned int point_idx); - - // Get/set global properties (which affect all line segments) - TextureClass * Get_Texture(void); - ShaderClass Get_Shader(void); - - float Get_Width(void); - void Get_Color(Vector3 &color); - float Get_Opacity(void); - float Get_Noise_Amplitude(void); - float Get_Merge_Abort_Factor(void); - unsigned int Get_Subdivision_Levels(void); - SegLineRendererClass::TextureMapMode Get_Texture_Mapping_Mode(void); - float Get_Texture_Tile_Factor(void); - Vector2 Get_UV_Offset_Rate(void); - int Is_Merge_Intersections(void); - int Is_Freeze_Random(void); - int Is_Sorting_Disabled(void); - int Are_End_Caps_Enabled(void); - - void Set_Texture(TextureClass *texture); - void Set_Shader(ShaderClass shader); - void Set_Width(float width); - void Set_Color(const Vector3 &color); - void Set_Opacity(float opacity); - void Set_Noise_Amplitude(float amplitude); - void Set_Merge_Abort_Factor(float factor); - void Set_Subdivision_Levels(unsigned int levels); - void Set_Texture_Mapping_Mode(SegLineRendererClass::TextureMapMode mode); - // WARNING! Do NOT set the tile factor to be too high (should be less than 8) or negative - //performance impact will result! - void Set_Texture_Tile_Factor(float factor); - void Set_UV_Offset_Rate(const Vector2 &rate); - void Set_Merge_Intersections(int onoff); - void Set_Freeze_Random(int onoff); - void Set_Disable_Sorting(int onoff); - void Set_End_Caps(int onoff); - - ///////////////////////////////////////////////////////////////////////////// - // Render Object Interface - Cloning and Identification - ///////////////////////////////////////////////////////////////////////////// - virtual RenderObjClass * Clone(void) const; - virtual int Class_ID(void) const { return CLASSID_SEGLINE; } - virtual int Get_Num_Polys(void) const; - - ///////////////////////////////////////////////////////////////////////////// - // Render Object Interface - Rendering - ///////////////////////////////////////////////////////////////////////////// - virtual void Render( RenderInfoClass & rinfo ); - - ///////////////////////////////////////////////////////////////////////////// - // Render Object Interface - Bounding Volumes - ///////////////////////////////////////////////////////////////////////////// - virtual void Get_Obj_Space_Bounding_Sphere(SphereClass & sphere) const; - virtual void Get_Obj_Space_Bounding_Box(AABoxClass & box) const; - - ///////////////////////////////////////////////////////////////////////////// - // Render Object Interface - Predictive LOD - ///////////////////////////////////////////////////////////////////////////// - virtual void Prepare_LOD(CameraClass &camera); - virtual void Increment_LOD(void); - virtual void Decrement_LOD(void); - virtual float Get_Cost(void) const; - virtual float Get_Value(void) const; - virtual float Get_Post_Increment_Value(void) const; - virtual void Set_LOD_Level(int lod); - virtual int Get_LOD_Level(void) const; - virtual int Get_LOD_Count(void) const; - - ///////////////////////////////////////////////////////////////////////////// - // Render Object Interface - Attributes, Options, Properties, etc - ///////////////////////////////////////////////////////////////////////////// -// virtual void Set_Texture_Reduction_Factor(float trf); - - /////////////////////////////////////////////////////////////////////////////////////////////////////////////// - // Render Object Interface - Collision Detection - /////////////////////////////////////////////////////////////////////////////////////////////////////////////// - virtual bool Cast_Ray(RayCollisionTestClass & raytest); - - void Set_LocsWidthsColors( unsigned int num_points, - Vector3 *locs, - float *widths = NULL, - Vector4 *colors = NULL, - unsigned int *personalities = NULL); - - - protected: - - void Set_Locs(unsigned int num_points, Vector3 *locs); - void Set_Widths(unsigned int num_points, float *widths); - void Set_Colors(unsigned int num_points, Vector4 *colors); - - void Render_Seg_Line(RenderInfoClass & rinfo); - void Render_Streak_Line(RenderInfoClass & rinfo); - - private: - - // Subdivision properties - unsigned int MaxSubdivisionLevels; - - - // per-particle seeds - unsigned int *Personalities; - - // Normalized screen area - used for LOD purposes - float NormalizedScreenArea; - - // Per-point location array - //ShareBufferClass *PointLocations; - SimpleDynVecClass PointLocations; // World/cameraspace point locs - SimpleDynVecClass PointColors; // RGBA - SimpleDynVecClass PointWidths; // float line thickness - - - - - - // LineRenderer, contains most of the line settings. - SegLineRendererClass LineRenderer; - StreakRendererClass StreakRenderer;//special, per-point alpha/color/size -}; - - - - - - - - - -#endif // SEGLINE_H diff --git a/Generals/Code/Libraries/Source/WWVegas/WW3D2/streakRender.cpp b/Generals/Code/Libraries/Source/WWVegas/WW3D2/streakRender.cpp deleted file mode 100644 index 1b10cfaa7ae..00000000000 --- a/Generals/Code/Libraries/Source/WWVegas/WW3D2/streakRender.cpp +++ /dev/null @@ -1,1425 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** EA PACIFIC CONFIDENTIAL *** - *********************************************************************************************** - * * - * Original Author:: Mark Lorenzen * - * * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - - -#include "streakRender.h" -#include "ww3d.h" -#include "rinfo.h" -#include "dx8wrapper.h" -#include "sortingrenderer.h" -#include "vp.h" -#include "Vector3i.h" -#include "RANDOM.H" -#include "v3_rnd.h" - -#ifdef RTS_INTERNAL -// for occasional debugging... -// #pragma optimize("", off) -// #pragma MESSAGE("************************************** WARNING, optimization disabled for debugging purposes") -#endif - -/* We have chunking logic which handles N segments at a time. To simplify the subdivision logic, -** we will ensure that N is a power of two and that N >= 2^MAX_STREAK_SUBDIV_LEVELS, so that the -** subdivision logic can be inside the chunking loop. -*/ - -#if MAX_STREAK_SUBDIV_LEVELS > 7 -#define STREAK_CHUNK_SIZE (1 << MAX_STREAK_SUBDIV_LEVELS) -#else -#define STREAK_CHUNK_SIZE (128) -#endif - -#define MAX_STREAK_POINT_BUFFER_SIZE (1 + STREAK_CHUNK_SIZE) -// This macro depends on the assumption that each line segment is two polys. -#define MAX_STREAK_POLY_BUFFER_SIZE (STREAK_CHUNK_SIZE * 2) - - - - -StreakRendererClass::StreakRendererClass(void) : - Texture(NULL), - Shader(ShaderClass::_PresetAdditiveSpriteShader), - Width(0.0f), - Color(Vector3(1,1,1)), - Opacity(1.0f), - SubdivisionLevel(0), - NoiseAmplitude(0.0f), - MergeAbortFactor(1.5f), - // TextureTileFactor(1.0f), - // LastUsedSyncTime(WW3D::Get_Sync_Time()), - // CurrentUVOffset(0.0f,0.0f), - // UVOffsetDeltaPerMS(0.0f, 0.0f), - Bits(DEFAULT_BITS), - m_vertexBufferSize(0), - m_vertexBuffer(NULL) -{ - // EMPTY -} - -StreakRendererClass::StreakRendererClass(const StreakRendererClass & that) : - Texture(NULL), - Shader(ShaderClass::_PresetAdditiveSpriteShader), - Width(0.0f), - Color(Vector3(1,1,1)), - Opacity(1.0f), - SubdivisionLevel(0), - NoiseAmplitude(0.0f), - MergeAbortFactor(1.5f), - // TextureTileFactor(1.0f), - // LastUsedSyncTime(that.LastUsedSyncTime), - // CurrentUVOffset(0.0f,0.0f), - // UVOffsetDeltaPerMS(0.0f, 0.0f), - Bits(DEFAULT_BITS), - m_vertexBufferSize(0), - m_vertexBuffer(NULL) -{ - *this = that; -} - -StreakRendererClass & StreakRendererClass::operator = (const StreakRendererClass & that) -{ - if (this != &that) { - REF_PTR_SET(Texture,that.Texture); - Shader = that.Shader; - Width = that.Width; - Color = that.Color; - Opacity = that.Opacity; - SubdivisionLevel = that.SubdivisionLevel; - NoiseAmplitude = that.NoiseAmplitude; - MergeAbortFactor = that.MergeAbortFactor; - // TextureTileFactor = that.TextureTileFactor; - // LastUsedSyncTime = that.LastUsedSyncTime; - // CurrentUVOffset = that.CurrentUVOffset; - // UVOffsetDeltaPerMS = that.UVOffsetDeltaPerMS; - Bits = that.Bits; - // Don't modify m_vertexBufferSize and m_vertexBuffer. - } - return *this; -} - -StreakRendererClass::~StreakRendererClass(void) -{ - REF_PTR_RELEASE(Texture); - delete [] m_vertexBuffer; -} - -void StreakRendererClass::Init(const W3dEmitterLinePropertiesStruct & props) -{ - // translate the flags - Set_Merge_Intersections(props.Flags & W3D_ELINE_MERGE_INTERSECTIONS); - Set_Freeze_Random(props.Flags & W3D_ELINE_FREEZE_RANDOM); - Set_Disable_Sorting(props.Flags & W3D_ELINE_DISABLE_SORTING); - Set_End_Caps(props.Flags & W3D_ELINE_END_CAPS); - - int texture_mode = ((props.Flags & W3D_ELINE_TEXTURE_MAP_MODE_MASK) >> W3D_ELINE_TEXTURE_MAP_MODE_OFFSET); - switch (texture_mode) - { - case W3D_ELINE_UNIFORM_WIDTH_TEXTURE_MAP: - Set_Texture_Mapping_Mode(UNIFORM_WIDTH_TEXTURE_MAP); - break; - case W3D_ELINE_UNIFORM_LENGTH_TEXTURE_MAP: - Set_Texture_Mapping_Mode(UNIFORM_LENGTH_TEXTURE_MAP); - break; - case W3D_ELINE_TILED_TEXTURE_MAP: - Set_Texture_Mapping_Mode(TILED_TEXTURE_MAP); - break; - }; - - // install all other settings - Set_Current_Subdivision_Level(props.SubdivisionLevel); - Set_Noise_Amplitude(props.NoiseAmplitude); - Set_Merge_Abort_Factor(props.MergeAbortFactor); - // Set_Texture_Tile_Factor(props.TextureTileFactor); - // Set_UV_Offset_Rate(Vector2(props.UPerSec,props.VPerSec)); -} - - -void StreakRendererClass::Set_Texture(TextureClass *texture) -{ - REF_PTR_SET(Texture,texture); -} - -TextureClass * StreakRendererClass::Get_Texture(void) const -{ - if (Texture != NULL) { - Texture->Add_Ref(); - } - return Texture; -} - -// void StreakRendererClass::Set_Current_UV_Offset(const Vector2 & offset) -// { -// CurrentUVOffset = offset; -// } - -// void StreakRendererClass::Set_Texture_Tile_Factor(float factor) -// { -// if (factor > 8.0f) { -// factor = 8.0f; -// WWDEBUG_SAY(("Texture Tile Factor too large in StreakRendererClass!\r\n")); -// } else { -// factor = MAX(factor, 0.0f); -// } -// TextureTileFactor = factor; -//} - -// void StreakRendererClass::Reset_Line(void) -// { - // LastUsedSyncTime = WW3D::Get_Sync_Time(); - // CurrentUVOffset.Set(0.0f,0.0f); -// } - -/////////////////////////////////////////////////////////////////////////////////////////// -/////////////////////////////////////////////////////////////////////////////////////////// -void StreakRendererClass::Render -( - RenderInfoClass & rinfo, - const Matrix3D & transform, - unsigned int num_points, - Vector3 * points, - const SphereClass & obj_sphere -) -{ - //NOTHING! - return; -} - -/////////////////////////////////////////////////////////////////////////////////////////// -/////////////////////////////////////////////////////////////////////////////////////////// -/////////////////////////////////////////////////////////////////////////////////////////// -/////////////////////////////////////////////////////////////////////////////////////////// - - - - -void StreakRendererClass::subdivision_util(unsigned int point_cnt, const Vector3 *xformed_pts, - const float *base_tex_v, unsigned int *p_sub_point_cnt, Vector3 *xformed_subdiv_pts, - float *subdiv_tex_v) -{ - // CAUTION: freezing the random offsets will make it more readily apparent that the offsets - // are in camera space rather than worldspace. - int freeze_random = Is_Freeze_Random(); - Random3Class randomize; - const float oo_int_max = 1.0f / (float)INT_MAX; - Vector3SolidBoxRandomizer randomizer(Vector3(1,1,1)); - Vector3 randvec(0,0,0); - unsigned int sub_pointIndex = 0; - - struct StreakSubdivision { - Vector3 StartPos; - Vector3 EndPos; - float StartTexV; // V texture coordinate of start point - float EndTexV; // V texture coordinate of end point - float Rand; - unsigned int Level; // Subdivision level - }; - - StreakSubdivision stack[2 * MAX_STREAK_SUBDIV_LEVELS]; // Maximum number needed - int tos = 0; - - for (unsigned int pointIndex = 0; pointIndex < point_cnt - 1; pointIndex++) { - - // Subdivide the (pointIndex, pointIndex + 1) segment. Produce pointIndex and all subdivided points up to - // (not including) pointIndex + 1. - tos = 0; - stack[0].StartPos = xformed_pts[pointIndex]; - stack[0].EndPos = xformed_pts[pointIndex + 1]; - stack[0].StartTexV = base_tex_v[pointIndex]; - stack[0].EndTexV = base_tex_v[pointIndex + 1]; - stack[0].Rand = NoiseAmplitude; - stack[0].Level = 0; - - for (; tos >= 0;) { - if (stack[tos].Level == SubdivisionLevel) { - // Generate point location and texture V coordinate - xformed_subdiv_pts[sub_pointIndex] = stack[tos].StartPos; - subdiv_tex_v[sub_pointIndex++] = stack[tos].StartTexV; - - // Pop - tos--; - } else { - // Recurse down: pop existing entry and push two subdivided ones. - if (freeze_random) { - randvec.Set(randomize * oo_int_max, randomize * oo_int_max, randomize * oo_int_max); - } else { - randomizer.Get_Vector(randvec); - } - stack[tos + 1].StartPos = stack[tos].StartPos; - stack[tos + 1].EndPos = (stack[tos].StartPos + stack[tos].EndPos) * 0.5f + randvec * stack[tos].Rand; - stack[tos + 1].StartTexV = stack[tos].StartTexV; - stack[tos + 1].EndTexV = (stack[tos].StartTexV + stack[tos].EndTexV) * 0.5f; - stack[tos + 1].Rand = stack[tos].Rand * 0.5f; - stack[tos + 1].Level = stack[tos].Level + 1; - stack[tos].StartPos = stack[tos + 1].EndPos; - // stack[tos].EndPos already has the right value - stack[tos].StartTexV = stack[tos + 1].EndTexV; - // stack[tos].EndTexV already has the right value - stack[tos].Rand = stack[tos + 1].Rand; - stack[tos].Level = stack[tos + 1].Level; - tos++; - } - } - } - // Last point - xformed_subdiv_pts[sub_pointIndex] = xformed_pts[point_cnt - 1]; - subdiv_tex_v[sub_pointIndex++] = base_tex_v[point_cnt - 1]; - - // Output: - *p_sub_point_cnt = sub_pointIndex; -} - - -/////// /////// /////// /////// /////// /////// /////// /////// -/////// /////// /////// /////// /////// /////// /////// /////// -/////// /////// /////// /////// /////// /////// /////// /////// -/////// /////// /////// /////// /////// /////// /////// /////// -/////// /////// /////// /////// /////// /////// /////// /////// -/////// /////// /////// /////// /////// /////// /////// /////// -/////// /////// /////// /////// /////// /////// /////// /////// -/////// /////// /////// /////// /////// /////// /////// /////// -/////// /////// /////// /////// /////// /////// /////// /////// - - - -void StreakRendererClass::RenderStreak -( - RenderInfoClass & rinfo, - const Matrix3D & transform, - unsigned int num_points, - Vector3 * points, - Vector4 * colors, /////////////// DIFFERENT FROM RENDER( ) - float * widths, /////////////// DIFFERENT FROM RENDER( ) - const SphereClass & obj_sphere, - unsigned int *personalities /////////////// DIFFERENT FROM RENDER( ) -) -{ - Matrix4x4 view; - DX8Wrapper::Get_Transform(D3DTS_VIEW,view); - - Matrix4x4 identity(true); - DX8Wrapper::Set_Transform(D3DTS_WORLD,identity); - DX8Wrapper::Set_Transform(D3DTS_VIEW,identity); - - /* - ** Handle texture UV offset animation (done once for entire line). - */ - // unsigned int delta = WW3D::Get_Sync_Time() - LastUsedSyncTime; - // float del = (float)delta; - //Vector2 uv_offset = CurrentUVOffset + UVOffsetDeltaPerMS * del; - - // ensure offsets are in [0, 1] range: - //uv_offset.X = uv_offset.X - floorf(uv_offset.X); - //uv_offset.Y = uv_offset.Y - floorf(uv_offset.Y); - - // Update state - //CurrentUVOffset = uv_offset; - // LastUsedSyncTime = WW3D::Get_Sync_Time(); - - // Used later - TextureMapMode map_mode = Get_Texture_Mapping_Mode(); - - /* - ** Process line geometry: - */ - - // This has been tweaked to produce empirically good results. - const float parallel_factor = 0.9f; - - // We reduce the chunk size to take account of subdivision levels (so that the # of points - // after subdivision will be no higher than the allowed maximum). We know this will not reduce - // the chunk size below 2, since the chunk size must be at least two to the power of the - // maximum allowable number of subdivisions. The plus 1 is because #points = #segments + 1. - unsigned int chunk_size = (STREAK_CHUNK_SIZE >> SubdivisionLevel) + 1; - if (chunk_size > num_points) chunk_size = num_points; - - // Chunk through the points (we increment by chunk_size - 1 because the last point of this - // chunk must be reused as the first point of the next chunk. This is also the reason we stop - // when chunkIndex = NumPoints - 1: the last point has already been processed in the previous - // iteration so we don't need another one). - for (unsigned int chunkIndex = 0; chunkIndex < num_points - 1; chunkIndex += (chunk_size - 1)) - { - unsigned int point_cnt = num_points - chunkIndex; - point_cnt = MIN(point_cnt, chunk_size); - - // We use these different loop indices (which loop INSIDE a chunk) to improve readability: - unsigned int pointIndex; // Point index - unsigned int segmentIndex; // Segment index - unsigned int intersectionIndex; // Intersection index - - - /* - ** Transform points in chunk from objectspace to eyespace: - */ - - Vector3 xformed_pts[MAX_STREAK_POINT_BUFFER_SIZE]; - - Matrix3D view2( view[0].X,view[0].Y,view[0].Z,view[0].W, - view[1].X,view[1].Y,view[1].Z,view[1].W, - view[2].X,view[2].Y,view[2].Z,view[2].W); - -#ifdef ALLOW_TEMPORARIES - Matrix3D modelview=view2*transform; -#else - Matrix3D modelview; - modelview.mul(view2, transform); -#endif - - VectorProcessorClass::Transform(&xformed_pts[0], - &points[chunkIndex], modelview, point_cnt); - - - /* - ** Prepare v parameter per point - used for texture mapping (esp. tiled mapping mode) - */ - - float base_tex_v[MAX_STREAK_POINT_BUFFER_SIZE]; - float u_values[2]; - - - // I HAVE HARD CODED IT TO USE UNIFORM WIDTH AND LENGTH - for (pointIndex = 0; pointIndex < point_cnt; pointIndex++) - { - // All 0 - base_tex_v[pointIndex] = 0.0f; - } - u_values[0] = 0.0f; - u_values[1] = 1.0f; - - - - - - -// switch (map_mode) -// { -// case UNIFORM_WIDTH_TEXTURE_MAP:// only non-dead case -// for (pointIndex = 0; pointIndex < point_cnt; pointIndex++) -// { -// // All 0 -// base_tex_v[pointIndex] = 0.0f; -// } -// u_values[0] = 0.0f; -// u_values[1] = 1.0f; -// break; -// case UNIFORM_LENGTH_TEXTURE_MAP: -// for (pointIndex = 0; pointIndex < point_cnt; pointIndex++) -// { -// // Increasing V -// base_tex_v[pointIndex] = (float)(pointIndex + chunkIndex) * TextureTileFactor; -// } -// u_values[0] = 0.0f; -// u_values[1] = 0.0f; -// break; -// case TILED_TEXTURE_MAP: -// for (pointIndex = 0; pointIndex < point_cnt; pointIndex++) -// { -// // Increasing V -// base_tex_v[pointIndex] = (float)(pointIndex + chunkIndex) * TextureTileFactor; -// } -// u_values[0] = 0.0f; -// u_values[1] = 1.0f; -// break; -// } - - - /* - ** Fractal noise recursive subdivision: - ** We find the midpoint for each section, apply a random offset, and recurse. We also find - ** the average V coordinate of the endpoints which is the midpoint V (for tiled texture - ** mapping). - */ - - Vector3 xformed_subdiv_pts[MAX_STREAK_POINT_BUFFER_SIZE]; - float subdiv_tex_v[MAX_STREAK_POINT_BUFFER_SIZE]; - unsigned int sub_point_cnt; - - subdivision_util(point_cnt, xformed_pts, base_tex_v, &sub_point_cnt, xformed_subdiv_pts, subdiv_tex_v); - - // Start using subdivided points from now on - Vector3 *points = xformed_subdiv_pts; - float *tex_v = subdiv_tex_v; - point_cnt = sub_point_cnt; - - - /* - ** Calculate line segment edge planes: - */ - - // For each line segment find the two silhouette planes from eyepoint to the line segment - // cylinder. To simplify we do not find the tangent planes but intersect the cylinder with a - // plane passing through its axis and perpendicular to the eye vector, find the edges of the - // resulting rectangle, and create planes through these edges and the eyepoint. - // Note that these planes are represented as a single normal rather than a normal and a - // distance; this is because they pass through the origin (eyepoint) so their distance is - // always zero. - - // Since the line has thickness, each segment has two edges. We name these 'top' and - // 'bottom' - note however that the top/bottom distinction does not relate to screen - // up/down and remains consistent throughout the segmented line. - enum SegmentEdge - { - FIRST_EDGE = 0, // For loop conditions - TOP_EDGE = 0, // Top Edge - BOTTOM_EDGE = 1, // Bottom Edge - MAX_EDGE = 1, // For loop conditions - NUM_EDGES = 2 // For array allocations - }; - - bool switch_edges = false; - - // We have dummy segments for "before the first point" and "after the last point" - in these - // segments the top and bottom edge are the same - they are a perpendicular plane defined by - // the endpoint vertices. This is so we can merge intersections properly for the first and - // last points. - - struct LineSegment - { - Vector3 StartPlane; - Vector3 EdgePlane[NUM_EDGES]; - }; - - // # segments = numpoints + 1 (numpoints - 1, plus two dummy segments) - LineSegment segment[MAX_STREAK_POINT_BUFFER_SIZE + 1]; - - // Intersections. This has data for two edges (top or bottom) intersecting. - struct LineSegmentIntersection - { - unsigned int PointCount; // How many points does this intersection represent - unsigned int NextSegmentID; // ID of segment after this intersection - Vector3 Direction; // Calculated intersection direction line - Vector3 Point; // Averaged 3D point on the line which this represents - float TexV; // Averaged texture V coordinate of points - bool Fold; // Does the line fold over at this intersection? - bool Parallel; // Edges at this intersection are parallel (or almost-) - }; - - // Used to calculate the edge planes - float radius = Width * 0.5f; - - - // The number of intersections is the number of points minus 2. However, we store - // intersection records for the first and last point, even though they are not really - // intersections. The reason we do this is for the intersection merging - the vertices for - // the first and last points can get merged just like any other intersection. Also, we have - // a dummy intersection record before the first point - this is because we want "previous - // segments" for the first point and each intersection only has an index for the next - // segment. - LineSegmentIntersection intersection[MAX_STREAK_POINT_BUFFER_SIZE + 1][NUM_EDGES]; - - - - - for (segmentIndex = 1; segmentIndex < point_cnt; segmentIndex++) - { // #segments = #points - 1 (+ 2 dummy segments) - - radius = widths[segmentIndex]; /// NEW ///// // TODO: Does not work correctly when subdivision are not 0 - - Vector3 &curr_point = points[segmentIndex - 1]; - Vector3 &next_point = points[segmentIndex]; - if (Equal_Within_Epsilon(curr_point, next_point, 0.0001f)) - { - next_point.X += 0.001f; - } - - // We temporarily store the segment direction in the segment's StartPlane (since it is - // used to calculate the StartPlane later). - Vector3 &segdir = segment[segmentIndex].StartPlane; - segdir = next_point - curr_point; - segdir.Normalize(); - - // Find nearest point on infinite line to eye (origin) - Vector3 nearest = curr_point + segdir * -Vector3::Dot_Product(segdir, curr_point); - - // Find top and bottom points on cylinder - Vector3 offset; - Vector3::Cross_Product(segdir, nearest, &offset); - offset.Normalize(); - Vector3 top = curr_point + offset * radius; - Vector3 bottom = curr_point + offset * -radius; - - // Find planes through top/bottom points and eyepoint. In addition to the two points, we - // know that the planes are parallel to the line segment. - Vector3 top_normal; - Vector3::Cross_Product(top, segdir, &top_normal); - top_normal.Normalize(); - segment[segmentIndex].EdgePlane[TOP_EDGE] = top_normal; - - Vector3 bottom_normal; - Vector3::Cross_Product(segdir, bottom, &bottom_normal); - bottom_normal.Normalize(); - segment[segmentIndex].EdgePlane[BOTTOM_EDGE] = bottom_normal; - - // If the visual angle between the previous and current line segments (we use the angle - // between the planes defined by each line segment and the eyepoint) is less than 90 - // degrees, switch the top and bottom edges for the current and subsequent segments and - // mark the intersection as having a fold - if (segmentIndex > 1) - { - - Vector3 prev_plane; - Vector3::Cross_Product(points[segmentIndex - 2], curr_point, &prev_plane); - prev_plane.Normalize(); - - Vector3 curr_plane; - Vector3::Cross_Product(curr_point, next_point, &curr_plane); - curr_plane.Normalize(); - - if (Vector3::Dot_Product(prev_plane, curr_plane) < 0.0f) - { - switch_edges = !switch_edges; - intersection[segmentIndex][TOP_EDGE].Fold = true; - intersection[segmentIndex][BOTTOM_EDGE].Fold = true; - } - else - { - intersection[segmentIndex][TOP_EDGE].Fold = false; - intersection[segmentIndex][BOTTOM_EDGE].Fold = false; - } - } - - if (switch_edges) - { - // We switch signs so the normals will always point inwards - segment[segmentIndex].EdgePlane[TOP_EDGE] = -bottom_normal; - segment[segmentIndex].EdgePlane[BOTTOM_EDGE] = -top_normal; - } - - } - - - - - - // The two dummy segments for the clipping edges of the first and last real segments will be - // defined later, with the first and last intersections. - - - /* - ** Calculate segment edge intersections: - */ - - unsigned int numsegs = point_cnt - 1; // Doesn't include the two dummy segments - unsigned int num_intersections[NUM_EDGES]; - - // These include the 1st, last point "intersections", not the pre-first dummy intersection - num_intersections[TOP_EDGE] = point_cnt; - num_intersections[BOTTOM_EDGE] = point_cnt; - - // Initialize pre-first point dummy intersection record (only NextSegmentID will be used). - intersection[0][TOP_EDGE].PointCount = 0; // Should never be used - intersection[0][TOP_EDGE].NextSegmentID = 0; // Points to first dummy segment - intersection[0][TOP_EDGE].Direction.Set(1,0,0); // Should never be used - intersection[0][TOP_EDGE].Point.Set(0,0,0); // Should never be used - intersection[0][TOP_EDGE].TexV = 0.0f; // Should never be used - intersection[0][TOP_EDGE].Fold = true; // Should never be used - intersection[0][TOP_EDGE].Parallel = false; // Should never be used - intersection[0][BOTTOM_EDGE].PointCount = 0; // Should never be used - intersection[0][BOTTOM_EDGE].NextSegmentID = 0; // Points to first dummy segment - intersection[0][BOTTOM_EDGE].Point.Set(0,0,0); // Should never be used - intersection[0][BOTTOM_EDGE].TexV = 0.0f; // Should never be used - intersection[0][BOTTOM_EDGE].Direction.Set(1,0,0); // Should never be used - intersection[0][BOTTOM_EDGE].Fold = true; // Should never be used - intersection[0][BOTTOM_EDGE].Parallel = false; // Should never be used - - // Initialize first point "intersection" record. - intersection[1][TOP_EDGE].PointCount = 1; - intersection[1][TOP_EDGE].NextSegmentID = 1; - intersection[1][TOP_EDGE].Point = points[0]; - intersection[1][TOP_EDGE].TexV = tex_v[0]; - intersection[1][TOP_EDGE].Fold = true; - intersection[1][TOP_EDGE].Parallel = false; - intersection[1][BOTTOM_EDGE].PointCount = 1; - intersection[1][BOTTOM_EDGE].NextSegmentID = 1; - intersection[1][BOTTOM_EDGE].Point = points[0]; - intersection[1][BOTTOM_EDGE].TexV = tex_v[0]; - intersection[1][BOTTOM_EDGE].Fold = true; - intersection[1][BOTTOM_EDGE].Parallel = false; - - // Find closest point to 1st top/bottom segment edge plane, and convert to direction vector - // and dummy segment edge plane. - - Vector3 top; - Vector3 bottom; - - Vector3 &first_point = points[0]; - Vector3 *first_plane = &(segment[1].EdgePlane[0]); - top = first_point - first_plane[TOP_EDGE] * Vector3::Dot_Product(first_plane[TOP_EDGE], first_point); - top.Normalize(); - intersection[1][TOP_EDGE].Direction = top; - bottom = first_point - first_plane[BOTTOM_EDGE] * Vector3::Dot_Product(first_plane[BOTTOM_EDGE], first_point); - bottom.Normalize(); - intersection[1][BOTTOM_EDGE].Direction = bottom; - - Vector3 segdir = points[1] - points[0]; - segdir.Normalize(); // Is this needed? Probably not - remove later when all works - Vector3 start_pl; - Vector3::Cross_Product(top, bottom, &start_pl); - start_pl.Normalize(); - float dp = Vector3::Dot_Product(segdir, start_pl); - if (dp > 0.0f) - { - segment[0].StartPlane = segment[0].EdgePlane[TOP_EDGE] = segment[0].EdgePlane[BOTTOM_EDGE] = start_pl; - } - else - { - segment[0].StartPlane = segment[0].EdgePlane[TOP_EDGE] = segment[0].EdgePlane[BOTTOM_EDGE] = -start_pl; - } - - // Initialize StartPlane for the first "real" segment - segment[1].StartPlane = segment[0].StartPlane; - - // Initialize last point "intersection" record. - unsigned int last_isec = num_intersections[TOP_EDGE]; // Same # top, bottom intersections - - intersection[last_isec][TOP_EDGE].PointCount = 1; - intersection[last_isec][TOP_EDGE].NextSegmentID = numsegs + 1; // Last dummy segment - intersection[last_isec][TOP_EDGE].Point = points[point_cnt - 1]; - intersection[last_isec][TOP_EDGE].TexV = tex_v[point_cnt - 1]; - intersection[last_isec][TOP_EDGE].Fold = true; - intersection[last_isec][TOP_EDGE].Parallel = false; - intersection[last_isec][BOTTOM_EDGE].PointCount = 1; - intersection[last_isec][BOTTOM_EDGE].NextSegmentID = numsegs + 1;// Last dummy segment - intersection[last_isec][BOTTOM_EDGE].Point = points[point_cnt - 1]; - intersection[last_isec][BOTTOM_EDGE].TexV = tex_v[point_cnt - 1]; - intersection[last_isec][BOTTOM_EDGE].Fold = true; - intersection[last_isec][BOTTOM_EDGE].Parallel = false; - - // Find closest point to last top/bottom segment edge plane, and convert to direction vector - // and dummy segment edge vector - - Vector3 &last_point = points[point_cnt - 1]; - Vector3 *last_plane = &(segment[numsegs].EdgePlane[0]); - top = last_point - last_plane[TOP_EDGE] * Vector3::Dot_Product(last_plane[TOP_EDGE], last_point); - top.Normalize(); - intersection[last_isec][TOP_EDGE].Direction = top; - bottom = last_point - last_plane[BOTTOM_EDGE] * Vector3::Dot_Product(last_plane[BOTTOM_EDGE], last_point); - bottom.Normalize(); - intersection[last_isec][BOTTOM_EDGE].Direction = bottom; - - segdir = points[point_cnt - 1] - points[point_cnt - 2]; - segdir.Normalize(); // Is this needed? Probably not - remove later when all works - Vector3::Cross_Product(top, bottom, &start_pl); - start_pl.Normalize(); - dp = Vector3::Dot_Product(segdir, start_pl); - if (dp > 0.0f) - { - segment[numsegs + 1].StartPlane = segment[numsegs + 1].EdgePlane[TOP_EDGE] = - segment[numsegs + 1].EdgePlane[BOTTOM_EDGE] = start_pl; - } - else - { - segment[numsegs + 1].StartPlane = segment[numsegs + 1].EdgePlane[TOP_EDGE] = - segment[numsegs + 1].EdgePlane[BOTTOM_EDGE] = -start_pl; - } - - // Calculate midpoint segment intersections. There are 2 segment intersections for each - // point: top and bottom (due to the fact that the segments have width, so they have a top - // edge and a bottom edge). Note that the top/bottom distinction does not relate to screen - // up/down. Since each segment edge is represented by a plane passing through the origin - // (eyepoint), the intersection of two such is a line passing through the origin, which is - // represented as a normalized direction vector. - // We use both segment intersections to define the startplane for the segment which begins - // at that intersection. - - float vdp; - - for (intersectionIndex = 2; intersectionIndex < num_intersections[TOP_EDGE]; intersectionIndex++) - { - - // Relevant midpoint: - Vector3 &midpoint = points[intersectionIndex - 1]; - float mid_tex_v = tex_v[intersectionIndex - 1]; - - // Initialize misc. fields - intersection[intersectionIndex][TOP_EDGE].PointCount = 1; - intersection[intersectionIndex][TOP_EDGE].NextSegmentID = intersectionIndex; - intersection[intersectionIndex][TOP_EDGE].Point = midpoint; - -// intersection[intersectionIndex][TOP_EDGE].TexV = mid_tex_v; - intersection[intersectionIndex][TOP_EDGE].TexV = personalities[intersectionIndex]&1;//LORENZEN LORENZEN - - intersection[intersectionIndex][BOTTOM_EDGE].PointCount = 1; - intersection[intersectionIndex][BOTTOM_EDGE].NextSegmentID = intersectionIndex; - intersection[intersectionIndex][BOTTOM_EDGE].Point = midpoint; - -// intersection[intersectionIndex][BOTTOM_EDGE].TexV = mid_tex_v; - intersection[intersectionIndex][BOTTOM_EDGE].TexV = personalities[intersectionIndex]&1;//LORENZEN LORENZEN - - // Intersection calculation: if the top/bottom planes of both adjoining segments are not - // very close to being parallel, intersect them to get top/bottom intersection lines. If - // the planes are almost parallel, pick one, find the point on the plane closest to the - // midpoint, and convert that point to a line direction vector. - - // Top: - vdp = Vector3::Dot_Product(segment[intersectionIndex - 1].EdgePlane[TOP_EDGE], segment[intersectionIndex].EdgePlane[TOP_EDGE]); - if (fabs(vdp) < parallel_factor) - { - - // Not parallel - intersect planes to get line (get vector, normalize it, ensure it is - // pointing towards the midpoint) - Vector3::Cross_Product(segment[intersectionIndex - 1].EdgePlane[TOP_EDGE], segment[intersectionIndex].EdgePlane[TOP_EDGE], - &(intersection[intersectionIndex][TOP_EDGE].Direction)); - intersection[intersectionIndex][TOP_EDGE].Direction.Normalize(); - if (Vector3::Dot_Product(intersection[intersectionIndex][TOP_EDGE].Direction, midpoint) < 0.0f) - { - intersection[intersectionIndex][TOP_EDGE].Direction = -intersection[intersectionIndex][TOP_EDGE].Direction; - } - - intersection[intersectionIndex][TOP_EDGE].Parallel = false; - - } - else - { - - // Parallel (or almost): find point on av. plane closest to midpoint, convert to line - - // Ensure average calculation is numerically stable: - Vector3 pl; - if (vdp > 0.0f) - { - pl = segment[intersectionIndex - 1].EdgePlane[TOP_EDGE] + segment[intersectionIndex].EdgePlane[TOP_EDGE]; - } - else - { - pl = segment[intersectionIndex - 1].EdgePlane[TOP_EDGE] - segment[intersectionIndex].EdgePlane[TOP_EDGE]; - } - pl.Normalize(); - - intersection[intersectionIndex][TOP_EDGE].Direction = midpoint - pl * Vector3::Dot_Product(pl, midpoint); - intersection[intersectionIndex][TOP_EDGE].Direction.Normalize(); - - intersection[intersectionIndex][TOP_EDGE].Parallel = true; - } - - // Bottom: - vdp = Vector3::Dot_Product(segment[intersectionIndex - 1].EdgePlane[BOTTOM_EDGE], segment[intersectionIndex].EdgePlane[BOTTOM_EDGE]); - if (fabs(vdp) < parallel_factor) - { - - // Not parallel - intersect planes to get line (get vector, normalize it, ensure it is - // pointing towards the midpoint) - Vector3::Cross_Product(segment[intersectionIndex - 1].EdgePlane[BOTTOM_EDGE], segment[intersectionIndex].EdgePlane[BOTTOM_EDGE], - &(intersection[intersectionIndex][BOTTOM_EDGE].Direction)); - intersection[intersectionIndex][BOTTOM_EDGE].Direction.Normalize(); - if (Vector3::Dot_Product(intersection[intersectionIndex][BOTTOM_EDGE].Direction, midpoint) < 0.0f) - { - intersection[intersectionIndex][BOTTOM_EDGE].Direction = -intersection[intersectionIndex][BOTTOM_EDGE].Direction; - } - - intersection[intersectionIndex][BOTTOM_EDGE].Parallel = false; - - } - else - { - - // Parallel (or almost): find point on av. plane closest to midpoint, convert to line - - // Ensure average calculation is numerically stable: - Vector3 pl; - if (vdp > 0.0f) - { - pl = segment[intersectionIndex - 1].EdgePlane[BOTTOM_EDGE] + segment[intersectionIndex].EdgePlane[BOTTOM_EDGE]; - } - else - { - pl = segment[intersectionIndex - 1].EdgePlane[BOTTOM_EDGE] - segment[intersectionIndex].EdgePlane[BOTTOM_EDGE]; - } - pl.Normalize(); - - intersection[intersectionIndex][BOTTOM_EDGE].Direction = midpoint - pl * Vector3::Dot_Product(pl, midpoint); - intersection[intersectionIndex][BOTTOM_EDGE].Direction.Normalize(); - - intersection[intersectionIndex][BOTTOM_EDGE].Parallel = true; - } - - // Find StartPlane: - Vector3::Cross_Product(intersection[intersectionIndex][TOP_EDGE].Direction, intersection[intersectionIndex][BOTTOM_EDGE].Direction, &start_pl); - start_pl.Normalize(); - dp = Vector3::Dot_Product(segment[intersectionIndex].StartPlane, start_pl); - if (dp > 0.0f) - { - segment[intersectionIndex].StartPlane = start_pl; - } - else - { - segment[intersectionIndex].StartPlane = -start_pl; - } - - } // for intersectionIndex - - - /* - ** Intersection merging: when an intersection is inside an adjacent segment and certain - ** other conditions hold true, we need to merge intersections to avoid visual glitches - ** caused by the polys folding over on themselves. - */ - - if (Is_Merge_Intersections()) - { - - // Since we are merging the intersections in-place, we have two index variables, a "read - // index" and a "write index". - unsigned int intersectionIndex_r; - unsigned int intersectionIndex_w; - - // The merges will be repeated in multiple passes until none are performed. The reason - // for this is that one merge may cause the need for another merge elsewhere. - bool merged = true; - - while (merged) - { - - merged = false; - - SegmentEdge edge; - for (edge = FIRST_EDGE; edge <= MAX_EDGE; edge = (SegmentEdge)((int)edge + 1)) - { - // Merge top and bottom edge intersections: loop through the intersections from the - // first intersection to the penultimate intersection, for each intersection check - // if it needs to be merged with the next one (which is why the loop doesn't go all - // the way to the last intersection). We start at 1 because 0 is the dummy - // "pre-first-point" intersection. - unsigned int num_isects = num_intersections[edge]; // Capture here because will change inside loop - for (intersectionIndex_r = 1, intersectionIndex_w = 1; intersectionIndex_r < num_isects; intersectionIndex_r++, intersectionIndex_w++) { - - // Check for either of two possible reasons to merge this intersection with the - // next: either the segment on the far side of the next intersection overlaps - // this intersection, or the previous segment overlaps the next intersection. - // Note that some other conditions need to be true as well. - - // Note: intersectionIndex_r is used for anything at or after the current position, intersectionIndex_w is - // used for anything before the current position (previous positions have - // potentially already been merged). - // Note: intersectionIndex_r is used for anything at or after the current position, intersectionIndex_w is - // used for anything before the current position (previous positions have - // potentially already been merged). - LineSegmentIntersection *curr_int = &(intersection[intersectionIndex_r][edge]); - LineSegmentIntersection *next_int = &(intersection[intersectionIndex_r + 1][edge]); - LineSegmentIntersection *write_int = &(intersection[intersectionIndex_w][edge]); - LineSegmentIntersection *prev_int = &(intersection[intersectionIndex_w - 1][edge]); - LineSegment *next_seg = &(segment[next_int->NextSegmentID]); - LineSegment *curr_seg = &(segment[curr_int->NextSegmentID]); - LineSegment *prev_seg = &(segment[prev_int->NextSegmentID]); - - // If this intersection is inside both the start plane and the segment edge - // plane of the segment after the next intersection, merge this edge - // intersection and the next. We repeat merging until no longer needed. - // NOTE - we do not merge across a fold. - while ( (!next_int->Fold && - (Vector3::Dot_Product(curr_int->Direction, next_seg->StartPlane) > 0.0f) && - (Vector3::Dot_Product(curr_int->Direction, next_seg->EdgePlane[edge]) > 0.0f )) || - (!curr_int->Fold && - (Vector3::Dot_Product(next_int->Direction, -curr_seg->StartPlane) > 0.0f) && - (Vector3::Dot_Product(next_int->Direction, prev_seg->EdgePlane[edge]) > 0.0f )) ) - { - - // First calculate location of merged intersection - this is so we can abort - // the merge if it yields funky results. - - // Find mean point (weighted so all points have same weighting) - unsigned int new_count = curr_int->PointCount + next_int->PointCount; - float oo_new_count = 1.0f / (float)new_count; - float curr_factor = oo_new_count * (float)curr_int->PointCount; - float next_factor = oo_new_count * (float)curr_int->PointCount; - Vector3 new_point = curr_int->Point * curr_factor + next_int->Point * next_factor; - float new_tex_v = curr_int->TexV * curr_factor + next_int->TexV * next_factor; - - // Calculate new intersection direction by intersecting prev_seg with next_seg - bool new_parallel; - Vector3 new_direction; - vdp = Vector3::Dot_Product(prev_seg->EdgePlane[edge], next_seg->EdgePlane[edge]); - if (fabs(vdp) < parallel_factor) - { - - // Not parallel - intersect planes to get line (get vector, normalize it, - // ensure it is pointing towards the current point) - Vector3::Cross_Product(prev_seg->EdgePlane[edge], next_seg->EdgePlane[edge], &new_direction); - new_direction.Normalize(); - if (Vector3::Dot_Product(new_direction, new_point) < 0.0f) - { - new_direction = -new_direction; - } - - new_parallel = false; - - } - else - { - - // Parallel (or almost). If the current intersection is not parallel, take - // the average plane and intersect it with the skipped plane. If the - // current intersection is parallel, find the average plane, and find the - // direction vector on it closest to the current intersections direction - // vector. - - // Ensure average calculation is numerically stable: - Vector3 pl; - if (vdp > 0.0f) - { - pl = prev_seg->EdgePlane[edge] + next_seg->EdgePlane[edge]; - } - else - { - pl = prev_seg->EdgePlane[edge] - next_seg->EdgePlane[edge]; - } - pl.Normalize(); - - if (curr_int->Parallel) - { - new_direction = new_direction - pl * Vector3::Dot_Product(pl, new_direction); - new_direction.Normalize(); - } - else - { - Vector3::Cross_Product(curr_seg->EdgePlane[edge], pl, &new_direction); - new_direction.Normalize(); - } - - new_parallel = true; - } - - // Now check to see if the merge caused any funky results - if so abort it. - // Currently we check to see if the distance of the direction from the two - // points is larger than the radius times the merge_abort factor. - if (MergeAbortFactor > 0.0f) - { - float abort_dist = radius * MergeAbortFactor; - float abort_dist2 = abort_dist * abort_dist; - Vector3 diff_curr = curr_int->Point - - new_direction * Vector3::Dot_Product(curr_int->Point, new_direction); - if (diff_curr.Length2() > abort_dist2) break; - Vector3 next_curr = next_int->Point - - new_direction * Vector3::Dot_Product(next_int->Point, new_direction); - if (next_curr.Length2() > abort_dist2) break; - } - - // Merge edge intersections (curr_int and next_int) into curr_int - merged = true; - - curr_int->Direction = new_direction; - curr_int->Parallel = new_parallel; - curr_int->Point = new_point; - curr_int->TexV = new_tex_v; - curr_int->PointCount = new_count; - curr_int->NextSegmentID = next_int->NextSegmentID; - curr_int->Fold = curr_int->Fold || next_int->Fold; - - // Decrement number of edge intersections - num_intersections[edge]--; - - // Advance intersectionIndex_r to shift subsequent entries backwards in result. - intersectionIndex_r++; - - // If we are at the end then break: - if (intersectionIndex_r == num_isects) - { - break; - } - - // Advance next_int and next_seg. - next_int = &(intersection[intersectionIndex_r + 1][edge]); - next_seg = &(segment[next_int->NextSegmentID]); - - } // while - - // Copy from "read index" to "write index" - write_int->PointCount = curr_int->PointCount; - write_int->NextSegmentID = curr_int->NextSegmentID; - write_int->Point = curr_int->Point; - write_int->TexV = curr_int->TexV; - write_int->Direction = curr_int->Direction; - write_int->Fold = curr_int->Fold; - - } // for intersectionIndex - - // If intersectionIndex_r is exactly equal to num_isects (rather than being larger by one) at this - // point, this means that the last intersection was not merged with the previous one. In - // this case, we need to do one last copy: - if (intersectionIndex_r == num_isects) - { - LineSegmentIntersection *write_int = &(intersection[intersectionIndex_w][edge]); - LineSegmentIntersection *curr_int = &(intersection[intersectionIndex_r][edge]); - write_int->PointCount = curr_int->PointCount; - write_int->NextSegmentID = curr_int->NextSegmentID; - write_int->Point = curr_int->Point; - write_int->TexV = curr_int->TexV; - write_int->Direction = curr_int->Direction; - write_int->Fold = curr_int->Fold; - } - -#ifdef ENABLE_WWDEBUGGING - // Testing code - ensure total PointCount fits the number of points - unsigned int total_cnt = 0; - for (unsigned int nidx = 0; nidx <= num_intersections[edge]; nidx++) - { - total_cnt += intersection[nidx][edge].PointCount; - } - assert(total_cnt == point_cnt); -#endif - - } // for edge - } // while (merged) - } // if (Is_Merge_Intersections()) - - /* - ** Find vertex positions, generate vertices and triangles: - ** Since we can have top/bottom intersections merged, we need to skip points if both the top - ** and bottom intersections are merged, generate triangle fans if one of the sides is merged - ** and the other isnt, and generate triangle strips otherwise. - */ - - // Configure vertex array and setup renderer. - unsigned int vnum = num_intersections[TOP_EDGE] + num_intersections[BOTTOM_EDGE]; - VertexFormatXYZUV1 *vertexArray = getVertexBuffer(vnum); - Vector3i v_index_array[MAX_STREAK_POLY_BUFFER_SIZE]; - - // Vertex and triangle indices - unsigned int vertexIndex = 0; - unsigned int triangleIndex = 0; - - - - - - - - - - - - - -// GENERALIZE FOR WHEN NO TEXTURE (DO NOT SET UV IN THESE CASES? NEED TO GENERALIZE FOR DIFFERENT TEXTURING MODES ANYWAY). - - // "Prime the pump" with two vertices (pick nearest point on each direction line): - Vector3 &top_dir = intersection[1][TOP_EDGE].Direction; - top = top_dir * Vector3::Dot_Product(points[0], top_dir); - Vector3 &bottom_dir = intersection[1][BOTTOM_EDGE].Direction; - bottom = bottom_dir * Vector3::Dot_Product(points[0], bottom_dir); - vertexArray[vertexIndex].x = top.X; - vertexArray[vertexIndex].y = top.Y; - vertexArray[vertexIndex].z = top.Z; - vertexArray[vertexIndex].u1 = u_values[0] ; - vertexArray[vertexIndex].v1 = intersection[1][TOP_EDGE].TexV ; - vertexIndex++; - vertexArray[vertexIndex].x = bottom.X; - vertexArray[vertexIndex].y = bottom.Y; - vertexArray[vertexIndex].z = bottom.Z; - vertexArray[vertexIndex].u1 = u_values[1] ; - vertexArray[vertexIndex].v1 = intersection[1][BOTTOM_EDGE].TexV ; - vertexIndex++; - - unsigned int last_top_vertexIndex = 0; - unsigned int last_bottom_vertexIndex = 1; - - // Loop over intersections, create new vertices and triangles. - unsigned int top_int_idx = 1; // Skip "pre-first-point" dummy intersection - unsigned int bottom_int_idx = 1; // Skip "pre-first-point" dummy intersection - pointIndex = 0; - unsigned int residual_top_points = intersection[1][TOP_EDGE].PointCount; - unsigned int residual_bottom_points = intersection[1][BOTTOM_EDGE].PointCount; - - // Reduce both pointcounts by the same amount so the smaller one is 1 (skip points) - unsigned int delta = MIN(residual_top_points, residual_bottom_points) - 1; - residual_top_points -= delta; - residual_bottom_points -= delta; - pointIndex += delta; - - for (; ; ) - { - - if (residual_top_points == 1 && residual_bottom_points == 1) - { - // Advance both intersections, creating a tristrip segment - v_index_array[triangleIndex].I = last_top_vertexIndex; - v_index_array[triangleIndex].J = last_bottom_vertexIndex; - v_index_array[triangleIndex].K = vertexIndex; - triangleIndex++; - v_index_array[triangleIndex].I = last_bottom_vertexIndex; - v_index_array[triangleIndex].J = vertexIndex + 1; - v_index_array[triangleIndex].K = vertexIndex; - triangleIndex++; - last_top_vertexIndex = vertexIndex; - last_bottom_vertexIndex = vertexIndex + 1; - - // Advance both intersections. - top_int_idx++; - bottom_int_idx++; - residual_top_points = intersection[top_int_idx][TOP_EDGE].PointCount; - residual_bottom_points = intersection[bottom_int_idx][BOTTOM_EDGE].PointCount; - - // Advance point index (must do here because the new point index is used below): - pointIndex++; - - // Generate two vertices for next point by picking nearest point on each direction line - Vector3 &top_dir = intersection[top_int_idx][TOP_EDGE].Direction; - top = top_dir * Vector3::Dot_Product(points[pointIndex], top_dir); - Vector3 &bottom_dir = intersection[bottom_int_idx][BOTTOM_EDGE].Direction; - bottom = bottom_dir * Vector3::Dot_Product(points[pointIndex], bottom_dir); - - vertexArray[vertexIndex].x = top.X; - vertexArray[vertexIndex].y = top.Y; - vertexArray[vertexIndex].z = top.Z; - vertexArray[vertexIndex].u1 = u_values[0] ; - vertexArray[vertexIndex].v1 = intersection[top_int_idx][TOP_EDGE].TexV ; - vertexIndex++; - vertexArray[vertexIndex].x = bottom.X; - vertexArray[vertexIndex].y = bottom.Y; - vertexArray[vertexIndex].z = bottom.Z; - vertexArray[vertexIndex].u1 = u_values[1] ; - vertexArray[vertexIndex].v1 = intersection[bottom_int_idx][BOTTOM_EDGE].TexV ; - vertexIndex++; - } - else - { - // Exactly one of the pointcounts is greater than one - advance it and draw one triangle - if (residual_top_points > 1) - { - // Draw one triangle (fan segment) - v_index_array[triangleIndex].I = last_top_vertexIndex; - v_index_array[triangleIndex].J = last_bottom_vertexIndex; - v_index_array[triangleIndex].K = vertexIndex; - triangleIndex++; - last_bottom_vertexIndex = vertexIndex; - - // Advance bottom intersection only - residual_top_points--; - bottom_int_idx++; - residual_bottom_points = intersection[bottom_int_idx][BOTTOM_EDGE].PointCount; - - // Advance point index (must do here because the new point index is used below): - pointIndex++; - - // Generate bottom vertex by picking nearest point on bottom direction line - Vector3 &bottom_dir = intersection[bottom_int_idx][BOTTOM_EDGE].Direction; - bottom = bottom_dir * Vector3::Dot_Product(points[pointIndex], bottom_dir); - - vertexArray[vertexIndex].x = bottom.X; - vertexArray[vertexIndex].y = bottom.Y; - vertexArray[vertexIndex].z = bottom.Z; - vertexArray[vertexIndex].u1 = u_values[1] ; - vertexArray[vertexIndex].v1 = intersection[bottom_int_idx][BOTTOM_EDGE].TexV ; - vertexIndex++; - } - else - { - - // residual_bottom_points > 1 - - // Draw one triangle (fan segment) - v_index_array[triangleIndex].I = last_top_vertexIndex; - v_index_array[triangleIndex].J = last_bottom_vertexIndex; - v_index_array[triangleIndex].K = vertexIndex; - triangleIndex++; - last_top_vertexIndex = vertexIndex; - - // Advance top intersection only - residual_bottom_points--; - top_int_idx++; - residual_top_points = intersection[top_int_idx][TOP_EDGE].PointCount; - - // Advance point index (must do here because the new point index is used below): - pointIndex++; - - // Generate top vertex by picking nearest point on top direction line - Vector3 &top_dir = intersection[top_int_idx][TOP_EDGE].Direction; - top = top_dir * Vector3::Dot_Product(points[pointIndex], top_dir); - vertexArray[vertexIndex].x = top.X; - vertexArray[vertexIndex].y = top.Y; - vertexArray[vertexIndex].z = top.Z; - vertexArray[vertexIndex].u1 = u_values[0] ; - vertexArray[vertexIndex].v1 = intersection[top_int_idx][TOP_EDGE].TexV ; - vertexIndex++; - } - } - - // Reduce both pointcounts by the same amount so the smaller one is 1 (skip points) - delta = MIN(residual_top_points, residual_bottom_points) - 1; - residual_top_points -= delta; - residual_bottom_points -= delta; - pointIndex += delta; - // Exit conditions - if ( (top_int_idx >= num_intersections[TOP_EDGE] && residual_top_points == 1) || - (bottom_int_idx >= num_intersections[BOTTOM_EDGE] && residual_bottom_points == 1)) - { - // Debugging check - if either intersection index is before end, both of them should be - // and the points should be before the end. - assert(top_int_idx == num_intersections[TOP_EDGE]); - assert(bottom_int_idx == num_intersections[BOTTOM_EDGE]); - assert(pointIndex == point_cnt - 1); - break; - } - } - - - - - /* - ** Set color, opacity, vertex flags: - */ - - // If color is not white or opacity not 100%, enable gradient in shader and in renderer - otherwise disable. - //unsigned int rgba; - //rgba=DX8Wrapper::Convert_Color(Color,Opacity); - //bool rgba_all=(rgba==0xFFFFFFFF); - -// int colorIndex = 0; -// for (vertexIndex = 0; vertexIndex < vnum; vertexIndex++) -// { -// //vertexArray[vertexIndex].diffuse = rgba;/// OLD WAY COLORS THEM ALL TO THE COLOR,OPACITY MEMBERS ///////////////// -// unsigned int perPointARGB; -// colorIndex = MIN(vertexIndex / 2, point_cnt); -// perPointARGB = DX8Wrapper::Convert_Color( colors[colorIndex] );// twice as many verts as points? or so? -// vertexArray[vertexIndex].diffuse = perPointARGB; -// vertexArray[vertexIndex].u1 = (float)((vertexIndex&2) == 2); -// vertexArray[vertexIndex].v1 = (float)((vertexIndex&1) == 1); -// } - - - - // Enable sorting if sorting has not been disabled and line is translucent and alpha testing is not enabled. - bool sorting = (!Is_Sorting_Disabled()) && (Shader.Get_Dst_Blend_Func() != ShaderClass::DSTBLEND_ZERO && Shader.Get_Alpha_Test() == ShaderClass::ALPHATEST_DISABLE); - /////////////////////////////////////////////////////////////////////////////////////// - ShaderClass shader = Shader; - shader.Set_Cull_Mode(ShaderClass::CULL_MODE_DISABLE); - shader.Set_Primary_Gradient(ShaderClass::GRADIENT_MODULATE); - - VertexMaterialClass *mat; - mat=VertexMaterialClass::Get_Preset(VertexMaterialClass::PRELIT_DIFFUSE); - DX8Wrapper::Set_Material(mat); - REF_PTR_RELEASE(mat); - - // If Texture is non-NULL enable texturing in shader - otherwise disable. - if (Texture) - { - shader.Set_Texturing(ShaderClass::TEXTURING_ENABLE); - } - else - { - shader.Set_Texturing(ShaderClass::TEXTURING_DISABLE); - } - /////////////////////////////////////////////////////////////////////////////////////////// - - - /* - ** Render - */ - - DynamicVBAccessClass Verts((sorting?BUFFER_TYPE_DYNAMIC_SORTING:BUFFER_TYPE_DYNAMIC_DX8),dynamic_fvf_type,vnum); - // Copy in the data to the VB - { - DynamicVBAccessClass::WriteLockClass Lock(&Verts); - unsigned int i; - unsigned char *vb=(unsigned char*)Lock.Get_Formatted_Vertex_Array(); - const FVFInfoClass& fvfinfo=Verts.FVF_Info(); - int segIdx = 0; - unsigned int argb = 0x00000000; - - unsigned int oddEven = 0; - - //oddEven = ( personalities[0] & 1 ); - - const unsigned verticesOffset = fvfinfo.Get_Location_Offset(); - const unsigned diffuseOffset = fvfinfo.Get_Diffuse_Offset(); - const unsigned textureOffset = fvfinfo.Get_Tex_Offset(0); - const unsigned vbSize = fvfinfo.Get_FVF_Size(); - - for (i=0; i(vb + verticesOffset); - vertex->X = vertexArray[i].x; - vertex->Y = vertexArray[i].y; - vertex->Z = vertexArray[i].z; - *reinterpret_cast(vb + diffuseOffset) = DX8Wrapper::Convert_Color_Clamp(colors[MIN((i/2), point_cnt)]); // TODO: Does not work correctly when subdivision are not 0 - Vector2 *texture = reinterpret_cast(vb + textureOffset); - texture->U = vertexArray[i].u1; - texture->V = vertexArray[i].v1; - vb += vbSize; - } - } // copy - - DynamicIBAccessClass ib_access((sorting?BUFFER_TYPE_DYNAMIC_SORTING:BUFFER_TYPE_DYNAMIC_DX8),triangleIndex*3); - { - unsigned int i; - DynamicIBAccessClass::WriteLockClass lock(&ib_access); - unsigned short* inds=lock.Get_Index_Array(); - - for (i=0; i m_vertexBufferSize) - { - unsigned int numberToAlloc = number + (number >> 1); - delete [] m_vertexBuffer; - m_vertexBuffer = W3DNEWARRAY VertexFormatXYZUV1[numberToAlloc]; - m_vertexBufferSize = numberToAlloc; - } - -#ifdef RTS_INTERNAL - for (unsigned i = 0; i < number; ++i) - { - m_vertexBuffer[i].x = m_vertexBuffer[i].y = m_vertexBuffer[i].z = m_vertexBuffer[i].u1 = m_vertexBuffer[i].v1 = (float)0xdeadbeef; - } -#endif - - return m_vertexBuffer; -} diff --git a/Generals/Code/Libraries/Source/WWVegas/WW3D2/streakRender.h b/Generals/Code/Libraries/Source/WWVegas/WW3D2/streakRender.h deleted file mode 100644 index 355c7b54ee4..00000000000 --- a/Generals/Code/Libraries/Source/WWVegas/WW3D2/streakRender.h +++ /dev/null @@ -1,227 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** 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 *** - *********************************************************************************************** - * * - * Project Name : ww3d * - * * - * $Archive:: /Commando/Code/ww3d2/Streakrender.h $* - * * - * Original Author:: Greg Hjelstrom * - * * - * $Author:: Greg_h $* - * * - * $Modtime:: 6/08/01 5:23p $* - * * - * $Revision:: 1 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#ifndef STREAKRENDER_H -#define STREAKRENDER_H - -#include "always.h" -#include "shader.h" -#include "texture.h" -#include "matrix3d.h" -#include "vector2.h" - -class RenderInfoClass; -class SphereClass; -struct W3dEmitterLinePropertiesStruct; -struct VertexFormatXYZUV1; - -// The maximum allowable level of subdivision. This should be no more than 7 to avoid increasing -// the chunk buffer size too much -#define MAX_STREAK_SUBDIV_LEVELS 7 - - - -/** -** StreakRendererClass -** This class implements the low-level line rendering functionality used by both SegmentedLineClass -** and ParticleBufferClass -*/ -class StreakRendererClass -{ -public: - - StreakRendererClass(void); - StreakRendererClass(const StreakRendererClass & that); - StreakRendererClass & operator = (const StreakRendererClass & that); - ~StreakRendererClass(void); - - enum TextureMapMode { - UNIFORM_WIDTH_TEXTURE_MAP = 0x00000000, // Entire line uses one row of texture (constant V) - UNIFORM_LENGTH_TEXTURE_MAP = 0x00000001, // Entire line uses one row of texture stretched length-wise - TILED_TEXTURE_MAP = 0x00000002 // Tiled continuously over line - }; - - void Init(const W3dEmitterLinePropertiesStruct & props); - - // Get properties used to render this line segment - TextureClass * Get_Texture(void) const; - TextureClass * Peek_Texture(void) const { return Texture; } - ShaderClass Get_Shader(void) const { return Shader; } - float Get_Width(void) const { return Width; } - const Vector3 & Get_Color(void) const { return Color; } - float Get_Opacity(void) const { return Opacity; } - float Get_Noise_Amplitude(void) const { return NoiseAmplitude; } - float Get_Merge_Abort_Factor(void) const { return MergeAbortFactor; } - unsigned int Get_Current_Subdivision_Level(void) const { return SubdivisionLevel; } - TextureMapMode Get_Texture_Mapping_Mode(void) const; - // float Get_Texture_Tile_Factor(void) const { return TextureTileFactor; } - // Vector2 Get_UV_Offset_Rate(void) const; - int Is_Merge_Intersections(void) const { return Bits & MERGE_INTERSECTIONS; } - int Is_Freeze_Random(void) const { return Bits & FREEZE_RANDOM; } - int Is_Sorting_Disabled(void) const { return Bits & DISABLE_SORTING; } - int Are_End_Caps_Enabled(void) const { return Bits & END_CAPS; } - - // Set properties used to render this line segment - void Set_Texture(TextureClass *texture); - void Set_Shader(ShaderClass shader) { Shader = shader; } - void Set_Width(float width) { Width = width; } - void Set_Color(const Vector3 &color) { Color = color; } - void Set_Opacity(float opacity) { Opacity = opacity; } - void Set_Noise_Amplitude(float amplitude) { NoiseAmplitude = amplitude; } - void Set_Merge_Abort_Factor(float factor) { MergeAbortFactor = factor; } - void Set_Current_Subdivision_Level(unsigned int lv) { - DEBUG_ASSERTCRASH(lv == 0, ("Streak renderer does not work for non-zero subdivisions")); - SubdivisionLevel = lv; SubdivisionLevel = 0; - } - void Set_Texture_Mapping_Mode(TextureMapMode mode); - // WARNING! Do NOT set the tile factor to be too high (should be less than 8) or negative - //performance impact will result! - // void Set_Texture_Tile_Factor(float factor); - // void Set_Current_UV_Offset(const Vector2 & offset); - // void Set_UV_Offset_Rate(const Vector2 &rate); - void Set_Merge_Intersections(int onoff) { if (onoff) { Bits |= MERGE_INTERSECTIONS; } else { Bits &= ~MERGE_INTERSECTIONS; }; } - void Set_Freeze_Random(int onoff) { if (onoff) { Bits |= FREEZE_RANDOM; } else { Bits &= ~FREEZE_RANDOM; }; } - void Set_Disable_Sorting(int onoff) { if (onoff) { Bits |= DISABLE_SORTING; } else { Bits &= ~DISABLE_SORTING; }; } - void Set_End_Caps(int onoff) { if (onoff) { Bits |= END_CAPS; } else { Bits &= ~END_CAPS; }; } - - void Reset_Line(void); - - - void Render( RenderInfoClass & rinfo, - const Matrix3D & transform, - unsigned int point_count, - Vector3 * points, - const SphereClass & obj_sphere); - - void RenderStreak( RenderInfoClass & rinfo, - const Matrix3D & transform, - unsigned int point_count, - Vector3 * points, - Vector4 * colors, - float * widths, - const SphereClass & obj_sphere, - unsigned int *personalities); - -private: - - // Utility functions - void subdivision_util(unsigned int point_cnt, const Vector3 *xformed_pts, - const float *base_tex_v, unsigned int *p_sub_point_cnt, - Vector3 *xformed_subdiv_pts, float *subdiv_tex_v); - - // Global properties - TextureClass * Texture; - ShaderClass Shader; - float Width; - Vector3 Color; - float Opacity; - - // Subdivision properties - unsigned int SubdivisionLevel; - float NoiseAmplitude; - - // If >0, will abort a merge which causes an intersection to move - // farther away than this factor * line radius from the line point. - // (defaults to 1.5, has no affect if intersection merging is disabled). - float MergeAbortFactor; - - // Affects tiled texture mapping mode only. If this is set too high, performance (and - // possibly visual) problems will result from excessive tiling over a single polygon, over - // the entire line, or both. - // float TextureTileFactor; - - // Used for texture coordinate animation - // unsigned int LastUsedSyncTime; // Last sync time used - // Vector2 CurrentUVOffset; // Current UV offset - // Vector2 UVOffsetDeltaPerMS; // Amount to increase offset each millisec - - // Various flags - enum BitShiftOffsets { - TEXTURE_MAP_MODE_OFFSET = 24 // By how many bits do I need to shift the texture mapping mode? - }; - enum { - MERGE_INTERSECTIONS = 0x00000001, // Merge intersections - FREEZE_RANDOM = 0x00000002, // Freeze random (note: offsets are in camera space) - DISABLE_SORTING = 0x00000004, // Disable sorting (even if shader has alpha-blending) - END_CAPS = 0x00000008, // Draw end caps on the line - - // Some bits are used to select the texture mapping mode: - TEXTURE_MAP_MODE_MASK = 0xFF000000, // Must cover all possible TextureMapMode values - - DEFAULT_BITS = MERGE_INTERSECTIONS | (UNIFORM_WIDTH_TEXTURE_MAP << TEXTURE_MAP_MODE_OFFSET) - }; - unsigned int Bits; - - friend class SegmentedLineClass; - - // Vertex buffer manager - VertexFormatXYZUV1 *getVertexBuffer(unsigned int number); - unsigned int m_vertexBufferSize; - VertexFormatXYZUV1 *m_vertexBuffer; -}; - - - -inline StreakRendererClass::TextureMapMode StreakRendererClass::Get_Texture_Mapping_Mode(void) const -{ - return (TextureMapMode)((Bits & TEXTURE_MAP_MODE_MASK) >> TEXTURE_MAP_MODE_OFFSET); -} - -inline void StreakRendererClass::Set_Texture_Mapping_Mode(StreakRendererClass::TextureMapMode mode) -{ - Bits &= ~TEXTURE_MAP_MODE_MASK; - Bits |= ((mode << TEXTURE_MAP_MODE_OFFSET) & TEXTURE_MAP_MODE_MASK); -} - -// inline Vector2 StreakRendererClass::Get_UV_Offset_Rate(void) const -// { -// return UVOffsetDeltaPerMS * 1000.0f; -// } - -// inline void StreakRendererClass::Set_UV_Offset_Rate(const Vector2 &rate) -// { -// UVOffsetDeltaPerMS = rate * 0.001f; -// } - -inline void StreakRendererClass::Reset_Line(void) -{ - // Empty -} - -#endif //STREAKRENDER_H - diff --git a/Generals/Code/Libraries/Source/WWVegas/WW3D2/stripoptimizer.cpp b/Generals/Code/Libraries/Source/WWVegas/WW3D2/stripoptimizer.cpp deleted file mode 100644 index 18b740a0575..00000000000 --- a/Generals/Code/Libraries/Source/WWVegas/WW3D2/stripoptimizer.cpp +++ /dev/null @@ -1,1019 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -#include "stripoptimizer.h" -#include "hashtemplate.h" -#include "wwdebug.h" - -template inline void swap (T& a, T& b) -{ - T t(a); - a = b; - b = t; -} - -//------------------------------------------------------------------------ -// Prototypes for sort functions. Note that class T must have -// operators =, > and < in order for the functions to compile. -//------------------------------------------------------------------------ - -template inline void Insertion_Sort (T* a, int N); -template inline void Quick_Sort (T* a, int N); - -template inline void Insertion_Sort (T* a, int N) -{ - for (int i = 1; i < N; i++) - if (a[i-1] > a[i]) - { - T v = a[i]; - int j = i; - while (a[j-1]> v) - { - a[j] = a[j-1]; // copy data - j--; - if (!j) - break; - }; - a[j] = v; - } -} - - -template inline void Quick_Sort (T* a, int l, int r) -{ - if (r-l <= 16) - { - Insertion_Sort(a+l,r-l+1); - return; - } - T v = a[r]; - int i = l-1; - int j = r; - do - { - do { i++; } while (i < r && a[i] < v); - do { j--; } while (j > 0 && a[j] > v); - swap(a[i],a[j]); - } while (j > i); - - T t = a[j]; - a[j] = a[i]; - a[i] = a[r]; - a[r] = t; - if ((i-1) > l) - Quick_Sort (a,l,i-1); - if (r > (i+1)) - Quick_Sort (a,i+1,r); -} - -template inline void Quick_Sort (T* a, int N) -{ - Quick_Sort(a,0,N-1); -} - -//------------------------------------------------------------------------ -// Implementation -//------------------------------------------------------------------------ - -/***************************************************************************** - * - * Function: StripOptimizerClass::getStripIndexCount() - * - * Description: Returns number of indices in a set of strips - * - * Parameters: - * - *****************************************************************************/ - -int StripOptimizerClass::Get_Strip_Index_Count (const int* strips, int strip_count) -{ - int cnt = 0; - for (int i = 0; i < strip_count; i++) - { - int len = *strips++; // read len - cnt += len; - strips += len; // skip data - } - return cnt; -} - -/***************************************************************************** - * - * Function: StripOptimizerClass::optimizeStripOrder() - * - * Description: - * - * Parameters: - * - *****************************************************************************/ - -// compares two strips and returns number of shared indices -static inline int Get_Strip_Similarity (const int* A, const int* B) -{ - int cnt = 0; - int lenA = *A++; - int lenB = *B++; - - for (int i = 0; i < lenA; i++) - { - int index = A[i]; // index of A - for (int j = 0; j < lenB; j++) - if (B[j] == index) // match - { - cnt++; - break; - } - } - - return cnt; -} - -// copies a strip, returns new destination pointer -static inline int* Copy_Strip (int* d, const int* s) -{ - int len = *s++; - *d++ = len; - for (int i = 0; i < len; i++) - *d++ = *s++; - return d; -} - -void StripOptimizerClass::Optimize_Strip_Order (int* strips, int strip_count) -{ - if (strip_count <= 0) - return; -// WWASSERT(strips); - - int** ss = W3DNEWARRAY int*[strip_count]; // pointers to beginning of strips - int* s = strips; - int i = 0; - for (; i < strip_count; i++) - { - ss[i] = s; - int len = *s++; // read len - s+=len; // skip - } - int outSize = Get_Strip_Index_Count(strips, strip_count)+strip_count; // output memory alloc size - int* out = W3DNEWARRAY int[outSize]; - int* o = out; // output pointer - - const int* prev = ss[0]; // previous strip - o = Copy_Strip (o, ss[0]); // output first strip - ss[0] = 0; - - for (;;) - { - int bestIndex = -1; - int bestSimilarity = -1; - - for (int j = 0; j < strip_count; j++) - if (ss[j]) - { - int sim = Get_Strip_Similarity (prev, ss[j]); // get similarity - if (sim > bestSimilarity) - { - bestSimilarity = sim; - bestIndex = j; - } - } - - if (bestIndex==-1) // we're done - break; - - o = Copy_Strip(o, ss[bestIndex]); // copy the strip - prev = ss[bestIndex]; // set to prev - ss[bestIndex] = NULL; // mark as selected - } - -// WWASSERT((out+outSize)==o); // HUH? - - for (i = 0; i < outSize; i++) // copy output - strips[i] = out[i]; - - delete[] out; - delete[] ss; -} - -/***************************************************************************** - * - * Function: StripOptimizerClass::optimizeTriangleOrder() - * - * Description: - * - * Parameters: - * - *****************************************************************************/ - -struct Tri -{ -public: - int a,b,c; - - bool operator< (const Tri& s) const { return a < s.a; } - bool operator> (const Tri& s) const { return a > s.a; } -}; - -static inline int Get_Similarity (const Tri& A, const Tri& B) -{ - int sim = 0; - - if (A.a == B.a || A.a == B.b || A.a == B.c) sim++; - if (A.b == B.a || A.b == B.b || A.b == B.c) sim++; - if (A.c == B.a || A.c == B.b || A.c == B.c) sim++; - - return sim; -} - -void StripOptimizerClass::Optimize_Triangle_Order (int *tris, int triangle_count) -{ - if (triangle_count<=0) - return; - WWASSERT(tris); - - Tri** t = W3DNEWARRAY Tri*[triangle_count]; - int i = 0; - for (; i < triangle_count; i++) - { - t[i] = (Tri*)(tris + i*3); - } - - Tri* out = W3DNEWARRAY Tri[triangle_count]; - Tri* o = out; - - Tri* prev = t[0]; - - *o++ = *prev; - t[0] = NULL; - - for (;;) - { - // match best - int bestIndex = -1; - int bestSim = -1; - - for (int j = 0; j < triangle_count; j++) - if (t[j]) - { - int sim = Get_Similarity (*prev, *t[j]); - if (sim > bestSim) - { - bestSim = sim; - bestIndex = j; - if (sim >= 2) // that's the best we could get - break; - } - } - - if (bestIndex == -1) // we're done - break; - - *o++ = *t[bestIndex]; - prev = t[bestIndex]; - t[bestIndex] = NULL; - } - - - WWASSERT(o == (out+triangle_count)); - - for (i = 0; i < triangle_count; i++) - { - Tri* d = (Tri*)(tris)+i; - *d = out[i]; - } - - delete[] t; - delete[] out; - -} - - -/***************************************************************************** - * - * Function: StripOptimizerClass::combineStrips() - * - * Description: Combines a number of strips into one - * - * Parameters: - * - *****************************************************************************/ - -int* StripOptimizerClass::Combine_Strips (const int* strips, int strip_count) -{ - int check = Get_Strip_Index_Count(strips,strip_count) + (strip_count-1)*3; - - int* out = W3DNEWARRAY int[check+1]; - int* o = out + 1; - - int* tmp = W3DNEWARRAY int[check]; // DEBUG DEBUG - - bool prevEven = true; - - for (int i = 0; i < strip_count; i++) - { - int len = *strips++; - - if (i != 0) - { - *o++ = *strips; // duplicate first - - if (!prevEven) - *o++ = *strips; - } - - for (int j = 0; j < len; j++) - *o++ = *strips++; // copy the strip - - if (i != (strip_count-1)) - *o++ = o[-1]; - - prevEven = (!(len&1)); - } - - delete[] tmp; -// WWASSERT(check == (o-out-1)); - *out = (o-out-1); // set length - return out; -} - -//------------------------------------------------------------------------ -// New striping code -//------------------------------------------------------------------------ - -namespace Strip -{ - -/***************************************************************************** - * - * Struct: Vector3i - * - * Description: Internal class for representing an edge - * - *****************************************************************************/ - -struct Vector3i -{ - int v[3]; - Vector3i () {} - Vector3i (int a, int b, int c) { v[0]=a; v[1]=b; v[2]=c; } - - int& operator[](int i) { return v[i]; } - const int& operator[](int i) const { return v[i]; } - -}; - -/***************************************************************************** - * - * Struct: Edge - * - * Description: Internal class for representing an edge - * - *****************************************************************************/ - -struct Edge -{ - Edge (void) {} - Edge (int v0, int v1) { v[0] = v0; v[1] = v1; } - bool operator== (const Edge& s) const { return v[0]==s.v[0] && v[1] == s.v[1]; } - void sort (void) { if (v[0]>v[1]) swap(v[0],v[1]); } - - int v[2]; // edge -}; - -/***************************************************************************** - * - * Struct: Triangle - * - * Description: Internal class for representing a triangle and - * associated connectivity information - * - *****************************************************************************/ - -struct Triangle -{ - Triangle (void) - { - m_neighbors[0] = 0; - m_neighbors[1] = 0; - m_neighbors[2] = 0; - m_vertices[0] = 0; - m_vertices[1] = 0; - m_vertices[2] = 0; - m_prev = 0; - m_next = 0; - m_bin = -1; - } - - Triangle* m_neighbors[3]; // pointers to neighbors of the triangle - Vector3i m_vertices; // vertices of the triangle - - Triangle* m_prev; // previous triangle in same bin - Triangle* m_next; // next triangle in same bin - int m_bin; // current bin (-1 == not in any bin) - - int getConnectivity (void) const { int cnt = 0; if (m_neighbors[0]) cnt++; if (m_neighbors[1]) cnt++; if (m_neighbors[2]) cnt++; return cnt;} - const Edge getEdge (int i) const { WWASSERT(i>=0 && i<3); return Edge(m_vertices[i],i==2?m_vertices[0]:m_vertices[i+1]); } - -}; - -/***************************************************************************** - * - * Class: TriangleQueue - * - * Description: Internal class for maintaining triangles sorted by - * connectivity - * - *****************************************************************************/ - -class TriangleQueue -{ -public: - TriangleQueue (Triangle* tris, int N); - ~TriangleQueue (void); - void removeTriangle (Triangle* t); - Triangle* getTop (void) const; - int getVertexConnectivity (int i) const; -private: - TriangleQueue (const TriangleQueue&); - TriangleQueue& operator= (const TriangleQueue&); - void reinsert (Triangle* t); - - Triangle* m_bin[4]; // bins (0 = triangles with zero neighbors, etc.) - int* m_nodeConnectivity; // node connectivity count - int m_vertexCount; -}; - -/***************************************************************************** - * - * Class: Stripify - * - * Description: Class for performing stripification - * - *****************************************************************************/ - -class Stripify -{ -public: - static int* stripify (const Vector3i* tris, int N); -private: - Stripify (void); // not permitted - Stripify (const Stripify&); - Stripify& operator= (const Stripify&); - - static Triangle* generateTriangleList (const Vector3i* tris, int N); - static Vector3i getTriangleNodeConnectivityWeights (const TriangleQueue& queue, const Triangle& tri); - static int getMod3 (int i) { WWASSERT(i>=0 && i<6); return s_mod[i]; } - static int s_mod[6]; // small lookup table for mod3 operation (see getMod3()) -}; - -int Stripify::s_mod[6] = {0,1,2,0,1,2}; -} // Strip - - -template <> inline unsigned int HashTemplateKeyClass::Get_Hash_Value(const Strip::Edge& s) -{ - return (s.v[0]*139) + (s.v[1]*7); -} - -namespace Strip -{ -/***************************************************************************** - * - * Function: TriangleQueue::getTop() - * - * Description: Returns pointer to triangle with smallest connectivity - * - * Returns: pointer to triangle with smallest connectivity or NULL - * if the queue is empty - * - *****************************************************************************/ - -inline Triangle* TriangleQueue::getTop (void) const -{ - for (int i = 0; i < 4; i++) - if (m_bin[i]) - return m_bin[i]; // return head - return 0; // end -} - -/***************************************************************************** - * - * Function: TriangleQueue::getVertexConnectivity() - * - * Description: Returns current connectivity count of specified vertex - * - * Parameters: i = vertex index - * - * Returns: connectivity count - * - *****************************************************************************/ - -inline int TriangleQueue::getVertexConnectivity (int i) const -{ - WWASSERT(i>=0 && i< m_vertexCount); - return m_nodeConnectivity[i]; -} - -/***************************************************************************** - * - * Function: TriangleQueue::~TriangleQueue() - * - * Description: Destructor - * - *****************************************************************************/ - -inline TriangleQueue::~TriangleQueue () -{ - delete[] m_nodeConnectivity; -} - -/***************************************************************************** - * - * Function: TriangleQueue::reinsert() - * - * Description: Internal function for recalculating a triangle's - * connectivity - * - * Parameters: t = pointer to triangle (non-NULL) - * - *****************************************************************************/ - -inline void TriangleQueue::reinsert (Triangle* t) -{ - WWASSERT (t && t->m_bin!=-1); // must be in some bin - int w = t->getConnectivity(); - - // remove from bin - if (t->m_prev) - t->m_prev->m_next = t->m_next; - else - { - WWASSERT(t->m_bin != -1); - WWASSERT(t == m_bin[t->m_bin]); // must be head - m_bin[t->m_bin] = t->m_next; // new head - } - - if (t->m_next) - t->m_next->m_prev = t->m_prev; - - t->m_prev = 0; - t->m_next = m_bin[w]; - if (t->m_next) - t->m_next->m_prev = t; - - m_bin[w] = t; // head of bin - t->m_bin = w; // set bin -} - -/***************************************************************************** - * - * Function: TriangleQueue::removeTriangle() - * - * Description: Removes a triangle from the queue - * - * Parameters: t = pointer to triangle (non-NULL) - * - *****************************************************************************/ - -inline void TriangleQueue::removeTriangle (Triangle* t) -{ - WWASSERT(t); - if (t->m_prev) - t->m_prev->m_next = t->m_next; - else - { - WWASSERT(t->m_bin != -1); - WWASSERT(t == m_bin[t->m_bin]); // must be head - m_bin[t->m_bin] = t->m_next; // new head - } - - if (t->m_next) - t->m_next->m_prev = t->m_prev; - t->m_bin = -1; - - // update connectivity of t's neighbors - - Triangle* update[3]; - int i; - - for (i = 0; i < 3; i++) - { - update[i] = 0; - if (t->m_neighbors[i]) - { - Triangle* n = t->m_neighbors[i]; - int k=0; - for (k = 0; k < 3; k++) - if (n->m_neighbors[k]==t) - break; - WWASSERT (k!=3); // WASS?? - n->m_neighbors[k] = 0; // reduce connection - t->m_neighbors[i] = 0; - update[i] = n; - } - } - - // update connectivity count of t's vertices - - for (i = 0; i < 3; i++) - { - m_nodeConnectivity[t->m_vertices[i]]--; - WWASSERT(m_nodeConnectivity[t->m_vertices[i]] >= 0); // WASS? - } - - for (i = 0; i < 3; i++) // perform reinsertions now... - if (update[i]) - reinsert(update[i]); - -} - -/***************************************************************************** - * - * Function: TriangleQueue::TriangleQueue() - * - * Description: Constructor - * - * Parameters: tris = array of triangles - * N = number of triangles in the array - * - *****************************************************************************/ - -inline TriangleQueue::TriangleQueue (Triangle* tris, int N) -{ - int i; - for (i = 0; i < 4; i++) - m_bin[i] = 0; // initialize to zero - - int largestIndex = 0; - - for (i = 0; i < N; i++) - for (int j = 0; j < 3; j++) - { - WWASSERT(tris[i].m_vertices[j]>=0); - if (tris[i].m_vertices[j] > largestIndex) - largestIndex = tris[i].m_vertices[j]; - } - - m_vertexCount = largestIndex+1; - m_nodeConnectivity = W3DNEWARRAY int[m_vertexCount]; // - for (i = 0; i < m_vertexCount; i++) - m_nodeConnectivity[i] = 0; - - - for (i = 0; i < N; i++) - { - Triangle* t = tris+i; - int w = t->getConnectivity(); - WWASSERT(w>=0 && w <=3); - WWASSERT(!t->m_prev && !t->m_next && t->m_bin==-1); // must not be in a bin - t->m_prev = 0; - t->m_next = m_bin[w]; - if (t->m_next) - t->m_next->m_prev = t; - m_bin[w] = t; // head of bin - t->m_bin = w; // set bin - for (int j = 0; j < 3; j++) - m_nodeConnectivity[t->m_vertices[j]]++; - } -} - - -/***************************************************************************** - * - * Function: Stripify::getTriangleConnectivityWeights() - * - * Description: Returns "node connectivity" weights for each triangle vertex - * - * Parameters: queue = reference to triangle queue - * tri = reference to triangle - * - * Returns: Vector structure containing three weights - * - *****************************************************************************/ - -inline Vector3i Stripify::getTriangleNodeConnectivityWeights (const TriangleQueue& queue, const Triangle& tri) -{ - int weight[3]; - int i = 0; - for (; i < 3; i++) - { - weight[i] = queue.getVertexConnectivity(tri.m_vertices[i]); - } - int highestVal = weight[0]; - if (weight[1] > highestVal) highestVal = weight[1]; - if (weight[2] > highestVal) highestVal = weight[2]; - - Vector3i v(-1,-1,-1); - - for (i = 0; i < 3; i++) { - if (weight[0] == highestVal) v[i] = +1; - } - - return v; -} - -/***************************************************************************** - * - * Function: Stripify::generateTriangleList() - * - * Description: Converts input triangles into internal Triangle structure - * - * Parameters: inTris = input triangles - * N = number of input triangles - * - * Returns: pointer to Triangle array - * - * Notes: The function sets up the initial connectivity information - * - *****************************************************************************/ - -Triangle* Stripify::generateTriangleList (const Vector3i* inTris, int N) -{ - WWASSERT (inTris && N>=0); - - Triangle* tris = W3DNEWARRAY Triangle[N]; // allocate triangles - int i; - - //-------------------------------------------------------------------- - // Copy triangle vertex data - //-------------------------------------------------------------------- - - for (i = 0; i < N; i++) - { - //-------------------------------------------------------------------- - // We could perform random rotation here (this way we don't need random - // comparisons later in the algo in equality cases). - //-------------------------------------------------------------------- - - tris[i].m_vertices[0] = inTris[i][0]; - tris[i].m_vertices[1] = inTris[i][1]; - tris[i].m_vertices[2] = inTris[i][2]; - } - - //-------------------------------------------------------------------- - // Build connectivity information using a hash table - //-------------------------------------------------------------------- - - HashTemplateClass hash; - Triangle* t = tris; - - for (i = 0; i < N; i++, t++) - { - for (int j = 0; j < 3; j++) - if (!t->m_neighbors[j]) // if neighbor not defined yet - { - Edge edge = tris[i].getEdge(j); - Edge e = edge; - e.sort(); // sort vertices (smaller first) - - Triangle* n = hash.Get(e); - if (n) // if edge is already in the hash... - { - int k=0; - for (k = 0; k < 3; k++) // find matching edge - if (!n->m_neighbors[k]) // this neighbor not located yet - { - Edge ek = n->getEdge(k); // get edge - if (ek.v[0] == edge.v[1] && ek.v[1] == edge.v[0]) // if matching edge (note that order must be different) - break; // .. we found the edge - } - - if (k < 3) // (k==3) -> no match - { - t->m_neighbors[j] = n; // set neighbor - n->m_neighbors[k] = t; // set neighbor - hash.Remove(e); // remove from hash (this speeds up the hash queries considerably) - } - } else - hash.Insert(e, t); // insert triangle into hash - } - } - - return tris; // return pointer to output data -} - -/***************************************************************************** - * - * Function: Stripify::stripify() - * - * Description: Builds a set of triangle strips out of a triangle array - * - * Parameters: inTris = input triangles (three vertices per triangle) - * N = number of input triangles - * - * Returns: pointer to strip data array - * - * Notes: The strip data array layout is as follows: - * - * [int] number of strips - * [int] length of first strip (in vertices) - * [int,..] vertex indices of the first strip - * [int] length of second strip - * ... - * - * The routine assumes that degenerate triangles have been - * remove and input vertices have been welded - * - *****************************************************************************/ - -int* Stripify::stripify (const Vector3i* inTris, int N) -{ - if (!inTris || N<=0) // boo! - return 0; - - //-------------------------------------------------------------------- - // Initial setup - //-------------------------------------------------------------------- - - Triangle* tris = generateTriangleList(inTris,N); // build connectivity info - int* out = W3DNEWARRAY int[N*5]; // absolute worst case situation - int* o = out; // internal ptr (save entry[0] for later use) - int strip_count = 0; // number of output strips - TriangleQueue queue (tris, N); // insert triangles into priority queue - - int nSwaps = 0; - int nLen = 0; - - //-------------------------------------------------------------------- - // Main loop. Always select triangle with smallest weight. - //-------------------------------------------------------------------- - - for (;;) - { - Triangle* t = queue.getTop(); // get triangle with smallest weight - if (!t) // ok, we ran out of triangles (we're done) - break; - - //-------------------------------------------------------------------- - // Choose initial direction by selecting neighbor with smallest - // weight - //-------------------------------------------------------------------- - - int* pLen = o; // get current pointer (as we need to take care of it later) - int len = 3; // initial length - int best = 0; // best edge - int bestWeight = 0x7fffffff; // initialize to maximum width - - Vector3i nodeWeights = getTriangleNodeConnectivityWeights(queue, *t); - - for (int i = 0; i < 3; i++) - if (t->m_neighbors[i]) // if triangle has a neighbor in this direction - { - int weight = t->m_neighbors[i]->getConnectivity(); // get connectivity of neighbor - - weight += nodeWeights[i]; // add node weights - weight += nodeWeights[getMod3(i+1)]; - - // DEBUG DEBUG ADD SWAP COST HERE? - if (weight <= bestWeight) - { - bestWeight = weight; - best = i; - } - } - - *o++ = len; // output the first three vertices - *o++ = t->m_vertices[getMod3(best+2)]; - *o++ = t->m_vertices[getMod3(best+0)]; - *o++ = t->m_vertices[getMod3(best+1)]; - - for (;;) - { - Triangle* next = 0; // find next triangle - - int i; - for (i = 0; i < 3; i++) - if (t->m_neighbors[i]) - { - Triangle* n = t->m_neighbors[i]; - for (int j = 0; j < 3; j++) - { - Edge e = n->getEdge(j); - if (!(len&1)) - swap(e.v[0],e.v[1]); // swap - if (e.v[0] == o[-1] && e.v[1] == o[-2]) - { - next = n; - break; - } - } - } - - queue.removeTriangle(t); // get rid of the old triangle - - if (!next) // we're done - break; - - //-------------------------------------------------------------------- - // Find out where we want to continue... - //-------------------------------------------------------------------- - - int bestEdge = -1; - int bestWeight = 0x7fffffff; - bool bestSwap = false; - - Vector3i nodeWeights = getTriangleNodeConnectivityWeights(queue, *next); - - for (i = 0; i < 3; i++) - if (next->m_neighbors[i]) // is there a neighbor? - { - Edge e = next->getEdge(i); // a swap happens if it contains the prevprev - - bool swap = (e.v[0] == o[-2] || e.v[1] == o[-2]); - - Triangle* n = next->m_neighbors[i]; // get pointer to neighbor - int w = n->getConnectivity(); - - - w += nodeWeights[i]; // add vertex weight - w += nodeWeights[getMod3(i+1)]; // add vertex weight - - w += (swap) ? 1 : -1; // add swap penalty - - if (w <= bestWeight) - { - bestWeight = w; - bestEdge = i; - bestSwap = swap; - } - } - - if (bestEdge != -1 && bestSwap) // if we're going to continue... - { - *o = o[-2]; // introduce swap vertex - o++; - len++; // adjust length - nSwaps++; // update statistics - } - - //-------------------------------------------------------------------- - // Find out which was the new vertex (store it to vIndex) - //-------------------------------------------------------------------- - - int vIndex = 0; - - if (next->m_vertices[1] != o[-1] && next->m_vertices[1] != o[-2]) vIndex = 1; else - if (next->m_vertices[2] != o[-1] && next->m_vertices[2] != o[-2]) vIndex = 2; else - WWASSERT (next->m_vertices[0] != o[-1] && next->m_vertices[0] != o[-2]); - - //-------------------------------------------------------------------- - // Output the vertex and move to next triangle - //-------------------------------------------------------------------- - - *o++ = next->m_vertices[vIndex]; // output the vertex - len++; // increase strip length - t = next; // move to next triangle - } - - *pLen = len; // patch final length - strip_count++; // increase strip count - - nLen += len; -// printf ("strip len = %d\n",len); - } - - //-------------------------------------------------------------------- - // Allocate new optimal-size array and copy output there. Then release - // all temporary memory allocations. - //-------------------------------------------------------------------- - -// printf ("total indices = %d\n",nLen); -// printf ("total swaps = %d\n",nSwaps); - - int len = o-out; // allocation length - int* rOut = W3DNEWARRAY int[len+1]; - - *rOut = strip_count; // first entry is number of strips - for (int i = 0; i < len; i++) - { - WWASSERT(out[i] >= 0); // would be nice to test for len as well - rOut[i+1] = out[i]; - } - - delete[] out; // delete internal output - delete[] tris; // delete internal triangle list - - return rOut; -} -} // Strip -int* StripOptimizerClass::Stripify(const int* tris, int N) -{ - return Strip::Stripify::stripify((const Strip::Vector3i*)tris,N); -} - -//------------------------------------------------------------------------ - diff --git a/Generals/Code/Libraries/Source/WWVegas/WW3D2/stripoptimizer.h b/Generals/Code/Libraries/Source/WWVegas/WW3D2/stripoptimizer.h deleted file mode 100644 index 1396369a291..00000000000 --- a/Generals/Code/Libraries/Source/WWVegas/WW3D2/stripoptimizer.h +++ /dev/null @@ -1,48 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -#if defined(_MSC_VER) -#pragma once -#endif - -#ifndef WW3D2_STRIP_OPTIMIZER_H__ -#define WW3D2_STRIP_OPTIMIZER_H__ - -#include "always.h" - - -// strip data = -// -// len = number of vertices in strip -// [vertex indices] -// len -// [vertex indices] -// .. - -class StripOptimizerClass -{ -public: - static int* Stripify(const int* tris, int tri_count); // Outputs a set of strips - static int* Combine_Strips(const int* strips, int strip_count); - static void Optimize_Strip_Order(int* strips, int strip_count); // Sorts strips for optimal access order - static void Optimize_Triangle_Order(int* tris, int triangle_count); // Sorts triangles (three indices each) into near-optimal access order - - static int Get_Strip_Index_Count(const int* strips, int strips_count); -}; - -#endif // WW3D2_STRIP_OPTIMIZER_H__ diff --git a/Generals/Code/Libraries/Source/WWVegas/WW3D2/surfaceclass.cpp b/Generals/Code/Libraries/Source/WWVegas/WW3D2/surfaceclass.cpp deleted file mode 100644 index d8e9f537350..00000000000 --- a/Generals/Code/Libraries/Source/WWVegas/WW3D2/surfaceclass.cpp +++ /dev/null @@ -1,1036 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** 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 *** - *********************************************************************************************** - * * - * Project Name : WW3D * - * * - * $Archive:: /Commando/Code/ww3d2/surfaceclass.cpp $* - * * - * Original Author:: Nathaniel Hoffman * - * * - * $Author:: Greg_h2 $* - * * - * $Modtime:: 8/30/01 2:01p $* - * * - * $Revision:: 25 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * SurfaceClass::Clear -- Clears a surface to 0 * - * SurfaceClass::Copy -- Copies a region from one surface to another of the same format * - * SurfaceClass::FindBBAlpha -- Finds the bounding box of non zero pixels in the region (x0, * - * PixelSize -- Helper Function to find the size in bytes of a pixel * - * SurfaceClass::Is_Transparent_Column -- Tests to see if the column is transparent or not * - * SurfaceClass::Copy -- Copies from a byte array to the surface * - * SurfaceClass::CreateCopy -- Creates a byte array copy of the surface * - * SurfaceClass::DrawHLine -- draws a horizontal line * - * SurfaceClass::DrawPixel -- draws a pixel * - * SurfaceClass::Copy -- Copies a block of system ram to the surface * - * SurfaceClass::Hue_Shift -- changes the hue of the surface * - * SurfaceClass::Is_Monochrome -- Checks if surface is monochrome or not * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#include "surfaceclass.h" -#include "formconv.h" -#include "dx8wrapper.h" -#include "vector2i.h" -#include "colorspace.h" -#include "bound.h" -#include - -/*********************************************************************************************** - * PixelSize -- Helper Function to find the size in bytes of a pixel * - * * - * * - * * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 2/13/2001 hy : Created. * - *=============================================================================================*/ - -unsigned int PixelSize(const SurfaceClass::SurfaceDescription &sd) -{ - unsigned int size=0; - - switch (sd.Format) - { - case WW3D_FORMAT_A8R8G8B8: - case WW3D_FORMAT_X8R8G8B8: - size=4; - break; - case WW3D_FORMAT_R8G8B8: - size=3; - break; - case WW3D_FORMAT_R5G6B5: - case WW3D_FORMAT_X1R5G5B5: - case WW3D_FORMAT_A1R5G5B5: - case WW3D_FORMAT_A4R4G4B4: - case WW3D_FORMAT_A8R3G3B2: - case WW3D_FORMAT_X4R4G4B4: - case WW3D_FORMAT_A8P8: - case WW3D_FORMAT_A8L8: - size=2; - break; - case WW3D_FORMAT_R3G3B2: - case WW3D_FORMAT_A8: - case WW3D_FORMAT_P8: - case WW3D_FORMAT_L8: - case WW3D_FORMAT_A4L4: - size=1; - break; - } - - return size; -} - -void Convert_Pixel(Vector3 &rgb, const SurfaceClass::SurfaceDescription &sd, const unsigned char * pixel) -{ - const float scale=1/255.0f; - switch (sd.Format) - { - case WW3D_FORMAT_A8R8G8B8: - case WW3D_FORMAT_X8R8G8B8: - case WW3D_FORMAT_R8G8B8: - { - rgb.X=pixel[2]; // R - rgb.Y=pixel[1]; // G - rgb.Z=pixel[0]; // B - } - break; - case WW3D_FORMAT_A4R4G4B4: - { - unsigned short tmp; - tmp=*(unsigned short*)&pixel[0]; - rgb.X=((tmp&0x0f00)>>4); // R - rgb.Y=((tmp&0x00f0)); // G - rgb.Z=((tmp&0x000f)<<4); // B - } - break; - case WW3D_FORMAT_A1R5G5B5: - { - unsigned short tmp; - tmp=*(unsigned short*)&pixel[0]; - rgb.X=(tmp>>7)&0xf8; // R - rgb.Y=(tmp>>2)&0xf8; // G - rgb.Z=(tmp<<3)&0xf8; // B - } - break; - case WW3D_FORMAT_R5G6B5: - { - unsigned short tmp; - tmp=*(unsigned short*)&pixel[0]; - rgb.X=(tmp>>8)&0xf8; - rgb.Y=(tmp>>3)&0xfc; - rgb.Z=(tmp<<3)&0xf8; - } - break; - - default: - // TODO: Implement other pixel formats - WWASSERT(0); - } - rgb*=scale; -} - -// Note: This function must never overwrite the original alpha -void Convert_Pixel(unsigned char * pixel,const SurfaceClass::SurfaceDescription &sd, const Vector3 &rgb) -{ - unsigned char r,g,b; - r=(unsigned char) (rgb.X*255.0f); - g=(unsigned char) (rgb.Y*255.0f); - b=(unsigned char) (rgb.Z*255.0f); - switch (sd.Format) - { - case WW3D_FORMAT_A8R8G8B8: - case WW3D_FORMAT_X8R8G8B8: - case WW3D_FORMAT_R8G8B8: - pixel[0]=b; - pixel[1]=g; - pixel[2]=r; - break; - case WW3D_FORMAT_A4R4G4B4: - { - unsigned short tmp; - tmp=*(unsigned short*)&pixel[0]; - tmp&=0xF000; - tmp|=(r&0xF0) << 4; - tmp|=(g&0xF0); - tmp|=(b&0xF0) >> 4; - *(unsigned short*)&pixel[0]=tmp; - } - break; - case WW3D_FORMAT_A1R5G5B5: - { - unsigned short tmp; - tmp=*(unsigned short*)&pixel[0]; - tmp&=0x8000; - tmp|=(r&0xF8) << 7; - tmp|=(g&0xF8) << 2; - tmp|=(b&0xF8) >> 3; - *(unsigned short*)&pixel[0]=tmp; - } - break; - case WW3D_FORMAT_R5G6B5: - { - unsigned short tmp; - tmp=(r&0xf8) << 8; - tmp|=(g&0xfc) << 3; - tmp|=(b&0xf8) >> 3; - *(unsigned short*)&pixel[0]=tmp; - } - break; - default: - // TODO: Implement other pixel formats - WWASSERT(0); - } -} - -/************************************************************************* -** SurfaceClass -*************************************************************************/ -SurfaceClass::SurfaceClass(unsigned width, unsigned height, WW3DFormat format): - D3DSurface(NULL), - SurfaceFormat(format) -{ - WWASSERT(width); - WWASSERT(height); - D3DSurface = DX8Wrapper::_Create_DX8_Surface(width, height, format); -} - -SurfaceClass::SurfaceClass(const char *filename): - D3DSurface(NULL) -{ - D3DSurface = DX8Wrapper::_Create_DX8_Surface(filename); - SurfaceDescription desc; - Get_Description(desc); - SurfaceFormat=desc.Format; -} - -SurfaceClass::SurfaceClass(IDirect3DSurface8 *d3d_surface) : - D3DSurface (NULL) -{ - Attach (d3d_surface); - SurfaceDescription desc; - Get_Description(desc); - SurfaceFormat=desc.Format; -} - -SurfaceClass::~SurfaceClass(void) -{ - if (D3DSurface) { - D3DSurface->Release(); - D3DSurface = NULL; - } -} - -void SurfaceClass::Get_Description(SurfaceDescription &surface_desc) -{ - D3DSURFACE_DESC d3d_desc; - ::ZeroMemory(&d3d_desc, sizeof(D3DSURFACE_DESC)); - DX8_ErrorCode(D3DSurface->GetDesc(&d3d_desc)); - surface_desc.Format = D3DFormat_To_WW3DFormat(d3d_desc.Format); - surface_desc.Height = d3d_desc.Height; - surface_desc.Width = d3d_desc.Width; -} - -void * SurfaceClass::Lock(int * pitch) -{ - D3DLOCKED_RECT lock_rect; - ::ZeroMemory(&lock_rect, sizeof(D3DLOCKED_RECT)); - DX8_ErrorCode(D3DSurface->LockRect(&lock_rect, 0, 0)); - *pitch = lock_rect.Pitch; - return (void *)lock_rect.pBits; -} - -void SurfaceClass::Unlock(void) -{ - DX8_ErrorCode(D3DSurface->UnlockRect()); -} - -/*********************************************************************************************** - * SurfaceClass::Clear -- Clears a surface to 0 * - * * - * * - * * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 2/13/2001 hy : Created. * - *=============================================================================================*/ -void SurfaceClass::Clear() -{ - SurfaceDescription sd; - Get_Description(sd); - - // size of each pixel in bytes - unsigned int size=PixelSize(sd); - - D3DLOCKED_RECT lock_rect; - ::ZeroMemory(&lock_rect, sizeof(D3DLOCKED_RECT)); - DX8_ErrorCode(D3DSurface->LockRect(&lock_rect,0,0)); - unsigned int i; - unsigned char *mem=(unsigned char *) lock_rect.pBits; - - for (i=0; iUnlockRect()); -} - - -/*********************************************************************************************** - * SurfaceClass::Copy -- Copies from a byte array to the surface * - * * - * * - * * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 3/15/2001 hy : Created. * - *=============================================================================================*/ -void SurfaceClass::Copy(const unsigned char *other) -{ - SurfaceDescription sd; - Get_Description(sd); - - // size of each pixel in bytes - unsigned int size=PixelSize(sd); - - D3DLOCKED_RECT lock_rect; - ::ZeroMemory(&lock_rect, sizeof(D3DLOCKED_RECT)); - DX8_ErrorCode(D3DSurface->LockRect(&lock_rect,0,0)); - unsigned int i; - unsigned char *mem=(unsigned char *) lock_rect.pBits; - - for (i=0; iUnlockRect()); -} - - -/*********************************************************************************************** - * SurfaceClass::Copy -- Copies a block of system ram to the surface * - * * - * * - * * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 5/2/2001 hy : Created. * - *=============================================================================================*/ -void SurfaceClass::Copy(Vector2i &min,Vector2i &max, const unsigned char *other) -{ - SurfaceDescription sd; - Get_Description(sd); - - // size of each pixel in bytes - unsigned int size=PixelSize(sd); - - D3DLOCKED_RECT lock_rect; - ::ZeroMemory(&lock_rect, sizeof(D3DLOCKED_RECT)); - RECT rect; - rect.left=min.I; - rect.right=max.I; - rect.top=min.J; - rect.bottom=max.J; - DX8_ErrorCode(D3DSurface->LockRect(&lock_rect,&rect,0)); - int i; - unsigned char *mem=(unsigned char *) lock_rect.pBits; - int dx=max.I-min.I; - - for (i=min.J; iUnlockRect()); -} - - -/*********************************************************************************************** - * SurfaceClass::CreateCopy -- Creates a byte array copy of the surface * - * * - * * - * * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 3/16/2001 hy : Created. * - *=============================================================================================*/ -unsigned char *SurfaceClass::CreateCopy(int *width,int *height,int*size,bool flip) -{ - SurfaceDescription sd; - Get_Description(sd); - - // size of each pixel in bytes - unsigned int mysize=PixelSize(sd); - - *width=sd.Width; - *height=sd.Height; - *size=mysize; - - unsigned char *other=W3DNEWARRAY unsigned char [sd.Height*sd.Width*mysize]; - - D3DLOCKED_RECT lock_rect; - ::ZeroMemory(&lock_rect, sizeof(D3DLOCKED_RECT)); - DX8_ErrorCode(D3DSurface->LockRect(&lock_rect,0,D3DLOCK_READONLY)); - unsigned int i; - unsigned char *mem=(unsigned char *) lock_rect.pBits; - - for (i=0; iUnlockRect()); - - return other; -} - - -/*********************************************************************************************** - * SurfaceClass::Copy -- Copies a region from one surface to another * - * * - * * - * * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 2/13/2001 hy : Created. * - *=============================================================================================*/ -void SurfaceClass::Copy( - unsigned int dstx, unsigned int dsty, - unsigned int srcx, unsigned int srcy, - unsigned int width, unsigned int height, - const SurfaceClass *other) -{ - WWASSERT(other); - WWASSERT(width); - WWASSERT(height); - - SurfaceDescription sd,osd; - Get_Description(sd); - const_cast (other)->Get_Description(osd); - - RECT src; - src.left=srcx; - src.right=srcx+width; - src.top=srcy; - src.bottom=srcy+height; - - if (src.right>int(osd.Width)) src.right=int(osd.Width); - if (src.bottom>int(osd.Height)) src.bottom=int(osd.Height); - - if (sd.Format==osd.Format && sd.Width==osd.Width && sd.Height==osd.Height) - { - POINT dst; - dst.x=dstx; - dst.y=dsty; - DX8Wrapper::_Copy_DX8_Rects(other->D3DSurface,&src,1,D3DSurface,&dst); - } - else - { - RECT dest; - dest.left=dstx; - dest.right=dstx+width; - dest.top=dsty; - dest.bottom=dsty+height; - - if (dest.right>int(sd.Width)) dest.right=int(sd.Width); - if (dest.bottom>int(sd.Height)) dest.bottom=int(sd.Height); - - DX8_ErrorCode(D3DXLoadSurfaceFromSurface(D3DSurface,NULL,&dest,other->D3DSurface,NULL,&src,D3DX_FILTER_NONE,0)); - } -} - -/*********************************************************************************************** - * SurfaceClass::Copy -- Copies a region from one surface to another * - * * - * * - * * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 2/13/2001 hy : Created. * - *=============================================================================================*/ -void SurfaceClass::Stretch_Copy( - unsigned int dstx, unsigned int dsty, unsigned int dstwidth, unsigned int dstheight, - unsigned int srcx, unsigned int srcy, unsigned int srcwidth, unsigned int srcheight, - const SurfaceClass *other) -{ - WWASSERT(other); - - SurfaceDescription sd,osd; - Get_Description(sd); - const_cast (other)->Get_Description(osd); - - RECT src; - src.left=srcx; - src.right=srcx+srcwidth; - src.top=srcy; - src.bottom=srcy+srcheight; - - RECT dest; - dest.left=dstx; - dest.right=dstx+dstwidth; - dest.top=dsty; - dest.bottom=dsty+dstheight; - - DX8_ErrorCode(D3DXLoadSurfaceFromSurface(D3DSurface,NULL,&dest,other->D3DSurface,NULL,&src,D3DX_FILTER_TRIANGLE ,0)); -} - -/*********************************************************************************************** - * SurfaceClass::FindBB -- Finds the bounding box of non zero pixels in the region * - * * - * * - * * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 2/13/2001 hy : Created. * - *=============================================================================================*/ -void SurfaceClass::FindBB(Vector2i *min,Vector2i*max) -{ - SurfaceDescription sd; - Get_Description(sd); - - WWASSERT(Has_Alpha(sd.Format)); - - int alphabits=Alpha_Bits(sd.Format); - int mask=0; - switch (alphabits) - { - case 1: mask=1; - break; - case 4: mask=0xf; - break; - case 8: mask=0xff; - break; - } - - D3DLOCKED_RECT lock_rect; - ::ZeroMemory(&lock_rect, sizeof(D3DLOCKED_RECT)); - RECT rect; - ::ZeroMemory(&rect, sizeof(RECT)); - - rect.bottom=max->J; - rect.top=min->J; - rect.left=min->I; - rect.right=max->I; - - DX8_ErrorCode(D3DSurface->LockRect(&lock_rect,&rect,D3DLOCK_READONLY)); - - int x,y; - unsigned int size=PixelSize(sd); - Vector2i realmin=*max; - Vector2i realmax=*min; - - // the assumption here is that whenever a pixel has alpha it's in the MSB - for (y = min->J; y < max->J; y++) { - for (x = min->I; x < max->I; x++) { - - // HY - this is not endian safe - unsigned char *alpha=(unsigned char*) ((unsigned int)lock_rect.pBits+(y-min->J)*lock_rect.Pitch+(x-min->I)*size); - unsigned char myalpha=alpha[size-1]; - myalpha=(myalpha>>(8-alphabits)) & mask; - if (myalpha) { - realmin.I = MIN(realmin.I, x); - realmax.I = MAX(realmax.I, x); - realmin.J = MIN(realmin.J, y); - realmax.J = MAX(realmax.J, y); - } - } - } - - DX8_ErrorCode(D3DSurface->UnlockRect()); - - *max=realmax; - *min=realmin; -} - - -/*********************************************************************************************** - * SurfaceClass::Is_Transparent_Column -- Tests to see if the column is transparent or not * - * * - * * - * * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 2/13/2001 hy : Created. * - *=============================================================================================*/ -bool SurfaceClass::Is_Transparent_Column(unsigned int column) -{ - SurfaceDescription sd; - Get_Description(sd); - - WWASSERT(columnLockRect(&lock_rect,&rect,D3DLOCK_READONLY)); - - int y; - - // the assumption here is that whenever a pixel has alpha it's in the MSB - for (y = 0; y < (int) sd.Height; y++) - { - // HY - this is not endian safe - unsigned char *alpha=(unsigned char*) ((unsigned int)lock_rect.pBits+y*lock_rect.Pitch); - unsigned char myalpha=alpha[size-1]; - myalpha=(myalpha>>(8-alphabits)) & mask; - if (myalpha) { - DX8_ErrorCode(D3DSurface->UnlockRect()); - return false; - } - } - - DX8_ErrorCode(D3DSurface->UnlockRect()); - return true; -} - -/*********************************************************************************************** - * SurfaceClass::Get_Pixel -- Returns the pixel's RGB valus to the caller * - * * - * * - * * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 2/13/2001 hy : Created. * - *=============================================================================================*/ -void SurfaceClass::Get_Pixel(Vector3 &rgb, int x,int y) -{ - SurfaceDescription sd; - Get_Description(sd); - - x = min(x,(int)sd.Width - 1); - y = min(y,(int)sd.Height - 1); - - D3DLOCKED_RECT lock_rect; - ::ZeroMemory(&lock_rect, sizeof(D3DLOCKED_RECT)); - RECT rect; - ::ZeroMemory(&rect, sizeof(RECT)); - - rect.bottom=y+1; - rect.top=y; - rect.left=x; - rect.right=x+1; - - DX8_ErrorCode(D3DSurface->LockRect(&lock_rect,&rect,D3DLOCK_READONLY)); - Convert_Pixel(rgb,sd,(unsigned char *) lock_rect.pBits); - DX8_ErrorCode(D3DSurface->UnlockRect()); -} - -/*********************************************************************************************** - * SurfaceClass::Attach -- Attaches a surface pointer to the object, releasing the current ptr.* - * * - * * - * * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 3/27/2001 pds : Created. * - *=============================================================================================*/ -void SurfaceClass::Attach (IDirect3DSurface8 *surface) -{ - Detach (); - D3DSurface = surface; - - // - // Lock a reference onto the object - // - if (D3DSurface != NULL) { - D3DSurface->AddRef (); - } - - return ; -} - - -/*********************************************************************************************** - * SurfaceClass::Detach -- Releases the reference on the internal surface ptr, and NULLs it. .* - * * - * * - * * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 3/27/2001 pds : Created. * - *=============================================================================================*/ -void SurfaceClass::Detach (void) -{ - // - // Release the hold we have on the D3D object - // - if (D3DSurface != NULL) { - D3DSurface->Release (); - } - - D3DSurface = NULL; - return ; -} - - -/*********************************************************************************************** - * SurfaceClass::DrawPixel -- draws a pixel * - * * - * * - * * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - *=============================================================================================*/ -void SurfaceClass::DrawPixel(const unsigned int x,const unsigned int y, unsigned int color) -{ - SurfaceDescription sd; - Get_Description(sd); - - unsigned int size=PixelSize(sd); - - D3DLOCKED_RECT lock_rect; - ::ZeroMemory(&lock_rect, sizeof(D3DLOCKED_RECT)); - RECT rect; - ::ZeroMemory(&rect, sizeof(RECT)); - - rect.bottom=y+1; - rect.top=y; - rect.left=x; - rect.right=x+1; - - DX8_ErrorCode(D3DSurface->LockRect(&lock_rect,&rect,0)); - unsigned char *cptr=(unsigned char*)lock_rect.pBits; - unsigned short *sptr=(unsigned short*)lock_rect.pBits; - unsigned int *lptr=(unsigned int*)lock_rect.pBits; - - switch (size) - { - case 1: - *cptr=(unsigned char) (color & 0xFF); - break; - case 2: - *sptr=(unsigned short) (color & 0xFFFF); - break; - case 4: - *lptr=color; - break; - } - - DX8_ErrorCode(D3DSurface->UnlockRect()); -} - -/*********************************************************************************************** - * SurfaceClass::DrawHLine -- draws a horizontal line * - * * - * * - * * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 4/9/2001 hy : Created. * - * 4/9/2001 hy : Created. * - *=============================================================================================*/ -void SurfaceClass::DrawHLine(const unsigned int y,const unsigned int x1, const unsigned int x2, unsigned int color) -{ - SurfaceDescription sd; - Get_Description(sd); - - unsigned int size=PixelSize(sd); - - D3DLOCKED_RECT lock_rect; - ::ZeroMemory(&lock_rect, sizeof(D3DLOCKED_RECT)); - RECT rect; - ::ZeroMemory(&rect, sizeof(RECT)); - - rect.bottom=y+1; - rect.top=y; - rect.left=x1; - rect.right=x2+1; - - DX8_ErrorCode(D3DSurface->LockRect(&lock_rect,&rect,0)); - unsigned char *cptr=(unsigned char*)lock_rect.pBits; - unsigned short *sptr=(unsigned short*)lock_rect.pBits; - unsigned int *lptr=(unsigned int*)lock_rect.pBits; - - unsigned int x; - // the assumption here is that whenever a pixel has alpha it's in the MSB - for (x=x1; x<=x2; x++) - { - switch (size) - { - case 1: - *cptr++=(unsigned char) (color & 0xFF); - break; - case 2: - *sptr++=(unsigned short) (color & 0xFFFF); - break; - case 4: - *lptr++=color; - break; - } - } - - DX8_ErrorCode(D3DSurface->UnlockRect()); -} - - -/*********************************************************************************************** - * SurfaceClass::Is_Monochrome -- Checks if surface is monochrome or not * - * * - * * - * * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 7/5/2001 hy : Created. * - *=============================================================================================*/ -bool SurfaceClass::Is_Monochrome(void) -{ - unsigned int x,y; - SurfaceDescription sd; - Get_Description(sd); - bool is_compressed = false; - - switch (sd.Format) - { - // these formats are always monochrome - case WW3D_FORMAT_A8L8: - case WW3D_FORMAT_A8: - case WW3D_FORMAT_L8: - case WW3D_FORMAT_A4L4: - return true; - break; - // these formats cannot be determined to be monochrome or not - case WW3D_FORMAT_UNKNOWN: - case WW3D_FORMAT_A8P8: - case WW3D_FORMAT_P8: - case WW3D_FORMAT_U8V8: // Bumpmap - case WW3D_FORMAT_L6V5U5: // Bumpmap - case WW3D_FORMAT_X8L8V8U8: // Bumpmap - return false; - break; - // these formats need decompression first - case WW3D_FORMAT_DXT1: - case WW3D_FORMAT_DXT2: - case WW3D_FORMAT_DXT3: - case WW3D_FORMAT_DXT4: - case WW3D_FORMAT_DXT5: - is_compressed = true; - break; - } - - // if it's in some compressed texture format, be sure to decompress first - if (is_compressed) { - WW3DFormat new_format = Get_Valid_Texture_Format(sd.Format, false); - SurfaceClass *new_surf = NEW_REF( SurfaceClass, (sd.Width, sd.Height, new_format) ); - new_surf->Copy(0, 0, 0, 0, sd.Width, sd.Height, this); - bool result = new_surf->Is_Monochrome(); - REF_PTR_RELEASE(new_surf); - return result; - } - - int pitch,size; - - size=PixelSize(sd); - unsigned char *bits=(unsigned char*) Lock(&pitch); - - Vector3 rgb; - bool mono=true; - - for (y=0; y. -*/ - -/*********************************************************************************************** - *** 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 *** - *********************************************************************************************** - * * - * Project Name : WW3D * - * * - * $Archive:: /VSS_Sync/ww3d2/surfaceclass.h $* - * * - * Original Author:: Nathaniel Hoffman * - * * - * $Author:: Vss_sync $* - * * - * $Modtime:: 8/29/01 9:32p $* - * * - * $Revision:: 17 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#if defined(_MSC_VER) -#pragma once -#endif - -#ifndef SURFACECLASS_H -#define SURFACECLASS_H - -#include "ww3dformat.h" -#include "refcount.h" - -struct IDirect3DSurface8; -class Vector2i; -class Vector3; - -/************************************************************************* -** SurfaceClass -** -** This is our surface class, which wraps IDirect3DSurface8. -** -** Hector Yee 2/12/01 - added in fills, blits etc for font3d class -** -*************************************************************************/ -class SurfaceClass : public W3DMPO, public RefCountClass -{ - W3DMPO_GLUE(SurfaceClass) - public: - - struct SurfaceDescription { - WW3DFormat Format; // Surface format - unsigned int Width; // Surface width in pixels - unsigned int Height; // Surface height in pixels - }; - - // Create surface with desired height, width and format. - SurfaceClass(unsigned width, unsigned height, WW3DFormat format); - - // Create surface from a file. - SurfaceClass(const char *filename); - - // Create the surface from a D3D pointer - SurfaceClass(IDirect3DSurface8 *d3d_surface); - - ~SurfaceClass(void); - - // Get surface description - void Get_Description(SurfaceDescription &surface_desc); - - // Lock / unlock the surface - void * Lock(int * pitch); - void Unlock(void); - - // HY -- The following functions are support functions for font3d - // zaps the surface memory to zero - void Clear(); - - // copies the contents of one surface to another - void Copy( - unsigned int dstx, unsigned int dsty, - unsigned int srcx, unsigned int srcy, - unsigned int width, unsigned int height, - const SurfaceClass *other); - - // support for copying from a byte array - void Copy(const unsigned char *other); - - // support for copying from a byte array - void Copy(Vector2i &min,Vector2i &max, const unsigned char *other); - - // copies the contents of one surface to another, stretches - void Stretch_Copy( - unsigned int dstx, unsigned int dsty,unsigned int dstwidth, unsigned int dstheight, - unsigned int srcx, unsigned int srcy, unsigned int srcwidth, unsigned int srcheight, - const SurfaceClass *source); - - // finds the bounding box of non-zero pixels, used in font3d - void FindBB(Vector2i *min,Vector2i*max); - - // tests a column to see if the alpha is nonzero, used in font3d - bool Is_Transparent_Column(unsigned int column); - - // makes a copy of the surface into a byte array - unsigned char *CreateCopy(int *width,int *height,int*size,bool flip=false); - - // For use by TextureClass: - IDirect3DSurface8 *Peek_D3D_Surface(void) { return D3DSurface; } - - // Attaching and detaching a surface pointer - void Attach (IDirect3DSurface8 *surface); - void Detach (void); - - // draws a horizontal line - void DrawHLine(const unsigned int y,const unsigned int x1, const unsigned int x2, unsigned int color); - - void DrawPixel(const unsigned int x,const unsigned int y, unsigned int color); - - // get pixel function .. to be used infrequently - void Get_Pixel(Vector3 &rgb, int x,int y); - - void Hue_Shift(const Vector3 &hsv_shift); - - bool Is_Monochrome(void); - - WW3DFormat Get_Surface_Format() const { return SurfaceFormat; } - - private: - - // Direct3D surface object - IDirect3DSurface8 *D3DSurface; - - WW3DFormat SurfaceFormat; - friend class TextureClass; -}; - -#endif - - diff --git a/Generals/Code/Libraries/Source/WWVegas/WW3D2/textdraw.cpp b/Generals/Code/Libraries/Source/WWVegas/WW3D2/textdraw.cpp deleted file mode 100644 index 2d53223abca..00000000000 --- a/Generals/Code/Libraries/Source/WWVegas/WW3D2/textdraw.cpp +++ /dev/null @@ -1,344 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*************************************************************************** - *** 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 *** - *************************************************************************** - * * - * Project Name : Commando * - * * - * $Archive:: /Commando/Code/ww3d2/textdraw.cpp $* - * * - * $Author:: Jani_p $* - * * - * $Modtime:: 3/22/01 8:03p $* - * * - * $Revision:: 7 $* - * * - *-------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#include "textdraw.h" -#include "font3d.h" -#include "simplevec.h" - -/*********************************************************************************************** - * * - * TextDrawClass::TextDrawClass( int ) -- Constructor * - * * - * Creates a TextDrawClass object by creating and initializing a Dynamic Mesh, inserting it * - * into the given scene, and allocating space for the given number of maximum chars. * - * * - ***********************************************************************************************/ -TextDrawClass::TextDrawClass( int max_chars ) : - DynamicMeshClass( max_chars * 2, max_chars * 4 ), - TextColor( 1.0f, 1.0f, 1.0f ) -{ - // Build the default Vertex Material - DefaultVertexMaterial = NEW_REF( VertexMaterialClass, () ); - DefaultVertexMaterial->Set_Diffuse( 0, 0, 0 ); - DefaultVertexMaterial->Set_Opacity(1); - DefaultVertexMaterial->Set_Emissive( 1, 1, 1 ); - Set_Vertex_Material( DefaultVertexMaterial ); - - // Build the default Shader - DefaultShader.Set_Depth_Mask( ShaderClass::DEPTH_WRITE_DISABLE ); - DefaultShader.Set_Depth_Compare( ShaderClass::PASS_ALWAYS ); - DefaultShader.Set_Dst_Blend_Func( ShaderClass::DSTBLEND_ONE_MINUS_SRC_ALPHA ); - DefaultShader.Set_Src_Blend_Func( ShaderClass::SRCBLEND_SRC_ALPHA ); - DefaultShader.Set_Texturing( ShaderClass::TEXTURING_ENABLE ); - DefaultShader.Set_Cull_Mode( ShaderClass::CULL_MODE_DISABLE ); - Set_Shader( DefaultShader ); - Enable_Sort(); - - Set_Coordinate_Ranges( Vector2( 0,0 ), Vector2( 1,1 ), Vector2( -1,0.75f ), Vector2( 1,-0.75 ) ); -// Set_Coordinate_Ranges( Vector2( -320,240 ), Vector2( 320,-240 ), Vector2( -320,240 ), Vector2( 320,-240 ) ); -} - -/*********************************************************************************************** - * * - * TextDrawClass::~TextDrawClass( void ) -- Destructor * - * * - ***********************************************************************************************/ -TextDrawClass::~TextDrawClass( void ) -{ - DefaultVertexMaterial->Release_Ref(); -} - -/*********************************************************************************************** - * * - * TextDrawClass::Reset( void ) -- Flush the mesh - * * - ***********************************************************************************************/ -void TextDrawClass::Reset( void ) -{ - Reset_Flags(); - Reset_Mesh_Counters(); - - // Reinstall the default vertex material and shader - Enable_Sort(); - Set_Vertex_Material( DefaultVertexMaterial ); - Set_Shader( DefaultShader ); -} - -/* -** -*/ -void TextDrawClass::Set_Coordinate_Ranges( - const Vector2 & src_ul, const Vector2 & src_lr, - const Vector2 & dest_ul, const Vector2 & dest_lr ) -{ - TranslateScale.X = (dest_lr.X - dest_ul.X) / (src_lr.X - src_ul.X); - TranslateScale.Y = (dest_lr.Y - dest_ul.Y) / (src_lr.Y - src_ul.Y); - TranslateOffset.X = dest_ul.X - TranslateScale.X * src_ul.X; - TranslateOffset.Y = dest_ul.Y - TranslateScale.Y * src_ul.Y; - - PixelSize.X = fabs((src_lr.X - src_ul.X) / 640.0f); - PixelSize.Y = fabs((src_lr.Y - src_ul.Y) / 480.0f); -} - - -/* -** -*/ -void TextDrawClass::Quad( float x0, float y0, float x1, float y1, float u0, float v0, float u1, float v1 ) -{ - // Translate coordinates - x0 = x0 * TranslateScale.X + TranslateOffset.X; - x1 = x1 * TranslateScale.X + TranslateOffset.X; - y0 = y0 * TranslateScale.Y + TranslateOffset.Y; - y1 = y1 * TranslateScale.Y + TranslateOffset.Y; - - bool flip_faces = ((x1-x0) * (y1-y0)) > 0; - - Begin_Tri_Strip(); - Vertex( x0, y0, 0, u0, v0); - if ( flip_faces ) { - Vertex( x1, y0, 0, u1, v0); - Vertex( x0, y1, 0, u0, v1); - } else { - Vertex( x0, y1, 0, u0, v1); - Vertex( x1, y0, 0, u1, v0); - } - Vertex( x1, y1, 0, u1, v1); - End_Tri_Strip(); -} - -void TextDrawClass::Quad( const RectClass & rect, const RectClass & uv ) -{ - TextDrawClass::Quad( rect.Left, rect.Top, rect.Right, rect.Bottom, uv.Left, uv.Top, uv.Right, uv.Bottom ); -} - -void TextDrawClass::Line( const Vector2 & _a, const Vector2 & _b, float width ) -{ - // Translate coordinates - Vector2 a; - Vector2 b; - a.X = _a.X * TranslateScale.X + TranslateOffset.X; - a.Y = _a.Y * TranslateScale.Y + TranslateOffset.Y; - b.X = _b.X * TranslateScale.X + TranslateOffset.X; - b.Y = _b.Y * TranslateScale.Y + TranslateOffset.Y; - width *= WWMath::Fabs(TranslateScale.X); - - Vector2 corner_offset = a - b; // get line relative to b - float temp = corner_offset.X; // Rotate 90 - corner_offset.X = corner_offset.Y; - corner_offset.Y = -temp; - corner_offset.Normalize(); // scale to length width/2 - corner_offset *= width / 2; - - Begin_Tri_Strip(); - Vertex( a + corner_offset ); - Vertex( a - corner_offset ); - Vertex( b + corner_offset ); - Vertex( b - corner_offset ); - End_Tri_Strip(); -} - -void TextDrawClass::Line_Ends( const Vector2 & a, const Vector2 & b, float width, float end_percent ) -{ - Vector2 a_ = b - a; - a_ *= end_percent; - a_ += a; - Line( a, a_, width ); - Vector2 b_ = a - b; - b_ *= end_percent; - b_ += b; - Line( b, b_, width ); -} - - -/*********************************************************************************************** - * * - * float TextDrawClass::Get_Width( Font3DInstanceClass *, char * ) * - * * - * WARNING: Should not be used to draw characters which need to wrap or have embedded line * - * feeds. * - * * - * Returns the scaled string width in normalized screen unit * - * * - ***********************************************************************************************/ -float TextDrawClass::Get_Width( Font3DInstanceClass *font, const char *message ) -{ - float total_width = 0.0f; - - /* - ** for each character, get_width it - */ - while (*message != 0) { - total_width += font->Char_Spacing( *message++ ); - } - - return total_width; -} - -float TextDrawClass::Get_Inter_Char_Width( Font3DInstanceClass *font ) -{ - // Get rid of this... -// return font->Get_Inter_Char_Spacing(); - return 1; -} - -float TextDrawClass::Get_Height( Font3DInstanceClass *font, const char *message ) -{ - return font->Char_Height(); -} - - -/*********************************************************************************************** - * * - * float TextDrawClass::Print( Font3DInstanceClass *, char, float, float, float ) * - * * - * Draws (actually creates two trianlges to display) a character on the screen at the given * - * normalized screen unit coordinates at the current font scale. * - * * - * Returns the scaled character width in normalized screen unit * - * * - ***********************************************************************************************/ -float TextDrawClass::Print( Font3DInstanceClass *font, char ch, float screen_x, float screen_y ) -{ - /* - ** Get the char width in scaled normalized screen units - */ - float width = font->Char_Width( ch ); // in scaled normalized screen units - float spacing = font->Char_Spacing( ch ); // in scaled normalized screen units - - /* - ** If asked to draw the space char (' '), don't add any triangles, just return the scaled spacing - */ - if (ch == ' ' ) - return spacing; - - /* - ** Calculate the lower right edge of the displayed rectangle - */ - // center each char in its spacing (in case mono spaced ) - // also, round to the nearest 640x480 pixels (needs to change for other reses) - float screen_x0 = screen_x + spacing/2 - width/2; - screen_x0 = floor(screen_x0 / PixelSize.X + 0.5f) * PixelSize.X; - float screen_x1 = screen_x0 + width; - screen_x1 = floor(screen_x1 / PixelSize.X + 0.5f) * PixelSize.X; - float screen_y0 = screen_y; - screen_y0 = floor(screen_y0 / PixelSize.Y + 0.5f) * PixelSize.Y; - float screen_y1 = screen_y0 + (font->Char_Height() * WWMath::Sign( -TranslateScale.Y )); - screen_y1 = floor(screen_y1 / PixelSize.Y + 0.5f) * PixelSize.Y; - - if ( WW3D::Is_Screen_UV_Biased() ) { // Global bais setting - screen_x0 += PixelSize.X / 2; - screen_x1 += PixelSize.X / 2; - screen_y0 += PixelSize.Y / 2; - screen_y1 += PixelSize.Y / 2; - } - - /* - ** Get the font texture uv coordinate for teh upper right and lower left corners of the rect - */ - RectClass font_uv = font->Char_UV( ch ); - - /* - ** Set the triangles' texture - */ - Set_Texture( font->Peek_Texture( ch ) ); - - /* - ** Draw the quad - */ - Quad( screen_x0, screen_y0, screen_x1, screen_y1, font_uv.Left, font_uv.Top, font_uv.Right, font_uv.Bottom ); - - /* - ** return the scaled spacing - */ - return spacing; -} - - -/*********************************************************************************************** - * * - * float TextDrawClass::Print( Font3DInstanceClass *, char *, float, float, float ) * - * * - * Draws the given string at the given pixel coordinates. Uses the given font and its current * - * scale. Passes each character to the above routine and moves the x-coordinate forward after * - * each char. * * - * * - * WARNING: Should not be used to draw characters which need to wrap or have embedded line * - * feeds. * * - * * - * Returns the string pixel width * - * * - ***********************************************************************************************/ -float TextDrawClass::Print( Font3DInstanceClass *font, const char *message, float screen_x, float screen_y ) -{ - /* - ** Keep track of the total drawn width - */ - float total_width = 0.0f; - - /* - ** for each character, print it and moved screen_x forward - */ - while (*message != 0) { - float width = Print( font, *message++, screen_x, screen_y ); - screen_x += width; - total_width += width; - } - - /* - ** return the total drawn width - */ - return total_width; -} - - -/*********************************************************************************************** - * * - * void TextDrawClass::Show_Font( Font3DInstanceClass *, float, float, float ) * - * * - * Dumps the font texture to the screen as two triangles. For debugging only. * - * * - ***********************************************************************************************/ -void TextDrawClass::Show_Font( Font3DInstanceClass *font, float screen_x, float screen_y ) -{ - // normalize coordinates - float size_x = PixelSize.X * 256; - float size_y = PixelSize.Y * 256; - - Set_Texture( font->Peek_Texture('A') ); - - Quad( screen_x, screen_y, screen_x + size_x, screen_y + size_y * WWMath::Sign( -TranslateScale.Y ) ); -} diff --git a/Generals/Code/Libraries/Source/WWVegas/WW3D2/textdraw.h b/Generals/Code/Libraries/Source/WWVegas/WW3D2/textdraw.h deleted file mode 100644 index 21fe7602246..00000000000 --- a/Generals/Code/Libraries/Source/WWVegas/WW3D2/textdraw.h +++ /dev/null @@ -1,120 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*************************************************************************** - *** 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 *** - *************************************************************************** - * * - * Project Name : Commando * - * * - * $Archive:: /Commando/Code/ww3d2/textdraw.h $* - * * - * $Author:: Greg_h $* - * * - * $Modtime:: 3/15/01 3:41p $* - * * - * $Revision:: 4 $* - * * - *-------------------------------------------------------------------------*/ - - -#if defined(_MSC_VER) -#pragma once -#endif - -#ifndef TEXTDRAW_H -#define TEXTDRAW_H - -#include "always.h" -#include "dynamesh.h" - -// sgc : wwlib and wwmath contain different rect.h files... -#include "../WWMath/rect.h" - -class Font3DInstanceClass; - -/****************************************************************** -** -** TextDrawClass -** -** This class provides a simple method to draw 2D text into a scene. -** Both strings and individual characters can be drawn to any normalized -** screen coordinates ( 0.. 1 ), or any scale/offset. -** This class uses a dynamic mesh for all polygon and vertex management -** -*******************************************************************/ - -class TextDrawClass : public DynamicMeshClass -{ - -public: - /* - ** Constructor and Destructor - */ - TextDrawClass( int max_chars ); - ~TextDrawClass(); - - // Set Coordinate Range - void Set_Coordinate_Ranges( const Vector2 & param_ul, const Vector2 & param_lr, - const Vector2 & dest_ul, const Vector2 & dest_lr ); - - // Reset all polys and verts - virtual void Reset( void ); - - /* - ** class id of this render object - */ - virtual int Class_ID(void) const { return CLASSID_TEXTDRAW; } - - /* - ** - */ - float Get_Width( Font3DInstanceClass *font, const char *message ); - float Get_Char_Width( Font3DInstanceClass *font, const char c ); - float Get_Inter_Char_Width( Font3DInstanceClass *font ); - float Get_Height( Font3DInstanceClass *font, const char *message = "" ); - - /* - ** Print the given char/string with the given font at the given loation in screen pixels - ** returns the pixel width of the drawn data. - */ - float Print( Font3DInstanceClass *font, char ch, float screen_x, float screen_y); - float Print( Font3DInstanceClass *font, const char *message, float screen_x, float screen_y); - - void Set_Text_Color( const Vector3 & color ) { Set_Vertex_Color(color); } - - /* - ** dump the font image (debuging) - */ - void Show_Font( Font3DInstanceClass *font, float screen_x, float screen_y ); - - void Quad( float x0, float y0, float x1, float y1, float u0 = 0, float v0 = 0, float u1 = 1, float v1 = 1); - void Quad( const RectClass & rect, const RectClass & uv = RectClass( 0, 0, 1, 1 ) ); - void Line( const Vector2 & a, const Vector2 & b, float width ); - void Line_Ends( const Vector2 & a, const Vector2 & b, float width, float end_percent ); - -private: - Vector3 TextColor; - VertexMaterialClass *DefaultVertexMaterial; - ShaderClass DefaultShader; - Vector2 TranslateScale; - Vector2 TranslateOffset; - Vector2 PixelSize; -}; - -#endif // TEXTDRAW_H diff --git a/Generals/Code/Libraries/Source/WWVegas/WW3D2/visrasterizer.cpp b/Generals/Code/Libraries/Source/WWVegas/WW3D2/visrasterizer.cpp deleted file mode 100644 index 123f12a15a7..00000000000 --- a/Generals/Code/Libraries/Source/WWVegas/WW3D2/visrasterizer.cpp +++ /dev/null @@ -1,730 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** 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 *** - *********************************************************************************************** - * * - * Project Name : ww3d * - * * - * $Archive:: /Commando/Code/ww3d2/visrasterizer.cpp $* - * * - * Original Author:: Greg Hjelstrom * - * * - * $Author:: Jani_p $* - * * - * $Modtime:: 11/24/01 5:42p $* - * * - * $Revision:: 11 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#include "visrasterizer.h" -#include "camera.h" -#include "plane.h" -#include "vp.h" - - -/** -** VisPolyClass - This class is used to clip polygons as they are -** sent through the vis rasterization system -*/ -class VisPolyClass -{ -public: - void Reset(void); - void Add_Vertex(const Vector3 & point); - void Clip(const PlaneClass & plane,VisPolyClass & dest) const; - - SimpleDynVecClass Verts; -}; - - -void VisPolyClass::Reset(void) -{ - Verts.Delete_All(false); -} - -void VisPolyClass::Add_Vertex(const Vector3 & point) -{ - Verts.Add(point); -} - -void VisPolyClass::Clip(const PlaneClass & plane,VisPolyClass & dest) const -{ - dest.Reset(); - - // temporary variables used in clipping - int i = 0; - int vcount = Verts.Count(); - int iprev = vcount - 1; - bool cur_point_in_front; - bool prev_point_in_front; - float alpha; - Vector3 int_point; - - if (vcount <= 2) return; - - // perform clipping - prev_point_in_front = !plane.In_Front(Verts[iprev]); // Note, plane normal is outward so we invert this test - for (int j=0; j=vcount) { - i = 0; - } - } -} - -static VisPolyClass _VisPoly0; -static VisPolyClass _VisPoly1; - - - -/********************************************************************************************* - - VisRasterizerClass Implementation - -*********************************************************************************************/ - - -VisRasterizerClass::VisRasterizerClass(void) : - ModelTransform(1), - Camera(NULL), - MVTransform(1) -{ -} - -VisRasterizerClass::~VisRasterizerClass(void) -{ - REF_PTR_RELEASE(Camera); -} - -void VisRasterizerClass::Set_Resolution(int width,int height) -{ - IDBuffer.Set_Resolution(width,height); -} - -void VisRasterizerClass::Get_Resolution(int * set_width,int * set_height) -{ - IDBuffer.Get_Resolution(set_width,set_height); -} - -void VisRasterizerClass::Set_Model_Transform(const Matrix3D & model) -{ - ModelTransform = model; - Update_MV_Transform(); -} - -void VisRasterizerClass::Set_Camera(CameraClass * camera) -{ - REF_PTR_SET(Camera,camera); - Update_MV_Transform(); -} - -CameraClass * VisRasterizerClass::Get_Camera(void) -{ - if (Camera != NULL) { - Camera->Add_Ref(); - } - return Camera; -} - -CameraClass * VisRasterizerClass::Peek_Camera(void) -{ - return Camera; -} - -void VisRasterizerClass::Update_MV_Transform(void) -{ - Matrix3D view_tm(1); - - if (Camera) { - Camera->Get_View_Matrix(&view_tm); - } - -#ifdef ALLOW_TEMPORARIES - MVTransform = view_tm * ModelTransform; -#else - MVTransform.mul(view_tm, ModelTransform); -#endif -} - -const Matrix3D & VisRasterizerClass::Get_MV_Transform(void) -{ - // TODO: optimize this - Update_MV_Transform(); // the user can and does mess with the camera directly! - return MVTransform; -} - -Vector3 * VisRasterizerClass::Get_Temp_Vertex_Buffer(int count) -{ - TempVertexBuffer.Uninitialised_Grow(count); - return &(TempVertexBuffer[0]); -} - - -bool VisRasterizerClass::Render_Triangles -( - const Vector3 * verts, - int vcount, - const TriIndex * tris, - int tcount,const - AABoxClass & bounds -) -{ - WWASSERT(verts != NULL); - WWASSERT(tris != NULL); - WWASSERT(vcount > 0); - WWASSERT(tcount > 0); - - /* - ** if the user supplied bounds, check if we need to clip - */ - if (CollisionMath::Overlap_Test(Camera->Get_Frustum(),bounds) == CollisionMath::INSIDE) { - return Render_Triangles_No_Clip(verts,vcount,tris,tcount); - } else { - return Render_Triangles_Clip(verts,vcount,tris,tcount); - } -} - - -bool VisRasterizerClass::Render_Triangles_No_Clip -( - const Vector3 * verts, - int vcount, - const TriIndex * tris, - int tcount -) -{ - bool pixel_passed = false; - - /* - ** 1. transform verts into homogeneous view space and project - */ - const Matrix3D & tm = Get_MV_Transform(); - Vector3 * tverts = Get_Temp_Vertex_Buffer(vcount); - - VectorProcessorClass::Transform(tverts,verts,tm,vcount); - - for (int i=0; iProject_Camera_Space_Point(tverts[i],tverts[i]); - } - - /* - ** 2. Pass triangles on to the ID buffer for scan conversion - */ - for (int tri_index=0; tri_indexGet_View_Space_Frustum_Planes(); - - /* - ** 3. Clip triangles to the view volume and pass on to the ID buffer for scan conversion - */ - for (int tri_index=0; tri_index= 3) { - - Vector3 * final_verts = &(_VisPoly0.Verts[0]); - - int i; - for (i=0; iProject_Camera_Space_Point(final_verts[i],final_verts[i]); - } - - /* - ** Pass the resulting triangle fan to the IDBuffer - */ - for (i=1; i 0) { - IDBuffer = W3DNEWARRAY uint32 [bufsize]; - ZBuffer = W3DNEWARRAY float [bufsize]; - } -} - -void IDBufferClass::Clear(void) -{ - if ((ResWidth > 0) && (ResHeight > 0)) { - int byte_count = ResWidth * ResWidth * sizeof(uint32); - - WWASSERT(IDBuffer != NULL); - WWASSERT(ZBuffer != NULL); - memset(IDBuffer,0,byte_count); - memset(ZBuffer,0,byte_count); - } -} - - -/** -** GradientsStruct -** Computes the gradients for a triangle. -*/ -struct GradientsStruct -{ - GradientsStruct(const Vector3 * verts) - { - float oodx = 1 / ( ((verts[1].X - verts[2].X) * (verts[0].Y - verts[2].Y)) - - ((verts[0].X - verts[2].X) * (verts[1].Y - verts[2].Y))); - float oody = -oodx; - - for(int i=0; i<3; i++) { - OOZ[i] = 1/verts[i].Z; - } - - DOOZ_DX = oodx * ( ((OOZ[1] - OOZ[2]) * (verts[0].Y - verts[2].Y)) - - ((OOZ[0] - OOZ[2]) * (verts[1].Y - verts[2].Y))); - - DOOZ_DY = oody * ( ((OOZ[1] - OOZ[2]) * (verts[0].X - verts[2].X)) - - ((OOZ[0] - OOZ[2]) * (verts[1].X - verts[2].X))); - } - - float OOZ[3]; // 1/z for each vertex - float DOOZ_DX; // change in 1/z per change in x - float DOOZ_DY; // change in 1/z per change in y -}; - - -/** -** EdgeStruct -** Can accurately scan convert an edge of a triangle. -*/ -struct EdgeStruct -{ - EdgeStruct(const GradientsStruct & grad,const Vector3 * verts,int top,int bottom) - { - Y = WWMath::Ceil(verts[top].Y); - Height = WWMath::Ceil(verts[bottom].Y) - Y; - - float y_prestep = Y - verts[top].Y; - float real_height = verts[bottom].Y - verts[top].Y; - float real_width = verts[bottom].X - verts[top].X; - - X = ((real_width * y_prestep)/real_height) + verts[top].X; - XStep = real_width / real_height; - float x_prestep = X - verts[top].X; - - OOZ = grad.OOZ[top] + y_prestep * grad.DOOZ_DY + x_prestep * grad.DOOZ_DX; - OOZStep = XStep * grad.DOOZ_DX + grad.DOOZ_DY; - } - - inline int Step(void) - { - X+=XStep; - Y++; - Height--; - OOZ+=OOZStep; - return Height; - } - - float X; // fractional x coord - float XStep; // change in x per scanline - int Y; // current y coord - int Height; // number of scanlines left - float OOZ; // current 1/z - float OOZStep; // change in 1/z per scanline -}; - - -bool IDBufferClass::Render_Triangle(const Vector3 & p0,const Vector3 & p1,const Vector3 & p2) -{ - if ((ZBuffer == NULL) || (IDBuffer == NULL)) { - return false; - } - - int pixels_passed = 0; - bool is_backfacing = Is_Backfacing(p0,p1,p2); - - if ((is_backfacing) && (TwoSidedRenderingEnabled == false)) { - if (RenderMode == NON_OCCLUDER_MODE) { - return false; - } - CurID = BackfaceID; - } else { - CurID = FrontfaceID; - } - - - - /* - ** Transform the coordinates to device coords - ** All coordinates come in with the range -1 -> +1 - */ - Vector3 points[3]; - points[0].X = 0.5f * (p0.X + 1.0f) * ResWidth; - points[1].X = 0.5f * (p1.X + 1.0f) * ResWidth; - points[2].X = 0.5f * (p2.X + 1.0f) * ResWidth; - - points[0].Y = 0.5f * (1.0f - p0.Y) * ResHeight; - points[1].Y = 0.5f * (1.0f - p1.Y) * ResHeight; - points[2].Y = 0.5f * (1.0f - p2.Y) * ResHeight; - - points[0].Z = 0.5f * (p0.Z + 1.001f) * 1000.0f; - points[1].Z = 0.5f * (p1.Z + 1.001f) * 1000.0f; - points[2].Z = 0.5f * (p2.Z + 1.001f) * 1000.0f; - - /* - ** Sort points based on Y - */ - float y0 = points[0].Y; - float y1 = points[1].Y; - float y2 = points[2].Y; - - int top,middle,bottom,middle_for_compare,bottom_for_compare; - - if(y0 < y1) { - if(y2 < y0) { - top = 2; middle = 0; bottom = 1; - middle_for_compare = 0; bottom_for_compare = 1; - } else { - top = 0; - if(y1 < y2) { - middle = 1; bottom = 2; - middle_for_compare = 1; bottom_for_compare = 2; - } else { - middle = 2; bottom = 1; - middle_for_compare = 2; bottom_for_compare = 1; - } - } - } else { - if(y2 < y1) { - top = 2; middle = 1; bottom = 0; - middle_for_compare = 1; bottom_for_compare = 0; - } else { - top = 1; - if(y0 < y2) { - middle = 0; bottom = 2; - middle_for_compare = 3; bottom_for_compare = 2; - } else { - middle = 2; bottom = 0; - middle_for_compare = 2; bottom_for_compare = 3; - } - } - } - - /* - ** Compute the gradients and set up the edge structures - */ - GradientsStruct grads(points); - EdgeStruct top_to_bottom_edge(grads,points,top,bottom); - EdgeStruct top_to_middle_edge(grads,points,top,middle); - EdgeStruct middle_to_bottom_edge(grads,points,middle,bottom); - - EdgeStruct * left_edge = NULL; - EdgeStruct * right_edge = NULL; - - bool middle_is_left = false; - if (bottom_for_compare > middle_for_compare) { - middle_is_left = 1 ^ is_backfacing; - } else { - middle_is_left = 0 ^ is_backfacing; - } - if (middle_is_left) { - left_edge = &top_to_middle_edge; - right_edge = &top_to_bottom_edge; - } else { - left_edge = &top_to_bottom_edge; - right_edge = &top_to_middle_edge; - } - - /* - ** Fill scanlines - */ - int height = top_to_middle_edge.Height; - - while (height--) { - if (RenderMode == OCCLUDER_MODE) { - pixels_passed += Render_Occluder_Scanline(grads,left_edge,right_edge); - } else { - pixels_passed += Render_Non_Occluder_Scanline(grads,left_edge,right_edge); - } - left_edge->Step(); - right_edge->Step(); - } - - if (middle_is_left) { - left_edge = &middle_to_bottom_edge; - right_edge = &top_to_bottom_edge; - } else { - left_edge = &top_to_bottom_edge; - right_edge = &middle_to_bottom_edge; - } - - height = middle_to_bottom_edge.Height; - - while (height--) { - if (RenderMode == OCCLUDER_MODE) { - pixels_passed += Render_Occluder_Scanline(grads,left_edge,right_edge); - } else { - pixels_passed += Render_Non_Occluder_Scanline(grads,left_edge,right_edge); - } - left_edge->Step(); - right_edge->Step(); - } - return (pixels_passed > 0); -} - - -int IDBufferClass::Render_Occluder_Scanline(GradientsStruct & grads,EdgeStruct * left,EdgeStruct * right) -{ - if ((left->Y < 1) || (left->Y >= ResHeight)) { - return 0; - } - - int xstart = WWMath::Float_To_Long(WWMath::Max(WWMath::Ceil(left->X),1.0f)); - int width = WWMath::Float_To_Long(WWMath::Ceil(right->X)) - xstart; - if (xstart + width > ResWidth) { - width = ResWidth - xstart; - } - - float xprestep = (float)xstart - left->X; - int address = Pixel_Coords_To_Address(xstart,left->Y); - float ooz = left->OOZ + xprestep * grads.DOOZ_DX; - int pixel_counter = 0; - - /* - ** Two separate loops, backfaces only render when LESS THAN - */ - if (CurID == BackfaceID) { - while (width-- > 0) { - if (ooz > ZBuffer[address]) { - IDBuffer[address] = CurID; - ZBuffer[address] = ooz; - pixel_counter++; - } - ooz += grads.DOOZ_DX; - address++; - } - /* - ** Front faces render when LESS THAN OR EQUAL TO - */ - } else { - while (width-- > 0) { - if (ooz >= ZBuffer[address]) { - IDBuffer[address] = CurID; - ZBuffer[address] = ooz; - pixel_counter++; - } - ooz += grads.DOOZ_DX; - address++; - } - } - - PixelCounter += pixel_counter; - return pixel_counter; -} - - -int IDBufferClass::Render_Non_Occluder_Scanline(GradientsStruct & grads,EdgeStruct * left,EdgeStruct * right) -{ - if ((left->Y < 1) || (left->Y >= ResHeight)) { - return 0; - } - - int xstart = WWMath::Float_To_Long(WWMath::Max(WWMath::Ceil(left->X),1)); - int width = WWMath::Float_To_Long(WWMath::Ceil(right->X)) - xstart; - if (xstart + width > ResWidth) { - width = ResWidth - xstart; - } - - float xprestep = (float)xstart - left->X; - int address = Pixel_Coords_To_Address(xstart,left->Y); - float ooz = left->OOZ + xprestep * grads.DOOZ_DX; - - while (width-- > 0) { - if (ooz >= ZBuffer[address]) { - PixelCounter++; - return 1; - } - ooz += grads.DOOZ_DX; - address++; - } - - return 0; -} - diff --git a/Generals/Code/Libraries/Source/WWVegas/WW3D2/visrasterizer.h b/Generals/Code/Libraries/Source/WWVegas/WW3D2/visrasterizer.h deleted file mode 100644 index 84fc42fd9e9..00000000000 --- a/Generals/Code/Libraries/Source/WWVegas/WW3D2/visrasterizer.h +++ /dev/null @@ -1,213 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** 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 *** - *********************************************************************************************** - * * - * Project Name : ww3d * - * * - * $Archive:: /Commando/Code/ww3d2/visrasterizer.h $* - * * - * Original Author:: Greg Hjelstrom * - * * - * $Author:: Jani_p $* - * * - * $Modtime:: 11/24/01 5:42p $* - * * - * $Revision:: 6 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#if defined(_MSC_VER) -#pragma once -#endif - -#ifndef VISRASTERIZER_H -#define VISRASTERIZER_H - -#include "always.h" -#include "matrix3d.h" -#include "matrix4.h" -#include "Vector3i.h" -#include "vector3.h" -#include "simplevec.h" -#include "bittype.h" -#include "plane.h" -#include "meshgeometry.h" - - -class CameraClass; -class AABoxClass; -struct GradientsStruct; -struct EdgeStruct; - -/** -** IDBufferClass -** This class manages the ID buffer and the Z buffer. It provides the low level -** rasterization code and stats about how many pixels and triangles are drawn. -*/ -class IDBufferClass -{ -public: - IDBufferClass(void); - ~IDBufferClass(void); - - /* - ** State interface - */ - void Set_Resolution(int w,int h); - void Get_Resolution(int * get_w,int * get_h); - - void Set_Backface_ID(uint32 id) { BackfaceID = id; } - void Set_Frontface_ID(uint32 id) { FrontfaceID = id; } - uint32 Get_Backface_ID(void) { return BackfaceID; } - uint32 Get_Frontface_ID(void) { return FrontfaceID; } - - void Enable_Two_Sided_Rendering(bool onoff) { TwoSidedRenderingEnabled = onoff; } - bool Is_Two_Sided_Rendering_Enabled(void) { return TwoSidedRenderingEnabled; } - - enum ModeType { OCCLUDER_MODE = 0, NON_OCCLUDER_MODE }; - void Set_Render_Mode(ModeType mode) { RenderMode = mode; } - ModeType Get_Render_Mode(void) { return RenderMode; } - - void Reset_Pixel_Counter(void) { PixelCounter = 0; } - int Get_Pixel_Counter(void) { return PixelCounter; } - - /* - ** Rendering interface - */ - void Clear(void); - bool Render_Triangle(const Vector3 & p0,const Vector3 & p1,const Vector3 & p2); - const uint32 * Get_Pixel_Row(int y,int min_x,int max_x); - -protected: - void Reset(void); - void Allocate_Buffers(void); - bool Is_Backfacing(const Vector3 & p0,const Vector3 & p1,const Vector3 & p2); - int Render_Occluder_Scanline(GradientsStruct & grads,EdgeStruct * left,EdgeStruct * right); - int Render_Non_Occluder_Scanline(GradientsStruct & grads,EdgeStruct * left,EdgeStruct * right); - int Pixel_Coords_To_Address(int x,int y) { return y*ResWidth + x; } - - uint32 BackfaceID; - uint32 FrontfaceID; - uint32 CurID; - int PixelCounter; - ModeType RenderMode; - bool TwoSidedRenderingEnabled; - - int ResWidth; - int ResHeight; - uint32 * IDBuffer; - float * ZBuffer; // actually a 1/z buffer... -}; - -inline const uint32 * IDBufferClass::Get_Pixel_Row(int y,int min_x,int max_x) -{ - WWASSERT(y>=0); - WWASSERT(y=0); - WWASSERT(max_x<=ResWidth); - - int addr = Pixel_Coords_To_Address(min_x,y); - return &(IDBuffer[addr]); -} - -inline bool IDBufferClass::Is_Backfacing(const Vector3 & p0,const Vector3 & p1,const Vector3 & p2) -{ - float x1=p1[0]-p0[0]; - float y1=p1[1]-p0[1]; - float x2=p2[0]-p0[0]; - float y2=p2[1]-p0[1]; - float r=x1*y2-x2*y1; - if (r<0.0f) return true; - return false; -} - - - - -/** -** VisRasterizerClass -** This class encapsulates the "ID buffer rasterization" code needed by the vis system. Basically -** it is a floating point z-buffer and an id buffer which is used by the visiblity precalculation system. -** The VisRasterizer will transform and clip triangles into homogeneous view space; then the clipped -** triangles will be passed on to the IDBufferClass which will scan convert them. -*/ -class VisRasterizerClass -{ -public: - - VisRasterizerClass(void); - ~VisRasterizerClass(void); - - /* - ** ID Buffer Interface - */ - void Set_Render_Mode(IDBufferClass::ModeType mode) { IDBuffer.Set_Render_Mode(mode); } - IDBufferClass::ModeType Get_Render_Mode(void) { return IDBuffer.Get_Render_Mode(); } - - void Set_Backface_ID(uint32 id) { IDBuffer.Set_Backface_ID(id); } - void Set_Frontface_ID(uint32 id) { IDBuffer.Set_Frontface_ID(id); } - uint32 Get_Backface_ID(void) { return IDBuffer.Get_Backface_ID(); } - uint32 Get_Frontface_ID(void) { return IDBuffer.Get_Frontface_ID(); } - - void Enable_Two_Sided_Rendering(bool onoff) { IDBuffer.Enable_Two_Sided_Rendering(onoff); } - bool Is_Two_Sided_Rendering_Enabled(void) { return IDBuffer.Is_Two_Sided_Rendering_Enabled(); } - - void Set_Resolution(int width,int height); - void Get_Resolution(int * set_width,int * set_height); - - void Reset_Pixel_Counter(void) { IDBuffer.Reset_Pixel_Counter(); } - int Get_Pixel_Counter(void) { return IDBuffer.Get_Pixel_Counter(); } - - /* - ** Rendering Interface - */ - void Set_Model_Transform(const Matrix3D & model); - void Set_Camera(CameraClass * camera); - - const Matrix3D & Get_Model_Transform(void); - CameraClass * Get_Camera(void); - CameraClass * Peek_Camera(void); - - void Clear(void) { IDBuffer.Clear(); } - bool Render_Triangles(const Vector3 * verts,int vcount,const TriIndex * tris, int tcount,const AABoxClass & bounds); - const uint32 * Get_Pixel_Row(int y,int min_x,int max_x) { return IDBuffer.Get_Pixel_Row(y,min_x,max_x); } - -protected: - - void Update_MV_Transform(void); - const Matrix3D & Get_MV_Transform(void); - Vector3 * Get_Temp_Vertex_Buffer(int count); - bool Render_Triangles_Clip(const Vector3 * verts,int vcount,const TriIndex * tris, int tcount); - bool Render_Triangles_No_Clip(const Vector3 * verts,int vcount,const TriIndex * tris, int tcount); - - Matrix3D ModelTransform; // AKA "World Transform" - CameraClass * Camera; - Matrix3D MVTransform; - - IDBufferClass IDBuffer; - - SimpleVecClass TempVertexBuffer; -}; - -#endif //VISRASTERIZER_H - diff --git a/Generals/Code/Libraries/Source/WWVegas/WW3D2/w3d_dep.cpp b/Generals/Code/Libraries/Source/WWVegas/WW3D2/w3d_dep.cpp deleted file mode 100644 index 9cb674162ee..00000000000 --- a/Generals/Code/Libraries/Source/WWVegas/WW3D2/w3d_dep.cpp +++ /dev/null @@ -1,575 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** 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 *** - *********************************************************************************************** - * * - * Project Name : G * - * * - * $Archive:: /Commando/Code/ww3d2/w3d_dep.cpp $* - * * - * $Author:: Byon_g $* - * * - * $Modtime:: 7/23/01 6:17p $* - * * - * $Revision:: 4 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * Get_W3D_Dependencies -- Scans a W3D file to determine which other files it depends on. * - * Scan_Chunk -- Chooses the correct chunk loader for this chunk. * - * Scan_Mesh -- Scans a mesh for references to other files. * - * Scan_Mesh_Header -- Scans a mesh's header for file references. * - * Scan_Mesh_Textures -- Scans a mesh's textures. * - * Scan_HTree -- Scans an HTree for references to other files. * - * Scan_Anim -- Scans an animation for references to other files. * - * Scan_Compressed_Anim -- Scans an animation for references to other files. * - * Scan_HModel -- Scans an HModel for references to other files. * - * Scan_Emitter -- Scans an emitter for references to other files. * - * Scan_Aggregate -- Scans an aggregate for references to other files. * - * Scan_HLOD -- Scans an HLOD for references to other files. * - * Get_W3D_Name -- Gets a W3D object name from a W3D filename. * - * Make_W3D_Filename -- Converts a W3D object name into a W3D filename. * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -//----------------------------------------------------------------------------- -// srj sez: hack festival :-( -class STLSpecialAlloc -{ -public: - // this one is needed for proper simple_alloc wrapping - static void* allocate(size_t __n) { return ::operator new(__n); } - static void deallocate(void* __p, size_t) { ::operator delete(__p); } -}; - - -#include "w3d_dep.h" -#include "w3d_file.h" -#include -#include -#include "ffactory.h" - - -/* -** Forward declarations. -*/ - -static void Scan_Chunk (ChunkLoadClass &cload, StringList &files, const char *w3d_name); - -static void Scan_Mesh (ChunkLoadClass &cload, StringList &files, const char *w3d_name); -static void Scan_Mesh_Header (ChunkLoadClass &cload, StringList &files, const char *w3d_name); -static void Scan_Mesh_Textures (ChunkLoadClass &cload, StringList &files, const char *w3d_name); - -static void Scan_Anim (ChunkLoadClass &cload, StringList &files, const char *w3d_name); -static void Scan_Compressed_Anim (ChunkLoadClass &cload, StringList &files, const char *w3d_name); -static void Scan_HModel (ChunkLoadClass &cload, StringList &files, const char *w3d_name); -static void Scan_Emitter (ChunkLoadClass &cload, StringList &files, const char *w3d_name); -static void Scan_Aggregate (ChunkLoadClass &cload, StringList &files, const char *w3d_name); -static void Scan_HLOD (ChunkLoadClass &cload, StringList &files, const char *w3d_name); - -static void Get_W3D_Name (const char *filename, char *w3d_name); -static const char * Make_W3D_Filename (const char *w3d_name); - - -/*********************************************************************************************** - * Get_W3D_Dependencies -- Scans a W3D file to determine which other files it depends on. * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 4/3/00 AJA : Created. * - *=============================================================================================*/ -bool Get_W3D_Dependencies (const char *w3d_filename, StringList &files) -{ - assert(w3d_filename); - - // Open the W3D file. - FileClass *file=_TheFileFactory->Get_File(w3d_filename); - if ( file ) { - file->Open(); - if ( ! file->Is_Open()) { - _TheFileFactory->Return_File(file); - file=NULL; - return false; - } - } else { - return false; - } - - // Get the W3D name from the filename. - char w3d_name[W3D_NAME_LEN]; - Get_W3D_Name(w3d_filename, w3d_name); - - // Create a chunk loader for this file, and scan the file. - ChunkLoadClass cload(file); - while (cload.Open_Chunk()) - { - Scan_Chunk(cload, files, w3d_name); - cload.Close_Chunk(); - } - - // Close the file. - file->Close(); - _TheFileFactory->Return_File(file); - file=NULL; - - // Sort the set of filenames, and remove any duplicates. - files.sort(); - files.unique(); - - return true; -} - - -/*********************************************************************************************** - * Scan_Chunk -- Chooses the correct chunk loader for this chunk. * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 4/3/00 AJA : Created. * - *=============================================================================================*/ -static void Scan_Chunk (ChunkLoadClass &cload, StringList &files, const char *w3d_name) -{ - assert(w3d_name); - - switch (cload.Cur_Chunk_ID()) - { - case W3D_CHUNK_MESH: - Scan_Mesh(cload, files, w3d_name); - break; - - case W3D_CHUNK_ANIMATION: - Scan_Anim(cload, files, w3d_name); - break; - - case W3D_CHUNK_COMPRESSED_ANIMATION: - Scan_Compressed_Anim(cload, files, w3d_name); - break; - - case W3D_CHUNK_HMODEL: - Scan_HModel(cload, files, w3d_name); - break; - - case W3D_CHUNK_EMITTER: - Scan_Emitter(cload, files, w3d_name); - break; - - case W3D_CHUNK_AGGREGATE: - Scan_Aggregate(cload, files, w3d_name); - break; - - case W3D_CHUNK_HLOD: - Scan_HLOD(cload, files, w3d_name); - break; - } -} - - -/*********************************************************************************************** - * Scan_Mesh -- Scans a mesh for references to other files. * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - *=============================================================================================*/ -static void Scan_Mesh (ChunkLoadClass &cload, StringList &files, const char *w3d_name) -{ - // Scan the mesh's sub-chunks. - while (cload.Open_Chunk()) - { - switch (cload.Cur_Chunk_ID()) - { - case W3D_CHUNK_MESH_HEADER3: - // Ahh, the mesh header. - Scan_Mesh_Header(cload, files, w3d_name); - break; - - case W3D_CHUNK_TEXTURES: - // We sure want textures... - Scan_Mesh_Textures(cload, files, w3d_name); - break; - } - cload.Close_Chunk(); - } -} - -/*********************************************************************************************** - * Scan_Mesh_Header -- Scans a mesh's header for file references. * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 4/3/00 AJA : Created. * - *=============================================================================================*/ -static void Scan_Mesh_Header (ChunkLoadClass &cload, StringList &files, const char *w3d_name) -{ - // In the mesh header, we want the 'ContainerName' string. - W3dMeshHeader3Struct hdr; - cload.Read(&hdr, sizeof(hdr)); - if (strcmp(hdr.ContainerName, w3d_name) != 0) - { - // The container is not this file... Create a W3D filename - // for the container object and add it to the list of - // files we refer to. - const char *filename = Make_W3D_Filename(hdr.ContainerName); - if (*filename) // don't push empty filenames - files.push_back(filename); - } -} - -/*********************************************************************************************** - * Scan_Mesh_Textures -- Scans a mesh's textures. * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 4/3/00 AJA : Created. * - *=============================================================================================*/ -static void Scan_Mesh_Textures (ChunkLoadClass &cload, StringList &files, const char *w3d_name) -{ - // Let's see which textures are used by this mesh... - while (cload.Open_Chunk()) - { - // We're interested in the TEXTURE sub-chunk. - if (cload.Cur_Chunk_ID() == W3D_CHUNK_TEXTURE) - { - while (cload.Open_Chunk()) - { - // We're interested in the TEXTURE_NAME sub-chunk. - if (cload.Cur_Chunk_ID() == W3D_CHUNK_TEXTURE_NAME) - { - // This chunk's data is a NULL-terminated string - // which is the texture filename. Read it and - // add it to the list of files referred to. - char texture[_MAX_PATH]; - cload.Read(texture, cload.Cur_Chunk_Length()); - if (*texture) // don't push empty filenames - files.push_back(texture); - } - cload.Close_Chunk(); - } - } - cload.Close_Chunk(); - } -} - - -/*********************************************************************************************** - * Scan_Anim -- Scans an animation for references to other files. * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - *=============================================================================================*/ -static void Scan_Anim (ChunkLoadClass &cload, StringList &files, const char *w3d_name) -{ - while (cload.Open_Chunk()) - { - // We only want the animation header, because it can refer to an HTree. - if (cload.Cur_Chunk_ID() == W3D_CHUNK_ANIMATION_HEADER) - { - // Read in the header. - W3dAnimHeaderStruct hdr; - cload.Read(&hdr, sizeof(hdr)); - if (strcmp(hdr.HierarchyName, w3d_name) != 0) - { - const char *hierarchy = Make_W3D_Filename(hdr.HierarchyName); - if (*hierarchy) // don't push an empty filename - files.push_back(hierarchy); - } - } - cload.Close_Chunk(); - } -} - - -/*********************************************************************************************** - * Scan_Compressed_Anim -- Scans a compressed animation mesh for references to other files. * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - *=============================================================================================*/ -static void Scan_Compressed_Anim (ChunkLoadClass &cload, StringList &files, const char *w3d_name) -{ - while (cload.Open_Chunk()) - { - // We only want the animation header, because it can refer to an HTree. - if (cload.Cur_Chunk_ID() == W3D_CHUNK_ANIMATION_HEADER) - { - // Read in the header. - W3dCompressedAnimHeaderStruct hdr; - cload.Read(&hdr, sizeof(hdr)); - if (strcmp(hdr.HierarchyName, w3d_name) != 0) - { - const char *hierarchy = Make_W3D_Filename(hdr.HierarchyName); - if (*hierarchy) // don't push an empty filename - files.push_back(hierarchy); - } - } - cload.Close_Chunk(); - } -} - - -/*********************************************************************************************** - * Scan_HModel -- Scans an HModel for references to other files. * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - *=============================================================================================*/ -static void Scan_HModel (ChunkLoadClass &cload, StringList &files, const char *w3d_name) -{ - while (cload.Open_Chunk()) - { - // We only want the header because it can refer to an HTree. - if (cload.Cur_Chunk_ID() == W3D_CHUNK_HMODEL_HEADER) - { - // Read in the header. - W3dHModelHeaderStruct hdr; - cload.Read(&hdr, sizeof(hdr)); - if (strcmp(hdr.HierarchyName, w3d_name) != 0) - { - const char *hierarchy = Make_W3D_Filename(hdr.HierarchyName); - if (*hierarchy) // don't push an empty filename - files.push_back(hierarchy); - } - } - cload.Close_Chunk(); - } -} - - -/*********************************************************************************************** - * Scan_Emitter -- Scans an emitter for references to other files. * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - *=============================================================================================*/ -static void Scan_Emitter (ChunkLoadClass &cload, StringList &files, const char *w3d_name) -{ - while (cload.Open_Chunk()) - { - // We only want the emitter info chunk, it has a texture name in it. - if (cload.Cur_Chunk_ID() == W3D_CHUNK_EMITTER_INFO) - { - // Read in the header. - W3dEmitterInfoStruct hdr; - cload.Read(&hdr, sizeof(hdr)); - if (hdr.TextureFilename[0]) // don't push an empty texture name - files.push_back(hdr.TextureFilename); - } - cload.Close_Chunk(); - } -} - - -/*********************************************************************************************** - * Scan_Aggregate -- Scans an aggregate for references to other files. * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - *=============================================================================================*/ -static void Scan_Aggregate (ChunkLoadClass &cload, StringList &files, const char *w3d_name) -{ - while (cload.Open_Chunk()) - { - // We want the aggregate info chunk. - if (cload.Cur_Chunk_ID() == W3D_CHUNK_AGGREGATE_INFO) - { - W3dAggregateInfoStruct chunk; - cload.Read(&chunk, sizeof(chunk)); - if (strcmp(chunk.BaseModelName, w3d_name) != 0) - { - // Check the name of the base model against the name of this file. - const char *base_model = Make_W3D_Filename(chunk.BaseModelName); - if (*base_model) - files.push_back(base_model); - } - - // Iterate through the sub-objects. - unsigned int i; - for (i = 0; i < chunk.SubobjectCount; ++i) - { - W3dAggregateSubobjectStruct subchunk; - cload.Read(&subchunk, sizeof(subchunk)); - if (strcmp(subchunk.SubobjectName, w3d_name) != 0) - { - // Check the name of the subobject against the name of this file. - const char *subobject = Make_W3D_Filename(subchunk.SubobjectName); - if (*subobject) - files.push_back(subobject); - } - } - } - cload.Close_Chunk(); - } -} - - -/*********************************************************************************************** - * Scan_HLOD -- Scans an HLOD for references to other files. * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - *=============================================================================================*/ -static void Scan_HLOD (ChunkLoadClass &cload, StringList &files, const char *w3d_name) -{ - while (cload.Open_Chunk()) - { - // We only want the header. - if (cload.Cur_Chunk_ID() == W3D_CHUNK_HLOD_HEADER) - { - W3dHLodHeaderStruct hdr; - cload.Read(&hdr, sizeof(hdr)); - if (strcmp(hdr.HierarchyName, w3d_name) != 0) - { - const char *hierarchy = Make_W3D_Filename(hdr.HierarchyName); - if (*hierarchy) - files.push_back(hierarchy); - } - } - cload.Close_Chunk(); - } -} - - -/*********************************************************************************************** - * Get_W3D_Name -- Gets a W3D object name from a W3D filename. * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 4/3/00 AJA : Created. * - *=============================================================================================*/ -static void Get_W3D_Name (const char *filename, char *w3d_name) -{ - assert(filename); - assert(w3d_name); - - // Figure out the first character of the name of the file - // (bypass the path if it was given). - const char *start = strrchr(filename, '\\'); - if (start) - ++start; // point to first character after the last backslash - else - start = filename; // point to the start of the filename - - // We don't want to copy the .w3d extension. Find where - // it occurs. - const char *end = strrchr(start, '.'); - if (!end) - end = start + strlen(start); // point to the null character - - // Copy all characters from start to end (excluding 'end') - // into the w3d_name buffer. Then capitalize the string. - memset(w3d_name, 0, W3D_NAME_LEN); // blank out the buffer - int num_chars = end - start; - strncpy(w3d_name, start, num_chars < W3D_NAME_LEN ? num_chars : W3D_NAME_LEN-1); - strupr(w3d_name); -} - - -/*********************************************************************************************** - * Make_W3D_Filename -- Converts a W3D object name into a W3D filename. * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 4/3/00 AJA : Created. * - *=============================================================================================*/ -static const char * Make_W3D_Filename (const char *w3d_name) -{ - assert(w3d_name); - assert(strlen(w3d_name) < W3D_NAME_LEN); - - // Copy the w3d name into a static buffer, turn it into lowercase - // letters, and append a ".w3d" file extension. That's the filename. - static char buffer[64]; - if (*w3d_name == 0) - { - // Empty W3D name case. - buffer[0] = 0; - return buffer; - } - strcpy(buffer, w3d_name); - char *dot = strchr(buffer, '.'); - if (dot) - *dot = 0; - strlwr(buffer); - strcat(buffer, ".w3d"); - return buffer; -} diff --git a/Generals/Code/Libraries/Source/WWVegas/WW3D2/w3d_dep.h b/Generals/Code/Libraries/Source/WWVegas/WW3D2/w3d_dep.h deleted file mode 100644 index e834ad3ad84..00000000000 --- a/Generals/Code/Libraries/Source/WWVegas/WW3D2/w3d_dep.h +++ /dev/null @@ -1,54 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** 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 *** - *********************************************************************************************** - * * - * Project Name : G * - * * - * $Archive:: /Commando/Code/ww3d2/w3d_dep.h $* - * * - * $Author:: Greg_h $* - * * - * $Modtime:: 1/08/01 10:04a $* - * * - * $Revision:: 1 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#ifndef W3D_DEP_H -#define W3D_DEP_H - -#pragma warning (push, 3) -#pragma warning (disable: 4018 4284 4786 4788) -#include -#pragma warning (pop) - -#pragma warning (push, 3) -#pragma warning (disable: 4018 4146 4284 4503) -#include -#include -#pragma warning (pop) - -typedef std::list StringList; -bool Get_W3D_Dependencies (const char *w3d_filename, StringList &files); - -#endif diff --git a/Generals/Code/Libraries/Source/WWVegas/WW3D2/w3d_obsolete.h b/Generals/Code/Libraries/Source/WWVegas/WW3D2/w3d_obsolete.h deleted file mode 100644 index c96ecf70b5d..00000000000 --- a/Generals/Code/Libraries/Source/WWVegas/WW3D2/w3d_obsolete.h +++ /dev/null @@ -1,333 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** 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 *** - *********************************************************************************************** - * * - * Project Name : WW3D * - * * - * $Archive:: /Commando/Code/ww3d2/w3d_obsolete.h $* - * * - * Author:: Greg Hjelstrom * - * * - * $Modtime:: 1/08/01 10:04a $* - * * - * $Revision:: 1 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - - -#if defined(_MSC_VER) -#pragma once -#endif - -#ifndef W3D_OBSOLETE_H -#define W3D_OBSOLETE_H - - -///////////////////////////////////////////////////////////////////////////////////////////// -// Obsolete chunk id's -// At one point in time I was using the 'O' prefix to mean obsolete. Now we just move stuff -// into this file... -///////////////////////////////////////////////////////////////////////////////////////////// -enum -{ - W3D_CHUNK_MESH_HEADER =0x00000001, // header for a mesh - W3D_CHUNK_SURRENDER_NORMALS =0x00000004, // array of surrender normals (one per vertex as req. by surrender) - W3D_CHUNK_TEXCOORDS =0x00000005, // array of texture coordinates - O_W3D_CHUNK_MATERIALS =0x00000006, // array of materials - O_W3D_CHUNK_TRIANGLES =0x00000007, // array of triangles - O_W3D_CHUNK_QUADRANGLES =0x00000008, // array of quads - O_W3D_CHUNK_SURRENDER_TRIANGLES =0x00000009, // array of surrender format tris - O_W3D_CHUNK_POV_TRIANGLES =0x0000000A, // POV format triangles - O_W3D_CHUNK_POV_QUADRANGLES =0x0000000B, // POV format quads - W3D_CHUNK_VERTEX_COLORS =0x0000000D, // Pre-set vertex coloring - W3D_CHUNK_DAMAGE =0x0000000F, // Mesh damage, new set of materials, vertex positions, vertex colors - W3D_CHUNK_DAMAGE_HEADER =0x00000010, // Header for the damage data, tells what is coming - W3D_CHUNK_DAMAGE_VERTICES =0x00000011, // Array of modified vertices (W3dMeshDamageVertexStruct's) - W3D_CHUNK_DAMAGE_COLORS =0x00000012, // Array of modified vert colors (W3dMeshDamageColorStruct's) - W3D_CHUNK_DAMAGE_MATERIALS =0x00000013, - - O_W3D_CHUNK_MATERIALS2 =0x00000014, // array of version 2 materials (with animation frame counts) - - W3D_CHUNK_MATERIALS3 =0x00000015, // array of version 3 materials (all new surrender features supported) - W3D_CHUNK_MATERIAL3 =0x00000016, // Each version 3 material wrapped with this chunk ID - W3D_CHUNK_MATERIAL3_NAME =0x00000017, // Name of the material (array of chars, null terminated) - W3D_CHUNK_MATERIAL3_INFO =0x00000018, // contains a W3dMaterial3Struct, general material info - W3D_CHUNK_MATERIAL3_DC_MAP =0x00000019, // wraps the following two chunks, diffuse color texture - W3D_CHUNK_MAP3_FILENAME =0x0000001A, // filename of the texture - W3D_CHUNK_MAP3_INFO =0x0000001B, // a W3dMap3Struct - W3D_CHUNK_MATERIAL3_DI_MAP =0x0000001C, // diffuse illimination map, same format as other maps - W3D_CHUNK_MATERIAL3_SC_MAP =0x0000001D, // specular color map, same format as other maps - W3D_CHUNK_MATERIAL3_SI_MAP =0x0000001E, // specular illumination map, same format as other maps - W3D_CHUNK_PER_TRI_MATERIALS =0x00000021, // Multi-Mtl meshes - An array of uint16 material id's -}; - - -///////////////////////////////////////////////////////////////////////////////////////////// -// Version 1.0 Material, array of these are found inside the W3D_CHUNK_MATERIALS chunk. -///////////////////////////////////////////////////////////////////////////////////////////// -struct W3dMaterialStruct -{ - char MaterialName[W3D_NAME_LEN]; // name of the material (NULL terminated) - char PrimaryName[W3D_NAME_LEN]; // primary texture name (NULL terminated) - char SecondaryName[W3D_NAME_LEN]; // secondary texture name (NULL terminated) - uint32 RenderFlags; // Rendering flags - uint8 Red; // Rgb colors - uint8 Green; - uint8 Blue; -}; - -///////////////////////////////////////////////////////////////////////////////////////////// -// Version 2.0 Material, array of these are found inside the W3D_CHUNK_MATERIALS2 chunk. -///////////////////////////////////////////////////////////////////////////////////////////// -struct W3dMaterial2Struct -{ - char MaterialName[W3D_NAME_LEN]; // name of the material (NULL terminated) - char PrimaryName[W3D_NAME_LEN]; // primary texture name (NULL terminated) - char SecondaryName[W3D_NAME_LEN]; // secondary texture name (NULL terminated) - uint32 RenderFlags; // Rendering flags - uint8 Red; // Rgb colors - uint8 Green; - uint8 Blue; - uint8 Alpha; - - uint16 PrimaryNumFrames; // number of animated frames (if 1, not animated) - uint16 SecondaryNumFrames; // number of animated frames (if 1, not animated) - - char Pad[12]; // expansion room -}; - - -///////////////////////////////////////////////////////////////////////////////////////////// -// MATERIAL ATTRIBUTES (version 3.0 onward) -///////////////////////////////////////////////////////////////////////////////////////////// -// Use alpha enables alpha channels, etc, Use sorting causes display lists using -// this material to be sorted (even with z-buf, translucent materials need to be sorted) -#define W3DMATERIAL_USE_ALPHA 0x00000001 -#define W3DMATERIAL_USE_SORTING 0x00000002 - -// Hints for render devices that cannot support all features -#define W3DMATERIAL_HINT_DIT_OVER_DCT 0x00000010 -#define W3DMATERIAL_HINT_SIT_OVER_SCT 0x00000020 -#define W3DMATERIAL_HINT_DIT_OVER_DIG 0x00000040 -#define W3DMATERIAL_HINT_SIT_OVER_SIG 0x00000080 -#define W3DMATERIAL_HINT_FAST_SPECULAR_AFTER_ALPHA 0x00000100 - -// Last byte is for PSX: Translucency type and a lighting disable flag. -#define W3DMATERIAL_PSX_MASK 0xFF000000 -#define W3DMATERIAL_PSX_TRANS_MASK 0x07000000 -#define W3DMATERIAL_PSX_TRANS_NONE 0x00000000 -#define W3DMATERIAL_PSX_TRANS_100 0x01000000 -#define W3DMATERIAL_PSX_TRANS_50 0x02000000 -#define W3DMATERIAL_PSX_TRANS_25 0x03000000 -#define W3DMATERIAL_PSX_TRANS_MINUS_100 0x04000000 -#define W3DMATERIAL_PSX_NO_RT_LIGHTING 0x08000000 - -///////////////////////////////////////////////////////////////////////////////////////////// -// MAPPING TYPES (version 3.0 onward) -///////////////////////////////////////////////////////////////////////////////////////////// -#define W3DMAPPING_UV 0 -#define W3DMAPPING_ENVIRONMENT 1 - -///////////////////////////////////////////////////////////////////////////////////////////// -// Version 3.0 Material, A W3D_CHUNK_MATERIALS3 chunk will wrap a bunch of -// W3D_CHUNK_MATERIAL3 chunks. Inside each chunk will be a name chunk, an 'info' chunk which -// contains the following struct, and one or more map chunks. a mesh with 2 materials might -// look like: -// -// W3D_CHUNK_MATERIALS3 <-- simply a wrapper around the array of mtls -// W3D_CHUNK_MATERIAL3 <-- a wrapper around each material -// W3D_CHUNK_STRING <-- name of the material -// W3D_CHUNK_MATERIAL3_INFO <-- standard material properties, a W3dMaterial3Struct -// W3D_CHUNK_MATERIAL3_DC_MAP <-- a map, W3dMap3Struct -// W3D_CHUNK_STRING <-- filename of the map -// W3D_CHUNK_MAP_INFO <-- map parameters -// W3D_CHUNK_MATERIAL3_SC_MAP -// W3D_CHUNK_STRING <-- filename of the map -// W3D_CHUNK_MAP_INFO -// W3D_CHUNK_MATERIAL3 -// W3D_CHUNK_MATERIAL3_NAME -// W3D_CHUNK_MATERIAL3_INFO -// W3D_CHUNK_MATERIAL3_SI_MAP -// -///////////////////////////////////////////////////////////////////////////////////////////// -struct W3dMaterial3Struct -{ - uint32 Attributes; // flags,hints,etc. - - W3dRGBStruct DiffuseColor; // diffuse color - W3dRGBStruct SpecularColor; // specular color - - W3dRGBStruct EmissiveCoefficients; // emmissive coefficients, default to 0,0,0 - W3dRGBStruct AmbientCoefficients; // ambient coefficients, default to 1,1,1 - W3dRGBStruct DiffuseCoefficients; // diffuse coeficients, default to 1,1,1 - W3dRGBStruct SpecularCoefficients; // specular coefficients, default to 0,0,0 - - float32 Shininess; // how tight the specular highlight will be, 1 - 1000 (default = 1) - float32 Opacity; // how opaque the material is, 0.0 = invisible, 1.0 = fully opaque (default = 1) - float32 Translucency; // how much light passes through the material. (default = 0) - float32 FogCoeff; // effect of fog (0.0=not fogged, 1.0=fogged) (default = 1) -}; - - -///////////////////////////////////////////////////////////////////////////////////////////// -// A map, only occurs as part of a material, will be preceeded by its name. -///////////////////////////////////////////////////////////////////////////////////////////// -struct W3dMap3Struct -{ - uint16 MappingType; // Mapping type, will be one of the above #defines (e.g. W3DMAPPING_UV) - uint16 FrameCount; // Number of frames (1 if not animated) - float32 FrameRate; // Frame rate, frames per second in floating point -}; - - -///////////////////////////////////////////////////////////////////////////////////////////// -// A triangle, occurs inside the W3D_CHUNK_SURRENDER_TRIANGLES chunk -///////////////////////////////////////////////////////////////////////////////////////////// -struct W3dSurrenderTriStruct -{ - uint32 Vindex[3]; // vertex, vert normal, and texture coord indexes (all use same index) - W3dTexCoordStruct TexCoord[3]; // texture coordinates (OBSOLETE!!!) - uint32 MaterialIdx; // material index - W3dVectorStruct Normal; // Face normal - uint32 Attributes; // collision flags, sort method, etc - W3dRGBStruct Gouraud[3]; // Pre-set shading values (OBSOLETE!!!) -}; - -///////////////////////////////////////////////////////////////////////////////////////////// -// Original (Obsolete) Mesh Header -///////////////////////////////////////////////////////////////////////////////////////////// -struct W3dMeshHeaderStruct -{ - uint32 Version; // Currently version 0x100 - char MeshName[W3D_NAME_LEN]; // name of the mesh (Null terminated) - uint32 Attributes; - - // - // Counts, these can be regarded as an inventory of what is to come in the file. - // - uint32 NumTris; // number of triangles (OBSOLETE!) - uint32 NumQuads; // number of quads; (OBSOLETE!) - uint32 NumSrTris; // number of triangles - - uint32 NumPovTris; // (NOT USED) - uint32 NumPovQuads; // (NOT USED) - - uint32 NumVertices; // number of unique vertices - uint32 NumNormals; // number of unique normals (OBSOLETE!) - uint32 NumSrNormals; // number of surrender normals (MUST EQUAL NumVertices or 0) - - uint32 NumTexCoords; // number of unique texture coords (MUST EQUAL NumVertices or 0) - uint32 NumMaterials; // number of unique materials needed - - uint32 NumVertColors; // number of vertex colors (MUST EQUAL NumVertices or 0) - uint32 NumVertInfluences;// vertex influences(MUST EQUAL NumVertices or 0) - uint32 NumDamageStages; // number of damage offset chunks - uint32 FutureCounts[5]; // reserve space for future counts (set to zero). - - // - // LOD controls - // - float32 LODMin; // min LOD distance - float32 LODMax; // max LOD distance - - // - // Collision / rendering quick-rejection - // - W3dVectorStruct Min; // Min corner of the bounding box - W3dVectorStruct Max; // Max corner of the bounding box - W3dVectorStruct SphCenter; // Center of bounding sphere - float32 SphRadius; // Bounding sphere radius - - // - // Default transformation - // - W3dVectorStruct Translation; - float32 Rotation[9]; - - // - // Physics Properties - // - W3dVectorStruct MassCenter; // Center of mass in object space - float32 Inertia[9]; // Inertia tensor (relative to MassCenter) - float32 Volume; // volume of the object - - // - // Name of possible hierarchy this mesh should be attached to - // - char HierarchyTreeName[W3D_NAME_LEN]; - char HierarchyModelName[W3D_NAME_LEN]; - uint32 FutureUse[24]; // Reserved for future use -}; - - -// -// Mesh Damage. This can include a new set of materials for the mesh, -// new positions for certain vertices in the mesh, and new vertex -// colors for certain vertices. -// -struct W3dMeshDamageStruct -{ - uint32 NumDamageMaterials; // number of materials to replace - uint32 NumDamageVerts; // number of vertices to replace - uint32 NumDamageColors; // number of vertex colors to replace - uint32 DamageIndex; // what index is this damage chunk assigned to - uint32 FutureUse[4]; -}; - -struct W3dMeshDamageVertexStruct -{ - uint32 VertexIndex; - W3dVectorStruct NewVertex; -}; - -struct W3dMeshDamageColorStruct -{ - uint32 VertexIndex; - W3dRGBStruct NewColor; -}; - - - -// -// W3dHModelAuxDataStruct. HModels had this extra chunk defining the counts of individual -// types of objects to be found in the model and some obsolete distance-based LOD settings. -// As changes were made to the ww3d library, all of this became useles so the chunk was -// "retired". -// -struct W3dHModelAuxDataStruct -{ - uint32 Attributes; - uint32 MeshCount; - uint32 CollisionCount; - uint32 SkinCount; - uint32 ShadowCount; - uint32 NullCount; - uint32 FutureCounts[6]; - - float32 LODMin; - float32 LODMax; - uint32 FutureUse[32]; -}; - - -#endif // W3D_OBSOLETE_H diff --git a/Generals/Code/Libraries/Source/WWVegas/WW3D2/w3d_util.cpp b/Generals/Code/Libraries/Source/WWVegas/WW3D2/w3d_util.cpp deleted file mode 100644 index 63ce64c1477..00000000000 --- a/Generals/Code/Libraries/Source/WWVegas/WW3D2/w3d_util.cpp +++ /dev/null @@ -1,142 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** 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 *** - *********************************************************************************************** - * * - * Project Name : WW3D * - * * - * $Archive:: /Commando/Code/ww3d2/w3d_util.cpp $* - * * - * Author:: Greg Hjelstrom * - * * - * $Modtime:: 7/23/01 5:31p $* - * * - * $Revision:: 5 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - - -#include "w3d_util.h" -#include "vector3.h" -#include "vector4.h" -#include "quat.h" -#include "shader.h" - - -void W3dUtilityClass::Convert_Vector(const W3dVectorStruct & v,Vector3 * set) -{ - set->X = v.X; - set->Y = v.Y; - set->Z = v.Z; -} - -void W3dUtilityClass::Convert_Vector(const Vector3 & v,W3dVectorStruct * set) -{ - set->X = v.X; - set->Y = v.Y; - set->Z = v.Z; -} - -void W3dUtilityClass::Convert_Quaternion(const W3dQuaternionStruct & q,Quaternion * set) -{ - set->X = q.Q[0]; - set->Y = q.Q[1]; - set->Z = q.Q[2]; - set->W = q.Q[3]; -} - -void W3dUtilityClass::Convert_Quaternion(const Quaternion & q,W3dQuaternionStruct * set) -{ - set->Q[0] = q.X; - set->Q[1] = q.Y; - set->Q[2] = q.Z; - set->Q[3] = q.W; -} - -void W3dUtilityClass::Convert_Color(const W3dRGBStruct & rgb,Vector3 * set) -{ - set->X = (float)rgb.R / 255.0f; - set->Y = (float)rgb.G / 255.0f; - set->Z = (float)rgb.B / 255.0f; -} - -void W3dUtilityClass::Convert_Color(const Vector3 & v,W3dRGBStruct * color) -{ - color->R = (uint8)(255.0f * v.X); - color->G = (uint8)(255.0f * v.Y); - color->B = (uint8)(255.0f * v.Z); - color->pad = 0; -} - -void W3dUtilityClass::Convert_Color(const W3dRGBAStruct & rgb,Vector4 * set) -{ - set->X = (float)rgb.R / 255.0f; - set->Y = (float)rgb.G / 255.0f; - set->Z = (float)rgb.B / 255.0f; - set->W = (float)rgb.A / 255.0f; -} - -void W3dUtilityClass::Convert_Color(const Vector4 & v,W3dRGBAStruct * color) -{ - color->R = (uint8)(255.0f * v.X); - color->G = (uint8)(255.0f * v.Y); - color->B = (uint8)(255.0f * v.Z); - color->A = (uint8)(255.0f * v.W); -} - -void W3dUtilityClass::Convert_Shader(const W3dShaderStruct & shader,ShaderClass * set) -{ - set->Set_Depth_Compare ((ShaderClass::DepthCompareType)W3d_Shader_Get_Depth_Compare(&shader)); - set->Set_Depth_Mask ((ShaderClass::DepthMaskType)W3d_Shader_Get_Depth_Mask(&shader)); - set->Set_Color_Mask (ShaderClass::COLOR_WRITE_ENABLE); - set->Set_Dst_Blend_Func ((ShaderClass::DstBlendFuncType)W3d_Shader_Get_Dest_Blend_Func(&shader)); - set->Set_Fog_Func (ShaderClass::FOG_DISABLE); - set->Set_Primary_Gradient ((ShaderClass::PriGradientType)W3d_Shader_Get_Pri_Gradient(&shader)); - set->Set_Secondary_Gradient((ShaderClass::SecGradientType)W3d_Shader_Get_Sec_Gradient(&shader)); - set->Set_Src_Blend_Func ((ShaderClass::SrcBlendFuncType)W3d_Shader_Get_Src_Blend_Func(&shader)); - set->Set_Texturing ((ShaderClass::TexturingType)W3d_Shader_Get_Texturing(&shader)); - set->Set_Alpha_Test ((ShaderClass::AlphaTestType)W3d_Shader_Get_Alpha_Test(&shader)); -// Jani: No cull mode settings for w3d shader - problem? -// set->Set_Dither_Mask (ShaderClass::DITHER_ENABLE); - // The tools do not enable setting post-detail stuff, and in any case we probably wouldn't - // want to confuse the artists with the distinction between detail and post-detail settings at - // this point, so we just copy the detail settings into the post-detail settings. -// set->Set_Post_Detail_Color_Func ((ShaderClass::DetailColorFuncType) W3d_Shader_Get_Post_Detail_Color_Func (&shader)); -// set->Set_Post_Detail_Alpha_Func ((ShaderClass::DetailAlphaFuncType) W3d_Shader_Get_Post_Detail_Alpha_Func (&shader)); - set->Set_Post_Detail_Color_Func ((ShaderClass::DetailColorFuncType) W3d_Shader_Get_Detail_Color_Func (&shader)); - set->Set_Post_Detail_Alpha_Func ((ShaderClass::DetailAlphaFuncType) W3d_Shader_Get_Detail_Alpha_Func (&shader)); -} - -void W3dUtilityClass::Convert_Shader(const ShaderClass & shader,W3dShaderStruct * set) -{ - W3d_Shader_Reset(set); - W3d_Shader_Set_Depth_Compare(set,shader.Get_Depth_Compare()); - W3d_Shader_Set_Depth_Mask(set,shader.Get_Depth_Mask()); - W3d_Shader_Set_Dest_Blend_Func(set,shader.Get_Dst_Blend_Func()); - W3d_Shader_Set_Pri_Gradient(set,shader.Get_Primary_Gradient()); - W3d_Shader_Set_Sec_Gradient(set,shader.Get_Secondary_Gradient()); - W3d_Shader_Set_Src_Blend_Func(set,shader.Get_Src_Blend_Func()); - W3d_Shader_Set_Texturing(set,shader.Get_Texturing()); - W3d_Shader_Set_Alpha_Test(set,shader.Get_Alpha_Test()); - W3d_Shader_Set_Post_Detail_Color_Func(set,shader.Get_Post_Detail_Color_Func()); - W3d_Shader_Set_Post_Detail_Alpha_Func(set,shader.Get_Post_Detail_Alpha_Func()); -} diff --git a/Generals/Code/Libraries/Source/WWVegas/WW3D2/w3d_util.h b/Generals/Code/Libraries/Source/WWVegas/WW3D2/w3d_util.h deleted file mode 100644 index a3ca9353c49..00000000000 --- a/Generals/Code/Libraries/Source/WWVegas/WW3D2/w3d_util.h +++ /dev/null @@ -1,80 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** 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 *** - *********************************************************************************************** - * * - * Project Name : WW3D * - * * - * $Archive:: /Commando/Code/ww3d2/w3d_util.h $* - * * - * Author:: Greg Hjelstrom * - * * - * $Modtime:: 1/08/01 10:04a $* - * * - * $Revision:: 1 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - - -#if defined(_MSC_VER) -#pragma once -#endif - -#ifndef W3D_UTIL_H -#define W3D_UTIL_H - -#include "always.h" -#include "w3d_file.h" - -class Vector3; -class Vector4; -class Quaternion; -class ShaderClass; - -/* -** These functions are just simple helpers which convert to and from the W3D file-format -** structures and the equivalent runtime classes. -*/ -class W3dUtilityClass -{ -public: - - static void Convert_Vector(const W3dVectorStruct & v,Vector3 * set); - static void Convert_Vector(const Vector3 & v,W3dVectorStruct * set); - - static void Convert_Quaternion(const W3dQuaternionStruct & q,Quaternion * set); - static void Convert_Quaternion(const Quaternion & q,W3dQuaternionStruct * set); - - static void Convert_Color(const W3dRGBStruct & rgb,Vector3 * set); - static void Convert_Color(const Vector3 & v,W3dRGBStruct * set); - - static void Convert_Color(const W3dRGBAStruct & rgb,Vector4 * set); - static void Convert_Color(const Vector4 & v,W3dRGBAStruct * set); - - static void Convert_Shader(const W3dShaderStruct & shader,ShaderClass * set); - static void Convert_Shader(const ShaderClass & shader,W3dShaderStruct * set); - -}; - -#endif - - diff --git a/Generals/Code/Libraries/Source/WWVegas/WW3D2/w3derr.h b/Generals/Code/Libraries/Source/WWVegas/WW3D2/w3derr.h deleted file mode 100644 index 8f2129ba24c..00000000000 --- a/Generals/Code/Libraries/Source/WWVegas/WW3D2/w3derr.h +++ /dev/null @@ -1,60 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** 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 *** - *********************************************************************************************** - * * - * Project Name : WW3D * - * * - * $Archive:: /Commando/Code/ww3d2/w3derr.h $* - * * - * $Author:: Greg_h $* - * * - * $Modtime:: 1/08/01 10:04a $* - * * - * $Revision:: 1 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - - -#if defined(_MSC_VER) -#pragma once -#endif - -#ifndef W3DERR_H -#define W3DERR_H - -#include "always.h" - -/* -** These are the error codes which should be returned by all WW3D functions that can fail -*/ -enum WW3DErrorType -{ - WW3D_ERROR_OK = 0, - WW3D_ERROR_GENERIC, - WW3D_ERROR_LOAD_FAILED, - WW3D_ERROR_SAVE_FAILED, - WW3D_ERROR_WINDOW_NOT_OPEN, - WW3D_ERROR_INITIALIZATION_FAILED, -}; - -#endif diff --git a/Generals/Code/Libraries/Source/WWVegas/WW3D2/w3dexclusionlist.cpp b/Generals/Code/Libraries/Source/WWVegas/WW3D2/w3dexclusionlist.cpp deleted file mode 100644 index c5ea49a6b39..00000000000 --- a/Generals/Code/Libraries/Source/WWVegas/WW3D2/w3dexclusionlist.cpp +++ /dev/null @@ -1,105 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/* $Header: /Commando/Code/ww3d2/w3dexclusionlist.cpp 1 12/12/02 3:36p Greg_h $ */ -/*********************************************************************************************** - *** Confidential - Westwood Studios *** - *********************************************************************************************** - * * - * Project Name : Commando / G 3D Library * - * * - * $Archive:: /Commando/Code/ww3d2/w3dexclusionlist.cpp $* - * * - * Author:: Greg_h * - * * - * $Modtime:: 12/12/02 10:04a $* - * * - * $Revision:: 1 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - - -#include "w3dexclusionlist.h" -#include "proto.h" -#include "htree.h" -#include "hanim.h" - - -W3DExclusionListClass::W3DExclusionListClass(const DynamicVectorClass & names) : - Names(names) -{ - for (int i=0; iGet_Name(); - char * root_name = copy.Peek_Buffer(); - - // don't preserve munged prototypes - if (strchr(root_name,'#') != NULL) { - return false; - } - - // chop off the sub-object name if present ( - char * tmp = strchr(root_name,'.'); - if (tmp != NULL) { - *tmp = 0; - } - - return Is_Excluded(root_name); -} - - -bool W3DExclusionListClass::Is_Excluded(HTreeClass * htree) const -{ - // plain old name... - return Is_Excluded(htree->Get_Name()); -} - - -bool W3DExclusionListClass::Is_Excluded(HAnimClass * hanim) const -{ - // For HAnims, the name to check is the one trailing the '.' - StringClass copy = hanim->Get_Name(); - char * root_name = copy.Peek_Buffer(); - - char * tmp = strchr(root_name,'.'); - if (tmp) { - return Is_Excluded(tmp + 1); - } else { - return false; // should never happen... - } -} - - -bool W3DExclusionListClass::Is_Excluded(const char * root_name) const -{ - return NameHash.Exists(StringClass(root_name)); -} - - diff --git a/Generals/Code/Libraries/Source/WWVegas/WW3D2/w3dexclusionlist.h b/Generals/Code/Libraries/Source/WWVegas/WW3D2/w3dexclusionlist.h deleted file mode 100644 index 06926556aa6..00000000000 --- a/Generals/Code/Libraries/Source/WWVegas/WW3D2/w3dexclusionlist.h +++ /dev/null @@ -1,84 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/* $Header: /Commando/Code/ww3d2/w3dexclusionlist.h 1 12/12/02 3:36p Greg_h $ */ -/*********************************************************************************************** - *** Confidential - Westwood Studios *** - *********************************************************************************************** - * * - * Project Name : Commando / G 3D Library * - * * - * $Archive:: /Commando/Code/ww3d2/w3dexclusionlist.h $* - * * - * Author:: Greg_h * - * * - * $Modtime:: 12/12/02 10:04a $* - * * - * $Revision:: 1 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#if defined(_MSC_VER) -#pragma once -#endif - -#ifndef W3DEXCLUSIONLIST_H -#define W3DEXCLUSIONLIST_H - -#include "always.h" -#include "Vector.H" -#include "wwstring.h" -#include "hashtemplate.h" - -class PrototypeClass; -class HTreeClass; -class HAnimClass; - - -/** -** W3DExclusionListClass -** This class ecapsulates an "exclusion list" which the asset manager and related classes use -** to filter what resources get released. This is useful between level loads for example. -** The Is_Excluded function uses w3d naming convention assumptions to determine whether the given -** asset name is in the list or is a child of something in the list. -*/ - -class W3DExclusionListClass -{ -public: - W3DExclusionListClass(const DynamicVectorClass & names); - ~W3DExclusionListClass(void); - - bool Is_Excluded(PrototypeClass * proto) const; - bool Is_Excluded(HTreeClass * htree) const; - bool Is_Excluded(HAnimClass * hanim) const; - - bool Is_Excluded(const char * root_name) const; - -protected: - - - const DynamicVectorClass & Names; - HashTemplateClass NameHash; -}; - - - -#endif //EXCLUSIONLIST_H \ No newline at end of file diff --git a/Generals/Code/Libraries/Source/WWVegas/WW3D2/ww3dformat.cpp b/Generals/Code/Libraries/Source/WWVegas/WW3D2/ww3dformat.cpp deleted file mode 100644 index 0f17b7cc259..00000000000 --- a/Generals/Code/Libraries/Source/WWVegas/WW3D2/ww3dformat.cpp +++ /dev/null @@ -1,455 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** 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 *** - *********************************************************************************************** - * * - * Project Name : WW3D * - * * - * $Archive:: /Commando/Code/ww3d2/ww3dformat.cpp $* - * * - * Original Author:: Hector Yee * - * * - * Author : Kenny Mitchell * - * * - * $Modtime:: 06/27/02 1:27p $* - * * - * $Revision:: 14 $* - * * - * 06/27/02 KM Z Format support * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#include "ww3dformat.h" -#include "vector4.h" -#include "wwdebug.h" -#include "TARGA.H" -#include "dx8wrapper.h" -#include "dx8caps.h" -#include - - /* - WW3D_FORMAT_UNKNOWN=0, - WW3D_FORMAT_R8G8B8, - WW3D_FORMAT_A8R8G8B8, - WW3D_FORMAT_X8R8G8B8, - WW3D_FORMAT_R5G6B5, - WW3D_FORMAT_X1R5G5B5, - WW3D_FORMAT_A1R5G5B5, - WW3D_FORMAT_A4R4G4B4, - WW3D_FORMAT_R3G3B2, - WW3D_FORMAT_A8, - WW3D_FORMAT_A8R3G3B2, - WW3D_FORMAT_X4R4G4B4, - WW3D_FORMAT_A8P8, - WW3D_FORMAT_P8, - WW3D_FORMAT_L8, - WW3D_FORMAT_A8L8, - WW3D_FORMAT_A4L4, - WW3D_FORMAT_COUNT // Used only to determine number of surface formats -*/ - -void Get_WW3D_Format_Name(WW3DFormat format, StringClass& name) -{ - switch (format) { - default: - case WW3D_FORMAT_UNKNOWN: name="Unknown"; break; - case WW3D_FORMAT_R8G8B8: name="R8G8B8"; break; - case WW3D_FORMAT_A8R8G8B8: name="A8R8G8B8"; break; - case WW3D_FORMAT_X8R8G8B8: name="X8R8G8B8"; break; - case WW3D_FORMAT_R5G6B5: name="R5G6B5"; break; - case WW3D_FORMAT_X1R5G5B5: name="X1R5G5B5"; break; - case WW3D_FORMAT_A1R5G5B5: name="A1R5G5B5"; break; - case WW3D_FORMAT_A4R4G4B4: name="A4R4G4B4"; break; - case WW3D_FORMAT_R3G3B2: name="R3G3B2"; break; - case WW3D_FORMAT_A8: name="A8"; break; - case WW3D_FORMAT_A8R3G3B2: name="A8R3G3B2"; break; - case WW3D_FORMAT_X4R4G4B4: name="X4R4G4B4"; break; - case WW3D_FORMAT_A8P8: name="A8P8"; break; - case WW3D_FORMAT_P8: name="P8"; break; - case WW3D_FORMAT_L8: name="L8"; break; - case WW3D_FORMAT_A8L8: name="A8L8"; break; - case WW3D_FORMAT_A4L4: name="A4L4"; break; - case WW3D_FORMAT_U8V8: name="U8V8"; break; // Bumpmap - case WW3D_FORMAT_L6V5U5: name="L6V5U5"; break; // Bumpmap - case WW3D_FORMAT_X8L8V8U8: name="X8L8V8U8"; break; // Bumpmap - case WW3D_FORMAT_DXT1: name="DXT1"; break; - case WW3D_FORMAT_DXT2: name="DXT2"; break; - case WW3D_FORMAT_DXT3: name="DXT3"; break; - case WW3D_FORMAT_DXT4: name="DXT4"; break; - case WW3D_FORMAT_DXT5: name="DXT5"; break; - } -} - -//********************************************************************************************** -//! Get W3D depth stencil format string name -/*! 06/27/02 KJM -*/ -void Get_WW3D_ZFormat_Name(WW3DZFormat format, StringClass& name) -{ - switch (format) - { - default: - case WW3D_FORMAT_UNKNOWN : name="Unknown"; break; - case WW3D_ZFORMAT_D16_LOCKABLE: name="D16Lockable"; break; // 16-bit z-buffer bit depth. This is an application-lockable surface format. - case WW3D_ZFORMAT_D32 : name="D32"; break; // 32-bit z-buffer bit depth. - case WW3D_ZFORMAT_D15S1 : name="D15S1"; break; // 16-bit z-buffer bit depth where 15 bits are reserved for the depth channel and 1 bit is reserved for the stencil channel. - case WW3D_ZFORMAT_D24S8 : name="D24S8"; break; // 32-bit z-buffer bit depth using 24 bits for the depth channel and 8 bits for the stencil channel. - case WW3D_ZFORMAT_D16 : name="D16"; break; // 16-bit z-buffer bit depth. - case WW3D_ZFORMAT_D24X8 : name="D24X8"; break; // 32-bit z-buffer bit depth using 24 bits for the depth channel. - case WW3D_ZFORMAT_D24X4S4 : name="D24X4S4"; break; // 32-bit z-buffer bit depth using 24 bits for the depth channel and 4 bits for the stencil channel. -#ifdef _XBOX - case WW3D_ZFORMAT_LIN_D24S8 : name="D24S8LIN"; break; - case WW3D_ZFORMAT_LIN_F24S8 : name="F24S8LIN"; break; - case WW3D_ZFORMAT_LIN_D16 : name="D16LIN"; break; - case WW3D_ZFORMAT_LIN_F16 : name="F16LIN"; break; -#endif - } -} - -// extract the luminance from the RGB using the CIE 709 standard -unsigned char RGB_to_CIEY(Vector4 color) -{ - float lum=0.2126f*color.X + 0.7152f*color.Y + 0.0722f*color.Z; - return (unsigned char) (255.0f*lum); -} - -void Vector4_to_Color(unsigned int *outc,const Vector4 &inc,const WW3DFormat format) -{ - // convert to ARGB 32-bit - unsigned int color=DX8Wrapper::Convert_Color(inc); - unsigned char *argb=(unsigned char*) &color; - unsigned char r,g,b,a,lum; - - switch (format) - { - case WW3D_FORMAT_R8G8B8: - case WW3D_FORMAT_A8R8G8B8: - case WW3D_FORMAT_X8R8G8B8: - *outc=color; - break; - case WW3D_FORMAT_R5G6B5: - r=argb[1] >> 3; - g=argb[2] >> 2; - b=argb[3] >> 3; - *outc=(r << 11) | (g<<5) | b; - break; - case WW3D_FORMAT_X1R5G5B5: - case WW3D_FORMAT_A1R5G5B5: - a=argb[0] >> 7; - r=argb[1] >> 3; - g=argb[2] >> 3; - b=argb[3] >> 3; - *outc=(a<<15) | (r<<10) | (g<<5) | b; - break; - - case WW3D_FORMAT_A4R4G4B4: - case WW3D_FORMAT_X4R4G4B4: - a=argb[0] >> 4; - r=argb[1] >> 4; - g=argb[2] >> 4; - b=argb[3] >> 4; - *outc=(a<<12) | (r<<8) | (g<<4) | b; - break; - case WW3D_FORMAT_R3G3B2: - case WW3D_FORMAT_A8R3G3B2: - a=argb[0]; - r=argb[1] >> 5; - g=argb[2] >> 5; - b=argb[3] >> 6; - *outc=(a<<8) | (r<<5) | (g<<2) | b; - break; - case WW3D_FORMAT_A8: - *outc=argb[0]; - break; - case WW3D_FORMAT_L8: - lum=RGB_to_CIEY(inc); - *outc=lum; - break; - case WW3D_FORMAT_A8L8: - a=argb[0]; - lum=RGB_to_CIEY(inc); - *outc=(a<<8) | lum; - break; - case WW3D_FORMAT_A4L4: - a=argb[0] >> 4; - lum=RGB_to_CIEY(inc); - lum=lum>>4; - *outc=(a<<4) | lum; - break; - default: - WWASSERT(0); - } -} - -void Color_to_Vector4(Vector4* outc,const unsigned int inc,const WW3DFormat format) -{ - WWASSERT(outc); - - unsigned char *argb=(unsigned char*) &inc; - unsigned char a,r,g,b; - a=r=g=b=0; - - switch (format) - { - case WW3D_FORMAT_R8G8B8: - case WW3D_FORMAT_A8R8G8B8: - case WW3D_FORMAT_X8R8G8B8: - a=argb[0]; - r=argb[1]; - g=argb[2]; - b=argb[3]; - break; - case WW3D_FORMAT_R5G6B5: - r=argb[1]<<3; - g=argb[2]<<2; - b=argb[3]<<3; - break; - case WW3D_FORMAT_X1R5G5B5: - case WW3D_FORMAT_A1R5G5B5: - a=argb[0]<<7; - r=argb[1]<<3; - g=argb[2]<<3; - b=argb[3]<<3; - break; - case WW3D_FORMAT_A4R4G4B4: - a=argb[0]<<4; - r=argb[1]<<4; - g=argb[2]<<4; - b=argb[3]<<4; - break; - case WW3D_FORMAT_R3G3B2: - r=argb[1]<<5; - g=argb[2]<<5; - b=argb[3]<<6; - break; - case WW3D_FORMAT_A8: - a=argb[0]; - break; - case WW3D_FORMAT_A8R3G3B2: - a=argb[0]; - r=argb[1]<<5; - g=argb[2]<<5; - b=argb[3]<<6; - break; - case WW3D_FORMAT_X4R4G4B4: - r=argb[1]<<4; - g=argb[2]<<4; - b=argb[3]<<4; - break; - default: - WWASSERT(0); - } - outc->X=r/255.0f; - outc->Y=g/255.0f; - outc->Z=b/255.0f; - outc->W=a/255.0f; -} - -// ---------------------------------------------------------------------------- -// -// Utility function for determining WW3D format from TGA file header. -// -// ---------------------------------------------------------------------------- - -void Get_WW3D_Format(WW3DFormat& dest_format,WW3DFormat& src_format,unsigned& src_bpp,const Targa& targa) -{ - Get_WW3D_Format(src_format,src_bpp,targa); - dest_format=src_format; - if ((dest_format==WW3D_FORMAT_P8) || (dest_format==WW3D_FORMAT_L8)) { - dest_format=WW3D_FORMAT_X8R8G8B8; - } - dest_format=Get_Valid_Texture_Format(dest_format,false); // No compressed destination format if reading from targa... - -} - -void Get_WW3D_Format(WW3DFormat& src_format,unsigned& src_bpp,const Targa& targa) -{ - // Guess the format from the TGA Header bits: - src_format = WW3D_FORMAT_UNKNOWN; - src_bpp=0; - switch (targa.Header.PixelDepth) { - case 32: src_format = WW3D_FORMAT_A8R8G8B8; src_bpp=4; break; - case 24: src_format = WW3D_FORMAT_R8G8B8; src_bpp=3; break; - case 16: src_format = WW3D_FORMAT_A1R5G5B5; src_bpp=2; break; - case 8: - src_bpp=1; - if (targa.Header.ColorMapType == 1) src_format = WW3D_FORMAT_P8; - else if (targa.Header.ImageType == TGA_MONO) src_format = WW3D_FORMAT_L8; - else src_format = WW3D_FORMAT_A8; - break; - default: - WWDEBUG_SAY(("TextureClass: Targa has unsupported bitdepth(%i)\n",targa.Header.PixelDepth)); -// WWASSERT(0); - break; - } -} - -// ---------------------------------------------------------------------------- -// -// Utility function for determining valid WW3D format -// -// ---------------------------------------------------------------------------- - -WW3DFormat Get_Valid_Texture_Format(WW3DFormat format, bool is_compression_allowed) -{ - int w,h,bits; - bool windowed; - - if (!DX8Wrapper::Get_Current_Caps()->Support_DXTC() || - !is_compression_allowed) { - switch (format) { - case WW3D_FORMAT_DXT1: format=WW3D_FORMAT_R8G8B8; break; - case WW3D_FORMAT_DXT2: - case WW3D_FORMAT_DXT3: - case WW3D_FORMAT_DXT4: - case WW3D_FORMAT_DXT5: format=WW3D_FORMAT_A8R8G8B8; break; - default: break; - } - } - else { - switch (format) { - case WW3D_FORMAT_DXT1: - // NVidia hack - switch to DXT2 is there is no DXT1 support (which is disabled on NVidia cards) - if (!DX8Wrapper::Get_Current_Caps()->Support_Texture_Format(WW3D_FORMAT_DXT1) && - DX8Wrapper::Get_Current_Caps()->Support_Texture_Format(WW3D_FORMAT_DXT2)) { - format=WW3D_FORMAT_DXT2; - } - break; - case WW3D_FORMAT_DXT2: - case WW3D_FORMAT_DXT3: - case WW3D_FORMAT_DXT4: - case WW3D_FORMAT_DXT5: - if (!DX8Wrapper::Get_Current_Caps()->Support_Texture_Format(format)) format=WW3D_FORMAT_A8R8G8B8; - break; - } - } - - if (format==WW3D_FORMAT_R8G8B8) { - format=WW3D_FORMAT_X8R8G8B8; - } - - WW3D::Get_Device_Resolution(w,h,bits,windowed); - if (WW3D::Get_Texture_Bitdepth()==16) bits=16; - - // if the device bitdepth is 16, don't allow 32 bit textures - if (bits<=16) { - switch (format) { - case WW3D_FORMAT_A8R8G8B8: return WW3D_FORMAT_A4R4G4B4; - case WW3D_FORMAT_X8R8G8B8: - case WW3D_FORMAT_R8G8B8: return WW3D_FORMAT_R5G6B5; - case WW3D_FORMAT_A4R4G4B4: - case WW3D_FORMAT_A1R5G5B5: - case WW3D_FORMAT_R5G6B5: - case WW3D_FORMAT_L8: - case WW3D_FORMAT_A8: - case WW3D_FORMAT_P8: - default: - // Basically, anything goes here (just make sure the most common 32 bit formats are converted to 16 bit - break; - } - - } - - // Fallback if the hardware doesn't support the texture format - if (!DX8Wrapper::Get_Current_Caps()->Support_Texture_Format(format)) { - format=WW3D_FORMAT_A8R8G8B8; - if (!DX8Wrapper::Get_Current_Caps()->Support_Texture_Format(format)) { - format=WW3D_FORMAT_A4R4G4B4; - if (!DX8Wrapper::Get_Current_Caps()->Support_Texture_Format(format)) { - // If still no luck, try non-alpha formats - - format=WW3D_FORMAT_X8R8G8B8; - if (!DX8Wrapper::Get_Current_Caps()->Support_Texture_Format(format)) { - format=WW3D_FORMAT_R5G6B5; - if (!DX8Wrapper::Get_Current_Caps()->Support_Texture_Format(format)) { - WWASSERT_PRINT(0,("No valid texture format found")); - } - } - } - } - } - - return format; -} - -unsigned Get_Bytes_Per_Pixel(WW3DFormat format) -{ - switch (format) { - case WW3D_FORMAT_X8R8G8B8: - case WW3D_FORMAT_X8L8V8U8: - case WW3D_FORMAT_A8R8G8B8: return 4; - case WW3D_FORMAT_R8G8B8: return 3; - case WW3D_FORMAT_A1R5G5B5: - case WW3D_FORMAT_A4R4G4B4: - case WW3D_FORMAT_U8V8: - case WW3D_FORMAT_L6V5U5: - case WW3D_FORMAT_R5G6B5: return 2; - case WW3D_FORMAT_R3G3B2: - case WW3D_FORMAT_L8: - case WW3D_FORMAT_A8: - case WW3D_FORMAT_P8: return 1; - - default: WWASSERT(0); break; - } - return 0; -} - -unsigned Get_Num_Depth_Bits(WW3DZFormat zformat) -{ - switch (zformat) - { - case WW3D_ZFORMAT_D16_LOCKABLE: return 16; break; - case WW3D_ZFORMAT_D32 : return 32; break; - case WW3D_ZFORMAT_D15S1 : return 15; break; - case WW3D_ZFORMAT_D24S8 : return 24; break; - case WW3D_ZFORMAT_D16 : return 16; break; - case WW3D_ZFORMAT_D24X8 : return 24; break; - case WW3D_ZFORMAT_D24X4S4 : return 24; break; -#ifdef _XBOX - case WW3D_ZFORMAT_LIN_D24S8 : return 24; break; - case WW3D_ZFORMAT_LIN_F24S8 : return 24; break; - case WW3D_ZFORMAT_LIN_D16 : return 16; break; - case WW3D_ZFORMAT_LIN_F16 : return 16; break; -#endif - }; - return 0; -}; - -unsigned Get_Num_Stencil_Bits(WW3DZFormat zformat) -{ - switch (zformat) - { - case WW3D_ZFORMAT_D16_LOCKABLE: return 0; break; - case WW3D_ZFORMAT_D32 : return 0; break; - case WW3D_ZFORMAT_D15S1 : return 1; break; - case WW3D_ZFORMAT_D24S8 : return 8; break; - case WW3D_ZFORMAT_D16 : return 0; break; - case WW3D_ZFORMAT_D24X8 : return 0; break; - case WW3D_ZFORMAT_D24X4S4 : return 4; break; -#ifdef _XBOX - case WW3D_ZFORMAT_LIN_D24S8 : return 8; break; - case WW3D_ZFORMAT_LIN_F24S8 : return 8; break; - case WW3D_ZFORMAT_LIN_D16 : return 0; break; - case WW3D_ZFORMAT_LIN_F16 : return 0; break; -#endif - }; - return 0; -}; diff --git a/Generals/Code/Libraries/Source/WWVegas/WW3D2/ww3dformat.h b/Generals/Code/Libraries/Source/WWVegas/WW3D2/ww3dformat.h deleted file mode 100644 index f3c8fe965da..00000000000 --- a/Generals/Code/Libraries/Source/WWVegas/WW3D2/ww3dformat.h +++ /dev/null @@ -1,209 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** 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 *** - *********************************************************************************************** - * * - * Project Name : WW3D * - * * - * $Archive:: /Commando/Code/ww3d2/ww3dformat.h $* - * * - * Original Author:: Nathaniel Hoffman * - * * - * Author : Kenny Mitchell * - * * - * $Modtime:: 06/27/02 1:27p $* - * * - * $Revision:: 12 $* - * * - * 06/27/02 KM Z Format support * - *---------------------------------------------------------------------------------------------* - * Functions: * - * Vector4_to_Color - converts a vector4 to the format in format * - * Color_to_Vector4 - converts a color in the format described in format to a Vector4 * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#if defined(_MSC_VER) -#pragma once -#endif - -#ifndef WW3DFORMAT_H -#define WW3DFORMAT_H - -#include "always.h" -#include "wwstring.h" - -class Vector4; -class Targa; - -/* -** Enum for possible surface formats. This is a small subset of the D3DFORMAT -** enum which lists the formats supported by DX8; we will add new members to -** this list as needed (keeping it in the same order as D3DFORMAT). -** NOTE: Whenever this is changed, formconv.h/.cpp must be modified as well -** (that contains the code for converting between this and D3DFORMAT).. -** -** The format names use the D3DFORMAT conventions: -** A = Alpha -** R = Red -** G = Green -** B = Blue -** X = Unused Bits -** P = Palette -** L = Luminance -** -** Further, the order of the pieces are from MSB first; hence -** WW3D_FORMAT_A8L8 indicates that the high byte of this two byte -** format is alpha. -*/ -enum WW3DFormat { - WW3D_FORMAT_UNKNOWN=0, - WW3D_FORMAT_R8G8B8, - WW3D_FORMAT_A8R8G8B8, - WW3D_FORMAT_X8R8G8B8, - WW3D_FORMAT_R5G6B5, - WW3D_FORMAT_X1R5G5B5, - WW3D_FORMAT_A1R5G5B5, - WW3D_FORMAT_A4R4G4B4, - WW3D_FORMAT_R3G3B2, - WW3D_FORMAT_A8, - WW3D_FORMAT_A8R3G3B2, - WW3D_FORMAT_X4R4G4B4, - WW3D_FORMAT_A8P8, - WW3D_FORMAT_P8, - WW3D_FORMAT_L8, - WW3D_FORMAT_A8L8, - WW3D_FORMAT_A4L4, - WW3D_FORMAT_U8V8, // Bumpmap - WW3D_FORMAT_L6V5U5, // Bumpmap - WW3D_FORMAT_X8L8V8U8, // Bumpmap - WW3D_FORMAT_DXT1, - WW3D_FORMAT_DXT2, - WW3D_FORMAT_DXT3, - WW3D_FORMAT_DXT4, - WW3D_FORMAT_DXT5, - WW3D_FORMAT_COUNT // Used only to determine number of surface formats -}; - -// depth stencil buffer formats -enum WW3DZFormat -{ - WW3D_ZFORMAT_UNKNOWN=0, - WW3D_ZFORMAT_D16_LOCKABLE, // 16-bit z-buffer bit depth. This is an application-lockable surface format. - WW3D_ZFORMAT_D32, // 32-bit z-buffer bit depth. - WW3D_ZFORMAT_D15S1, // 16-bit z-buffer bit depth where 15 bits are reserved for the depth channel and 1 bit is reserved for the stencil channel. - WW3D_ZFORMAT_D24S8, // 32-bit z-buffer bit depth using 24 bits for the depth channel and 8 bits for the stencil channel. - WW3D_ZFORMAT_D16, // 16-bit z-buffer bit depth. - WW3D_ZFORMAT_D24X8, // 32-bit z-buffer bit depth using 24 bits for the depth channel. - WW3D_ZFORMAT_D24X4S4, // 32-bit z-buffer bit depth using 24 bits for the depth channel and 4 bits for the stencil channel. -#ifdef _XBOX - WW3D_ZFORMAT_LIN_D24S8, - WW3D_ZFORMAT_LIN_F24S8, - WW3D_ZFORMAT_LIN_D16, - WW3D_ZFORMAT_LIN_F16, -#endif - WW3D_ZFORMAT_COUNT -}; - -// Utility function - not much used otherwise it would use an array. -// NOTE: when adding values to WW3DFormat add here also (if they have alpha). -inline bool Has_Alpha(WW3DFormat format) { - switch (format) { - case WW3D_FORMAT_A8R8G8B8: - case WW3D_FORMAT_A1R5G5B5: - case WW3D_FORMAT_A4R4G4B4: - case WW3D_FORMAT_A8: - case WW3D_FORMAT_A8R3G3B2: - case WW3D_FORMAT_A8P8: - case WW3D_FORMAT_A8L8: - case WW3D_FORMAT_A4L4: - case WW3D_FORMAT_DXT2: - case WW3D_FORMAT_DXT3: - case WW3D_FORMAT_DXT4: - case WW3D_FORMAT_DXT5: - return true; - break; - default: - return false; - break; - }; -} - -inline int Alpha_Bits(WW3DFormat format) { - switch (format) { - case WW3D_FORMAT_A8R8G8B8: - case WW3D_FORMAT_A8: - case WW3D_FORMAT_A8R3G3B2: - case WW3D_FORMAT_A8P8: - case WW3D_FORMAT_A8L8: - return 8; - break; - case WW3D_FORMAT_A4R4G4B4: - case WW3D_FORMAT_A4L4: - case WW3D_FORMAT_DXT3: - case WW3D_FORMAT_DXT4: - case WW3D_FORMAT_DXT5: - return 4; - break; - case WW3D_FORMAT_A1R5G5B5: - case WW3D_FORMAT_DXT2: - return 1; - break; - default: - return 0; - break; - }; -} - -// Color convertion routines - -// The color will be returned as an unsigned int always -// any unused bits will be garbage -void Vector4_to_Color(unsigned int *outc,const Vector4 &inc,const WW3DFormat format); - -// If the format does not support alpha -// the alpha will be garbage -void Color_to_Vector4(Vector4* outc,const unsigned int inc,const WW3DFormat format); - -// Define matching WW3D format based from Targa header. -// -// dest_format - WW3DFormat that can be used as a destination (D3D surface) on current hardware -// src_format - WW3DFormat that represents the format the bitmap is stored in the targa file. -// src_bpp - bytes per pixel in the source surface -// targa - reference to the targa object... -void Get_WW3D_Format(WW3DFormat& dest_format,WW3DFormat& src_format,unsigned& src_bpp,const Targa& targa); - -// The same as above, but doesn't validate the device - only checks the source format. -void Get_WW3D_Format(WW3DFormat& src_format,unsigned& src_bpp,const Targa& targa); - -// Get valid texture format (on current hardware) that is closest to the given format (for instance, 32 bit ARGB8888 would -// return 16 bit ARGB4444 if the device doesn't support 32 bit textures). -// Pass false to the second parameter if you don't wish to consider compressed textures on hardware that supports them. -// The parameter has no effect on hardware that doesn't support compression. -WW3DFormat Get_Valid_Texture_Format(WW3DFormat format,bool is_compression_allowed); - -unsigned Get_Bytes_Per_Pixel(WW3DFormat format); - -void Get_WW3D_Format_Name(WW3DFormat format, StringClass& name); -void Get_WW3D_ZFormat_Name(WW3DZFormat format, StringClass& name); - -unsigned Get_Num_Depth_Bits(WW3DZFormat zformat); -unsigned Get_Num_Stencil_Bits(WW3DZFormat zformat); - -#endif \ No newline at end of file diff --git a/Generals/Code/Libraries/Source/WWVegas/WW3D2/ww3dids.h b/Generals/Code/Libraries/Source/WWVegas/WW3D2/ww3dids.h deleted file mode 100644 index 83e2f64018b..00000000000 --- a/Generals/Code/Libraries/Source/WWVegas/WW3D2/ww3dids.h +++ /dev/null @@ -1,77 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** 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 *** - *********************************************************************************************** - * * - * Project Name : WW3D * - * * - * $Archive:: /Commando/Code/ww3d2/ww3dids.h $* - * * - * Author:: Greg Hjelstrom * - * * - * $Modtime:: 1/08/01 10:04a $* - * * - * $Revision:: 1 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - - -#if defined(_MSC_VER) -#pragma once -#endif - - -#ifndef WW3DIDS_H -#define WW3DIDS_H - -#include "saveloadids.h" - -/* -** These are the chunk-id's used by all persistant objects in WW3D. The persistant object -** framework is defined in the WWSaveLoad library. -** -** Sept 23, 1999 -** - Initial implementation of making the Commando engine persistant included making some -** of WW3D persistant. For this initial implementation, we're going to assume that we -** can re-create all of our game objects from the asset manager and patch up any state -** changes with custom game object code. Therefore, the base class RenderObjClass has -** a persist manager which simply saves the name of the render object and its transform -** and re-creates that render object from the asset manager. -** -** - Currently lights are procedurally created rather than created from the asset manager. -** For this reason, I'm implementing a persist manager and save-load functionality for -** light class. In the future lights may come from the asset manager in which case we -** could remove this code. -** -** - It is also possible that later on when we make the save game stuff more robust we may -** need to implement actual save load calls for more render objects but hopefully we can -** avoid that since it will at least double the size of our files and just seems like a -** lot of work to solve a few specific problems. -*/ -enum -{ - WW3D_PERSIST_CHUNKID_RENDEROBJ = CHUNKID_WW3D_BEGIN, - WW3D_PERSIST_CHUNKID_LIGHT, - WW3D_PERSIST_CHUNKID_DAZZLE, -}; - -#endif \ No newline at end of file diff --git a/Generals/Code/Libraries/Source/WWVegas/WW3D2/ww3dtrig.h b/Generals/Code/Libraries/Source/WWVegas/WW3D2/ww3dtrig.h deleted file mode 100644 index 257989c2dfd..00000000000 --- a/Generals/Code/Libraries/Source/WWVegas/WW3D2/ww3dtrig.h +++ /dev/null @@ -1,61 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -/*********************************************************************************************** - *** 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 *** - *********************************************************************************************** - * * - * Project Name : WW3D * - * * - * $Archive:: /Commando/Code/ww3d2/ww3dtrig.h $* - * * - * $Author:: Greg_h $* - * * - * $Modtime:: 1/08/01 10:04a $* - * * - * $Revision:: 1 $* - * * - *---------------------------------------------------------------------------------------------* - * Functions: * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - - -#if defined(_MSC_VER) -#pragma once -#endif - -#ifndef WW3DTRIG_H -#define WW3DTRIG_H - - -/* -** The WW3D Library will check for debugging triggers using the following ID's -** Your application may install a trigger handler into the WWDebug library and then -** watch for these ID's coming through. Then if you wish to "trigger" one, then -** assign a key or something to the trigger and when your trigger handler is called, -** check if the key is down. The trigger can be enabled in any way you want but -** in practice, most things will probably be tied to keys. -*/ -enum -{ - WW3D_TRIGGER_RENDER_STATS = 0x100, // display render stats in the debug window - WW3D_TRIGGER_SURFACE_CACHE_STATS = 0x101, // display surface cache info in the debug window - WW3D_TRIGGER_PROCESS_STATS = 0x102 // render stats for last frame only -}; - -#endif \ No newline at end of file diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/CMakeLists.txt b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/CMakeLists.txt index 6aa9ede6dfb..b1a98488375 100644 --- a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/CMakeLists.txt +++ b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/CMakeLists.txt @@ -1,57 +1,57 @@ set(WW3D2_SRC - aabtree.cpp - aabtree.h + #aabtree.cpp + #aabtree.h aabtreebuilder.cpp aabtreebuilder.h - agg_def.cpp - agg_def.h - animatedsoundmgr.cpp - animatedsoundmgr.h + #agg_def.cpp + #agg_def.h + #animatedsoundmgr.cpp + #animatedsoundmgr.h animobj.cpp animobj.h assetmgr.cpp assetmgr.h - assetstatus.cpp - assetstatus.h - bitmaphandler.cpp - bitmaphandler.h + #assetstatus.cpp + #assetstatus.h + #bitmaphandler.cpp + #bitmaphandler.h bmp2d.cpp bmp2d.h boxrobj.cpp boxrobj.h - bwrender.cpp - bwrender.h + #bwrender.cpp + #bwrender.h camera.cpp camera.h #classid.h - collect.cpp - collect.h - colorspace.h - coltest.cpp - coltest.h - coltype.h - composite.cpp - composite.h + #collect.cpp + #collect.h + #colorspace.h + #coltest.cpp + #coltest.h + #coltype.h + #composite.cpp + #composite.h dazzle.cpp dazzle.h ddsfile.cpp ddsfile.h decalmsh.cpp decalmsh.h - decalsys.cpp - decalsys.h - distlod.cpp - distlod.h - dllist.h + #decalsys.cpp + #decalsys.h + #distlod.cpp + #distlod.h + #dllist.h dx8caps.cpp dx8caps.h dx8fvf.cpp dx8fvf.h dx8indexbuffer.cpp dx8indexbuffer.h - dx8list.h - dx8polygonrenderer.cpp - dx8polygonrenderer.h + #dx8list.h + #dx8polygonrenderer.cpp + #dx8polygonrenderer.h dx8renderer.cpp dx8renderer.h dx8rendererdebugger.cpp @@ -60,54 +60,54 @@ set(WW3D2_SRC dx8texman.h dx8vertexbuffer.cpp dx8vertexbuffer.h - dx8webbrowser.cpp - dx8webbrowser.h + #dx8webbrowser.cpp + #dx8webbrowser.h dx8wrapper.cpp dx8wrapper.h - dynamesh.cpp - dynamesh.h - font3d.cpp - font3d.h - formconv.cpp - formconv.h - FramGrab.cpp - framgrab.h - hanim.cpp - hanim.h + #dynamesh.cpp + #dynamesh.h + #font3d.cpp + #font3d.h + #formconv.cpp + #formconv.h + #FramGrab.cpp + #framgrab.h + #hanim.cpp + #hanim.h hanimmgr.cpp hanimmgr.h - hcanim.cpp - hcanim.h + #hcanim.cpp + #hcanim.h hlod.cpp hlod.h - hmdldef.cpp - hmdldef.H + #hmdldef.cpp + #hmdldef.H hmorphanim.cpp hmorphanim.h hrawanim.cpp hrawanim.h - htree.cpp - htree.h + #htree.cpp + #htree.h htreemgr.cpp htreemgr.h - intersec.cpp - intersec.h - intersec.inl - inttest.h - layer.cpp - layer.h + #intersec.cpp + #intersec.h + #intersec.inl + #inttest.h + #layer.cpp + #layer.h light.cpp light.h lightenvironment.cpp lightenvironment.h - line3d.cpp - line3d.h + #line3d.cpp + #line3d.h linegrp.cpp linegrp.h mapper.cpp mapper.h - matinfo.cpp - matinfo.h + #matinfo.cpp + #matinfo.h matpass.cpp matpass.h matrixmapper.cpp @@ -116,8 +116,8 @@ set(WW3D2_SRC mesh.h meshbuild.cpp meshbuild.h - meshdam.cpp - meshdam.h + #meshdam.cpp + #meshdam.h meshgeometry.cpp meshgeometry.h meshmatdesc.cpp @@ -125,10 +125,10 @@ set(WW3D2_SRC meshmdl.cpp meshmdl.h meshmdlio.cpp - metalmap.cpp - metalmap.h - missingtexture.cpp - missingtexture.h + #metalmap.cpp + #metalmap.h + #missingtexture.cpp + #missingtexture.h motchan.cpp motchan.h nullrobj.cpp @@ -139,71 +139,71 @@ set(WW3D2_SRC part_emt.h part_ldr.cpp part_ldr.h - pivot.cpp - pivot.h - pointgr.cpp - pointgr.h - polyinfo.cpp - polyinfo.h - predlod.cpp - predlod.h - prim_anim.cpp - prim_anim.h - projector.cpp - projector.h - proto.cpp - proto.h - proxy.h - rddesc.h + #pivot.cpp + #pivot.h + #pointgr.cpp + #pointgr.h + #polyinfo.cpp + #polyinfo.h + #predlod.cpp + #predlod.h + #prim_anim.cpp + #prim_anim.h + #projector.cpp + #projector.h + #proto.cpp + #proto.h + #proxy.h + #rddesc.h render2d.cpp render2d.h - render2dsentence.cpp - render2dsentence.h - renderobjectrecycler.cpp - renderobjectrecycler.h - rendobj.cpp - rendobj.h + #render2dsentence.cpp + #render2dsentence.h + #renderobjectrecycler.cpp + #renderobjectrecycler.h + #rendobj.cpp + #rendobj.h rinfo.cpp rinfo.h - ringobj.cpp - ringobj.h - robjlist.h + #ringobj.cpp + #ringobj.h + #robjlist.h scene.cpp scene.h - segline.cpp - segline.h - seglinerenderer.cpp - seglinerenderer.h + #segline.cpp + #segline.h + #seglinerenderer.cpp + #seglinerenderer.h shader.cpp shader.h - shattersystem.cpp - shattersystem.h + #shattersystem.cpp + #shattersystem.h shdlib.h - snappts.cpp - snapPts.h + #snappts.cpp + #snapPts.h sortingrenderer.cpp sortingrenderer.h - soundlibrarybridge.h - soundrobj.cpp - soundrobj.h - sphereobj.cpp - sphereobj.h - static_sort_list.cpp - static_sort_list.h - statistics.cpp - statistics.h - streak.cpp - streak.h - streakRender.cpp - streakRender.h - stripoptimizer.cpp - stripoptimizer.h - surfaceclass.cpp - surfaceclass.h + #soundlibrarybridge.h + #soundrobj.cpp + #soundrobj.h + #sphereobj.cpp + #sphereobj.h + #static_sort_list.cpp + #static_sort_list.h + #statistics.cpp + #statistics.h + #streak.cpp + #streak.h + #streakRender.cpp + #streakRender.h + #stripoptimizer.cpp + #stripoptimizer.h + #surfaceclass.cpp + #surfaceclass.h texproject.cpp texproject.h #textdraw.cpp - textdraw.h + #textdraw.h texture.cpp texture.h texturefilter.cpp @@ -214,23 +214,23 @@ set(WW3D2_SRC texturethumbnail.h vertmaterial.cpp vertmaterial.h - visrasterizer.cpp - visrasterizer.h - w3d_dep.cpp - w3d_dep.h + #visrasterizer.cpp + #visrasterizer.h + #w3d_dep.cpp + #w3d_dep.h w3d_file.h - w3d_obsolete.h - w3d_util.cpp - w3d_util.h - w3derr.h - w3dexclusionlist.cpp - w3dexclusionlist.h + #w3d_obsolete.h + #w3d_util.cpp + #w3d_util.h + #w3derr.h + #w3dexclusionlist.cpp + #w3dexclusionlist.h ww3d.cpp ww3d.h - ww3dformat.cpp - ww3dformat.h - ww3dids.h - ww3dtrig.h + #ww3dformat.cpp + #ww3dformat.h + #ww3dids.h + #ww3dtrig.h ) add_library(z_ww3d2 STATIC) @@ -238,13 +238,7 @@ set_target_properties(z_ww3d2 PROPERTIES OUTPUT_NAME ww3d2) target_sources(z_ww3d2 PRIVATE ${WW3D2_SRC}) -if (NOT IS_VS6_BUILD) - target_link_libraries(z_ww3d2 PUBLIC - comsuppw - ) -endif() - target_link_libraries(z_ww3d2 PRIVATE - core_browserengine + corei_ww3d2 z_wwcommon ) diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/DX8 Rationalizations.txt b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/DX8 Rationalizations.txt deleted file mode 100644 index c4cf6aca72b..00000000000 --- a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/DX8 Rationalizations.txt +++ /dev/null @@ -1,25 +0,0 @@ -This document is going to be a place to put descriptions of our reasoning for any "confusing" design decisions made during the conversion to DX8. - -TODO: WRITE PROPER DESCRIPTIONS FOR ALL OF THE FOLLOWING!!! - -Lighting --------- -The user has two choices regarding lighting. SimpleSceneClass will just install the first four LightClasses -into DX8 and let them affect all objects. Otherwise, you need to implement a SceneClass which wraps each -top-level render object and associates a LightEnvironmentClass with it. In your 'Customized_Render' function -you need to update each object's LightEnvironment object from the lights around it. - -Mesh Rendering System ---------------------- -Grouped by FVF format and material settings. Many meshes can share a single VB and IB... - -MeshModel Sharing ------------------ -It would be nice if MeshClass just Add_Ref'd the same mesh model whenever we re-use a mesh. The problems with -this are: -- the transform which is used during deffered rendering and during decal rendering -- instance specific light environment pointer is in the mesh model class -- lots of other stuff <-- FILL THIS IN! - - - diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/DX8 Status.txt b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/DX8 Status.txt deleted file mode 100644 index 31d3ab71d08..00000000000 --- a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/DX8 Status.txt +++ /dev/null @@ -1,274 +0,0 @@ - - -Now we've got WW3D up and running with the skeleton app. Here is a somewhat more detailed/organized -list of what is left to do: - -LIMITATIONS/POTENTIAL PROBLEMS: -- Skins need to use a limited set of rendering features? -- Polys going into the alpha system must use a limited set of rendering features. -- Additional procedural material passes cannot be applied to alpha blended meshes (no multi-pass alpha) -- Meshes only get two vertex color arrays. Their vertex materials must be configured properly to enable them. -- HY: Simplescene supports only four global lights -- HY: WW3D Spoltlights have an approximate inverse linear attentuation instead of max linear attentuation - - -UPDATED TODO LIST: -agg_def: - - Texture replacement feature needs to be implemented -assetmgr: - - Texture cache, - - Dazzle loader, -bmp2d - - works. Code for setting aspect ratio was added but not used due to legacy - HY -boxrobj - - Alpha blending support needed - - Vis rendering code needed -camera - - *** CameraClass projection convention changed to -1Apply() and the state is being tracked by the shader class. -Materials have been converted to Material->Apply() which calls Mapper->Apply() - -Now, some big issues we need to think about are (in no particular order): - -SOME GOALS - Maintain as many existing class interfaces as we can so that our apps don't have much re-coding! - Input data is existing W3D files, no format changes or new tools! (for now anyway :-) - Incorporate the ideas in Jani's DX8 code, grouping small meshes together in larger VBs, etc - -GERD Replacement - our new low-level rendering interface needs to be the replacement for everywhere we are using the GERD. It needs to supply all of the features that we are using in the GERD currently while allowing us to use Jani's mesh optimizations. There is a lot to think about here and almost everything depends on us doing this right. It also might need to serve as an abstraction layer so that I can implement a software VIS-renderer behind it. -SOLUTION: No GERD replacement, no abstraction layer. DX8Wrapper will be a thin insulation layer though. - -VIS - I'll have to re-implement the rendering code for VIS. It will be a 32bit, solid fill, zbuffering software rasterizer. Not too hard but still a bit of work. Needs to be done in a way that all render objects can be rendered through it easily. -SOLUTION: Vis rendering will branch at the render object level to a new custom vis rasterizer possibly based on the bw shadow code - -TEXTURES - there are many features in the textures system, the "file cache", background loading, LOD, tga loading, global texture reduction factor, etc. -SOLUTION: Naty is working on this system. - -MESHMODEL - I think we'll need to do some load-time conversion of all of our mesh-models into a form similar to Jani's dx8 mesh code. More thought needs to be put into this. - -ALPHA SORTING - This issue becomes especially complex when you think about mixing different types of render objects. This issue will influence how we design the low level rendering interface. -SOLUTION: There will be a custom alpha sorting/rendering system. RenderObjects will be allowed to talk to either DX8 or this system. - -UNIX - It looks like Neal has put some effort into making ww3d compile under Unix. We will probably make life very difficult for him if there are DX8 calls all over the place :-) -SOLUTION: UNIX version of E&B will not use WW3D2. It only needs collision detection so we'll implement a custom solution. - - -Optimizations: -============== -* Currently we search a linear list for textures with the same name every time we ask -the asset manager for a new texture. We should probably use the hashtable template -for this instead. -* The VectorProcessorClass stuff is completely unoptimized - we might want to -optimize this in future. - - -********* NEW STUFF ************ -DX8 Features which we currently do not support and might want to in future: -* Different modes than clamp and wrap - DX8 exposes all kinds of cool modes like mirror, mirror once - do we expose these in our tools? How well are they supported in hardware? If they are not universally supported then we probably don't want to expose them... -* Cube and volume textures - support via inheriting from shared base class with TextureClass? -* Anisotropic filtering: currently trilinear is enabled in the TextureClass but not in our tools. There are issues to think about for both trilinear and anisotropic like: not all hardware supports it, some hardware supports it if there is just one texture but not otherwise, or with a slowdown etc. - this is probably not something we want the artist to specify directly: perhaps the artist can mark those meshes which would benefit from "advanced filtering", and we turn it on selectively depending on hardware? - -We can do fancy texture matrix operations "for free" now. (Only on Hardware T&L cards!) diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/DX8ToolModifications.txt b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/DX8ToolModifications.txt deleted file mode 100644 index 667390d83fb..00000000000 --- a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/DX8ToolModifications.txt +++ /dev/null @@ -1,7 +0,0 @@ - -- Detect skins that are using materials that are too complex (max of two uv channels, one pass???) -- Remove Translucency from max plugin -- Editor has to resolve all of the cases where it is rendering to secondary windows -- VIS system needs a new z-buffering software renderer -- WWConfig needs to be updated -- Classic environment mapper and env mapper are the same thing now... diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/MAPPERS.TXT b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/MAPPERS.TXT deleted file mode 100644 index 80736705e74..00000000000 --- a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/MAPPERS.TXT +++ /dev/null @@ -1,148 +0,0 @@ -MAPPER_NAME -Description: -What the mapper does -Params: -What to type in the argument space - = (type) -e.g. if it says -UPerSec=(float) 0.0; -it means you have to type in -UPerSec=1.0; -to get your U coordinate scrolling at one unit per second and it has to be a float. If you don't type anything the -default value is 0.0. - -Types: -(float) - any real number -(int) - any integer -(bool) - either TRUE or FALSE - - -LINEAR_OFFSET -Description: -Makes the texture scroll at the speed specified -Params: -UPerSec=(float) 0.0; -VPerSec=(float) 0.0; -UScale=(float) 1.0; -VScale=(float) 1.0; - -CLASSIC_ENVIRONMENT -Description: -Uses the Normals to look up the environment map - -ENVIRONMENT -Description: -Uses the Reflection direction to look up the environment map - -SCREEN -Description: -Projects takes the screen coordinate as the UV coordinate -Params: -UScale=(float) 1.0f; -VScale=(float) 1.0f; - -SILHOUETTE -Description: Obsolete, not supported - -SCALE -Description: -Scales the UV coordinates. Useful for detail mapping. -Params: -UScale=(float) 1.0f; -VScale=(float) 1.0f; - -GRID -Description: -Given a texture that is divided up in to a grid, it animates the texture by looking -up the texture from the topleft to the bottom right, going left to right and then -top to bottom (the same way you would read English text). The texture map must be divided -up evenly. -Params: -FPS=(float) 1.0f; The frames per second -Log2Width=(int) 1; So 0=width 1, 1=width 2, 2=width 4. The default means animate using a texture divided up into quarters. -Last=(int) GridWidth*GridWidth; The last frame to use - -ROTATE -Description: -Rotates a texture map counterclockwise about a specified center then scales the texture -Params: -Speed=(float) 0.1f; In Hertz. 1 = 1 rotate per second -UCenter=(float) 0.0f; -VCenter=(float) 0.0f; -UScale=(float) 1.0; -VScale=(float) 1.0; - -SINE_LINEAR_OFFSET -Description: -Moves the texture map in the shape of a Lissajous figure. -Params: -UAmp=(float) 1.0f; -UFreq=(float) 1.0f; -UPhase=(float) 0.0f; -VAmp=(float) 1.0f; -VFreq=(float) 1.0f; -VPhase=(float) 0.0f; - -STEP_LINEAR_OFFSET -Description: -Similar to Linear Offset but moves stuff around in discrete steps -Params: -UStep=(float) 0.0f; -VStep=(float) 0.0f; -SPS=(float) 0.0f; Steps per second - -ZIGZAG_LINEAR_OFFSET -Description: -Similar to Linear Offset but reverses direction periodically. -Params: -UPerSec=(float) 0.0f; -VPerSec=(float) 0.0f; -Period=(float) 0.0f; Time it takes to make a zigzag in seconds - -WS_CLASSIC_ENVIRONMENT -Description: -World space normal environment map - -WS_ENVIRONMENT -Description: -World space reflection environment map - -GRID_CLASSIC_ENVIRONMENT -Description: -Animated normal environment map - -GRID_ENVIRONMENT -Description: -Animated reflection environtment map - -RANDOM -Description: Randomly rotates and translates a texture with linear offset -FPS=(float) 0.0f; Frames per second -UPerSec=(float) 0.0; -VPerSec=(float) 0.0; - -EDGE -Description: Uses the Z-coordinate of the reflection or normal vector to access the U coordinate -The V-coordinate is linear offset -VPerSec=(float) 0.0 -UseReflect=FALSE -VStart=(float) 0.0 - -BUMPENV -Description: Sets up and possibly animates the bump matrix, also has the LinearOffset features -NOTE: even if you don't want to animate the bump matrix, you should use this mapper -so that the matrix gets set up with the identity settings. -BumpRotation = (float) 0.1f; In Hertz. 1 = 1 rotate per second (DEFAULT = 0.0) -BumpScale = scale factor applied to the bumps (DEFAULT = 1.0) -UPerSec=(float) 0.0; -VPerSec=(float) 0.0; -UScale=(float) 1.0; -VScale=(float) 1.0; - - ------------ -TODO: --the ability to affect the period of the zigzag in only one direction (V) while the other (U) continues to offset undisturbed in the original linear fashion. --groovy scaling --scale random --random mapper random time \ No newline at end of file diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/RenderObjectGuide.txt b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/RenderObjectGuide.txt deleted file mode 100644 index a32b04ea684..00000000000 --- a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/RenderObjectGuide.txt +++ /dev/null @@ -1,25 +0,0 @@ -HY 2/14/01 Created. - -Polygons are rendered via: -A. The Mesh packet renderer -B. Render object's render method -C. Alpha sorting pipeline - -NB. Shaders and Vertex Mateirals have presets that you can use to set state - -Guidelines for B type polygons: - -1. Always set the World matrix -2. Always use a Shader (Shader.Apply()) -3. Always use a VertexMaterial (VertexMaterial.Apply()) -4. If there is a Texture, use Texture.Apply() - -For any other render state, save the initial state, set your state, render then -restore the original state. - -e.g. save the VIEW matrix if you're nuking it, then restore it after you're done. - -Guidelines for C type polygons: - -1. All vertices submitted must be in View Coordinates -2. All states submitted must be entirely contained in Shader,VertexMaterial & Texture \ No newline at end of file diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/RequiredAssets/AddProjectorGradient.tga b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/RequiredAssets/AddProjectorGradient.tga deleted file mode 100644 index 7cd0b7a2cf8a490087f023720808205426e3141c..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1068 zcmZA0v1?jU6bA4|t2By2AfbT>3JMV-Z3l%oSct=Wpe+j3mJG?DUm zv=E01?Vv*kGen3(9SoQug*aHK@B|AHo=`}jV6l{hLcepL26KPs-0ytZ#)FeX!MJ7bqQB0+{>Sw;c%$n4HZQ}QIw0p zV1RcqjUP0ryWQ^u*=5n0^{vx6KX12bfueo(_3Vz*)+uSVs31<7 zCrzSev)O1gzF^cq*6a0Syouv_?FbOHT8+-pAylh}RXWr^bIRp%rCgz{P_2CYL^FZ% zp@acMse~vNiwDz(a`67$U2i#sd;#)>JT3Y@-RiA3Tx-mQ2%zC&*Z2N93Owwc&A3N{*Hq7hc2k*&?mEfost1}78_ zheIJO1t!P@0s*xI{j;9={gNb!qDV<2N?xyb9dpa$@jPXVLf!3NTXWBFI$bW8(}m*% zm-7k7;c%?tA?U0+>~{Og3dLk?R;$&9up#JL%odB;OiRsTHkp=b2(D>)N%e4Ymlnw4 z!XlwM&oLT}20UUwG3fO=9iAR^G!Hl$jaI9nVYHfioayi9Z}`Pa@s%&+3kDu-NWSOd GW8pu$C;N2( diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/RequiredAssets/Dazzle.INI b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/RequiredAssets/Dazzle.INI deleted file mode 100644 index 1b7afe4e28b..00000000000 --- a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/RequiredAssets/Dazzle.INI +++ /dev/null @@ -1,161 +0,0 @@ -;--------------------------------------------------------------------------------------------------------------------- -; -; DAZZLE.INI - -; This file is a sample DAZZLE.INI file, indicating how to set up dazzles and lens -; flares for an application. PLEASE USE THIS FOR REFERENCE ONLY. You should consult the -; asset manager of your project in order to find the location of the actual DAZZLE.INI -; file that is specific to your project. -; -; PLEASE NOTE: some of the tools and library code assume that the dazzle type 'DEFAULT' -; exists and is the first dazzle type. -; -; -; DAZZLE DEFINITION PARAMETERS: -;------------------------------- -; After the dot product between the camera direction and the camera space location of the light source, -; we do a power to Halopow for the halo size and power to DazzlePow for the dazzle size. Halo/DazzleArea -; defines the angle where the values are valid, so any angle beyond HaloArea/DazzleArea results the halo or -; dazzle being scaled to zero. The angles are re-scaled from normalized angle scale of (-1.0...1.0) -; only HaloArea/DazzleArea defined part is used. -; -; HaloIntensityPow - 1.0 would be linear fadeout, smaller than that will steepen the curve (smaller hotspot) -; HaloSizePow - 1.0 would be linear fadeout, smaller than that will steepen the curve (smaller hotspot) -; DazzleIntensityPow -; DazzleSizePow -; HaloArea -; DazzleArea - Something like 0.05 is a good starting point for a dazzle... -; HaloScaleX - X scale factor for the halo -; HaloScaleY - Y scale factor for the halo -; DazzleScaleX - X scale factor for the dazzle -; DazzleScaleY - Y scale factor for the dazzle -; HaloIntensity - base intensity of the halo -; DazzleIntensity - base intensity of the dazzle -; -; Direction area defines the maximum difference between the light direction and the eyespace location, -; so the dazzle can only be seen if the camera is inside the light cone. Value 0.0 means dazzle is not -; directional, it can be seen from any direction. Halo is not affected. Dazzle direction defines the light -; direction vector. -; -; DazzleDirectionArea - Something like 0.5 might be a good test value -; DazzleDirection - direction vector (gth - we should lock this paramter to 0,0,1) -; FadeoutStart - distance in meters where the halo and dazzle start to fade out -; FadeoutEnd - distance in meters where the halo and dazzle are completely faded out -; SizeOptimizationLimit- NOT FINISHED -; HistoryWeight - The weight of history for the intensities. The history weight is per millisecond, -; so if you want to have any real history, values higher than 0.95 are recommended -; (don't use value of 1.0 or anything higher!) -; DazzleTextureName - texture filename for the dazzle -; HaloTextureName - texture filename for the halo -; UseCameraTranslation - If false, camera matrix's translation term isn't used. If translation isn't used -; the dazzle is treated as always visible, scene graph visibility is not used. -; HaloColor - color of the halo -; DazzleColor - color of the dazzle -; -; DazzleTestColor - Dazzle test color could be white in many cases but if the level has a lot of -; white then another color can be defined. -; LensflareName - Dazzle can use a lensflare by defining a name of lensflare in the ini -; -; -; LENSFLARE DEFINITION PARAMETERS: -;---------------------------------- -; -; TextureName - Texture to be used by the lensflare -; FlareCount - The number of flare sprites in lensflare. The FlareLocation, FlareSize and FlareColor -; paremeters are procedural, the names are produced based on this parameter. If -; FlareCount is 3, there exists FlareLocation1, FlareLocation2 and FlareLocation3... And so on. -; FlareLocation - 1D-locations of the flares. 0.0 means the location of the center of the screen and -; 1.0 means the location of the lightsource. The values can be smaller than zero and -; larger than 1.0. -; FlareSize - Normalized flare sizes -; FlareColor - Colors for each flare sprite -; FlareUV - Uv coordinates (as there can be only one texture used, but one may want multiple images). -; The values is a 4-float vector: start_u, start_v, end_u, end_v. -; -;--------------------------------------------------------------------------------------------------------------------- - - -[Dazzles_List] -0=DEFAULT -1=SUN - -[Lensflares_List] -0=SUN_LENSFLARE - - -;========================================== DAZZLE DEFINITIONS ==================== - -[DEFAULT] -HaloIntensity=1.0 -HaloIntensityPow=0.95 -HaloSizePow=0.95 -HaloArea=1.0 -HaloScaleX=0.2 -HaloScaleY=0.2 -DazzleArea=0.05 -DazzleDirectionArea=0 -DazzleDirection=0,1,1 -DazzleSizePow=0.9 -DazzleIntensityPow=0.9 -DazzleIntensity=50 -DazzleScaleX=1.0 -DazzleScaleY=1.0 -FadeoutStart=30.0 -FadeoutEnd=40.0 -SizeOptimizationLimit=0.05 -HistoryWeight=0.975 -UseCameraTranslation=1 -HaloTextureName=SunHalo.tga -DazzleTextureName=SunDazzle.tga -DazzleColor=1,1,1 -HaloColor=1,1,1 -DazzleTestColor=1,1,1 - -[SUN] -HaloSizePow=1.0 -HaloIntensityPow=1.0 -HaloArea=1.0 -HaloScaleX=0.25 -HaloScaleY=0.25 -DazzleArea=0.04 -DazzleDirectionArea=0 -DazzleDirection=0,1,1 -DazzleSizePow=1.0 -DazzleIntensityPow=1.0 -DazzleIntensity=1.0 -DazzleScaleX=4.0 -DazzleScaleY=4.0 -FadeoutStart=20.0 -FadeoutEnd=30.0 -SizeOptimizationLimit=0.05 -HistoryWeight=0.1 -UseCameraTranslation=0 -HaloTextureName=SunHalo.tga -DazzleTextureName=SunDazzle.tga -DazzleColor=1.0,1.0,1.0 -LensflareName=SUN_LENSFLARE - - -;========================================== LENSFLARE DEFINITIONS ================= - -[SUN_LENSFLARE] -TextureName=SunLensFlare.tga -FlareCount=6 -FlareLocation1=1.3 -FlareLocation2=0.4 -FlareLocation3=-0.1 -FlareLocation4=-0.6 -FlareLocation5=-0.9 -FlareLocation6=-1.2 -FlareSize1=0.06 -FlareSize2=0.04 -FlareSize3=0.03 -FlareSize4=0.15 -FlareSize5=0.20 -FlareSize6=0.30 -FlareUV1=0.000,0.000,0.118,0.238 -FlareUV2=0.134,0.048,0.204,0.190 -FlareUV3=0.228,0.079,0.276,0.175 -FlareUV4=0.000,0.619,0.165,1.000 -FlareUV5=0.181,0.365,0.488,1.000 -FlareUV6=0.496,0.000,1.000,1.000 diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/RequiredAssets/MultProjectorGradient.tga b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/RequiredAssets/MultProjectorGradient.tga deleted file mode 100644 index 02e9f132baee673d3982eaedaa68f676153add16..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1068 zcmeIwAxr{c7zW_m*bW98xIw@GK??+-XptgpC~OWky>o6*jv_^qMGF)xSfD_GWP+jz z3Z%0@!6HQi1PK~oJ2u!1zTf|IIB0gC@BiNK&9@T-gP_|G4g{0wd(CV%pU-*V%;r-~ z)234m!=5%CPbQNwlD+Zd^J~>;H2T1DXhUYe&u}<+)4lW3@AqG!uTQV{!r=C3yPa-_ zUZ=~Osy?fPr>eGFt#+%8*W#twXy9>8)TdvMRBN?*jcvVFucJP!sZ^`OoLnvg*=&Xl#jWm!m+LiGa7nSqbUJ;3T~ZV!rKA7_ zO-U>z6Uk&EA9pG&cFy6TX0_V%v4PcWwwM_@7PCbZMWfM3OGgw9 dYxKYS|NiX@NGEdmEP5J^$9B#SqsL*N@B``mYybcN diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/RequiredAssets/ShatterAVel.tbl b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/RequiredAssets/ShatterAVel.tbl deleted file mode 100644 index b6119c8fe5e7e0e2b06349728e7da19ef1c7381e..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 209 zcmZoD;$hgxz|g?Nz`?K*NHZ`BFt9K%Fg(}?WCGb!fnu8MOboqHIuuBUvN17m0@W}u zGBC2R0_iZIfDMrL_U3m4iG#qhrC%LZuL`n<@FqAgFx&vM<>da^hlUyg`3wxYy1n+R zSIq&lwSbmrfCPac@s8O(FG21DkEDeTRIgGzaB!m6flHSr?Pp{VII#BeqJ1DWjX;MB OfEaMFz=46m!4UvUd@3aX diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/RequiredAssets/ShatterPlanes0.w3d b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/RequiredAssets/ShatterPlanes0.w3d deleted file mode 100644 index c5d41cd0224361e28c4f79a4173741bdcb1ba1c5..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2444 zcmah}4LDTk9zSN}qs3sO6y^FD)f#iooa;ODQdn)6>-&oE$ZTt`viVvTyQ65Ik|?_j ztBu0d?P1QGmu**>u}imvB88T=&qbxDO(jXW=N$7G`#kr#_kEso-v9r+zu*7!{U1aF zLGpDGi3YXXAPAy?Xd)qgUZJ5r!GH7j3iJs<5yX`GzI3rD?D}O05-bvhh6Z~DhWLtt z11P{ewU**2S)$VEeaRyMjB%7QzGMx1h|YWEh|Yo7A^r%b3*7H61JtgRZ`KzU9Kry# zE9iZJi!Cy#a1caVCl^;2dwgZD4S4-GmFLkS!MVJZWND_S((#BP)?j8%-oLzF#l;u7 zEK15rOGRVyZg`AFo)CU)Vy(Py_m+s$?&Pr}sujr@$wW|GEkAo*s*3Bh$YoPfV1G4H zCDv1VJzEB9>aKtv0|0+Y6pjr~x&Vv9V+1-_g(BLjm@(%?t|lc-Mm|SBPoMCpi5(P* zO-=!~Yc9l>jgB&r?<(NCCRG-aa!gjz6`=B~=F)!u{=GI49Uh^0LP|Zo6>kVL2$U`GXW!fwTkqI2(@^0Q^9 z1d$!(@k}1MtL+E4T27$3iWO zga^655f}e?1_dS=s+iTYU_f&p1MI{(6hx-nQ9S4_Q@UO^#D3Xffd1-gpzOg8qrxw` zW!Q+SznHpK96I_4vAm=sSokyRmM}TtAjrO?DUW|(gspkN0wFEu3BQ-W^Es?&m0xwf zwBOTvFY<%PVqr>*6R>bHQksez&^2W&Lg`bi$QN_aM^z)T>le~hT=m^BqPVt&rD(=` z5t}3~9PqZ~0^qn5pl++(u!NHW(7DZqn7#zjqp{8^uKK@0*J|VQ*+wJ0P{`rER=g=* z(SB=S6wN(cBv0-9RB2c~M3~wP5;xZO2p48SJ^Sxd+=-)K5JATp+bUnO!M7b(!SSNA z#Jh)6GAq&*%t&ixB~uQBh6@T*|HRFrut4t+iuYfZMD>l{mpl@{rY?geJ@AMG&~Nqn z|9al?EwHtFnrg5o75E~aT(BVl(g?|^vF%NbpL{#p#GFrOK>vMJWT7Mq*P!rI1!D4| z9~=K;e?Cd;)ww#{_IXGmeJlq5Wx`t6KJyveQ`9e@&*x$);Kq{$_&~HFr1h#ykBLO=~}6AAR{#{p^{wg6lu@P{SYr+B!TKcGU_`tlW&VDSfZBt66Fp z3*WH5X{Pi0WbXm4o^urJbG2ab-_?EqEqkr-f=d9)tVdI zlAdo&2-^Ou6EozVRff1vXW>G=3ZrJJ{3fZXc?cze?#(M?!YR1 zCk$fn`B`7fXVyOU4Nr~UyoQxagM#fQ_yX84P7dnUj64VukO`+T8Itv=H)8{J86v%XX= zN!!7v`*&Pv1-E=|i(6T4Wa0_l`5JaAHQ|9h|6=Cr^}~DI*c3m!q$f#E+gHyzE&Xr( EKU-@&IsgCw diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/RequiredAssets/ShatterVel.tbl b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/RequiredAssets/ShatterVel.tbl deleted file mode 100644 index 58368bc445dcb295bf7066fdad23e90e12181ba4..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 209 zcmZoD;$hgxz|g?Nz`?K*NHZ`BFt9K%Fi33GXJ7=frvk+^*_jx6p>!ya4rOCv-~_5+ zU}RuqVFl7*Kmi*d-J@sa_{4(G79_Xp1(Rdn;}!NGcF9Fo2cWnEi2ZU=xBco>N5E{L zdZ4_5BS>5eXo&`h0R$f6clWKCx!^$Z*2DwC$5!q)E#Glq>iik|dEZRk|8f!cK9HJ5 Ppu+_~3^)Lp^T81SaI!9- diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/RequiredAssets/w3d_missing_texture.tga b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/RequiredAssets/w3d_missing_texture.tga deleted file mode 100644 index 974d3a232d8fb3090bdff06e885750a1e0fb2fd0..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 49196 zcmeFa1zeTc)<6E}q%-5#j)-(4T~gBBh#+F1NOzxe=w(en&b;@%6FB$%{qH@W{W(78$f@sI>$}!od+oImWG(XH7K8*LJCLRS-u{cge-ZdE z0{=zeKOTXiqN2c0Zu$B7y}iBv@u>WL0H~^}esIn||NFxaKfHhc{_pz+|Jk3kg8%N_ zyTK6RgWB`&-U&M3k!>j|L@_y!aqlj90BDQ6&3w#@O<_+2IZ&H zs33*U{zv)Pdyy z_GSKA015n81pizfL?Y=~(<_^#WD!sAJwCp2fx(KQ;kvQ$=9yW+=g&WGX(f<|A6`vc zTA+bOqxS&vhi6y*h5sOt=O}>x(gN55d7ea_n_pNK$NyO`0N*@4JsslDfBY%`hDQ@q z)2Hs-GmJ}8ii*>WOHhrDQ;djK2#+#IOm;3RI{oN=Ti2V#+0G?G*V4>;+DsR1rk6H5 zxIh?Pn44TA&n{8s7HDMRJRZC-$YqW?Pry%+#wREQ0&Rf`wty1S|GisVTiZ(HdF|S@ zf7iELo;U$Gpx30D*VPXB1!}1|2AO&LGII>lvb2-Z)Dx0bV-xqMq=cV6)lgGGd4FlC z=Mt^^+I;uz`JRX5f#;OrI_l_K+EgcTs*^A?Kqcb|bF&lUBeMhjr19|u3I+5Z=4bz| zANbEc7eWz9Ny!!bd3kx^;XnJ!&-nZTg*rD$neC@db}Wp)UK+3JtUu>dn690bZ;)4H zl2>S)cWQs`NyF?sowO|Fgfyen)VQ+LrU$X}^$|<2Bjy^S35^NFSDB=@r{>x(;Ja?% z`<~5>y(UhyjrF~qXn!-)+es$kAte1jsQwWV5n5VWEBJ5RxRHm4=QHB`tG9+IojSKj z9HUNk&JEQOyYG_Tl@niO6B^xV(a|)yP?{Lbtm&4`Ug~)n)%wg9l!V3qN>{B=H25r?;N{!>)7S%s5s7FJXBVp zcd|q)_q0uVP8Qbhwww2xQw4*KkERCe$P+cR;TvPMF`X61+e(fO-S;E3oFxywq)xtD zB#kXD{5xp&7Z84ZwSxbzpIz<8i`4lA!Z3CGExGS8>0KG2HhlIa4&M|<>Zzp7ydsac z_t!kE%E>ry>zF358^|W2fypK-PV>KHnk1b^-WffpIbh9YWd)?#odP%x9%Ok zar@Yn8;8zcGAKQ7n3QRC$S#OWI$c`rBF3%ubk0!Sqw&tCeJ=_+F8TFdx0`(8hHp$G zwO^zRJf}^zFV0Ud{gIi)YJ>3)@Auj9hd_OP7J?JB%|^Thg?ndhE_*NK$jM~ibk z#EEyE_b*@f#bqe#g>uMv?+|g=EMT>j-|8np8&*;4?Yk|%W3_d_*|&7qziqRtX|S!X zw|P-(^Q_AH$qUN|Pfpx@aN_12;3(tDD`qbKcC6xo?7I`?mGg9suLOA4olR-KUNBHy zGW8~Vs>*-rIfl@fHrH{LGSaYs9|Q;V4?z5z9(-2(fpX!OQimJKo!5y?srV|;`Plis zTZ?o3~VVC=J4vBLsPRu{Tut5M%$`7>t|I~51$^t_wdl|yJl(G_WKS52#EPHi-ht? z=j>Cx=ww`15H|VlA!V|W*j_&Q+;{Q`hWPdrrSB1KymfJI66R|ECg6Ym*w2Um!u$+v zs+~OWbgrcoUllZ4g`InUfrjs0njammzxOaYAlG1jl!#I=hb)d+%86dYnqJ6iCpv5y zL~M5n+cAmS>=L%36Sm&SW4(#nDJ;o-c-*af(6yt-rM=tb-Fv5&4yU*64o$6gb+7GS z)>=J!e)Q3^L**A7oSZ$mguHeMM2L&0C=xPBKSP`F9P_~@fLE=UDE69nHSzb^^~#3CGsR~w!8Pixr?s$sfxOh zf=Us5iou+6p3Hk3b_%0t1O9YEHjE;m{~!fxdSS~Q=rfiZxUF{xx)fjZB+R?_4ZHUY zxpfb?cJ;Y-_PVxrJGZ`feDlt}_LcRs>SK?d9l3GK($>X|i7%92AW1Nu2ZI=r!x;UmQ>qiTzMhGfL3Mhwi$@{X%crr-3Gw*R?5VPMY;=n9w z$0%aYC~CV?*m{SsHJHFoVXO5VcEYNj^>4lAs9po(o`W#PJO)NV9AFe~@B3Wdbve9h zv3*&0;>q*FH}2TDdWVV#B}?*T>x!hQNTevKojqaEa4Kr@%>(ji7kRiIm~i%mH}Op_ zgaovyjwK4=PoVeLU$V;hqu`HGN1Nt4ui)##XRH0@dah9kBa5UF2!7t*JbeS_e#+!< zio9Nos9MY(wMY@=P#%R4Hu)e{xnM52Kn_`dR+#{vy?$J>eq4KTtkO7UX)Lo83=Fd* zW+N}|hzoXf+KWiWj81!xO?$)j@RaA!gy+DRN8gZZXP;AZJNShYPhK9qeb?RFJ5^RN zUxOz@Q#@HwF-z0noXyeN?9l1v2aEV&+H@zOC3mI@M|zz>?tMUoxQLAZ>v;arcUVpQ z(G<=IWw?H>?c8jYFTOE~Jl04fjM0dL)XC<7Cug6;2VZcsKYhqNTgN0r%`j8XC{05@ zaj$l~ghs5WT7slToS0gSuxgyRTC|W#l#ogUuVMt3LIjs$1gAm-r(y)#-tZlw!2$6& z+9H-f#!e8hljy)q;4$N~-lJ0>1-G6-m$oj4hPPH#b>{b;ctnKe=?b3I7D`iB%uv@W zJYZbuX#VO<++1JH5^01+7$Nmsoqgd&Xo#Qhx{Z2d^51O*tB3#M0&x^lVRLO2v(^6i z`f$p`TN-hkI@7mE=ppqyZNHrRG9~hEu+LR5w+cJEvJ;jiHWo$ZM{*5J(p3zS<+Ky` zYQ>7HMF}ZKi>O5IR*vLT3gc7=5lvt$@P=$OaN%=;3legrCJ9PiOT z;`+YV>Fqn~hPNl4y-bL}T(&T{;_Z0d*XbtC?nx}R?NS!0`^f?xzTN8 z*d^k?0KQllh8+wh5!;>o_TMskxcK7c$vEmF7OVh|4j&TD2Tuk=2p}&7(3X6NG_R3q zm)7@Iuix1{d7c}Bec)#GJlwr1(zQN2`2Ed%V#i(DOeb}=mkQZe;y9`I#>`7ELQ^WZ zJ>-a+?dU!B_=Rn5ew?jkhPzFEfZP3KzxImc@w!UtNG)ylJ$z481f)q)_vP7_ z-lVsAXiz#k@b}~>{wn^kx-`=RIzwno!dK(S!_R2MN%ZH;_E5)PPrbd-b|wFLYQzm6 zPaymPphNIG!e9zP9njJ&v~q?m`Wh|6vfM@|u!ZS>y8CO-WGxJ6L)g}|kyqt`Fevu@nB z?aQC&zuU>OiIJ0D(vjP->yGyb;b2CVL1e_fu+YP&iw|GBospSX6X)4_E@h(r5*4Ok zGu_KPIY=W66Wa=bKS?cTC_}Xi#EHKlU;3Buhk%DLN*SyszR91h_L=Xy16l;3J`CDq z^YrWMtrxPNCWc=1b}c@39H>6SKqq~_dio*d3`?aCa zyCgH0?hd81h+P&#ysL7ggLIgMbnrpR00VKHnm8DO*B((fAyH>uVOP%G-Yg8btZXm= z-^C^0xj88-(;Yj%VcJc{$i0o8Wg8>!Cb>xDNcDct{xP%c{KLhihbylfuc$m$Ql6L? zciY3_dAv{axs0*;OSI7jP$6JTDt-vmp71JZ_NC8UdnIM;?cWfQ{uTV;>rsLB+s;F@ zNo>sn{h>j&2Y$%ZyV-Yl-d)Uok`#Oe<6L5KEZ1m%y1rKGe$})?O6eyQQ=R0Ky%kbJ zHL~IiOiu{ylBHu;WZ+a_VB5pI$77?$O=SPsA0mUL65QpY9Hk;GBtuOl0uA=~sY_sG z#XLk&{N4D4Fq|x2@(S3dw*gB__Ko#yqRb4Oo0<6OnE2>+u`-Ap-mHHfF}S?Jx$C+2 z;H-OBzvKG>$GeZB?Cc5*bjmGEuVWmZC5E(I$ew;^7tFd?7;j)=lpof)Vtd)S2G`^;4b=G6+4;a zozTiWp`78MnBlIJiB(GTRfzZB8ylgJnW`HRt1q^Xok@<4Ta}SxFB6Xzy=uW%T2~Q` zi)-DY*b|N`h8>j(-oGb6N76@G!dprVl;4F{*ojNnQ&7NXkAOGhPON`Oz#K(2*pr_1 zdltc+ECO_loV(bicB&?Sv+o+BU5c1jx%=RkyoM%S-}l*c_Ini+W+*8Y>8hT!JaQG| z@-!*5{YnA8?e5}q8*R3qI@1jnO&)kSTjfoBn@=6Af%W}AI;HwUfB&cPUx0vfsD|`5 z9};VX_t$4f+sAurM>-$(HkQ?2iny6(dp6jx&{H|bQ6k-rKh=RR#aST5SvbK#G|EOi z!d5KCO)3SWcJzc4lPVpD8Uv>q1G_Af1ZIQIRYdCoqIMZMn6n|oTq0awIzShEu{cga z%v(ytQ%uxTOxROQ$XA9xNSW79oGnO0$u2LAO^%nDZ#%2-E*3$0MlMFt6Ppb#t}(cX z=#(NxS2#U~yRefKkKO^Nu6~=>Ex`^h`Euf?_Uo1$I}Y6VA}zA(_UXBv#|tx^G+3CM z=|>$wEBr2>`HoA}$+pj$ss5ArQ^_z@nd`hfQ{_9+lseQ^+wtmpYi)VsqofCA&Xvjg zibE9gy@WFzSyHUGC0cAquvi~+;`?yRA3`j*2iY+PyK=?)N#NY11$9|jw03dpFmk9e z@fhw@Df~+33Ziu$^dHfvT;m+Y5N#(MYResboIA*jH^69jfDV6vmSCWUNT`lbl)gZ? zhERySpppz5z35IBF$Pvq24;RncBx&;iQj_q>zzaN$`QS?FKpkW`x2JCh9}&+`s{j# zoGY%RYwpcgmdw#LDmFiU1Lskl9ozq;j67JqFblr8kBT3pOt#Jd3pFG_eZ>M{aA^rG zEBzd|KZXDDRCnMxp($_%3z{239c! zW&vg~%PlL)58&&cLv%}#12?5G6BF1;vPb{03z$GlSGbRB&R&5u1+`o~)QU0?2 z0n%cJnOO~XaPQy6sl&9}bf?P6pOqi+A9`$uP4^F>pvRunIGBDeh8B{niMSA2c8I{~V%!7REZecP0Kr z)C4@b2kblgTyNY+(N{_pmrPgIDlj?-^YKS9L2Z|FiSHjQOt+yXKp3P>ci|gjpdQ6vQyuRg#~YM9i=l3(-Hzuvn5Nt4 zBwH&cT1iCM@C7*Y;&39^5MgYL05*x!KaI`Ei-CFHR!)=coW?uYb$3Yy{-|>q(Y}Zx z|8b~aUTc-PBixfC%$Y01fiKufDAZCU(n>VKLM+OZIn{WhtKK%wz4R=5nKJz|f>yXP;eLw@c;aL`C@|@jZ#sYFU~_rN>X)3Bom>%ba?1oiZGDokk8nI^=_z zz`T3!p!2);HuZ19>@Cv8_+mum6J@mW_Z_Tsc7#}{``#I1=RMj)3l&Ob2&1HqvY8iN zuviK4#?oh~UHO;zlNS~MdBC5txHw0in;3fCS%0$jhWUf5=2vd{mt3~bIjfvlKp&R= zonP7y*z~Q~wC%W*EtsSqFbV6tYFXVh#I= zuUXB$EivKn$>KhHS z&5R0+oXU(`$_(ssOgy?fHFCZ(x{T<5V1AVR&mo58C8G5>|m6c=6%mU;?j7(nhK(C<9e!l`mn8GX4r*9|n;I1lx=AGk?GS z1MN_k2YfVPYPh@MLfuuTd&Lr!@C|;E--pC~8=1H+HuZZa-z_|vjLb?5Txtv}_)EBLLY2P)sOBH^AMgi> z=$0W`XAp}Te?P*a_sEP}SD$0+d)voPqs(*?1VzGm6%(X1^9@Wdx;ni`jer^1Y|E_$ zSigYjJbn=70{EI>a?c&`!hb*hE1!t6(89vVK=bRDg)go;JUnl5=SJwY8Q1HU!0Oj7<0;HTnC5xb@l=+Za`uI5ikJ z)fqUH88|g|sbzk%|1!!ppW+V>4VU>x?<@iowEwEG*JzK=%#wTGpmTe-^{ZxIU)LCJ z?mz~qP&Vo0y_%)w$L@vT8crn-JS(RRzFYtkAWqEp-@{k?!(u&@b1bcPvBdw*KL9)E zKWuG)@>L3r(m(X>&6{h@Ps6(Ea|XNXdfFZ~zAU|cF6lzDcae`-wyk`MIah)?V}d1p zwDp#7yB{MQ*GD+53wQk{9P@3M?>Di5-yiq-a<>!0?SkxfM7XRF(a<$o7ZL3bF+b@4 zM=1dRtl$sNXkYjOb4E5P??6VbM(HW_&=^I&{V;K(=hkE7(q?2=W)`vCW>B%luwohi z<*;)l_yp!z(SN{Sw*&&AZ!DVmYqWpMe$v9bqc%=g=n#QLNnP2vF zeVP#Z?o#ed%S~9kKy&GnEvOf6N}&$duQ~<&@A!lAg9uhaU#OfUj<-*?R!r0c&-6W* z!HH`{#HKLdSeCDGMu1^*sD5myT113wNStgyl9X?{1SWT{Z;=W% zUsB5V2ToUn-yPv|LIgb!l_Esz^3RxmM1F;ZQ2$$jdIZ!9TtLiASz@v*GV@O4XCE+j z6l2t(=Qdz~!KuT@Wk|1*`Lz*{&$74uwf=)UKxe_|&@2QKkn|ks#Z4}__YBy->vnx~ zFF(Yk#KW)DE26?D;*5<;=?TkQ{$BO@2?I~d$%9o;AcUqPT5|C`hNi-h6TrJ#R- z{~}Dh(WncJJm+R9qp$JJr-xtV4voGWn(AwBzyIR?nJZ_LN>7EJ%)w@**eA!E#U~hq zCm95$8u(-ydF2>;R&_*&!bd>^3R8{;(S5> zQT)%M`0Ex!M(8{Hwo2U0lE=W9b7#L(O>HF3JxWG1R#-bt@j#}QX`$(1@B&X0!`iQ& z#CJdnv}1uZHTV8J6s$tNg*M#{yPsB31pf>EuxAIhG(+$+OQlSa$y2jqBLlS^ug|nK zpX(j#>Kko+-FWTJ#mury|GY@M6kpR=H?3$Fr7+h${?3BFZoGcpTz*()KOB>v&#qA4 zZ9xIs)cn5X$05QPM9>qxN0tB5FUtQBf1o2!e!zdl5a0qefs2TB%D0J@oAi!v-etU< z%j736~J z#NxCCBlI`}^>zjs{TO-x2{%K+k0IffNW48_?}bSCA)>yB7>K|Nk%>is`87Te{zvd3 z;L$w0R{O#-{;1lc7pN>QASS2RSRdQOzkf5^p>13Tf8sR#iB10}QIGYI=hwf0YCcN! z%lN}HdS}<@m90T70yKYRfc}>u8fOrlb30u7>Ty#`?!Cj15p~GSb!O!EWe^YLP>2>* zO;a@}I%Ez-8dVuleGf_~Lsg3q1;NgySMkJG>98)gx{EUZ41eGp=%+AGqv0tOARpLB zNSW@1JwAk*0Ls9_CDQ18&y$X;`Hy4#DjY2GP4!c?72?(Q#A%C!YVY>fWeYUi<>RdE z6J_HcZxxp5}J}qoEGq4{CoIk;bf-4_~*h5`FSh z{I$RY3K8??o|y4@kAX?&zCpW+OZMDSUOx#2v&%>DC??5h(n2nTkLE2o_X@t$KuKg!b47x@x_Yxe{p62Yhy$fu#o4>}L} z591^M>s?1=gT80v+a(?Pz5exI{O^hh=w3q9OV;dm_>S%12F@d!SdBOD3H%n4{Q8wB z{y&GB5b(fMF83=A8F~TpO@>~>ua>vg@Cu>_`~y0_qW|ZSeIP`y^^EK+9NOD83ci4J z+^6~v_-mCST1CjQsu1syd6)hX`=?cQiUy7wIs8~_B((nzDl*xCH9)Ws7m?~a$cFNypnxvo^ zvqvFHa<7lLxSO!Bhrn(R1sUfDPu%*)fMzZ0%H^Uq$b=)Zk%&|%9iyUu3jz4RRVKPjYr119hb{{R<3R`W8VdJ>&GGnjrQ;`f#Qg*65M@A8~? zCHORi*+enIZ@!5|ik?k#`yRh_U;-cgFRTRs|DYl$LX0j8y7%?F4oo>TytXwuZu0|+ z7mFlRq5=ga!d%$!V5O78v!pPnT$=BD0r<}kJi^z8!Eyj?s%vreb`AVq{O4xC^$;2p z39plAGw;d6ja|12A4Lb9v$4t2-XANe7Qrtcv|HMpThx(9$c=~BLtVx3d5y;i(Q|NE z_l&ws2%->+$VDMC5r}FbqWNLM_0j)oz(UEj^(MEy`7Qa`4{U^_sG!qEaKxbSKP&&T zF8~A4twh8E5w_!qN-hEkhZXQw_y>{?1{c4QjoJwBzQZ@-ccE?|*3 zL>aAtiegf0F>RuK6|1v;H~y2bfe02ONG&;w_+C(sZtE@*1O_s6Hbf`;}rWq7aA3M;n+suI18ise6+i#!hrbhlC0JSQ8A9jNx92i$`g=n$bBerfB%d+_51vetHuOT)P%gNO+gVNBwV~B*V8ozIT`mSu zN=6jp(4k&}XnqJgKjN=>4pA%r%DSy6WNFE|=^5uiI(FmDFv9{9&_1^o0M|K(TEPnb zXdna+VM?_e>a6HLggvm%rCYYnvHK)uiXh=F&#a4Z9p1`rvQ@xtgLcUpG%335e^LG^ zMe)}?0~w*OPc)oz>7BL5h1hOpx2G4vu}DFoZ{%*JR0X}$W=F5%JYg0v*?0xkh0#Q4 zT^Q+Y0r)|5E9)xVekcA*qzM{q*R6}1Z!cUT_T%3@d|jM!4dZso*epRxBb-w%kXgo+ zUes#4faOnu)|)u(B-LCS-XE_ysgnGqax$Wnf+)r#D%q&!YgGOmc7DWPwG`QRPYE+K zgw}16NHW3un03GAFs9=)+oqKDmHw3vQ-I}+5C{TwxGPEiW#$Lxi%xrs5#t*oIN}rt zQNJ{d)$l8h1M9gCZs9z*Svl=1)C-g$I-vi6KY(A14y{7O_?C`y_o#DNj3WcPJrlnd zt3(L<-f$j;L}{&)MrKz$TU}=ikTTI;Mx5;(X?ajvl787Ack1YgB-MRUV%i~sYVJIH?b)U5Ii&0v1e}zO9INZ} zDwLFx5Y;q9B?SQ~s2496HhgfqEBFKRtDZ$HTeAGg0RCdY;?nV#*SQXX32b89My-L&sfP7Zmu`a+4fPbR@5aH;b{ob}U2Vz~o-?H`&_fb05eP3}M+R9TZG1`tbl+16Hui|7b4g45C^5<$*`;frS^+OpYWTIG%21 zS7`29eB9%l6YhFo|9%ZI; z{O$ePlS!An-SbV4Br57fiE0E3tGe>ZI`T+6@yWV!$+*aB8)olT%SSY_5fFh|CZYjz z{}14Q#9yNVQ7cn|EPpA*+v;__~3tA|9<}qd&Vh4 zb+e7hGjG!7r`kqA{|l2UecbbpnI{|Ui`UkT(AL7KDPzUB-OpKielkP zfm{o>*J~AMSmK zi(mpr?w7NhY-Zp8Bm4dx623p669JeYS0KOOzf3;xP^aumo3|Ou^!2j@aRk(e49la~ z_J7M^x}Njk7LJ3PWh1`g`|RkFLMKDgcE<8E+=O z$(yN+eVb4eKL3?qt6fgnQ3q&1e&_p25#(i|F>Zvcm1b~77a8v{z zoG&Qwf!p%9*-2FS(Ty;u1;ItY!jkj*W`1jS79;S&ThKt%X}u=QydZX64t`cl0IpGs zIJ4H-XJhCwx)AHF(e|4Y9JVAoZAo|EmG381mZ*NU`0#`K5zilB8tz-R)FyRz+#4C{ zAQGlwRq(H(|2yhW;3EKkusF(82eGwyx-MdFv}U@ew()G*C7e^fsa}%0OsuMKl;&j!5vG`+z@@h9NJ( zz*3fimX^$`ZgL#l!Mg7|cB37lnDvkyg~{)y`0GM#RmBFop38o)7YttYVPNLbcko+S z(k>2R-M^0O&_>XIuEU$ZS%uyO|5E>d7BRH&n(3SGxQMR_ zA`jl58-CMzA?s=oF5k&1*~BbXQzu+Q*;i90Kty{MAe+rE^&2@Ye;;Tk)k!sYFPLv2Tf?|7qQz zlUm^?wW7)l<1ZafyJ(zQteSOFS;u)N^MOrhp_j=PZi|hod1xT|5r3!)LdR)zZgMDZ zonOM%;J6K8(ceWzeiIx0U0Nc2VS)U`YxZ{^20Xf|Uwg~4z2Vf@NHdW%4XYxQ#f3R2 zNJE?Z{dqb3FZvJf3QJ%F3I&~iQKqF=`GO4gp;KRmMr{cX`!OK=hmeqO z!~DL8_E{Sj`E6?Imb{c7PKF|-L5Qb2B&#=b9NNNVwh2r?GU(f%a}g`#^8tU2VnnZK zEiU%Q_>e8}A={Ed88X9pPbVo~J8Si_Dz%|D;nh8hcQtXn?;i|L^p4L?Ob{lAh%+N| zBoM)$NB>{(KZuq{g|4zxJe4|4oSqqZHT61gtUh{rq_*$X{b#xH7d$+2jgBTM?N5+D z94KvMiv0=Ve4SU!)-(BjfjUVW_-_=?3yt43WeDoP7k6csRll#5GykSepI&?;J z643$jIfJMH@}H6qJcPn>m~)-|!m>FX5)L0@el%zyE`rlcIOm;nVnd!IPqEjJX_j>P zcH6VvH%OUpqc`2gZnBLJOrYosFada5^McKhfdYvk{BeIg<0!#-tfD7P&8JXE8xwx+(U$k5f^b7tvrxBGih{?$vC$n%@ zPi0>z$+=yg|NMGM^Xmuihg;sZ-EMq)@pX4?+gQ&KkuZsJ0<;nT6rn$P{X6l8kAmgk zxtT#i_ubLjnBlgvvB9RsTcuaxBTjjEWgc{l(?5JHh7qt`QGO7?KU01PJN0i0c}{kJ zs{G6GCk;beioKhXYqz7ojjt59DZ`c}$AS60_f}iGttwz0!y2w+I{HRcYSQKrF@e+>n7LD~6j`0_Z^4}95Bp&A{5$7kD6sMP&Zc>n{ zeJWbIC|vS%m_kl~j=lpQ!@>1DM_^HAGuP3Ls##w^M($Vm!*^CIL(F2oOEi!vIHG^v z-@2weVY0WH)PECSvr>Q9vFatze+YkQt3;h>CAF48F%os?;Z*bEs?5mq$8FN(^(-(u z0C3$RRR4i|K>1aE!#pVYoP)B5?e1f(zfpd4-UR#;FxZviDxGzltI&CCq8Ufh5zdni zn+hGa7TU5TTC><6*(GnfT`}ZaOej-=^`2;F(KvVEICqg4chLk-zBm`&1UI3iFr};* z)q-&00$-+6n4N`Kx&l`=H(Ms=qZ@Y}-N1TyBO96y`W8~AkhS~B{}3kw{t$&~7p)Dk z6)!(}^lrGv`#XiyiMPae1+!@V?cD_e)ZeZK>HKN^hYi>Gf%%?$uo6mY&6yjhX|2q= z;o+5QVqy_a5BNhq4fG%K>Z<3L$$ur<{KN_%>^$)72qf7c$?!q#muIZYnI9ZX#7Oh8 zL8h68n+mMg#pu$<>N6G`|1$5`7pVuf=9q2IHlYvJ;`G*I2{B-a)MX3TXO7y(5V?;b z!jK_)|Bgt*pCb3|jI-RG<}8$Lw3izlCUck~8!Y&qMnd~Sy@lBNWu4o)wl z8PoUwlznh(ycTVWyKvvYm5ug)Z2c6Z8C zF^yx>4B(ftv}QDj*<={K=|JqpgE2pvM*e7AEV%E{KBEVEMt3xi)c9g&XIE0q|AYPm z1;G+n|8O==t?1aA7(@0Lea@UCo3jsZNi<-N*JX=P;lhaWdkPD9i3oZM33v$!!tjJ4 zD1a3e@Ddd8chx-+o9Z8VTieOLSlwF&7?D7cNmpHeok5acF%O!J(KSs(I4T z?5ew4V^IpB>jk;z;!KqfT5~eqvh;a+^!*9^VGjb-!p(PHfwm8G9Yw^h>ZZcP3r_aw z>V~ioAIdC`*(GUDC+x)|h~pP@r|0ot6L!fz>o!gG9-hTc&HK#EL8BgM8uLHvKau9W zxD@mHTCwA|$tK$qOc`^Jf0c9W>m*~k1Ow&>4GydXADDo*2&(+v!UEnx0-*e$`8Y9t zxc1-|z=#QlY0Agw?TOcBOEdZ@S)VOTaW_U($W1^PD<$hKDeEF6>@F(iAtL4>Am+AP z%!yMJ%OM%YE*HtIlrFDde%$JDRM5cVO6tTbLQ^cd1-t(Vbjn(F&%0txe+GZ}D$wU- zsG9gX8(-^78G17O^6G;K-=c#@5~Q`lp^YB9j4O+%J0AeT@60afx}DACu%&Zbm)ppM z_wWQX3WIi4fIs#Vwf|HW5QPRz52uBw#K`{;p~IPeU~8K3Pq8|z(Hb1V3f%5|f-XGE zgImazN6?K&5boV~3&Ll43ZVM$B`O@Mp%A4b0nQ@TaA$%xM~Ez+7km?5LGL|#Jw;_4 zxrCg#MV+`s963bnScRQgMFZGnq3k49Ts_~&6p9L7m8257tLMAV1INyFT%@gP!NUsd zAMgJh{@{sVhvxkI8~EB_QfoSS`E7hY#rkmA(c=LIbU`uuic=Wd`|4b&UD;v z>;f)DB`#yr9s?uLv=Hsv2Cc(D1pkv2U`dP6hdttEL5#}QNOk7a1N5mz^wApZk!qZQ zvOLb*f{yIya9|U3WD|5^6LerjAA%H|IfR@!1l{;Vf|L})RV5>pITJKlq7=FPL;jI=!mis`y!P*RZg}N7GT}8a3hfF}5zH)$;I~$Qr(zeD{3eGZyo_VyH>8>V1o|JX z#Tu#387Rl&!Y$~;34jYYun7S2FzlHH99RULIfWdTAG+=q2~t)LQ;`Z+;EGk{4Bxxk zR~QwOEu)YJzk(BowB-(dXmO0T+oczBVM1%(Lb(*;r8G{N9J=Y}1=}ttBd+qy;bm|H{%BuI1$-6(duBm<7C{t$un1N`x80(_Dk>pLl3{Y3QOevQGW<9pK@br1 z)b$otb>@&cv7K+F*Ref=h!2ZQD4Tq=uu7J;(Rq8jnw;p_ju+IS`_R;d`1T~a=X7rB zx1g=!Gk+d`@B)y98gGVHQL|M6^KCiA-s+|^X_b!lIlB8}#Z+R1WTGU+-8rFeo{%%U z2#%G_OHR?@&J$;7TH8D1H9U!mV44Ko3vmS07yJVkfe03taD#&pC)5)Z)+ZV4a?Qg`ur$Fq<4Sx=d5nhl2BmQT{_!5OcmD)CWVQ$9&HN zIOXSa?0NrGe18RhV8sRKa|jJrn@`Wy_)+^VO|?FInGto)#wtU@FhNowSw=E&_Z|mm zCd@31;TQI1U~xEb!oK0HOV1#*tA%bDAOas$1oQucJ0Q`(1OiKQV-@HUwCSU@xgynh z0_6Cdd4wG}g&jGB>{*5FScL3hunK`M_*wrsggk^KLo_sk6!(Pe<&IS54U&a0Siq50 zz==)VM^ej?Z4clNosB)2_Jpv>L8)8PUTvtNydB{E{$?>{w4V4T0bdgc%mbMgI56T< ztUkx}U&0^05NwTsefs?`h)rqu8XRTd)=2H`Cvm~078aQr+Ntug(SkBqHc1eH2ZSg* zd`{ar?1Ew(pl^0(5A*?85dn4z8mOXNw7h^0Yv`z7#?CI!#b##0F~{N+Hb-l5Mr!U3 zQsQ$H5OL-eafavxl>#~(*n}N9g-~AN5OU%a@)DN`)7B1DkO-FJj!@nmEW?i#2KY@5L_&e`&o-@Wf7j0N;c0 zXYk`BG+?XIB{#>Wq7-~rHMzTd2BrN|RCL=Zq}o=$+s1D#Xch2B9RU%l@?b^=`}7G- z;pBlwJ@+f_1bUX3n`WqLM)50zKx1uQ32%PjVIhYt9L@(0L&tuHwjNgyLC=uq(75;5 z3~c?Dul&`4pLZdsf{*sUN(n09|%*a zOMX2)I0J1AJ0s+LRx}@ct}Uam4Jrt@7hZP3s4T!2V5Jp9G_)~7!agFrfzrGE_wc!J z30gAW=f`BJss`(MQ7drRC=_HBsJ@;wT@0Vz+R^Itrh5ywv ztA#&E0NVajMjBzl2-#_3Q}|rZ-QEZ1A4U0BWjF#*0e_@kn~Gio3J$hDdUG zC52iwwK_C+y0&(@cJ)J01bd=^j=Yw8%P*7C&mGQTI)Hib%u`Ilm6a2e+;%y7UztOp z_q$MdZ5RZtcY$>X`Rr8;R@U^`E#$?==O@nRBgO}lGABk+IAsHMxZJSAQM+Kj8RQHb zPp3~cKO}dR<6&=aV+y(F9@_l*^W=Gc1^dT`tA{_(5ENvLgB8FgHGFM2ObRIdcfcLP zE~>H<7Fk;QsftR`0((PwWPG_LLd19@^#$FNqE9rn+r4RXZf=8 z0Z7SfWD+LJFfh<+p1OpIPjcDD0R5j~mxs+xL16Nq$MR&>8hr+WOkrO+m`f>0YlfV$e=ixY3|*W@NuI$EDL+n1`K7AGbjDIgOqBbBHl5Uan( zEj!%;&TwgX>)6=r)Z78x`yn(!%>j*3hdn_MgJWJWriqx|L07}WHtShz;DDY_@&71@ z9pH;aaB@n%GD^;z{O&vg0pdbYlA;m3GT~hEF(PVk=s+=aI0^IVyj@Q0emdWg4-S{` zI(xqN0f7H+IRayq@kd1fRxkydM95t?A$drs!IC@j@Es4@t`t8Ab1OAB%hAv98&fJpUypIi5`IA-VEpViq3 zDq4TfWJ8aJk-r*nY85yFtgMocq>>l6NU(rdywsjVN$FT&#UxqnJi`MQ9Bp4_#DYnZ z`)`rn#6pKpI5-mREjIK1-$FYp;KMx}ga^mr!J&8%&VQt)zi_d*03GR}M`G{e<<`)? zbIl3!-Pd3*ZEa5U6>r-@<9%70>e;5Mg%;|?db}C>ydFv6=8s-jJbnQOd)dCIwXJEi zuYc{(*bK68eB0*K(&_xJ)1{-wb$r_SR5|EB97+X;!mQvAX*4T3ARj@i9YW4*V!?{) zk+NE0eA4k^(y8)tX-aB2y2fS4PuvZ`wOl$q(|VuMb(YW=1WUSbR0O2g7H0dGXsfoL z?stL)M?J!Uk00@e3pfrE4u$-kFaKSCMxBGE%H-iX2#W9xall1$%}K=et9=j4pT^=Y z*dHyn-Cydo|E#5Ai5^pdF1wGn^WjT3j>7SFckaVEcUF&|SwDSg^Ss*TWxZ`plU?mA z`?@y{Z`vJu2OSb~P_#F2f(UGO3c+O7ahHfYg9L^_GLUC)qMCk+iebVYrA$@z0wcpR z3-jB7nAfE_6HWK#yRVSm#^P%O39qur-FIl?=*D)aE&g3UXSM$b4m^cpPgg_$2cbqp zM6C8FKuknkfKxC=-_CX4CBDf)1MCJLa_8yM>hh-3iMM0juZP)P$L^~*AzZefGf#;Z zV{3D$I|_1-6U77%K2%asFV zu$~C(xo|Mw=SwXAOEBTUUpV%61%F9N$b&9_w$8sqUb*qN8OvFE96 zj|!WvWi*`hzU!xT#c^->A*p;-@t{Ko4`$@=D?5MS?D@kLm50w?gabFtFJCvmdgIvj zTW}EPiCcFqp1-hs^4#0pC6Z1&oJBUATLI3Ci4{?W)*0D)M&-^9S8$$p!?3W1*#G1L zq5am}yKG{80HHPr_AkK7H5|PPhf)6hoby|Wz_Hh2Vq!o2^b;I}{oDUt&1axYm^exs zYlhktIQew?MZoAC$DRk+o|^QL>WtPB_v*yM4?>JDIT@Cl>ZKe%W)~T$lYLSTj$l4j zY7X$6=ckoJNIGRC1u=;^CsQ*x=yj5q^z13C-sV`X65yZMrhva(=cY zkMt@AUl)YV1mEPrIvr&4!3N>L$3+_DPks6Szq|-G?Z7F()9>f|>n2}a9jGoGsfr)G zeyr!LWN*1-N7S*55SKdUNb)a?jPEw(_9fJDJlB#rW5! z@o!Gy>l0|NVwT=UzkeK&dNSNF&`;bQBa8J_3kcE(3DpP<(+msOiilJUjg$)x&pnq( z?0L8}+Y0;CDAPR)^Al*7hSh7-^AA5@l^*o=_69EB;9`~D@^`%r^v{7sZ8DKKG1NaX z(naWN7_Ym~doQ=`QcnM~Yoz`r%E%k?@GHu|i}{|1l-|2b1Gg4?t~FPmi#?U5iN%RJ zx=OfsC}4e6{Q}hd1Jnb86#Rqt`UM4^%pDkB{vrRSkp6f5_)q@m>C>kx@h4n-^7QAw z1hu5i)8^-9#zv>c28biA<4w2wo}BBvbAGVCiab5NNG8Eij6fZbQ>8)R1gjy$fhF<) zdA6sey{Y8ZHLKV-X(u-k8+%D7S9wp2vNu-76C>*4aV$Fi=F4g*4fy=OVHG~%--EB<1KLU~MbyOxS+`oB?|F4~^d2J$y;vReGrT;=ac~JB! zULypG;iVgH=6b}kftXL|P1T9+7mh>QAA~9H6S|P!Y)Ta5^WItxV z)B0-{Crft|nr@rKBsnaTw{PFf{N~NRxBHu&rs0p4U>DOecC(jQE-x^@xKu3j<=x8X z_iOWUh2yc#-O^YafvRcAbo%wo%)KX1`-l9;eYcJc4jvk~aq!C3GeiE!>}-kUEJJBy zr&*$A;=k$4>zc0eq)51ooLMX_&aK8~atmJ-o?ox?qe6h3UdztKu~TZFu;^ zP2bUh>zDj@U%Yv{lu8jobbPSYGLK!xh&L7g%_aa4BC&#yR|`M+RE$~p#C%Vv0=q;1 zxAj|45IKfPEH6)d_;~->^V<)C!I!V%-{!N00udWWEZVk>3dhFAkob7LUL*dZfWHt@ zg@zRrO%lbD%x3uCOXNqKq!(451BQFm08BHEkRr$7NF=#Mrhwb+Hjp6B8@7#{6 zD}qo|NKwqC<<(_1pF~vN+VFnoHvT`&>FH^B`?ep1jqeFU04FfA$m=4ju`4S3N0)`o z8&l(((vdX+X-Of1P%0}@Sr!zoq|0LKyr1lZG11p`Q6`$EAnnmrwX9*!kFNV~M5EEI zmlKskFc{n?e*oY*HWHyvSo>6sGqW|waf+2u!}$0(P#YN;(X`#~Q3DI+=!~+<<+Anw zR5DIk<@HNi-RH4Bp&CU_u|lu$GOeel2blPLzWPC^TtRKpFdYtuE2lR$Kv{xBHh6rq zyj{y!B7#*4Aj+*=EyW6b2c-q@`}+E_Sx29&nr&Jk1$PPhm@@cQh4zzRl@5T#S_RPM z+ZbDlRUi<6PH%5-Boc9m0JUkgV+=7W>ewGhb2D#Cv7&%@JRV7M^terJTJcBKw4%-| zVBG?okRn5|N+y$t#qfW?5(XDOnz)@sV1!PU{dXpuDpvt7lAGUT?872 bz`xLZ{_F+!MbA0U=~IU. -*/ - -#include "assetstatus.h" -#include "hashtemplate.h" -#include "wwstring.h" -#include "RAWFILE.H" - -AssetStatusClass AssetStatusClass::Instance; - -const char* ReportCategoryNames[AssetStatusClass::REPORT_COUNT]={ - "LOAD_ON_DEMAND_ROBJ", - "LOAD_ON_DEMAND_HANIM", - "LOAD_ON_DEMAND_HTREE", - "MISSING_ROBJ", - "MISSING_HANIM", - "MISSING_HTREE" -}; - -AssetStatusClass::AssetStatusClass() - : - Reporting (true), - LoadOnDemandReporting(false) -{ -} - -AssetStatusClass::~AssetStatusClass() -{ -#ifdef WWDEBUG - if (Reporting) { - StringClass report("Load-on-demand and missing assets report\r\n\r\n"); - for (int i=0;i ite(ReportHashTables[i]); - for (ite.First();!ite.Is_Done();ite.Next()) { - report+=ite.Peek_Key(); - int count=ite.Peek_Value(); - if (count>1) { - StringClass tmp(0,true); - tmp.Format("\t(reported %d times)",count); - report+=tmp; - } - report+="\r\n"; - } - report+="\r\n"; - } - if (report.Get_Length()) { - RawFileClass raw_log_file("asset_report.txt"); - raw_log_file.Create(); - raw_log_file.Open(RawFileClass::WRITE); - raw_log_file.Write(report,report.Get_Length()); - raw_log_file.Close(); - } - } -#endif -} - -void AssetStatusClass::Add_To_Report(int index, const char* name) -{ - StringClass lower_case_name(name,true); - _strlwr(lower_case_name.Peek_Buffer()); - // This is a bit slow - two accesses to the same member, but currently there's no better way to do it. - int count=ReportHashTables[index].Get(lower_case_name); - count++; - ReportHashTables[index].Set_Value(lower_case_name,count); -} - -void AssetStatusClass::Report_Load_On_Demand_RObj(const char* name) -{ - if (LoadOnDemandReporting) Add_To_Report(REPORT_LOAD_ON_DEMAND_ROBJ,name); -} - -void AssetStatusClass::Report_Load_On_Demand_HAnim(const char* name) -{ - if (LoadOnDemandReporting) Add_To_Report(REPORT_LOAD_ON_DEMAND_HANIM,name); -} - -void AssetStatusClass::Report_Load_On_Demand_HTree(const char* name) -{ - if (LoadOnDemandReporting) Add_To_Report(REPORT_LOAD_ON_DEMAND_HTREE,name); -} - -void AssetStatusClass::Report_Missing_RObj(const char* name) -{ - Add_To_Report(REPORT_MISSING_ROBJ,name); -} - -void AssetStatusClass::Report_Missing_HAnim(const char* name) -{ - Add_To_Report(REPORT_MISSING_HANIM,name); -} - -void AssetStatusClass::Report_Missing_HTree(const char* name) -{ - Add_To_Report(REPORT_MISSING_HTREE,name); -} - diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/assetstatus.h b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/assetstatus.h deleted file mode 100644 index 0e7cb183adc..00000000000 --- a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/assetstatus.h +++ /dev/null @@ -1,68 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -#if defined(_MSC_VER) -#pragma once -#endif - -#ifndef WW3D_ASSET_STATUS_H -#define WW3D_ASSET_STATUS_H - -#include "always.h" -#include "hashtemplate.h" - -class AssetStatusClass -{ -public: - enum { - REPORT_LOAD_ON_DEMAND_ROBJ, - REPORT_LOAD_ON_DEMAND_HANIM, - REPORT_LOAD_ON_DEMAND_HTREE, - REPORT_MISSING_ROBJ, - REPORT_MISSING_HANIM, - REPORT_MISSING_HTREE, - REPORT_COUNT - }; - - AssetStatusClass(); - ~AssetStatusClass(); - - void Enable_Reporting(bool enable) { Reporting=enable; } - void Enable_Load_On_Demand_Reporting(bool enable) { LoadOnDemandReporting=enable; } - - void Report_Load_On_Demand_RObj(const char* name); - void Report_Load_On_Demand_HAnim(const char* name); - void Report_Load_On_Demand_HTree(const char* name); - - void Report_Missing_RObj(const char* name); - void Report_Missing_HAnim(const char* name); - void Report_Missing_HTree(const char* name); - - static AssetStatusClass* Peek_Instance() { return &Instance; } - -private: - bool Reporting; - bool LoadOnDemandReporting; - static AssetStatusClass Instance; - HashTemplateClass ReportHashTables[REPORT_COUNT]; - - void Add_To_Report(int index, const char* name); - -}; - -#endif