Richard Boegli's CnC_Generals_Zero_Hour Fork WIP
This is documentation of Richard Boegil's Zero Hour Fork
 
Loading...
Searching...
No Matches
wbview3d.h
Go to the documentation of this file.
1/*
2** Command & Conquer Generals Zero Hour(tm)
3** Copyright 2025 Electronic Arts Inc.
4**
5** This program is free software: you can redistribute it and/or modify
6** it under the terms of the GNU General Public License as published by
7** the Free Software Foundation, either version 3 of the License, or
8** (at your option) any later version.
9**
10** This program is distributed in the hope that it will be useful,
11** but WITHOUT ANY WARRANTY; without even the implied warranty of
12** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13** GNU General Public License for more details.
14**
15** You should have received a copy of the GNU General Public License
16** along with this program. If not, see <http://www.gnu.org/licenses/>.
17*/
18
19
20// WbView3d.h
21// Class to encapsulate height map.
22// Author: Steven Johnson, Aug 2001
23
24#if !defined(AFX_WBVIEW3D_H__832D8241_87F6_11D5_8CE0_00010297BBAC__INCLUDED_)
25#define AFX_WBVIEW3D_H__832D8241_87F6_11D5_8CE0_00010297BBAC__INCLUDED_
26
27#if _MSC_VER > 1000
28#pragma once
29#endif // _MSC_VER > 1000
30// wbview3d.h : header file
31//
32
33#include "Lib/BaseType.h"
34#include "rendobj.h"
35#include "robjlist.h"
36#include "WbView.h"
37#include "common/gameType.h"
38#include "common/GlobalData.h"
39#include "common/ModelState.h"
40#include "dx8wrapper.h"
41
42//#include "GameLogic/Module/BodyModule.h" -- Yikes... not necessary to include this! (KM)
43enum BodyDamageType; //Ahhhh much better!
44
45class WorldHeightMap;
46class LayerClass;
48class W3DAssetManager;
50class CameraClass;
51class WBHeightMap;
52class LightClass;
53class MapObject;
54class DrawObject;
56class BuildListInfo;
57class TransRenderObj;
58struct ID3DXFont;
59
61// WbView3d view
62
63class WbView3d : public WbView, public DX8_CleanupHook
64{
65protected:
66 WbView3d(); // protected constructor used by dynamic creation
67 DECLARE_DYNCREATE(WbView3d)
68
69// Attributes
70public:
71
72 // DX8_CleanupHook methods
73 virtual void ReleaseResources(void);
74 virtual void ReAcquireResources(void);
75
76// Operations
77public:
78
79// Overrides
80 // ClassWizard generated virtual function overrides
81 //{{AFX_VIRTUAL(WbView3d)
82 protected:
83 virtual void OnDraw(CDC* pDC); // overridden to draw this view
84 //}}AFX_VIRTUAL
85
86// Implementation
87protected:
88 virtual ~WbView3d();
89#ifdef _DEBUG
90 virtual void AssertValid() const;
91 virtual void Dump(CDumpContext& dc) const;
92#endif
93
94 // Generated message map functions
95protected:
96 //{{AFX_MSG(WbView3d)
97 afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
98 afx_msg void OnPaint();
99 afx_msg void OnSize(UINT nType, int cx, int cy);
100 afx_msg BOOL OnMouseWheel(UINT nFlags, short zDelta, CPoint pt);
101 afx_msg void OnTimer(UINT nIDEvent);
102 afx_msg void OnDestroy();
103 afx_msg void OnShowWindow(BOOL bShow, UINT nStatus);
104 afx_msg void OnViewShowwireframe();
105 afx_msg void OnUpdateViewShowwireframe(CCmdUI* pCmdUI);
106 afx_msg BOOL OnEraseBkgnd(CDC* pDC);
107 afx_msg void OnViewShowentire3dmap();
108 afx_msg void OnUpdateViewShowentire3dmap(CCmdUI* pCmdUI);
109 afx_msg void OnViewShowtopdownview();
110 afx_msg void OnUpdateViewShowtopdownview(CCmdUI* pCmdUI);
111 afx_msg void OnViewShowclouds();
112 afx_msg void OnUpdateViewShowclouds(CCmdUI* pCmdUI);
113 afx_msg void OnViewShowmacrotexture();
114 afx_msg void OnUpdateViewShowmacrotexture(CCmdUI* pCmdUI);
115 afx_msg void OnEditSelectmacrotexture();
116 afx_msg void OnViewShowshadows();
117 afx_msg void OnUpdateViewShowshadows(CCmdUI* pCmdUI);
118 afx_msg void OnViewShowSoftWater();
119 afx_msg void OnUpdateViewShowSoftWater(CCmdUI* pCmdUI);
120 afx_msg void OnViewExtraBlends();
121 afx_msg void OnUpdateViewShowExtraBlends(CCmdUI* pCmdUI);
122 afx_msg void OnEditShadows();
123 afx_msg void OnEditMapSettings();
124 afx_msg void OnViewShowimpassableareas();
125 afx_msg void OnUpdateViewShowimpassableareas(CCmdUI* pCmdUI);
126 afx_msg void OnImpassableAreaOptions();
127 afx_msg void OnViewPartialmapsize96x96();
128 afx_msg void OnUpdateViewPartialmapsize96x96(CCmdUI* pCmdUI);
129 afx_msg void OnViewPartialmapsize192x192();
130 afx_msg void OnUpdateViewPartialmapsize192x192(CCmdUI* pCmdUI);
131 afx_msg void OnViewPartialmapsize160x160();
132 afx_msg void OnUpdateViewPartialmapsize160x160(CCmdUI* pCmdUI);
133 afx_msg void OnViewPartialmapsize128x128();
134 afx_msg void OnUpdateViewPartialmapsize128x128(CCmdUI* pCmdUI);
135 afx_msg void OnViewShowModels();
136 afx_msg void OnUpdateViewShowModels(CCmdUI* pCmdUI);
137 afx_msg void OnViewBoundingBoxes();
138 afx_msg void OnUpdateViewBoundingBoxes(CCmdUI* pCmdUI);
139 afx_msg void OnViewSightRanges();
140 afx_msg void OnUpdateViewSightRanges(CCmdUI* pCmdUI);
141 afx_msg void OnViewWeaponRanges();
142 afx_msg void OnUpdateViewWeaponRanges(CCmdUI* pCmdUI);
143 afx_msg void OnHighlightTestArt();
144 afx_msg void OnUpdateHighlightTestArt(CCmdUI* pCmdUI);
145 afx_msg void OnShowLetterbox();
146 afx_msg void OnUpdateShowLetterbox(CCmdUI* pCmdUI);
147 afx_msg void OnViewLayersList();
148 afx_msg void OnUpdateViewLayersList(CCmdUI* pCmdUI);
149 afx_msg void OnViewGarrisoned();
150 afx_msg void OnUpdateViewGarrisoned(CCmdUI* pCmdUI);
151 afx_msg void OnViewShowMapBoundaries();
152 afx_msg void OnUpdateViewShowMapBoundaries(CCmdUI* pCmdUI);
153 afx_msg void OnViewShowAmbientSounds();
154 afx_msg void OnUpdateViewShowAmbientSounds(CCmdUI* pCmdUI);
155 afx_msg void OnViewShowSoundCircles();
156 afx_msg void OnUpdateViewShowSoundCircles(CCmdUI* pCmdUI);
157 //}}AFX_MSG
158 DECLARE_MESSAGE_MAP()
159
160private:
161 HINSTANCE m_hInst;
162 W3DAssetManager *m_assetManager;
163 SkeletonSceneClass *m_scene;
164 SkeletonSceneClass *m_overlayScene;
165 SkeletonSceneClass *m_baseBuildScene;
166 SkeletonSceneClass *m_transparentObjectsScene;
167 CameraClass *m_camera;
168 WBHeightMap *m_heightMapRenderObj;
169
170 RenderObjClass *m_objectToolTrackingObj;
171 Bool m_showObjToolTrackingObj;
172 AsciiString m_objectToolTrackingModelName;
173
174 Real m_mouseWheelOffset;
175 Real m_groundLevel;
176 Coord3D m_cameraOffset;
177 CPoint m_actualWinSize;
178 Real m_theta;
179 Real m_cameraAngle;
180 Real m_FXPitch;
181 Bool m_doPitch;
182 Real m_actualHeightAboveGround; // for camera tool display only
183 Vector3 m_cameraSource; // for camera tool display only
184 Vector3 m_cameraTarget; // for camera tool display only
185 Int m_time;
186 Int m_updateCount;
187 UINT m_timer;
188 DrawObject *m_drawObject;
189 RefRenderObjListClass m_lightList;
190 LayerClass *m_layer;
191 LayerClass *m_buildLayer;
192 IntersectionClass *m_intersector;
193 Bool m_showWireframe;
194 Bool m_ww3dInited;
195 Bool m_needToLoadRoads;
196 LightClass *m_globalLight[MAX_GLOBAL_LIGHTS];
197 RenderObjClass *m_lightFeedbackMesh[MAX_GLOBAL_LIGHTS];
198
199 Real m_buildRedMultiplier;
200
201 Real m_curTrackingZ;
202
203
204 Bool m_projection;
205 Bool m_showEntireMap;
206 Bool m_showShadows;
207 Bool m_firstPaint;
208 Bool m_showLayersList;
209 Bool m_showMapBoundaries;
210 Bool m_showAmbientSounds;
211 Bool m_showSoundCircles;
212 Bool m_showBoundingBoxes;
213 Bool m_showSightRanges;
214 Bool m_showWeaponRanges;
215 Bool m_highlightTestArt;
216 Bool m_showLetterbox;
217
218
219 ID3DXFont* m3DFont;
220 Int m_pickPixels;
221 Int m_partialMapSize;
222
223protected:
224
226 void init3dScene();
227 void initAssets();
228 void initWW3D();
229 void drawCircle( HDC hdc, const Coord3D & centerPoint, Real radius, COLORREF color );
230 void drawLabels(HDC hdc);
231 void drawLabels(void);
232 void shutdownWW3D();
233 void killTheTimer();
234 void render();
235 void setupCamera();
236 void updateHysteresis(void);
237 void updateLights();
238 void updateScorches();
239 void updateTrees();
240
241public:
242 virtual Bool viewToDocCoords(CPoint curPt, Coord3D *newPt, Bool constrain=true);
243 virtual Bool docToViewCoords(Coord3D curPt, CPoint* newPt);
244
245 virtual void updateHeightMapInView(WorldHeightMap *htMap, Bool partial, const IRegion2D &partialRange);
246
248 virtual void invalObjectInView(MapObject *pObj);
249
250 // find the best model for an object
252
255
257 virtual void invalidateCellInView(int xIndex, int yIndex);
258
260 virtual void scrollInView(Real x, Real y, Bool end);
261
262 virtual void setDefaultCamera();
263 virtual void rotateCamera(Real delta);
264 virtual void pitchCamera(Real delta);
265 void setCameraPitch(Real absolutePitch);
266 Real getCameraPitch(void);
267 Real getCurrentZoom(void); //WST 10/17/2002
268 Real getHeightAboveGround(void) { return m_actualHeightAboveGround; }
269 Vector3 getCameraSource(void) { return m_cameraSource; }
270 Vector3 getCameraTarget(void) { return m_cameraTarget; }
271 Real getCameraAngle(void) { return m_cameraAngle; }
272 CPoint getActualWinSize(void) {return m_actualWinSize;}
273
274 virtual MapObject *picked3dObjectInView(CPoint viewPt);
275 virtual BuildListInfo *pickedBuildObjectInView(CPoint viewPt);
276
277 void removeFenceListObjects(MapObject *pObject);
278 void updateFenceListObjects(MapObject *pObject);
279
281 void resetRenderObjects();
282
283 void stepTimeOfDay(void);
284
285 void reset3dEngineDisplaySize(Int width, Int height);
286 void setLighting(const GlobalData::TerrainLighting *tl, Int whichLighting, Int whichLight=0);
287
288 DrawObject *getDrawObject(void) {return m_drawObject;};
289
291
292 virtual Int getPickPixels(void) {return m_pickPixels;}
293 virtual Bool viewToDocCoordZ(CPoint curPt, Coord3D *newPt, Real Z);
294public:
295
296// void init(CWorldBuilderView *pMainView, HINSTANCE hInstance, CWnd* parent);
297 void redraw();
298
299 virtual void setCenterInView(Real x, Real y);
300
303
304 void setObjTracking(MapObject *pMapObj, Coord3D pos, Real angle, Bool show);
305 void setViewLayersList(Bool showLayersList) { m_showLayersList = showLayersList; }
306
307 Bool getShowMapBoundaryFeedback(void) const { return m_showMapBoundaries; }
308 Bool getShowAmbientSoundsFeedback(void) const { return m_showAmbientSounds; }
309
310 void togglePitchAndRotation( void ) { m_doPitch = !m_doPitch; }
311 virtual Bool isDoingPitch( void ) { return m_doPitch; }
312 void setShowBoundingBoxes(Bool toggle) {m_showBoundingBoxes = toggle;}
313 Bool getShowBoundingBoxes(void) { return m_showBoundingBoxes;}
314 void setShowSightRanges(Bool toggle) {m_showSightRanges = toggle;}
315 Bool getShowSightRanges(void) { return m_showSightRanges;}
316 void setShowWeaponRanges(Bool toggle) {m_showWeaponRanges = toggle;}
317 Bool getShowWeaponRanges(void) { return m_showWeaponRanges;}
318 void setHighlightTestArt(Bool toggle) {m_highlightTestArt = toggle;}
319 Bool getHighlightTestArt(void) { return m_highlightTestArt;}
320 void setShowLetterbox(Bool toggle) {m_showLetterbox = toggle;}
321 Bool getShowLetterbox(void) { return m_showLetterbox;}
322};
323
324inline UINT WbView3d::getLastDrawTime() { return m_time; }
325inline Bool WbView3d::getShowWireframe() { return m_showWireframe; }
326
327
329
330//{{AFX_INSERT_LOCATION}}
331// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
332
333#endif // !defined(AFX_WBVIEW3D_H__832D8241_87F6_11D5_8CE0_00010297BBAC__INCLUDED_)
bool Bool
Definition BaseType.h:132
float Real
Definition BaseType.h:124
BodyDamageType
Definition BodyModule.h:54
Color scale(const Color &a, const Color &b)
Definition GameMtl.cpp:722
const Int MAX_GLOBAL_LIGHTS
Definition GlobalData.h:56
unsigned int UINT
Definition bittype.h:63
BitFlags< MODELCONDITION_COUNT > ModelConditionFlags
Definition ModelState.h:250
#define BOOL
Definition Wnd_File.h:57
afx_msg void OnUpdateShowLetterbox(CCmdUI *pCmdUI)
afx_msg void OnViewBoundingBoxes()
afx_msg void OnUpdateViewShowwireframe(CCmdUI *pCmdUI)
Bool getShowMapBoundaryFeedback(void) const
Definition wbview3d.h:307
void init3dScene()
Definition wbview3d.cpp:764
Vector3 getCameraTarget(void)
Definition wbview3d.h:270
void setViewLayersList(Bool showLayersList)
Definition wbview3d.h:305
AsciiString getBestModelName(const ThingTemplate *tt, const ModelConditionFlags &c)
afx_msg void OnViewShowmacrotexture()
Real getHeightAboveGround(void)
Definition wbview3d.h:268
afx_msg void OnUpdateViewPartialmapsize192x192(CCmdUI *pCmdUI)
void invalBuildListItemInView(BuildListInfo *pBuild)
Invalidates an build list object.
void setLighting(const GlobalData::TerrainLighting *tl, Int whichLighting, Int whichLight=0)
Definition wbview3d.cpp:875
void render()
afx_msg void OnViewShowMapBoundaries()
void resetRenderObjects()
Removes all render objects. Call when swithing to a new map.
Definition wbview3d.cpp:805
virtual BuildListInfo * pickedBuildObjectInView(CPoint viewPt)
void setShowBoundingBoxes(Bool toggle)
Definition wbview3d.h:312
virtual Bool docToViewCoords(Coord3D curPt, CPoint *newPt)
afx_msg void OnUpdateViewGarrisoned(CCmdUI *pCmdUI)
void initAssets()
Definition wbview3d.cpp:607
afx_msg void OnUpdateViewShowclouds(CCmdUI *pCmdUI)
afx_msg void OnViewShowtopdownview()
void setObjTracking(MapObject *pMapObj, Coord3D pos, Real angle, Bool show)
Definition wbview3d.cpp:343
afx_msg void OnUpdateViewShowmacrotexture(CCmdUI *pCmdUI)
afx_msg void OnViewShowentire3dmap()
Vector3 getCameraSource(void)
Definition wbview3d.h:269
Real getCameraAngle(void)
Definition wbview3d.h:271
void updateScorches()
Definition wbview3d.cpp:996
void stepTimeOfDay(void)
Definition wbview3d.cpp:864
afx_msg void OnShowWindow(BOOL bShow, UINT nStatus)
afx_msg void OnViewPartialmapsize160x160()
afx_msg void OnImpassableAreaOptions()
virtual void rotateCamera(Real delta)
afx_msg void OnViewShowModels()
afx_msg void OnUpdateViewPartialmapsize128x128(CCmdUI *pCmdUI)
Bool getShowAmbientSoundsFeedback(void) const
Definition wbview3d.h:308
DrawObject * getDrawObject(void)
Definition wbview3d.h:288
void drawCircle(HDC hdc, const Coord3D &centerPoint, Real radius, COLORREF color)
Draw a (not very good) circle into the hdc.
void setShowSightRanges(Bool toggle)
Definition wbview3d.h:314
afx_msg void OnSize(UINT nType, int cx, int cy)
afx_msg void OnShowLetterbox()
afx_msg void OnUpdateViewPartialmapsize160x160(CCmdUI *pCmdUI)
afx_msg void OnEditSelectmacrotexture()
afx_msg void OnUpdateHighlightTestArt(CCmdUI *pCmdUI)
afx_msg void OnUpdateViewSightRanges(CCmdUI *pCmdUI)
AsciiString getModelNameAndScale(MapObject *pMapObj, Real *scale, BodyDamageType curDamageState)
Bool getShowTerrain()
void redraw()
Real getCurrentZoom(void)
afx_msg void OnDestroy()
afx_msg void OnViewShowSoftWater()
Bool getShowBoundingBoxes(void)
Definition wbview3d.h:313
afx_msg void OnUpdateViewShowtopdownview(CCmdUI *pCmdUI)
virtual void pitchCamera(Real delta)
void shutdownWW3D()
Definition wbview3d.cpp:459
afx_msg void OnUpdateViewShowModels(CCmdUI *pCmdUI)
void initWW3D()
afx_msg void OnViewSightRanges()
afx_msg void OnHighlightTestArt()
virtual void ReAcquireResources(void)
Reacquire all resources after device reset.
Definition wbview3d.cpp:538
afx_msg void OnViewExtraBlends()
afx_msg void OnViewShowAmbientSounds()
afx_msg void OnViewShowSoundCircles()
afx_msg void OnUpdateViewShowSoundCircles(CCmdUI *pCmdUI)
UINT getLastDrawTime()
Definition wbview3d.h:324
Bool getShowWireframe()
Definition wbview3d.h:325
virtual ~WbView3d()
Definition wbview3d.cpp:444
void updateFenceListObjects(MapObject *pObject)
afx_msg void OnUpdateViewShowimpassableareas(CCmdUI *pCmdUI)
virtual void setDefaultCamera()
void reset3dEngineDisplaySize(Int width, Int height)
Closes & reinitializes w3d.
Definition wbview3d.cpp:590
Bool getHighlightTestArt(void)
Definition wbview3d.h:319
afx_msg void OnViewShowclouds()
void togglePitchAndRotation(void)
Definition wbview3d.h:310
void updateTrees()
afx_msg void OnUpdateViewLayersList(CCmdUI *pCmdUI)
afx_msg void OnUpdateViewShowSoftWater(CCmdUI *pCmdUI)
afx_msg void OnViewShowwireframe()
void setHighlightTestArt(Bool toggle)
Definition wbview3d.h:318
void setShowLetterbox(Bool toggle)
Definition wbview3d.h:320
void setShowWeaponRanges(Bool toggle)
Definition wbview3d.h:316
afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct)
afx_msg void OnPaint()
virtual Bool viewToDocCoords(CPoint curPt, Coord3D *newPt, Bool constrain=true)
virtual void updateHeightMapInView(WorldHeightMap *htMap, Bool partial, const IRegion2D &partialRange)
Update the height map in the 3d window.
void removeFenceListObjects(MapObject *pObject)
virtual void invalidateCellInView(int xIndex, int yIndex)
Invalidates the area of one height map cell in the 2d view.
afx_msg BOOL OnMouseWheel(UINT nFlags, short zDelta, CPoint pt)
virtual Int getPickPixels(void)
Definition wbview3d.h:292
afx_msg void OnEditShadows()
void drawLabels(void)
Bool getShowSightRanges(void)
Definition wbview3d.h:315
virtual MapObject * picked3dObjectInView(CPoint viewPt)
void updateLights()
Definition wbview3d.cpp:910
virtual Bool viewToDocCoordZ(CPoint curPt, Coord3D *newPt, Real Z)
virtual Bool isDoingPitch(void)
Definition wbview3d.h:311
Bool getShowWeaponRanges(void)
Definition wbview3d.h:317
afx_msg void OnViewPartialmapsize128x128()
afx_msg BOOL OnEraseBkgnd(CDC *pDC)
afx_msg void OnViewShowshadows()
virtual void invalObjectInView(MapObject *pObj)
Invalidates an object. Pass NULL to inval all objects.
afx_msg void OnViewShowimpassableareas()
virtual void ReleaseResources(void)
Release all dx8 resources so the device can be reset.
Definition wbview3d.cpp:519
void killTheTimer()
Definition wbview3d.cpp:581
Real getCameraPitch(void)
afx_msg void OnUpdateViewWeaponRanges(CCmdUI *pCmdUI)
afx_msg void OnUpdateViewShowshadows(CCmdUI *pCmdUI)
Bool getShowLetterbox(void)
Definition wbview3d.h:321
afx_msg void OnViewLayersList()
afx_msg void OnViewPartialmapsize96x96()
afx_msg void OnUpdateViewPartialmapsize96x96(CCmdUI *pCmdUI)
virtual void OnDraw(CDC *pDC)
void setCameraPitch(Real absolutePitch)
virtual void setCenterInView(Real x, Real y)
Set the center for display.
afx_msg void OnViewWeaponRanges()
afx_msg void OnUpdateViewShowMapBoundaries(CCmdUI *pCmdUI)
afx_msg void OnTimer(UINT nIDEvent)
afx_msg void OnViewGarrisoned()
afx_msg void OnEditMapSettings()
afx_msg void OnViewPartialmapsize192x192()
afx_msg void OnUpdateViewShowExtraBlends(CCmdUI *pCmdUI)
afx_msg void OnUpdateViewShowentire3dmap(CCmdUI *pCmdUI)
void updateHysteresis(void)
CPoint getActualWinSize(void)
Definition wbview3d.h:272
void setupCamera()
Definition wbview3d.cpp:633
afx_msg void OnUpdateViewShowAmbientSounds(CCmdUI *pCmdUI)
virtual void scrollInView(Real x, Real y, Bool end)
Scrolls the window by this amount.
afx_msg void OnUpdateViewBoundingBoxes(CCmdUI *pCmdUI)
WbView()
Definition wbview.cpp:51
RefMultiListClass< RenderObjClass > RefRenderObjListClass
Definition robjlist.h:59