Richard Boegli's CnC_Generals_Zero_Hour Fork WIP
This is documentation of Richard Boegil's Zero Hour Fork
 
Loading...
Searching...
No Matches
boxrobj.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 *** 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 ***
21 ***********************************************************************************************
22 * *
23 * Project Name : WW3D *
24 * *
25 * $Archive:: /Commando/Code/ww3d2/boxrobj.h $*
26 * *
27 * Author:: Greg Hjelstrom *
28 * *
29 * $Modtime:: 10/11/01 2:24p $*
30 * *
31 * $Revision:: 6 $*
32 * *
33 *---------------------------------------------------------------------------------------------*
34 * Functions: *
35 * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
36
37#if defined(_MSC_VER)
38#pragma once
39#endif
40
41#ifndef BOXROBJ_H
42#define BOXROBJ_H
43
44#include "always.h"
45#include "rendobj.h"
46#include "w3d_file.h"
47#include "shader.h"
48#include "proto.h"
49#include "obbox.h"
50
52
53
76{
77
78public:
79
84
85 virtual int Get_Num_Polys(void) const;
86 virtual const char * Get_Name(void) const;
87 virtual void Set_Name(const char * name);
88 void Set_Color(const Vector3 & color);
89 void Set_Opacity(float opacity) { Opacity = opacity; }
90
91 static void Init(void);
92 static void Shutdown(void);
93
94 static void Set_Box_Display_Mask(int mask);
95 static int Get_Box_Display_Mask(void);
96
97 void Set_Local_Center_Extent(const Vector3 & center,const Vector3 & extent);
98 void Set_Local_Min_Max(const Vector3 & min,const Vector3 & max);
99
100 const Vector3 & Get_Local_Center(void) { return ObjSpaceCenter; }
101 const Vector3 & Get_Local_Extent(void) { return ObjSpaceExtent; }
102
103protected:
104
105 virtual void update_cached_box(void) = 0;
106 void render_box(RenderInfoClass & rinfo,const Vector3 & center,const Vector3 & extent);
107 void vis_render_box(SpecialRenderInfoClass & rinfo,const Vector3 & center,const Vector3 & extent);
108
113 float Opacity;
114
115 static bool IsInitted;
116 static int DisplayMask;
117};
118
119inline void BoxRenderObjClass::Set_Local_Center_Extent(const Vector3 & center,const Vector3 & extent)
120{
121 ObjSpaceCenter = center;
122 ObjSpaceExtent = extent;
124}
125
127{
128 ObjSpaceCenter = (max + min) / 2.0f;
129 ObjSpaceExtent = (max - min) / 2.0f;
131}
132
133
134/*
135** AABoxRenderObjClass -- RenderObject for axis-aligned collision boxes.
136*/
138{
140public:
141
145 AABoxRenderObjClass(const AABoxClass & box);
147
149 // Render Object Interface
151 virtual RenderObjClass * Clone(void) const;
152 virtual int Class_ID(void) const;
153 virtual void Render(RenderInfoClass & rinfo);
154 virtual void Special_Render(SpecialRenderInfoClass & rinfo);
155 virtual void Set_Transform(const Matrix3D &m);
156 virtual void Set_Position(const Vector3 &v);
157 virtual bool Cast_Ray(RayCollisionTestClass & raytest);
158 virtual bool Cast_AABox(AABoxCollisionTestClass & boxtest);
159 virtual bool Cast_OBBox(OBBoxCollisionTestClass & boxtest);
160 virtual bool Intersect_AABox(AABoxIntersectionTestClass & boxtest);
161 virtual bool Intersect_OBBox(OBBoxIntersectionTestClass & boxtest);
162 virtual void Get_Obj_Space_Bounding_Sphere(SphereClass & sphere) const;
163 virtual void Get_Obj_Space_Bounding_Box(AABoxClass & box) const;
164
166 // AABoxRenderObjClass Interface
168 const AABoxClass & Get_Box(void);
169
170protected:
171
172 virtual void update_cached_box(void);
173
175
176};
177
179{
182 return CachedBox;
183}
184
185/*
186** OBBoxRenderObjClass - render object for oriented collision boxes
187*/
189{
191public:
192
196 OBBoxRenderObjClass(const OBBoxClass & box);
198
200 // Render Object Interface
202 virtual RenderObjClass * Clone(void) const;
203 virtual int Class_ID(void) const;
204 virtual void Render(RenderInfoClass & rinfo);
205 virtual void Special_Render(SpecialRenderInfoClass & rinfo);
206 virtual void Set_Transform(const Matrix3D &m);
207 virtual void Set_Position(const Vector3 &v);
208 virtual bool Cast_Ray(RayCollisionTestClass & raytest);
209 virtual bool Cast_AABox(AABoxCollisionTestClass & boxtest);
210 virtual bool Cast_OBBox(OBBoxCollisionTestClass & boxtest);
211 virtual bool Intersect_AABox(AABoxIntersectionTestClass & boxtest);
212 virtual bool Intersect_OBBox(OBBoxIntersectionTestClass & boxtest);
213 virtual void Get_Obj_Space_Bounding_Sphere(SphereClass & sphere) const;
214 virtual void Get_Obj_Space_Bounding_Box(AABoxClass & box) const;
215
217 // OBBoxRenderObjClass Interface
219 OBBoxClass & Get_Box(void);
220
221protected:
222
223 virtual void update_cached_box(void);
224
226
227};
228
229
230/*
231** Loader for boxes
232*/
234{
235public:
236 virtual int Chunk_Type (void) { return W3D_CHUNK_BOX; }
237 virtual PrototypeClass * Load_W3D(ChunkLoadClass & cload);
238};
239
240
241// ----------------------------------------------------------------------------
242/*
243** Prototype for Box objects
244*/
246{
248public:
250 virtual const char * Get_Name(void) const;
251 virtual int Get_Class_ID(void) const;
252 virtual RenderObjClass * Create(void);
253 virtual void DeleteSelf() { delete this; }
254private:
255 W3dBoxStruct Definition;
256};
257
258/*
259** Instance of the loader which the asset manager installs
260*/
262
263
264
265
266#endif
267
#define min(x, y)
Definition BaseType.h:101
#define max(x, y)
Definition BaseType.h:105
#define W3D_NAME_LEN
Definition w3d_file.h:319
@ W3D_CHUNK_BOX
Definition w3d_file.h:473
#define W3DMPO_GLUE(ARGCLASS)
Definition always.h:120
BoxLoaderClass _BoxLoader
Definition boxrobj.cpp:1389
virtual void Get_Obj_Space_Bounding_Sphere(SphereClass &sphere) const
Definition boxrobj.cpp:919
virtual bool Intersect_AABox(AABoxIntersectionTestClass &boxtest)
Definition boxrobj.cpp:881
const AABoxClass & Get_Box(void)
Definition boxrobj.h:178
virtual void Special_Render(SpecialRenderInfoClass &rinfo)
Definition boxrobj.cpp:724
virtual void update_cached_box(void)
Definition boxrobj.cpp:786
virtual void Set_Position(const Vector3 &v)
Definition boxrobj.cpp:767
virtual bool Intersect_OBBox(OBBoxIntersectionTestClass &boxtest)
Definition boxrobj.cpp:900
virtual RenderObjClass * Clone(void) const
Definition boxrobj.cpp:667
virtual void Get_Obj_Space_Bounding_Box(AABoxClass &box) const
Definition boxrobj.cpp:937
AABoxRenderObjClass & operator=(const AABoxRenderObjClass &)
Definition boxrobj.cpp:645
AABoxClass CachedBox
Definition boxrobj.h:174
virtual bool Cast_Ray(RayCollisionTestClass &raytest)
Definition boxrobj.cpp:805
virtual void Set_Transform(const Matrix3D &m)
Definition boxrobj.cpp:748
virtual void Render(RenderInfoClass &rinfo)
Definition boxrobj.cpp:703
virtual bool Cast_OBBox(OBBoxCollisionTestClass &boxtest)
Definition boxrobj.cpp:856
virtual int Class_ID(void) const
Definition boxrobj.cpp:685
virtual bool Cast_AABox(AABoxCollisionTestClass &boxtest)
Definition boxrobj.cpp:831
virtual int Chunk_Type(void)
Definition boxrobj.h:236
virtual PrototypeClass * Load_W3D(ChunkLoadClass &cload)
Definition boxrobj.cpp:1348
virtual const char * Get_Name(void) const
Definition boxrobj.cpp:1363
BoxPrototypeClass(W3dBoxStruct box)
Definition boxrobj.cpp:1358
virtual RenderObjClass * Create(void)
Definition boxrobj.cpp:1377
virtual void DeleteSelf()
Definition boxrobj.h:253
virtual int Get_Class_ID(void) const
Definition boxrobj.cpp:1368
char Name[2 *W3D_NAME_LEN]
Definition boxrobj.h:109
void Set_Color(const Vector3 &color)
Definition boxrobj.cpp:327
static void Init(void)
Definition boxrobj.cpp:347
virtual void update_cached_box(void)=0
virtual int Get_Num_Polys(void) const
Definition boxrobj.cpp:271
void Set_Local_Min_Max(const Vector3 &min, const Vector3 &max)
Definition boxrobj.h:126
static bool IsInitted
Definition boxrobj.h:115
BoxRenderObjClass(void)
Definition boxrobj.cpp:182
Vector3 ObjSpaceExtent
Definition boxrobj.h:112
const Vector3 & Get_Local_Center(void)
Definition boxrobj.h:100
void Set_Opacity(float opacity)
Definition boxrobj.h:89
void Set_Local_Center_Extent(const Vector3 &center, const Vector3 &extent)
Definition boxrobj.h:119
static int Get_Box_Display_Mask(void)
Definition boxrobj.cpp:426
virtual void Set_Name(const char *name)
Definition boxrobj.cpp:307
static void Shutdown(void)
Definition boxrobj.cpp:384
void render_box(RenderInfoClass &rinfo, const Vector3 &center, const Vector3 &extent)
Definition boxrobj.cpp:444
BoxRenderObjClass & operator=(const BoxRenderObjClass &)
Definition boxrobj.cpp:246
void vis_render_box(SpecialRenderInfoClass &rinfo, const Vector3 &center, const Vector3 &extent)
Definition boxrobj.cpp:536
static void Set_Box_Display_Mask(int mask)
Definition boxrobj.cpp:408
Vector3 ObjSpaceCenter
Definition boxrobj.h:111
const Vector3 & Get_Local_Extent(void)
Definition boxrobj.h:101
virtual const char * Get_Name(void) const
Definition boxrobj.cpp:289
static int DisplayMask
Definition boxrobj.h:116
virtual bool Cast_AABox(AABoxCollisionTestClass &boxtest)
Definition boxrobj.cpp:1214
OBBoxClass & Get_Box(void)
Definition boxrobj.cpp:1338
virtual void Set_Transform(const Matrix3D &m)
Definition boxrobj.cpp:1130
OBBoxClass CachedBox
Definition boxrobj.h:225
virtual void Get_Obj_Space_Bounding_Sphere(SphereClass &sphere) const
Definition boxrobj.cpp:1302
virtual void Render(RenderInfoClass &rinfo)
Definition boxrobj.cpp:1089
virtual void Special_Render(SpecialRenderInfoClass &rinfo)
Definition boxrobj.cpp:1108
virtual void Set_Position(const Vector3 &v)
Definition boxrobj.cpp:1149
virtual bool Intersect_OBBox(OBBoxIntersectionTestClass &boxtest)
Definition boxrobj.cpp:1283
virtual bool Intersect_AABox(AABoxIntersectionTestClass &boxtest)
Definition boxrobj.cpp:1264
virtual int Class_ID(void) const
Definition boxrobj.cpp:1071
OBBoxRenderObjClass & operator=(const OBBoxRenderObjClass &)
Definition boxrobj.cpp:1031
virtual void update_cached_box(void)
Definition boxrobj.cpp:1168
virtual RenderObjClass * Clone(void) const
Definition boxrobj.cpp:1053
virtual bool Cast_Ray(RayCollisionTestClass &raytest)
Definition boxrobj.cpp:1188
virtual bool Cast_OBBox(OBBoxCollisionTestClass &boxtest)
Definition boxrobj.cpp:1239
virtual void Get_Obj_Space_Bounding_Box(AABoxClass &box) const
Definition boxrobj.cpp:1320
PrototypeClass(void)
Definition proto.h:90
PrototypeLoaderClass(void)
Definition proto.h:139
RenderObjClass(void)
Definition rendobj.cpp:170
virtual void Validate_Transform(void) const
Definition rendobj.cpp:464