Richard Boegli's CnC_Generals_Zero_Hour Fork WIP
This is documentation of Richard Boegil's Zero Hour Fork
 
Loading...
Searching...
No Matches
animobj.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/animobj.h $*
26 * *
27 * Author:: Greg_h *
28 * *
29 * $Modtime:: 12/10/01 11:18a $*
30 * *
31 * $Revision:: 4 $*
32 * *
33 *---------------------------------------------------------------------------------------------*
34 * Functions: *
35 * Animatable3DObjClass::Base_Update -- animation update function for the base pose *
36 * Animatable3DObjClass::Anim_Update -- Update function for a single animation *
37 * Animatable3DObjClass::Blend_Update -- update function for a blend of two animations *
38 * Animatable3DObjClass::Combo_Update -- Animation update for a combination of anims *
39 * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
40
41#if defined(_MSC_VER)
42#pragma once
43#endif
44
45#ifndef ANIMOBJ_H
46#define ANIMOBJ_H
47
48#include "always.h"
49#include "composite.h"
50#include "htree.h"
51#include "hanim.h"
52
53class SkinClass;
54class RenderInfoClass;
55
56
57
64{
65public:
66
67 Animatable3DObjClass(const char * htree_name);
70 virtual ~Animatable3DObjClass(void);
71
73 // Render Object Interface - Rendering
75 virtual void Render(RenderInfoClass & rinfo);
76 virtual void Special_Render(SpecialRenderInfoClass & rinfo);
77
79 // Render Object Interface - "Scene Graph"
81 virtual void Set_Transform(const Matrix3D &m);
82 virtual void Set_Position(const Vector3 &v);
83
85 // Render Object Interface - Hierarchical Animation
87 virtual void Set_Animation(void);
88 virtual void Set_Animation( HAnimClass * motion,
89 float frame, int anim_mode = ANIM_MODE_MANUAL);
90 virtual void Set_Animation( HAnimClass * motion0,
91 float frame0,
92 HAnimClass * motion1,
93 float frame1,
94 float percentage);
95 virtual void Set_Animation( HAnimComboClass * anim_combo);
96
97 virtual void Set_Animation_Frame_Rate_Multiplier(float multiplier); // 020607 srj -- added
98
99 virtual HAnimClass * Peek_Animation_And_Info(float& frame, int& numFrames, int& mode, float& mult); // 020710 srj -- added
100
101 virtual HAnimClass * Peek_Animation( void );
102 virtual bool Is_Animation_Complete( void ) const;
103 virtual int Get_Num_Bones(void);
104 virtual const char * Get_Bone_Name(int bone_index);
105 virtual int Get_Bone_Index(const char * bonename);
106 virtual const Matrix3D & Get_Bone_Transform(const char * bonename);
107 virtual const Matrix3D & Get_Bone_Transform(int boneindex);
108 virtual void Capture_Bone(int boneindex);
109 virtual void Release_Bone(int boneindex);
110 virtual bool Is_Bone_Captured(int boneindex) const;
111 virtual void Control_Bone(int bindex,const Matrix3D & objtm,bool world_space_translation = false);
112 virtual const HTreeClass * Get_HTree(void) const { return HTree; }
113
114 //
115 // Simple bone evaluation methods for when the caller doesn't want
116 // to update the heirarchy, but needs to know the transform of
117 // a bone at a given frame.
118 //
119 virtual bool Simple_Evaluate_Bone(int boneindex, Matrix3D *tm) const;
120 virtual bool Simple_Evaluate_Bone(int boneindex, float frame, Matrix3D *tm) const;
121
122 // (gth) TESTING DYNAMICALLY SWAPPING SKELETONS!
123 virtual void Set_HTree(HTreeClass * htree);
126 void Friend_Set_Hierarchy_Valid(bool onoff) const { IsTreeValid = onoff; }
127
128protected:
129
130 // internally used to compute the current frame if the object is in ANIM_MODE_MANUAL
131 float Compute_Current_Frame(float *newDirection=NULL) const;
132
133 // Update the sub-object transforms according to the current anim state and root transform.
134 virtual void Update_Sub_Object_Transforms(void);
135
136 // Update the transforms using the base pose only
137 void Base_Update(const Matrix3D & root);
138
139 // Update the transforms using a single frame of motion data
140 void Anim_Update( const Matrix3D & root,
141 HAnimClass * motion,
142 float frame);
143
144 // Update the transforms blending two frames of motion data
145 void Blend_Update( const Matrix3D & root,
146 HAnimClass * motion0,
147 float frame0,
148 HAnimClass * motion1,
149 float frame1,
150 float percentage);
151
152 // Update the transforms with an AnimationCombination
153 void Combo_Update( const Matrix3D & root,
154 HAnimComboClass *anim);
155
156 // flag to kep track of whether the hierarchy tree transforms are currently valid
157 bool Is_Hierarchy_Valid(void) const { return IsTreeValid; }
158 void Set_Hierarchy_Valid(bool onoff) const { IsTreeValid = onoff; }
159
160 // Progress anims for single anim (loop and once)
161 void Single_Anim_Progress( void );
162
163 // Release any anims
164 void Release( void );
165
166protected:
167
168 // Is the hierarchy tree currently valid
169 mutable bool IsTreeValid;
170
171 // Hierarchy Tree
173
174 // Animation state for the next frame. When we add more flexible motion
175 // compositing, add a new state and its associated data to the union below
176 enum {
177 NONE = 0,
182 };
183
185
186 union {
187 // CurMotionMode == SINGLE_ANIM
188 struct {
190 float Frame;
193 mutable int LastSyncTime;
195 float frameRateMultiplier; // 020607 srj -- added
197
198 // CurMotionMode == DOUBLE_ANIM
199 struct {
200
203 float Frame0;
204 float Frame1;
209
210 // CurMotionMode == MULTIPLE_ANIM
211 struct {
214
215 };
216
217 friend class SkinClass;
218};
219
220
221
222
223/***********************************************************************************************
224 * Animatable3DObjClass::Base_Update -- animation update function for the base pose *
225 * *
226 * INPUT: *
227 * *
228 * OUTPUT: *
229 * *
230 * WARNINGS: *
231 * *
232 * HISTORY: *
233 * 3/2/99 GTH : Created. *
234 *=============================================================================================*/
236{
237 /*
238 ** This method simply puts the meshes in the base pose's configuration
239 */
240 if (HTree) {
241 HTree->Base_Update(root);
242 }
244}
245
246
247/***********************************************************************************************
248 * Animatable3DObjClass::Anim_Update -- Update function for a single animation *
249 * *
250 * INPUT: *
251 * *
252 * OUTPUT: *
253 * *
254 * WARNINGS: *
255 * *
256 * HISTORY: *
257 * 3/2/99 GTH : Created. *
258 *=============================================================================================*/
259inline void Animatable3DObjClass::Anim_Update(const Matrix3D & root,HAnimClass * motion,float frame)
260{
261 /*
262 ** Apply motion to the base pose
263 */
264 if ((motion) && (HTree)) {
265 if (ModeAnim.Motion->Class_ID() == HAnimClass::CLASSID_HRAWANIM)
266 HTree->Anim_Update(Transform,(HRawAnimClass*)ModeAnim.Motion,ModeAnim.Frame);
267 else
268 HTree->Anim_Update(root,motion,frame);
269 }
271}
272
273
274/***********************************************************************************************
275 * Animatable3DObjClass::Blend_Update -- update function for a blend of two animations *
276 * *
277 * INPUT: *
278 * *
279 * OUTPUT: *
280 * *
281 * WARNINGS: *
282 * *
283 * HISTORY: *
284 * 3/2/99 GTH : Created. *
285 *=============================================================================================*/
287(
288 const Matrix3D & root,
289 HAnimClass * motion0,
290 float frame0,
291 HAnimClass * motion1,
292 float frame1,
293 float percentage
294)
295{
296 /*
297 ** Apply motion to the base pose
298 */
299 if (HTree) {
300 HTree->Blend_Update(root,motion0,frame0,motion1,frame1,percentage);
301 }
303}
304
305
306/***********************************************************************************************
307 * Animatable3DObjClass::Combo_Update -- Animation update for a combination of anims *
308 * *
309 * INPUT: *
310 * *
311 * OUTPUT: *
312 * *
313 * WARNINGS: *
314 * *
315 * HISTORY: *
316 * 3/2/99 GTH : Created. *
317 *=============================================================================================*/
319{
320 if (HTree) {
321 HTree->Combo_Update(root, anim);
322 }
324}
325
326
327
328#endif //ANIMOBJ_H
#define NULL
Definition BaseType.h:92
HAnimComboClass * AnimCombo
Definition animobj.h:212
virtual const Matrix3D & Get_Bone_Transform(const char *bonename)
Definition animobj.cpp:632
virtual bool Simple_Evaluate_Bone(int boneindex, Matrix3D *tm) const
Definition animobj.cpp:870
void Set_Hierarchy_Valid(bool onoff) const
Definition animobj.h:158
virtual HAnimClass * Peek_Animation_And_Info(float &frame, int &numFrames, int &mode, float &mult)
Definition animobj.cpp:1107
Animatable3DObjClass(const char *htree_name)
Definition animobj.cpp:84
virtual void Render(RenderInfoClass &rinfo)
Definition animobj.cpp:288
virtual void Update_Sub_Object_Transforms(void)
Definition animobj.cpp:780
virtual bool Is_Bone_Captured(int boneindex) const
Definition animobj.cpp:730
float Compute_Current_Frame(float *newDirection=NULL) const
Definition animobj.cpp:949
struct Animatable3DObjClass::@274255212152070234202005354334045134277330066032::@107271141224054257360210075076210275034114224025 ModeInterp
virtual void Control_Bone(int bindex, const Matrix3D &objtm, bool world_space_translation=false)
Definition animobj.cpp:752
Animatable3DObjClass & operator=(const Animatable3DObjClass &)
Definition animobj.cpp:198
virtual const HTreeClass * Get_HTree(void) const
Definition animobj.h:112
virtual int Get_Bone_Index(const char *bonename)
Definition animobj.cpp:429
bool Is_Hierarchy_Valid(void) const
Definition animobj.h:157
virtual void Special_Render(SpecialRenderInfoClass &rinfo)
Definition animobj.cpp:319
virtual void Set_HTree(HTreeClass *htree)
Definition animobj.cpp:1131
HAnimClass * Motion1
Definition animobj.h:202
struct Animatable3DObjClass::@274255212152070234202005354334045134277330066032::@265165303263313322022336070002244172025153143316 ModeCombo
void Friend_Set_Hierarchy_Valid(bool onoff) const
Definition animobj.h:126
virtual HAnimClass * Peek_Animation(void)
Definition animobj.cpp:610
struct Animatable3DObjClass::@274255212152070234202005354334045134277330066032::@111374312050245341017050215151003212205312230222 ModeAnim
virtual void Release_Bone(int boneindex)
Definition animobj.cpp:710
void Base_Update(const Matrix3D &root)
Definition animobj.h:235
float frameRateMultiplier
Definition animobj.h:195
virtual void Set_Animation_Frame_Rate_Multiplier(float multiplier)
Definition animobj.cpp:1123
virtual void Set_Animation(void)
Definition animobj.cpp:452
virtual bool Is_Animation_Complete(void) const
Definition animobj.cpp:1089
HAnimClass * Motion
Definition animobj.h:189
void Blend_Update(const Matrix3D &root, HAnimClass *motion0, float frame0, HAnimClass *motion1, float frame1, float percentage)
Definition animobj.h:287
HAnimClass * Motion0
Definition animobj.h:201
virtual int Get_Num_Bones(void)
Definition animobj.cpp:385
virtual const char * Get_Bone_Name(int bone_index)
Definition animobj.cpp:407
void Single_Anim_Progress(void)
Definition animobj.cpp:1048
friend class SkinClass
Definition animobj.h:217
void Combo_Update(const Matrix3D &root, HAnimComboClass *anim)
Definition animobj.h:318
void Anim_Update(const Matrix3D &root, HAnimClass *motion, float frame)
Definition animobj.h:259
virtual void Set_Position(const Vector3 &v)
Definition animobj.cpp:366
virtual void Capture_Bone(int boneindex)
Definition animobj.cpp:690
virtual void Set_Transform(const Matrix3D &m)
Definition animobj.cpp:347
HTreeClass * HTree
Definition animobj.h:172
virtual ~Animatable3DObjClass(void)
Definition animobj.cpp:176
@ CLASSID_HRAWANIM
Definition hanim.h:81
Matrix3D Transform
Definition rendobj.h:549