Richard Boegli's CnC_Generals_Zero_Hour Fork WIP
This is documentation of Richard Boegil's Zero Hour Fork
 
Loading...
Searching...
No Matches
hiersave.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/Tools/max2w3d/hiersave.h 29 10/26/00 5:59p Greg_h $ */
20/***********************************************************************************************
21 *** Confidential - Westwood Studios ***
22 ***********************************************************************************************
23 * *
24 * Project Name : Commando / G 3D Engine *
25 * *
26 * $Archive:: /Commando/Code/Tools/max2w3d/hiersave.h $*
27 * *
28 * $Author:: Greg_h $*
29 * *
30 * $Modtime:: 10/26/00 5:09p $*
31 * *
32 * $Revision:: 29 $*
33 * *
34 *---------------------------------------------------------------------------------------------*
35 * Functions: *
36 * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
37
38#ifndef HIERSAVE_H
39#define HIERSAVE_H
40
41#include "always.h"
42
43#include <Max.h>
44#include <stdio.h>
45
46#ifndef W3D_FILE_H
47#include "w3d_file.h"
48#endif
49
50#ifndef PROGRESS_H
51#include "progress.h"
52#endif
53
54#ifndef CHUNKIO_H
55#include "chunkio.h"
56#endif
57
58#ifndef NODELIST_H
59#include "nodelist.h"
60#endif
61
62#ifndef VECTOR_H
63#include "vector.h"
64#endif
65
66
67
69{
70 INode * MaxNode;
73
74 bool operator == (const HierarchyNodeStruct & that) { return false; }
75 bool operator != (const HierarchyNodeStruct & that) { return !(*this == that); }
76};
77
78
80{
81
82public:
83
84 enum {
88 };
89
91
93 INode * root,
94 TimeValue time,
95 Progress_Meter_Class & treemeter,
96 char * hname,
97 int fixup_type = MATRIX_FIXUP_NONE,
98 HierarchySaveClass * fixuptree = NULL);
99
101 INodeListClass * rootlist,
102 TimeValue time,
103 Progress_Meter_Class & treemeter,
104 char * hname,
105 int fixup_type = MATRIX_FIXUP_NONE,
106 HierarchySaveClass * fixuptree = NULL,
107 const Matrix3 & origin_offset = Matrix3(1));
108
110
111 bool Save(ChunkSaveClass & csave);
112 bool Load(ChunkLoadClass & cload);
113 int Num_Nodes(void) const { return CurNode; }
114 const char * Get_Name(void) const;
115 const char * Get_Node_Name(int node) const;
116
117 // get ahold of the max inode
118 INode * Get_Node(int node) const;
119
120 // Returns the node's transform from object to world space
121 Matrix3 Get_Node_Transform(int node) const;
122
123 // Returns the node's transform relative to its parent
124 Matrix3 Get_Node_Relative_Transform(int node) const { return get_relative_transform(node); }
125
126 // Get the fixup matrix for the given pivot (always applied to the *relative* transform)
127 Matrix3 Get_Fixup_Transform(int node) const;
128
129 // Finds a node by name
130 int Find_Named_Node(const char * name) const;
131
132 // Get the coordinate system to use when exporting the given INode. Note that this
133 // function takes into account the multiple skeletons present when exporting LOD models.
134 void Get_Export_Coordinate_System(INode * node,int * set_bone_index,INode ** set_bone_node,Matrix3 * set_transform);
135
136 // Turning on terrian mode will cause all HTrees to force all normal meshes to be
137 // attached to the RootTransform regardless of the status of their 'Export_Transform' flag
138 static void Enable_Terrain_Optimization(bool onoff) { TerrainModeEnabled = onoff; }
139
140private:
141
142 enum { MAX_PIVOTS = 4096, DEFAULT_NODE_ARRAY_SIZE = 512, NODE_ARRAY_GROWTH_SIZE = 32 };
143
144 TimeValue CurTime;
145 W3dHierarchyStruct HierarchyHeader;
146 DynamicVectorClass<HierarchyNodeStruct> Node;
147 int CurNode;
148 int FixupType;
149 Matrix3 OriginOffsetTransform; // this transform makes a node relative to the origin
150 HierarchySaveClass * FixupTree;
151
152 static bool TerrainModeEnabled;
153
154 void add_tree(INode * node,int pidx);
155 int add_node(INode * node,int pidx);
156
157 bool save_header(ChunkSaveClass & csave);
158 bool save_pivots(ChunkSaveClass & csave);
159 bool save_fixups(ChunkSaveClass & csave);
160
161 bool load_header(ChunkLoadClass & cload);
162 bool load_pivots(ChunkLoadClass & cload);
163 bool load_fixups(ChunkLoadClass & cload);
164
165 Matrix3 get_relative_transform(int nodeidx) const;
166 Matrix3 fixup_matrix(const Matrix3 & src) const;
167 void Free(void);
168};
169
170#endif /*HIERSAVE_H*/
#define NULL
Definition BaseType.h:92
int Find_Named_Node(const char *name) const
Definition hiersave.cpp:383
Matrix3 Get_Fixup_Transform(int node) const
Definition hiersave.cpp:768
Matrix3 Get_Node_Relative_Transform(int node) const
Definition hiersave.h:124
bool Load(ChunkLoadClass &cload)
Definition hiersave.cpp:539
void Get_Export_Coordinate_System(INode *node, int *set_bone_index, INode **set_bone_node, Matrix3 *set_transform)
Definition hiersave.cpp:409
const char * Get_Name(void) const
Definition hiersave.cpp:324
Matrix3 Get_Node_Transform(int node) const
Definition hiersave.cpp:255
int Num_Nodes(void) const
Definition hiersave.h:113
const char * Get_Node_Name(int node) const
Definition hiersave.cpp:362
INode * Get_Node(int node) const
Definition hiersave.cpp:342
static void Enable_Terrain_Optimization(bool onoff)
Definition hiersave.h:138
bool Save(ChunkSaveClass &csave)
Definition hiersave.cpp:494
bool operator!=(const HierarchyNodeStruct &that)
Definition hiersave.h:75
bool operator==(const HierarchyNodeStruct &that)
Definition hiersave.h:74
W3dPivotFixupStruct Fixup
Definition hiersave.h:72
W3dPivotStruct Pivot
Definition hiersave.h:71