| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308 |
- /*
- ** 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 <http://www.gnu.org/licenses/>.
- */
- // WbView3d.h
- // Class to encapsulate height map.
- // Author: Steven Johnson, Aug 2001
- #if !defined(AFX_WBVIEW3D_H__832D8241_87F6_11D5_8CE0_00010297BBAC__INCLUDED_)
- #define AFX_WBVIEW3D_H__832D8241_87F6_11D5_8CE0_00010297BBAC__INCLUDED_
- #if _MSC_VER > 1000
- #pragma once
- #endif // _MSC_VER > 1000
- // wbview3d.h : header file
- //
- #include "Lib/BaseType.h"
- #include "rendobj.h"
- #include "robjlist.h"
- #include "WbView.h"
- #include "common/gameType.h"
- #include "common/GlobalData.h"
- #include "common/ModelState.h"
- #include "dx8wrapper.h"
- //#include "GameLogic/Module/BodyModule.h" -- Yikes... not necessary to include this! (KM)
- enum BodyDamageType; //Ahhhh much better!
- class WorldHeightMap;
- class LayerClass;
- class IntersectionClass;
- class W3DAssetManager;
- class SkeletonSceneClass;
- class CameraClass;
- class WBHeightMap;
- class LightClass;
- class MapObject;
- class DrawObject;
- class CWorldBuilderView;
- class BuildListInfo;
- class TransRenderObj;
- struct ID3DXFont;
- /////////////////////////////////////////////////////////////////////////////
- // WbView3d view
- class WbView3d : public WbView, public DX8_CleanupHook
- {
- protected:
- WbView3d(); // protected constructor used by dynamic creation
- DECLARE_DYNCREATE(WbView3d)
- // Attributes
- public:
- // DX8_CleanupHook methods
- virtual void ReleaseResources(void); ///< Release all dx8 resources so the device can be reset.
- virtual void ReAcquireResources(void); ///< Reacquire all resources after device reset.
- // Operations
- public:
- // Overrides
- // ClassWizard generated virtual function overrides
- //{{AFX_VIRTUAL(WbView3d)
- protected:
- virtual void OnDraw(CDC* pDC); // overridden to draw this view
- //}}AFX_VIRTUAL
- // Implementation
- protected:
- virtual ~WbView3d();
- #ifdef _DEBUG
- virtual void AssertValid() const;
- virtual void Dump(CDumpContext& dc) const;
- #endif
- // Generated message map functions
- protected:
- //{{AFX_MSG(WbView3d)
- afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
- afx_msg void OnPaint();
- afx_msg void OnSize(UINT nType, int cx, int cy);
- afx_msg BOOL OnMouseWheel(UINT nFlags, short zDelta, CPoint pt);
- afx_msg void OnTimer(UINT nIDEvent);
- afx_msg void OnDestroy();
- afx_msg void OnShowWindow(BOOL bShow, UINT nStatus);
- afx_msg void OnViewShowwireframe();
- afx_msg void OnUpdateViewShowwireframe(CCmdUI* pCmdUI);
- afx_msg BOOL OnEraseBkgnd(CDC* pDC);
- afx_msg void OnViewShowentire3dmap();
- afx_msg void OnUpdateViewShowentire3dmap(CCmdUI* pCmdUI);
- afx_msg void OnViewShowtopdownview();
- afx_msg void OnUpdateViewShowtopdownview(CCmdUI* pCmdUI);
- afx_msg void OnViewShowclouds();
- afx_msg void OnUpdateViewShowclouds(CCmdUI* pCmdUI);
- afx_msg void OnViewShowmacrotexture();
- afx_msg void OnUpdateViewShowmacrotexture(CCmdUI* pCmdUI);
- afx_msg void OnEditSelectmacrotexture();
- afx_msg void OnLookEast();
- afx_msg void OnUpdateLookEast(CCmdUI* pCmdUI);
- afx_msg void OnLookNorth();
- afx_msg void OnUpdateLookNorth(CCmdUI* pCmdUI);
- afx_msg void OnLookSouth();
- afx_msg void OnUpdateLookSouth(CCmdUI* pCmdUI);
- afx_msg void OnLookWest();
- afx_msg void OnUpdateLookWest(CCmdUI* pCmdUI);
- afx_msg void OnViewShowshadows();
- afx_msg void OnUpdateViewShowshadows(CCmdUI* pCmdUI);
- afx_msg void OnViewShowSoftWater();
- afx_msg void OnUpdateViewShowSoftWater(CCmdUI* pCmdUI);
- afx_msg void OnViewExtraBlends();
- afx_msg void OnUpdateViewShowExtraBlends(CCmdUI* pCmdUI);
- afx_msg void OnEditShadows();
- afx_msg void OnEditMapSettings();
- afx_msg void OnViewShowimpassableareas();
- afx_msg void OnUpdateViewShowimpassableareas(CCmdUI* pCmdUI);
- afx_msg void OnImpassableAreaOptions();
- afx_msg void OnViewPartialmapsize96x96();
- afx_msg void OnUpdateViewPartialmapsize96x96(CCmdUI* pCmdUI);
- afx_msg void OnViewPartialmapsize192x192();
- afx_msg void OnUpdateViewPartialmapsize192x192(CCmdUI* pCmdUI);
- afx_msg void OnViewPartialmapsize160x160();
- afx_msg void OnUpdateViewPartialmapsize160x160(CCmdUI* pCmdUI);
- afx_msg void OnViewPartialmapsize128x128();
- afx_msg void OnUpdateViewPartialmapsize128x128(CCmdUI* pCmdUI);
- afx_msg void OnViewShowModels();
- afx_msg void OnUpdateViewShowModels(CCmdUI* pCmdUI);
- afx_msg void OnViewLayersList();
- afx_msg void OnUpdateViewLayersList(CCmdUI* pCmdUI);
- afx_msg void OnViewGarrisoned();
- afx_msg void OnUpdateViewGarrisoned(CCmdUI* pCmdUI);
- afx_msg void OnViewShowMapBoundaries();
- afx_msg void OnUpdateViewShowMapBoundaries(CCmdUI* pCmdUI);
- afx_msg void OnViewShowAmbientSounds();
- afx_msg void OnUpdateViewShowAmbientSounds(CCmdUI* pCmdUI);
- //}}AFX_MSG
- DECLARE_MESSAGE_MAP()
- private:
- HINSTANCE m_hInst;
- W3DAssetManager *m_assetManager;
- SkeletonSceneClass *m_scene;
- SkeletonSceneClass *m_overlayScene;
- SkeletonSceneClass *m_baseBuildScene;
- SkeletonSceneClass *m_transparentObjectsScene;
- CameraClass *m_camera;
- WBHeightMap *m_heightMapRenderObj;
- RenderObjClass *m_objectToolTrackingObj;
- Bool m_showObjToolTrackingObj;
- AsciiString m_objectToolTrackingModelName;
- Real m_mouseWheelOffset;
- Real m_groundLevel;
- Coord3D m_cameraOffset;
- CPoint m_actualWinSize;
- Real m_theta;
- Real m_cameraAngle;
- Real m_FXPitch;
- Bool m_doPitch;
- Real m_actualHeightAboveGround; // for camera tool display only
- Vector3 m_cameraSource; // for camera tool display only
- Vector3 m_cameraTarget; // for camera tool display only
- Int m_time;
- Int m_updateCount;
- UINT m_timer;
- DrawObject *m_drawObject;
- RefRenderObjListClass m_lightList;
- LayerClass *m_layer;
- LayerClass *m_buildLayer;
- IntersectionClass *m_intersector;
- Bool m_showWireframe;
- Bool m_ww3dInited;
- Bool m_needToLoadRoads;
- LightClass *m_globalLight[MAX_GLOBAL_LIGHTS];
- RenderObjClass *m_lightFeedbackMesh[MAX_GLOBAL_LIGHTS];
- Real m_buildRedMultiplier;
- Real m_curTrackingZ;
- Bool m_projection; ///< True if top down projection instead of "isometric" perspective.
- Bool m_showEntireMap; ///< True if drawing entire map instead of cached fast subset.
- Bool m_showShadows; ///< True if drawing shadows.
- Bool m_firstPaint; ///< True if we haven't painted yet.
- Bool m_showLayersList; ///< Flag whether the layers list is visible or not.
- Bool m_showMapBoundaries; ///< Flag whether to show all the map boundaries or not
- Bool m_showAmbientSounds; ///< Flag whether to show all the ambient sounds or not
- ID3DXFont* m3DFont;
- Int m_pickPixels;
- Int m_partialMapSize;
- protected:
- UINT getLastDrawTime();
- void init3dScene();
- void initAssets();
- void initWW3D();
- void drawLabels(HDC hdc);
- void drawLabels(void);
- void shutdownWW3D();
- void killTheTimer();
- void render();
- void setupCamera();
- void updateHysteresis(void);
- void updateLights();
- void updateScorches();
- public:
- virtual Bool viewToDocCoords(CPoint curPt, Coord3D *newPt, Bool constrain=true);
- virtual Bool docToViewCoords(Coord3D curPt, CPoint* newPt);
- virtual void updateHeightMapInView(WorldHeightMap *htMap, Bool partial, const IRegion2D &partialRange);
- /// Invalidates an object. Pass NULL to inval all objects.
- virtual void invalObjectInView(MapObject *pObj);
- // find the best model for an object
- AsciiString getBestModelName(const ThingTemplate* tt, const ModelConditionFlags& c);
- /// Invalidates an build list object.
- void invalBuildListItemInView(BuildListInfo *pBuild);
- /// Invalidates the area of one height map cell in the 2d view.
- virtual void invalidateCellInView(int xIndex, int yIndex);
- /// Scrolls the window by this amount.
- virtual void scrollInView(Real x, Real y, Bool end);
- virtual void setDefaultCamera();
- virtual void rotateCamera(Real delta);
- virtual void pitchCamera(Real delta);
- void setCameraPitch(Real absolutePitch);
- Real getCameraPitch(void);
- Real getHeightAboveGround(void) { return m_actualHeightAboveGround; }
- Vector3 getCameraSource(void) { return m_cameraSource; }
- Vector3 getCameraTarget(void) { return m_cameraTarget; }
- Real getCameraAngle(void) { return m_cameraAngle; }
- virtual MapObject *picked3dObjectInView(CPoint viewPt);
- virtual BuildListInfo *pickedBuildObjectInView(CPoint viewPt);
- void removeFenceListObjects(MapObject *pObject);
- void updateFenceListObjects(MapObject *pObject);
- /// Removes all render objects. Call when swithing to a new map.
- void resetRenderObjects();
- void stepTimeOfDay(void);
- void reset3dEngineDisplaySize(Int width, Int height); ///< Closes & reinitializes w3d.
- void setLighting(const GlobalData::TerrainLighting *tl, Int whichLighting, Int whichLight=0);
- DrawObject *getDrawObject(void) {return m_drawObject;};
- AsciiString getModelNameAndScale(MapObject *pMapObj, Real *scale, BodyDamageType curDamageState);
- virtual Int getPickPixels(void) {return m_pickPixels;}
- virtual Bool viewToDocCoordZ(CPoint curPt, Coord3D *newPt, Real Z);
- public:
- // void init(CWorldBuilderView *pMainView, HINSTANCE hInstance, CWnd* parent);
- void redraw();
- virtual void setCenterInView(Real x, Real y);
- Bool getShowTerrain();
- Bool getShowWireframe();
- void setObjTracking(MapObject *pMapObj, Coord3D pos, Real angle, Bool show);
- void setViewLayersList(Bool showLayersList) { m_showLayersList = showLayersList; }
- Bool getShowMapBoundaryFeedback(void) const { return m_showMapBoundaries; }
- Bool getShowAmbientSoundsFeedback(void) const { return m_showAmbientSounds; }
- void togglePitchAndRotation( void ) { m_doPitch = !m_doPitch; }
- virtual Bool isDoingPitch( void ) { return m_doPitch; }
- };
- inline UINT WbView3d::getLastDrawTime() { return m_time; }
- inline Bool WbView3d::getShowWireframe() { return m_showWireframe; }
- /////////////////////////////////////////////////////////////////////////////
- //{{AFX_INSERT_LOCATION}}
- // Microsoft Visual C++ will insert additional declarations immediately before the previous line.
- #endif // !defined(AFX_WBVIEW3D_H__832D8241_87F6_11D5_8CE0_00010297BBAC__INCLUDED_)
|