Richard Boegli's CnC_Generals_Zero_Hour Fork WIP
This is documentation of Richard Boegil's Zero Hour Fork
 
Loading...
Searching...
No Matches
w3dappdata.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 : Max2W3d *
24 * *
25 * $Archive:: /Commando/Code/Tools/max2w3d/w3dappdata.h $*
26 * *
27 * Original Author:: Greg Hjelstrom *
28 * *
29 * $Author:: Greg_h $*
30 * *
31 * $Modtime:: 8/21/01 9:44a $*
32 * *
33 * $Revision:: 8 $*
34 * *
35 *---------------------------------------------------------------------------------------------*
36 * Functions: *
37 * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
38
39#ifndef W3DAPPDATA_H
40#define W3DAPPDATA_H
41
42#include <Max.h>
43
44/*
45** The W3DUtilityClass uses several app-data chunks to store user-options for INodes
46** in the MAX scene. Below are the IDs for each app-data chunk type:
47*/
48
49#define W3D_APPDATA_0 0
50#define W3D_APPDATA_1 1
51#define W3D_APPDATA_2 2
52#define W3D_DAZZLE_APPDATA 3
53
54
55/*
56** Classifying INodes for w3d exporting
57**
58** NOTE: Use these utility functions rather than going straight to the AppData
59** structure!
60**
61** - There are bits stored in AppData for each node
62** - These bits indicate wether something should be exported as hierarchy,
63** geometry (and if so, what type of geometry: mesh, collision box, bitmap, etc)
64**
65** When we say something is "Hierarchy" that means its transform should be put
66** into any hierarchy tree or motion being created. In some places I used
67** the term "Bone" which means the same thing.
68**
69** When we say something is "Geometry" that means that the object will become
70** some sort of render object (normal mesh, bitmap, collision mesh, etc)
71**
72*/
73
74/*
75** Either or both of these will return true for a given INode
76*/
77bool Is_Bone(INode * node);
78bool Is_Geometry(INode * node);
79
80/*
81** Geometry Type:
82** One of the following will return true if the given INode is
83** to have its geometry exported
84*/
85bool Is_Normal_Mesh(INode * node);
86bool Is_Camera_Aligned_Mesh(INode * node);
87bool Is_Camera_Oriented_Mesh(INode * node);
88bool Is_Collision_AABox(INode * node);
89bool Is_Collision_OBBox(INode * node);
90bool Is_Skin(INode * node);
91bool Is_Shadow(INode * node);
92bool Is_Null_Object(INode * node);
93bool Is_Dazzle(INode * node);
94bool Is_Aggregate(INode * node);
95
96/*
97** Collision Bits, any or all of these may return true for a given INode
98*/
99bool Is_Physical_Collision(INode * node);
100bool Is_Projectile_Collision(INode * node);
101bool Is_Vis_Collision(INode * node);
102bool Is_Camera_Collision(INode * node);
103bool Is_Vehicle_Collision(INode * node);
104
105/*
106** Miscellaneous settings
107*/
108bool Is_Hidden(INode * node);
109bool Is_Two_Sided(INode * node);
110bool Is_ZNormals(INode * node);
111bool Is_Vertex_Alpha(INode * node);
112bool Is_Shatterable(INode * node);
113bool Is_NPatchable(INode * node);
114
115/*
116** Proxy support. If a node has a name which contains a ~ it is considered a
117** proxy for an application defined named object. This overrides all other
118** settings (in the future, we shouldn't do things this way!)
119*/
120inline bool Is_Proxy(INode &node)
121{
122 return (::strchr (node.GetName (), '~') != NULL);
123}
124
125
126
127/*
128** AJA 9/24/99
129** NOTE: Whenever you add a new W3DAppDataStruct, you must add an accessor function
130** to the bottom of this file. Then the WWScript.dlx project must be modified. That
131** project implements an extension to the MAXScript language in the form of a function
132** called "wwCopyAppData". The implementation of this wwCopyAppData function must be
133** aware of the new W3DAppDataStruct. The modification is pretty straightfoward.
134**
135** The wwCopyAppData extension was added to MAXScript so that the data we define
136** below can be preserve when a model is cloned (copy/instance/reference). What
137** happens without using wwCopyAppData is that a new INode is created that contains
138** a copy/instance/reference to the original mesh/bone in the source model. When
139** this new INode is created, it has no app data. When the app data is examined later
140** on, it gets the default values! That means all information concerning Export
141** Geometry/Transform, mesh type, and damage region is lost. wwCopyAppData allows
142** a script to duplicate a model INCLUDING all W3D app data, so that this information
143** is preserved.
144*/
145
146
147/*
148** The W3DAppData0Struct contains a bitfield. These #defines are
149** used to interpret the bits.
150** (gth) NOTE: AppData0 is now OBSOLETE!!! Use W3DAppData2Struct now.
151*/
152#define EXPORT_TYPE_MASK 0x000F
153#define GEOMETRY_TYPE_MASK 0x01F0
154#define COLLISION_TYPE_MASK 0xF000
155
156#define EXPORT_BONE_FLAG 0x0001 // export a bone (transform) for this node
157#define EXPORT_GEOMETRY_FLAG 0x0002 // export the geometry for this node
158#define EXPORT_HIDDEN_FLAG 0x0004 // mesh should be hidden by default
159#define EXPORT_TWO_SIDED_FLAG 0x0008 // mesh should be two sided
160
161#define GEOMETRY_TYPE_CAMERA_ALIGNED 0x0010 // interpret this geometry as a camera-aligned mesh
162#define GEOMETRY_TYPE_NORMAL_MESH 0x0020 // this is a normal mesh
163#define GEOMETRY_TYPE_OBBOX 0x0030 // this is an oriented box (should have 8 verts, etc)
164#define GEOMETRY_TYPE_AABOX 0x0040 // this is an axis aligned box
165#define GEOMETRY_TYPE_CAMERA_ORIENTED 0x0050 // interpret this geometry as a camera-oriented mesh
166#define GEOMETRY_TYPE_NULL 0x0100 // this is a null (for LOD)
167
168#define EXPORT_CAST_SHADOW_FLAG 0x0200 // this mesh casts a shadow
169#define EXPORT_VERTEX_ALPHA_FLAG 0x0400 // convert vertex colors to alpha
170#define EXPORT_ZNORMALS_FLAG 0x0800 // force vertex normals to point along +z
171
172#define COLLISION_TYPE_PHYSICAL 0x1000 // runtime engine performs physical collision against this mesh
173#define COLLISION_TYPE_PROJECTILE 0x2000 // perform projectile collisions against this mesh
174#define COLLISION_TYPE_VIS 0x4000 // perform vis group collisions against this mesh
175
176#define DEFAULT_MESH_EXPORT_FLAGS (EXPORT_BONE_FLAG | EXPORT_GEOMETRY_FLAG | GEOMETRY_TYPE_NORMAL_MESH)
177#define DEFAULT_EXPORT_FLAGS 0
178
179
180/*
181** W3D Utility AppData sub-type 0 (OBSOLETE!)
182** ----------------------------------------------------
183** The utility provides a right-click menu which allows
184** the user to toggle the export flags.
185** (gth) NOTE: AppData0 is now OBSOLETE!!! Use W3DAppData2Struct now.
186*/
188{
190
193
200
204
210
211 unsigned short ExportFlags; // what was I thinking??? (gth)
212};
213
214
215
216/*
217** W3D Utility AppData sub-type 1
218** ----------------------------------------------------
219** This AppData contains the damage region number for
220** the current object.
221*/
222
223// Maximum number of damage regions on a model.
224#define MAX_DAMAGE_REGIONS ((char)16)
225// Value that represents no damage region.
226#define NO_DAMAGE_REGION ((char)-1)
227
229{
231
232 /*
233 ** NO_DAMAGE_REGION means the object isn't part of
234 ** any damage region, 0 through MAX_DAMAGE_REGIONS-1
235 ** are valid damage regions.
236 */
238};
239
240
241
242/*
243** W3D Utility AppData sub-type 2
244** ----------------------------------------------------
245** This is an app-data struct that is meant to contain all
246** of the w3d export options for an object in MAX. It
247** replaces the old AppData sub-type 0. Call the static
248** member functions in the class to get a pointer to
249** the AppData2 struct hanging off any INode and automatically
250** create one for you if there isn't already one...
251*/
252
254{
255 W3DAppData2Struct(void);
257
258 void Init_With_Mesh_Defaults(void);
259 void Init_With_Other_Defaults(void);
261 void Update_Version(void);
262
264 {
265 GEO_TYPE_CAMERA_ALIGNED = 0x00000001, // Geometry types are mutually exclusive
267 GEO_TYPE_OBBOX = 0x00000003,
268 GEO_TYPE_AABOX = 0x00000004,
270 GEO_TYPE_NULL = 0x00000006,
271 GEO_TYPE_DAZZLE = 0x00000007,
272 GEO_TYPE_AGGREGATE = 0x00000008,
273 };
274
275 /*
276 ** Read Access
277 */
278 bool Is_Bone(void) const { return (ExportFlags & EXPORT_TRANSFORM) == EXPORT_TRANSFORM; }
279 bool Is_Geometry(void) const { return (ExportFlags & EXPORT_GEOMETRY) == EXPORT_GEOMETRY; }
280
281 int Get_Geometry_Type(void) const { return GeometryType; }
282 bool Is_Normal_Mesh(void) const { return GeometryType == GEO_TYPE_NORMAL_MESH; }
285 bool Is_Collision_AABox(void) const { return GeometryType == GEO_TYPE_AABOX; }
286 bool Is_Collision_OBBox(void) const { return GeometryType == GEO_TYPE_OBBOX; }
287 bool Is_Null(void) const { return GeometryType == GEO_TYPE_NULL; }
288 bool Is_Dazzle(void) const { return GeometryType == GEO_TYPE_DAZZLE; }
289
297
303
304 /*
305 ** Write Access
306 */
307 void Enable_Export_Transform(bool onoff) { if (onoff) { ExportFlags |= EXPORT_TRANSFORM; } else { ExportFlags &= ~EXPORT_TRANSFORM; } }
308 void Enable_Export_Geometry(bool onoff) { if (onoff) { ExportFlags |= EXPORT_GEOMETRY; } else { ExportFlags &= ~EXPORT_GEOMETRY; } }
309
310 void Set_Geometry_Type(GeometryTypeEnum type) { GeometryType = (unsigned int)type; }
311
312 void Enable_Hidden(bool onoff) { if (onoff) { GeometryFlags |= GEOMETRY_FLAG_HIDDEN; } else { GeometryFlags &= ~GEOMETRY_FLAG_HIDDEN; } }
319
325
326 /*
327 ** Comparison
328 */
329 bool operator == (const W3DAppData2Struct & that);
330 bool operator != (const W3DAppData2Struct & that) { return !(*this == that); }
331 bool Geometry_Options_Match(const W3DAppData2Struct & that);
332
333 /*
334 ** Get the W3DAppData2Struct for a given INode and create one if
335 ** there isn't already one.
336 */
337 static W3DAppData2Struct * Get_App_Data(INode * node,bool create_if_missing = true);
338
339protected:
340
343
345 {
346 EXPORT_TRANSFORM = 0x00000001, // Export flags bit-field
347 EXPORT_GEOMETRY = 0x00000002,
348
349 VERSION_MASK = 0xFFFF0000, // upper 16bits is version number.
351 };
352
354 {
355 GEOMETRY_FLAG_HIDDEN = 0x00000001, // Geometry Flags bitfield
362 };
363
372
373 unsigned int ExportFlags;
374 unsigned int GeometryType;
375 unsigned int GeometryFlags;
376 unsigned int CollisionFlags;
377
378 // future expansion, initialized to zeros
379 unsigned int UnUsed[4];
380};
381
382
383
384/*
385** W3D Utility Dazzle App Data
386** ----------------------------------------------------
387** This app-data struct is used to contain parameters
388** specific to dazzle render objects. It currently only
389** contains a type name which is limited to 128 characters
390** and some padding variables for future use.
391*/
392
394{
395 /*
396 ** Constructor, zeros everything, then initializes DazzleType to "DEFAULT"
397 */
399
400 /*
401 ** Get the W3DAppData2Struct for a given INode and create one if
402 ** there isn't already one.
403 */
404 static W3DDazzleAppDataStruct * Get_App_Data(INode * node,bool create_if_missing = true);
405
406 /*
407 ** Members
408 */
409 unsigned int UnUsed[4];
410 char DazzleType[128];
411};
412
413
414#endif
415
#define NULL
Definition BaseType.h:92
bool Is_Collision_AABox(void)
Definition w3dappdata.h:197
bool Is_Normal_Mesh(void)
Definition w3dappdata.h:194
bool Is_Vis_Collision(void)
Definition w3dappdata.h:203
bool Is_Hidden(void)
Definition w3dappdata.h:205
bool Is_ZNormals(void)
Definition w3dappdata.h:208
bool Is_Physical_Collision(void)
Definition w3dappdata.h:201
bool Is_Bone(void)
Definition w3dappdata.h:191
unsigned short ExportFlags
Definition w3dappdata.h:211
bool Is_Vertex_Alpha(void)
Definition w3dappdata.h:207
bool Is_Camera_Aligned_Mesh(void)
Definition w3dappdata.h:195
bool Is_Projectile_Collision(void)
Definition w3dappdata.h:202
bool Is_Two_Sided(void)
Definition w3dappdata.h:206
bool Is_Geometry(void)
Definition w3dappdata.h:192
bool Is_Null(void)
Definition w3dappdata.h:199
bool Is_Camera_Oriented_Mesh(void)
Definition w3dappdata.h:196
bool Is_Shadow(void)
Definition w3dappdata.h:209
bool Is_Collision_OBBox(void)
Definition w3dappdata.h:198
void Enable_Export_Transform(bool onoff)
Definition w3dappdata.h:307
int Get_Geometry_Type(void) const
Definition w3dappdata.h:281
void Enable_Projectile_Collision(bool onoff)
Definition w3dappdata.h:321
void Enable_Export_Geometry(bool onoff)
Definition w3dappdata.h:308
void Enable_Two_Sided(bool onoff)
Definition w3dappdata.h:313
void Enable_Camera_Collision(bool onoff)
Definition w3dappdata.h:323
void Set_Geometry_Type(GeometryTypeEnum type)
Definition w3dappdata.h:310
bool Is_Bone(void) const
Definition w3dappdata.h:278
bool Is_Physical_Collision_Enabled(void) const
Definition w3dappdata.h:298
bool Is_Vertex_Alpha_Enabled(void) const
Definition w3dappdata.h:292
void Init_With_Mesh_Defaults(void)
void Enable_Vehicle_Collision(bool onoff)
Definition w3dappdata.h:324
int Get_Version(void)
Definition w3dappdata.h:342
void Enable_NPatchable(bool onoff)
Definition w3dappdata.h:318
bool operator==(const W3DAppData2Struct &that)
bool operator!=(const W3DAppData2Struct &that)
Definition w3dappdata.h:330
bool Is_NPatchable_Enabled(void) const
Definition w3dappdata.h:296
bool Is_Camera_Aligned_Mesh(void) const
Definition w3dappdata.h:283
void Enable_Vis_Collision(bool onoff)
Definition w3dappdata.h:322
bool Is_Camera_Oriented_Mesh(void) const
Definition w3dappdata.h:284
void Init_With_Other_Defaults(void)
void Init_From_AppData0(W3DAppData0Struct &olddata)
void Set_Version(int ver)
Definition w3dappdata.h:341
bool Is_Geometry(void) const
Definition w3dappdata.h:279
unsigned int CollisionFlags
Definition w3dappdata.h:376
unsigned int GeometryType
Definition w3dappdata.h:374
void Update_Version(void)
static W3DAppData2Struct * Get_App_Data(INode *node, bool create_if_missing=true)
void Enable_Physical_Collision(bool onoff)
Definition w3dappdata.h:320
void Enable_Shadow(bool onoff)
Definition w3dappdata.h:314
unsigned int GeometryFlags
Definition w3dappdata.h:375
bool Is_ZNormals_Enabled(void) const
Definition w3dappdata.h:293
bool Is_Vis_Collision_Enabled(void) const
Definition w3dappdata.h:300
unsigned int UnUsed[4]
Definition w3dappdata.h:379
bool Is_Two_Sided_Enabled(void) const
Definition w3dappdata.h:291
bool Is_Hidden_Enabled(void) const
Definition w3dappdata.h:290
bool Is_Shatterable_Enabled(void) const
Definition w3dappdata.h:295
void Enable_Shatterable(bool onoff)
Definition w3dappdata.h:317
void Enable_ZNormals(bool onoff)
Definition w3dappdata.h:316
unsigned int ExportFlags
Definition w3dappdata.h:373
bool Geometry_Options_Match(const W3DAppData2Struct &that)
void Enable_Hidden(bool onoff)
Definition w3dappdata.h:312
bool Is_Null(void) const
Definition w3dappdata.h:287
bool Is_Camera_Collision_Enabled(void) const
Definition w3dappdata.h:301
bool Is_Collision_OBBox(void) const
Definition w3dappdata.h:286
void Enable_Vertex_Alpha(bool onoff)
Definition w3dappdata.h:315
bool Is_Normal_Mesh(void) const
Definition w3dappdata.h:282
bool Is_Collision_AABox(void) const
Definition w3dappdata.h:285
bool Is_Vehicle_Collision_Enabled(void) const
Definition w3dappdata.h:302
bool Is_Shadow_Enabled(void) const
Definition w3dappdata.h:294
bool Is_Projectile_Collision_Enabled(void) const
Definition w3dappdata.h:299
bool Is_Dazzle(void) const
Definition w3dappdata.h:288
unsigned int UnUsed[4]
Definition w3dappdata.h:409
static W3DDazzleAppDataStruct * Get_App_Data(INode *node, bool create_if_missing=true)
bool Is_Collision_OBBox(INode *node)
bool Is_Proxy(INode &node)
Definition w3dappdata.h:120
bool Is_Dazzle(INode *node)
bool Is_Geometry(INode *node)
#define COLLISION_TYPE_PROJECTILE
Definition w3dappdata.h:173
#define EXPORT_TWO_SIDED_FLAG
Definition w3dappdata.h:159
bool Is_Hidden(INode *node)
bool Is_Shatterable(INode *node)
#define GEOMETRY_TYPE_CAMERA_ORIENTED
Definition w3dappdata.h:165
bool Is_Aggregate(INode *node)
bool Is_Normal_Mesh(INode *node)
#define EXPORT_ZNORMALS_FLAG
Definition w3dappdata.h:170
bool Is_Camera_Oriented_Mesh(INode *node)
bool Is_Camera_Aligned_Mesh(INode *node)
#define NO_DAMAGE_REGION
Definition w3dappdata.h:226
#define GEOMETRY_TYPE_NORMAL_MESH
Definition w3dappdata.h:162
bool Is_Skin(INode *node)
bool Is_Null_Object(INode *node)
bool Is_Vertex_Alpha(INode *node)
bool Is_Projectile_Collision(INode *node)
bool Is_Collision_AABox(INode *node)
bool Is_Two_Sided(INode *node)
bool Is_Vis_Collision(INode *node)
bool Is_Camera_Collision(INode *node)
#define EXPORT_HIDDEN_FLAG
Definition w3dappdata.h:158
#define EXPORT_GEOMETRY_FLAG
Definition w3dappdata.h:157
#define GEOMETRY_TYPE_NULL
Definition w3dappdata.h:166
bool Is_Bone(INode *node)
#define EXPORT_CAST_SHADOW_FLAG
Definition w3dappdata.h:168
bool Is_NPatchable(INode *node)
#define EXPORT_VERTEX_ALPHA_FLAG
Definition w3dappdata.h:169
#define COLLISION_TYPE_VIS
Definition w3dappdata.h:174
#define DEFAULT_EXPORT_FLAGS
Definition w3dappdata.h:177
#define GEOMETRY_TYPE_OBBOX
Definition w3dappdata.h:163
#define GEOMETRY_TYPE_CAMERA_ALIGNED
Definition w3dappdata.h:161
bool Is_Physical_Collision(INode *node)
bool Is_Shadow(INode *node)
#define GEOMETRY_TYPE_MASK
Definition w3dappdata.h:153
#define GEOMETRY_TYPE_AABOX
Definition w3dappdata.h:164
bool Is_ZNormals(INode *node)
#define COLLISION_TYPE_PHYSICAL
Definition w3dappdata.h:172
#define EXPORT_BONE_FLAG
Definition w3dappdata.h:156
bool Is_Vehicle_Collision(INode *node)