forked from electronicarts/CnC_Generals_Zero_Hour
-
Notifications
You must be signed in to change notification settings - Fork 169
Expand file tree
/
Copy pathDrawObject.h
More file actions
191 lines (157 loc) · 8.34 KB
/
DrawObject.h
File metadata and controls
191 lines (157 loc) · 8.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
/*
** 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 <http://www.gnu.org/licenses/>.
*/
#pragma once
#include "always.h"
#include "rendobj.h"
#include "w3d_file.h"
#include "dx8vertexbuffer.h"
#include "dx8indexbuffer.h"
#include "shader.h"
#include "vertmaterial.h"
#include "Lib/BaseType.h"
#include "Common/AsciiString.h"
// The draw objects draw a circle of diameter 1.0 cells.
#define THE_RADIUS (0.8f*MAP_XY_FACTOR)
class MeshClass;
class PolygonTrigger;
class WaterRenderObjClass;
class MapObject;
class Render2DClass;
//
// DrawObject: Draws 3d feedback for tools & objects.
//
//
class DrawObject : public RenderObjClass
{
public:
DrawObject(void);
DrawObject(const DrawObject & src);
DrawObject & operator = (const DrawObject &);
~DrawObject(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);
//TODO: MW: do these later - only needed for collision detection
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 Get_Obj_Space_Bounding_Sphere(SphereClass & sphere) const;
virtual void Get_Obj_Space_Bounding_Box(AABoxClass & aabox) const;
// 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; }
Int freeMapResources(void);
int initData(void);
void setDrawObjects(Bool val, Bool waypoints, Bool poly, Bool bounding, Bool sight, Bool weapon, Bool sound, Bool testart, Bool letterbox) { m_drawObjects = val; m_drawWaypoints=waypoints; m_drawPolygonAreas = poly; m_drawBoundingBoxes = bounding; m_drawSightRanges = sight; m_drawWeaponRanges = weapon; m_drawSoundRanges = sound; m_drawTestArtHighlight = testart, m_drawLetterbox = letterbox;}
static void setDoBrushFeedback(Bool val) { m_toolWantsFeedback = val; m_meshFeedback=false;}
static void setDoMeshFeedback(Bool val) { m_meshFeedback = val; }
static void setDoRampFeedback(Bool val) { m_rampFeedback = val; }
static void setDoBoundaryFeedback(Bool val) { m_boundaryFeedback = val; }
static void setDoAmbientSoundFeedback(Bool val) { m_ambientSoundFeedback = val; }
static void setBrushFeedbackParms(Bool square, Int width, Int featherWidth)
{ m_squareFeedback = square; m_brushWidth=width;
m_meshFeedback = false; m_brushFeatherWidth = featherWidth;}
static void disableFeedback(void) {m_disableFeedback = true;};
static void enableFeedback(void) {m_disableFeedback = false;};
static Bool isFeedbackEnabled(void) { return !m_disableFeedback;};
static void setFeedbackPos(Coord3D pos);
static Coord3D getFeedbackPos() { return m_feedbackPoint; }
static void setWaypointDragFeedback(const Coord3D &start, const Coord3D &end);
static void setRampFeedbackParms(const Coord3D *start, const Coord3D *end, Real rampWidth);
static void stopWaypointDragFeedback();
MeshClass *peekMesh(void) {return m_moldMesh;};
void getMeshBounds(SphereClass *pSphere) {*pSphere = m_moldMeshBounds;};
protected:
enum {MAX_RADIUS = 50, NUM_FEEDBACK_VERTEX = 201*201, NUM_FEEDBACK_INDEX = 101*101*6};
Int m_numTriangles; //dimensions of list
DX8IndexBufferClass *m_indexBuffer; ///< indices defining a object icon
ShaderClass m_shaderClass; ///< shader or rendering state for heightmap
VertexMaterialClass *m_vertexMaterialClass;
DX8VertexBufferClass *m_vertexBufferTile1; ///< First vertex buffer.
DX8VertexBufferClass *m_vertexBufferTile2; ///< Second vertex buffer.
DX8VertexBufferClass *m_vertexBufferWater; ///< Vertex buffer for the water plane.
DX8IndexBufferClass *m_indexWater; ///< indices defining a triangle strip for the water on terrain
Int m_waterVertexCount;
WaterRenderObjClass *m_waterDrawObject;
Bool m_drawObjects;
Bool m_drawWaypoints;
Bool m_drawPolygonAreas;
Bool m_drawBoundingBoxes;
Bool m_drawSightRanges;
Bool m_drawWeaponRanges;
Bool m_drawSoundRanges;
Bool m_drawTestArtHighlight;
Bool m_drawLetterbox;
DX8VertexBufferClass *m_vertexFeedback; ///< Vertex buffer for brush feedback.
DX8IndexBufferClass *m_indexFeedback; ///< indices defining a triangle strip for the feedback on terrain
Int m_feedbackIndexCount;
Int m_feedbackVertexCount;
AsciiString m_curMeshModelName; ///< Model name of m_moldMesh.
MeshClass *m_moldMesh; ///< W3D mesh model for the mold.
SphereClass m_moldMeshBounds; ///< Bounding sphere for mold mesh.
Render2DClass *m_lineRenderer; //< Used to render 2D lines for bounding boxes.
CPoint m_winSize; //< Holds the size of the window.
protected: // static state vars.
static Bool m_squareFeedback; ///< True for square brush feedback, false for round.
static Int m_brushWidth; ///< Width of brush feedback.
static Int m_brushFeatherWidth; ///< Width of brush feathered feedback.
static Bool m_toolWantsFeedback; ///< True to display brush feedback.
static Bool m_disableFeedback; ///< True to disable feedback.
static Coord3D m_feedbackPoint; ///< Current brush feedback location.
static CPoint m_cellCenter; ///< Cell to show feedback from.
static Bool m_meshFeedback;
static Bool m_rampFeedback; ///< should we be showing feedback for the ramp tool?
static Bool m_boundaryFeedback;
static Bool m_ambientSoundFeedback;
static Bool m_dragWaypointFeedback; ///< True for the waypoint tool dragging.
static Coord3D m_dragWayStart;///< Start drag waypoint feedback.
static Coord3D m_dragWayEnd; ///< End drag waypoint.
static Coord3D m_rampStartPoint; ///< Beginning ramp point
static Coord3D m_rampEndPoint; ///< End ramp point
static Real m_rampWidth;
protected:
void addCircleToLineRenderer( const Coord3D & center, Real radius, Real width, unsigned long color, CameraClass* camera );
Int updateVB(DX8VertexBufferClass *vertexBufferTile, Int color, Bool doArrow, Bool doDiamond);
void updatePolygonVB(PolygonTrigger *pTrig, Bool selected, Bool isOpen);
void updateFeedbackVB(void);
void updateMeshVB(void);
void updateRampVB(void);
void updateWaypointVB(void);
void updateForWater(void);
void updateBoundaryVB(void);
void updateAmbientSoundVB(void);
void updateVBWithBoundingBox(MapObject *pMapObj, CameraClass* camera);
void updateVBWithSightRange(MapObject *pMapObj, CameraClass* camera);
void updateVBWithWeaponRange(MapObject *pMapObj, CameraClass* camera);
void updateVBWithTestArtHighlight(MapObject *pMapObj, CameraClass* camera);
void updateVBWithSoundRanges(MapObject *pMapObj, CameraClass* camera);
bool worldToScreen(const Coord3D *w, ICoord2D *s, CameraClass* camera);
};
void BuildRectFromSegmentAndWidth(const Coord3D* b, const Coord3D* t, Real width,
Coord3D* outBL, Coord3D* outTL, Coord3D* outBR, Coord3D* outTR);