Richard Boegli's CnC_Generals_Zero_Hour Fork WIP
This is documentation of Richard Boegil's Zero Hour Fork
 
Loading...
Searching...
No Matches
htree.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/htree.h 6 10/01/01 5:55p Patrick $ */
20/***********************************************************************************************
21 *** Confidential - Westwood Studios ***
22 ***********************************************************************************************
23 * *
24 * Project Name : Commando / G 3D Library *
25 * *
26 * $Archive:: /Commando/Code/ww3d2/htree.h $*
27 * *
28 * Author:: Greg_h *
29 * *
30 * $Modtime:: 9/28/01 3:05p $*
31 * *
32 * $Revision:: 6 $*
33 * *
34 *---------------------------------------------------------------------------------------------*
35 * Functions: *
36 * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
37
38#if defined(_MSC_VER)
39#pragma once
40#endif
41
42#ifndef HTREE_H
43#define HTREE_H
44
45#include "always.h"
46#include "pivot.h"
47#include "quat.h"
48#include "matrix3d.h"
49#include "vector3.h"
50#include "w3d_file.h"
51#include "wwdebug.h"
52
53class HAnimClass;
54class HAnimComboClass;
55class MeshClass;
56class ChunkLoadClass;
57class ChunkSaveClass;
58class HRawAnimClass;
59
60/*
61
62 HTreeClass
63
64 A hierarchy of coordinate systems in an initial
65 configuration. All motion data is applied to one
66 of these objects. Motion is stored as deltas from
67 the hierarchy tree's initial configuration.
68
69 Normally, the user will probably not deal with
70 HTreeClasses; they are used internally
71 by the HierarchyModelClass.
72
73*/
74class HTreeClass : public W3DMPO
75{
77public:
78
79 enum
80 {
83 };
84
85 HTreeClass(void);
86 HTreeClass(const HTreeClass & src);
87 ~HTreeClass(void);
88
89 int Load_W3D(ChunkLoadClass & cload);
90 void Init_Default(void);
91
92 WWINLINE const char * Get_Name(void) const { return Name; }
93 WWINLINE int Num_Pivots(void) const { return NumPivots; }
94 int Get_Bone_Index(const char * name) const;
95 const char * Get_Bone_Name(int boneid) const;
96 int Get_Parent_Index(int bone_indx) const;
97
98 void Base_Update(const Matrix3D & root);
99
100 void Anim_Update( const Matrix3D & root,
101 HAnimClass * motion,
102 float frame);
103 void Anim_Update(const Matrix3D & root,HRawAnimClass * motion,float frame);
104
105 void Blend_Update( const Matrix3D & root,
106 HAnimClass * motion0,
107 float frame0,
108 HAnimClass * motion1,
109 float frame1,
110 float percentage);
111
112 void Combo_Update( const Matrix3D & root,
113 HAnimComboClass * anim);
114
115 WWINLINE const Matrix3D & Get_Transform(int pivot) const;
116 WWINLINE bool Get_Visibility(int pivot) const;
117
118 WWINLINE const Matrix3D & Get_Root_Transform(void) const;
119
120 // User control over a bone. While a bone is captured, you can over-ride the
121 // animation transform used by the bone.
122 void Capture_Bone(int boneindex);
123 void Release_Bone(int boneindex);
124 bool Is_Bone_Captured(int boneindex) const;
125 void Control_Bone(int boneindex,const Matrix3D & relative_tm,bool world_space_translation = false);
126 void Get_Bone_Control(int boneindex, Matrix3D & relative_tm) const;
127
128
129
130 //
131 // Simple pivot evaluation methods for when the caller doesn't want
132 // to update the whole animation, but needs to know the transform of
133 // a pivot at a given frame.
134 //
135 bool Simple_Evaluate_Pivot (HAnimClass *motion, int pivot_index, float frame, const Matrix3D &obj_tm, Matrix3D *end_tm) const;
136 bool Simple_Evaluate_Pivot (int pivot_index, const Matrix3D &obj_tm, Matrix3D *end_tm) const;
137
138 // Scale this HTree by a constant factor:
139 void Scale(float factor);
140
141 // Morph the bones on the HTree based on the scale passed in
142 static HTreeClass * Alter_Avatar_HTree( const HTreeClass *tree, Vector3 &scale );
143
144 // Morph the bones on the HTree using weights from a number of other HTrees
145 static HTreeClass * Create_Morphed( int num_morph_sources,
146 const float morph_weights[],
147 const HTreeClass *tree_array[] );
148
149 // Create an HTree by Interpolating between others
150 static HTreeClass * Create_Interpolated( const HTreeClass * tree_a0_b0,
151 const HTreeClass * tree_a0_b1,
152 const HTreeClass * tree_a1_b0,
153 const HTreeClass * tree_a1_b1,
154 float lerp_a, float lerp_b );
155
156 // Create an HTree by Interpolating between others
157 static HTreeClass * Create_Interpolated( const HTreeClass * tree_base,
158 const HTreeClass * tree_a,
159 const HTreeClass * tree_b,
160 float a_scale, float b_scale );
161
162private:
163
164 char Name[W3D_NAME_LEN];
165 int NumPivots;
166 PivotClass * Pivot;
167 float ScaleFactor;
168
169 void Free(void);
170 bool read_pivots(ChunkLoadClass & cload,bool pre30);
171
172 friend class MeshClass;
173
174
175
176};
177
179{
180 return Pivot[0].Transform;
181}
182
184{
185 WWASSERT(pivot >= 0);
186 WWASSERT(pivot < NumPivots);
187 return Pivot[pivot].IsVisible;
188}
189
190/***********************************************************************************************
191 * HTreeClass::Get_Transform -- returns the transformation for the desired pivot *
192 * *
193 * INPUT: *
194 * *
195 * OUTPUT: *
196 * *
197 * WARNINGS: *
198 * *
199 * HISTORY: *
200 * 08/11/1997 GH : Created. *
201 *=============================================================================================*/
203{
204 assert(pivot >= 0);
205 assert(pivot < NumPivots);
206
207 return Pivot[pivot].Transform;
208}
209
210
211
212#endif
Color scale(const Color &a, const Color &b)
Definition GameMtl.cpp:722
#define WWASSERT
#define W3D_NAME_LEN
Definition w3d_file.h:319
#define W3DMPO_GLUE(ARGCLASS)
Definition always.h:120
#define WWINLINE
Definition always.h:172
void Init_Default(void)
Definition htree.cpp:85
friend class MeshClass
Definition htree.h:172
int Get_Parent_Index(int bone_indx) const
Definition htree.cpp:968
int Load_W3D(ChunkLoadClass &cload)
Definition htree.cpp:176
void Blend_Update(const Matrix3D &root, HAnimClass *motion0, float frame0, HAnimClass *motion1, float frame1, float percentage)
Definition htree.cpp:701
void Combo_Update(const Matrix3D &root, HAnimComboClass *anim)
Definition htree.cpp:773
void Scale(float factor)
Definition htree.cpp:982
void Base_Update(const Matrix3D &root)
Definition htree.cpp:531
WWINLINE int Num_Pivots(void) const
Definition htree.h:93
HTreeClass(void)
Definition htree.cpp:78
WWINLINE const Matrix3D & Get_Root_Transform(void) const
Definition htree.h:178
WWINLINE const char * Get_Name(void) const
Definition htree.h:92
@ LOAD_ERROR
Definition htree.h:82
void Capture_Bone(int boneindex)
Definition htree.cpp:1001
bool Simple_Evaluate_Pivot(HAnimClass *motion, int pivot_index, float frame, const Matrix3D &obj_tm, Matrix3D *end_tm) const
Definition htree.cpp:384
void Control_Bone(int boneindex, const Matrix3D &relative_tm, bool world_space_translation=false)
Definition htree.cpp:1038
~HTreeClass(void)
Definition htree.cpp:118
bool Is_Bone_Captured(int boneindex) const
Definition htree.cpp:1031
static HTreeClass * Create_Morphed(int num_morph_sources, const float morph_weights[], const HTreeClass *tree_array[])
Definition htree.cpp:1129
static HTreeClass * Alter_Avatar_HTree(const HTreeClass *tree, Vector3 &scale)
Definition htree.cpp:1072
int Get_Bone_Index(const char *name) const
Definition htree.cpp:922
WWINLINE const Matrix3D & Get_Transform(int pivot) const
Definition htree.h:202
const char * Get_Bone_Name(int boneid) const
Definition htree.cpp:945
static HTreeClass * Create_Interpolated(const HTreeClass *tree_a0_b0, const HTreeClass *tree_a0_b1, const HTreeClass *tree_a1_b0, const HTreeClass *tree_a1_b1, float lerp_a, float lerp_b)
Definition htree.cpp:1163
void Anim_Update(const Matrix3D &root, HAnimClass *motion, float frame)
Definition htree.cpp:562
void Release_Bone(int boneindex)
Definition htree.cpp:1016
void Get_Bone_Control(int boneindex, Matrix3D &relative_tm) const
Definition htree.cpp:1055
WWINLINE bool Get_Visibility(int pivot) const
Definition htree.h:183