Richard Boegli's CnC_Generals_Zero_Hour Fork WIP
This is documentation of Richard Boegil's Zero Hour Fork
 
Loading...
Searching...
No Matches
mesh.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/* $Header: /Commando/Code/ww3d2/mesh.h 16 11/07/01 5:50p Jani_p $ */
20/***********************************************************************************************
21 *** Confidential - Westwood Studios ***
22 ***********************************************************************************************
23 * *
24 * Project Name : Commando / G 3D engine *
25 * *
26 * File Name : MESH.H *
27 * *
28 * Programmer : Greg Hjelstrom *
29 * *
30 * Start Date : 06/11/97 *
31 * *
32 * Last Update : June 11, 1997 [GH] *
33 * *
34 *---------------------------------------------------------------------------------------------*
35 * Functions: *
36 * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
37
38
39#if defined(_MSC_VER)
40#pragma once
41#endif
42
43#ifndef MESH_H
44#define MESH_H
45
46#include "always.h"
47#include "rendobj.h"
48#include "bittype.h"
49#include "w3derr.h"
50#include "LightEnvironment.h" //added for 'Generals'
51
53class HModelClass;
54class AuxMeshDataClass;
55class MeshLoadInfoClass;
56class W3DMeshClass;
58class ChunkLoadClass;
59class ChunkSaveClass;
60class RenderInfoClass;
61class MeshModelClass;
62class DecalMeshClass;
67class TextureClass;
70
74class MeshClass : public W3DMPO, public RenderObjClass
75{
77public:
78
79 MeshClass(void);
80 MeshClass(const MeshClass & src);
82 virtual ~MeshClass(void);
83
85 // Render Object Interface
87 virtual RenderObjClass * Clone(void) const;
88 virtual int Class_ID(void) const { return CLASSID_MESH; }
89 virtual const char * Get_Name(void) const;
90 virtual void Set_Name(const char * name);
91 virtual int Get_Num_Polys(void) const;
92 virtual void Render(RenderInfoClass & rinfo);
94 virtual void Special_Render(SpecialRenderInfoClass & rinfo);
95
97 // Render Object Interface - Collision Detection
99 virtual bool Cast_Ray(RayCollisionTestClass & raytest);
100 virtual bool Cast_AABox(AABoxCollisionTestClass & boxtest);
101 virtual bool Cast_OBBox(OBBoxCollisionTestClass & boxtest);
102 virtual bool Intersect_AABox(AABoxIntersectionTestClass & boxtest);
103 virtual bool Intersect_OBBox(OBBoxIntersectionTestClass & boxtest);
104
106 // Render Object Interface - Bounding Volumes
108 virtual void Get_Obj_Space_Bounding_Sphere(SphereClass & sphere) const;
109 virtual void Get_Obj_Space_Bounding_Box(AABoxClass & box) const;
110
112 // Render Object Interface - Attributes, Options, Properties, etc
114 virtual void Scale(float scale);
115 virtual void Scale(float scalex, float scaley, float scalez);
116 virtual MaterialInfoClass * Get_Material_Info(void);
117
118 virtual int Get_Sort_Level(void) const;
119 virtual void Set_Sort_Level(int level);
120
121
123 // Render Object Interface - Decals
125 virtual void Create_Decal(DecalGeneratorClass * generator);
126 virtual void Delete_Decal(uint32 decal_id);
127
129 // MeshClass Interface
131 WW3DErrorType Init(const MeshBuilderClass & builder,MaterialInfoClass * matinfo,const char * name,const char * hmodelname);
133 void Generate_Culling_Tree(void);
136 uint32 Get_W3D_Flags(void);
137 const char * Get_User_Text(void) const;
138 int Get_Draw_Call_Count(void) const;
139
140 bool Contains(const Vector3 &point);
141
142 void Get_Deformed_Vertices(Vector3 *dst_vert, Vector3 *dst_norm);
143 void Get_Deformed_Vertices(Vector3 *dst_vert);
144
147 inline float Get_Alpha_Override(void) { return m_alphaOverride;}
148
149 void Set_Next_Visible_Skin(MeshClass * next_visible) { NextVisibleSkin = next_visible; }
151
152 void Set_Base_Vertex_Offset(int base) { BaseVertexOffset = base; }
154
155 // Do old .w3d mesh files get fog turned on or off?
157
158 void Replace_Texture(TextureClass* texture,TextureClass* new_texture);
160
161 void Make_Unique(bool force_meshmdl_clone = false);
162 unsigned Get_Debug_Id() const { return MeshDebugId; }
163
166
167protected:
168
169 virtual void Add_Dependencies_To_List (DynamicVectorClass<StringClass> &file_list, bool textures_only = false);
170
171 virtual void Update_Cached_Bounding_Volumes(void) const;
172
173 void Free(void);
174
175 void install_materials(MeshLoadInfoClass * loadinfo);
176 void clone_materials(const MeshClass & srcmesh);
177
180
181 LightEnvironmentClass * LightEnvironment; // cached pointer to the light environment for this mesh
183 float m_alphaOverride; //added for 'Generals' to allow variable alpha on meshes.
184 float m_materialPassEmissiveOverride; //added for 'Generals' to allow variable emissive on additional passes.
185 float m_materialPassAlphaOverride; //added for 'Generals' to allow variable alpha on additional render passes.
186 int BaseVertexOffset; // offset to our first vertex in whatever vb this mesh is in.
187 MeshClass * NextVisibleSkin; // linked list of visible skins
188
189 unsigned MeshDebugId;
191
192 friend class MeshBuilderClass;
193};
194
196{
197 return Model;
198}
199
200
201// This utility function recurses throughout the subobjects of a renderobject,
202// and for each MeshClass it finds it sets the given MeshModel flag on its
203// model. This is useful for stuff like making a RenderObjects' polys sort.
204//void Set_MeshModel_Flag(RenderObjClass *robj, MeshModelClass::FlagsType flag, int onoff);
205void Set_MeshModel_Flag(RenderObjClass *robj, int flag, int onoff);
206
207#endif /*MESH_H*/
208
#define NULL
Definition BaseType.h:92
Color scale(const Color &a, const Color &b)
Definition GameMtl.cpp:722
#define W3DMPO_GLUE(ARGCLASS)
Definition always.h:120
unsigned long uint32
Definition bittype.h:46
LightEnvironmentClass m_localLightEnv
Definition mesh.h:182
DecalMeshClass * DecalMesh
Definition mesh.h:179
void install_materials(MeshLoadInfoClass *loadinfo)
virtual void Render(RenderInfoClass &rinfo)
Definition mesh.cpp:660
virtual void Get_Obj_Space_Bounding_Sphere(SphereClass &sphere) const
Definition mesh.cpp:1403
virtual RenderObjClass * Clone(void) const
Definition mesh.cpp:306
void Replace_Texture(TextureClass *texture, TextureClass *new_texture)
Definition mesh.cpp:1072
float m_materialPassEmissiveOverride
Definition mesh.h:184
WW3DErrorType Load_W3D(ChunkLoadClass &cload)
Definition mesh.cpp:1139
float Get_Alpha_Override(void)
Definition mesh.h:147
void Generate_Culling_Tree(void)
Definition mesh.cpp:1448
virtual void Delete_Decal(uint32 decal_id)
Definition mesh.cpp:615
void Render_Material_Pass(MaterialPassClass *pass, IndexBufferClass *ib)
Definition mesh.cpp:823
bool Contains(const Vector3 &point)
Definition mesh.cpp:266
WW3DErrorType Init(const MeshBuilderClass &builder, MaterialInfoClass *matinfo, const char *name, const char *hmodelname)
int BaseVertexOffset
Definition mesh.h:186
void Make_Unique(bool force_meshmdl_clone=false)
Definition mesh.cpp:1114
static bool Legacy_Meshes_Fogged
Definition mesh.h:156
unsigned MeshDebugId
Definition mesh.h:189
virtual bool Cast_Ray(RayCollisionTestClass &raytest)
Definition mesh.cpp:1218
virtual bool Intersect_OBBox(OBBoxIntersectionTestClass &boxtest)
Definition mesh.cpp:1379
friend class MeshBuilderClass
Definition mesh.h:192
int Get_Draw_Call_Count(void) const
Definition mesh.cpp:1579
void Get_Deformed_Vertices(Vector3 *dst_vert, Vector3 *dst_norm)
Definition mesh.cpp:500
virtual int Get_Num_Polys(void) const
Definition mesh.cpp:635
virtual void Create_Decal(DecalGeneratorClass *generator)
Definition mesh.cpp:540
virtual void Set_Name(const char *name)
Definition mesh.cpp:342
void Set_Base_Vertex_Offset(int base)
Definition mesh.h:152
MeshModelClass * Get_Model(void)
Definition mesh.cpp:419
MeshClass(void)
Definition mesh.cpp:161
virtual const char * Get_Name(void) const
Definition mesh.cpp:324
int Get_Base_Vertex_Offset(void)
Definition mesh.h:153
void Set_Lighting_Environment(LightEnvironmentClass *light_env)
Definition mesh.h:145
virtual void Special_Render(SpecialRenderInfoClass &rinfo)
Definition mesh.cpp:1027
virtual void Scale(float scale)
Definition mesh.cpp:438
virtual int Get_Sort_Level(void) const
Definition mesh.cpp:1564
MeshClass & operator=(const MeshClass &)
Definition mesh.cpp:218
virtual int Class_ID(void) const
Definition mesh.h:88
virtual MaterialInfoClass * Get_Material_Info(void)
Definition mesh.cpp:395
LightEnvironmentClass * Get_Lighting_Environment(void)
Definition mesh.h:146
void Set_Debugger_Disable(bool b)
Definition mesh.h:164
void Replace_VertexMaterial(VertexMaterialClass *vmat, VertexMaterialClass *new_vmat)
Definition mesh.cpp:1093
virtual void Get_Obj_Space_Bounding_Box(AABoxClass &box) const
Definition mesh.cpp:1426
void Set_Next_Visible_Skin(MeshClass *next_visible)
Definition mesh.h:149
virtual ~MeshClass(void)
Definition mesh.cpp:247
MeshModelClass * Peek_Model(void)
Definition mesh.h:195
unsigned Get_Debug_Id() const
Definition mesh.h:162
bool Is_Disabled_By_Debugger() const
Definition mesh.h:165
MeshModelClass * Model
Definition mesh.h:178
MeshClass * Peek_Next_Visible_Skin(void)
Definition mesh.h:150
virtual void Update_Cached_Bounding_Volumes(void) const
Definition mesh.cpp:1515
virtual void Add_Dependencies_To_List(DynamicVectorClass< StringClass > &file_list, bool textures_only=false)
Definition mesh.cpp:1467
virtual bool Cast_OBBox(OBBoxCollisionTestClass &boxtest)
Definition mesh.cpp:1304
bool IsDisabledByDebugger
Definition mesh.h:190
virtual bool Intersect_AABox(AABoxIntersectionTestClass &boxtest)
Definition mesh.cpp:1352
float m_materialPassAlphaOverride
Definition mesh.h:185
float m_alphaOverride
Definition mesh.h:183
virtual void Set_Sort_Level(int level)
Definition mesh.cpp:1572
void Free(void)
Definition mesh.cpp:287
void clone_materials(const MeshClass &srcmesh)
virtual bool Cast_AABox(AABoxCollisionTestClass &boxtest)
Definition mesh.cpp:1274
LightEnvironmentClass * LightEnvironment
Definition mesh.h:181
MeshClass * NextVisibleSkin
Definition mesh.h:187
const char * Get_User_Text(void) const
Definition mesh.cpp:377
uint32 Get_W3D_Flags(void)
Definition mesh.cpp:359
RenderObjClass(void)
Definition rendobj.cpp:170
void Set_MeshModel_Flag(RenderObjClass *robj, int flag, int onoff)
Definition mesh.cpp:1542
unsigned char flag
Definition vchannel.cpp:273
WW3DErrorType
Definition w3derr.h:51