Richard Boegli's CnC_Generals_Zero_Hour Fork WIP
This is documentation of Richard Boegil's Zero Hour Fork
 
Loading...
Searching...
No Matches
hmorphanim.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/hmorphanim.h $*
26 * *
27 * Original Author:: Greg Hjelstrom *
28 * *
29 * $Author:: Jani_p $*
30 * *
31 * $Modtime:: 6/27/01 7:41p $*
32 * *
33 * $Revision:: 4 $*
34 * *
35 *---------------------------------------------------------------------------------------------*
36 * Functions: *
37 * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
38
39#if defined(_MSC_VER)
40#pragma once
41#endif
42
43#ifndef HMORPHANIM_H
44#define HMORPHANIM_H
45
46#include "always.h"
47#include "hanim.h"
48#include "simplevec.h"
49
51class ChunkLoadClass;
52class ChunkSaveClass;
53class TextFileClass;
54
55/**********************************************************************************
56
57 HMorphAnimClass
58
59 This is an animation format designed for facial animation. It basically morphs the
60 htree between a set of poses. These animations are created by exporting an
61 HRawAnimClass which contains the poses, using Magpie to create a text file
62 describing which pose to use on each frame, and finally using W3dView to combine
63 the data into an HMorphAnimClass.
64
65 There can be multiple channels for the morphing. For example, some of the
66 bones can be controlled by the "phoneme" poses (e.g. mouth) while other bones are
67 controlled by the "expression" poses (e.g. eyebrows)
68
69**********************************************************************************/
70
72{
73
74public:
75
76 enum
77 {
80 };
81
82 HMorphAnimClass(void);
83 ~HMorphAnimClass(void);
84
85 void Free_Morph(void);
86 int Create_New_Morph(const int channels, HAnimClass *anim[]);
87 int Load_W3D(ChunkLoadClass & cload);
88 int Save_W3D(ChunkSaveClass & csave);
89
90 const char * Get_Name(void) const { return Name; }
91 const char * Get_HName(void) const { return HierarchyName; }
92
93 int Get_Num_Frames(void) { return FrameCount; }
94 float Get_Frame_Rate() { return FrameRate; }
95 float Get_Total_Time() { return (float)FrameCount / FrameRate; }
96
97// Vector3 Get_Translation(int pividx,float frame);
98// Quaternion Get_Orientation(int pividx,float frame);
99 void Get_Translation(Vector3& translation, int pividx,float frame) const;
100 void Get_Orientation(Quaternion& orientation, int pividx,float frame) const;
101 void Get_Transform(Matrix3D& transform, int pividx,float frame) const;
102 bool Get_Visibility(int pividx,float frame) { return true; }
103
104 void Insert_Morph_Key (const int channel, uint32 morph_frame, uint32 pose_frame);
105 void Release_Keys (void);
106
107 bool Is_Node_Motion_Present(int pividx) { return true; }
108 int Get_Num_Pivots(void) const { return NumNodes; }
109
110 void Set_Name(const char * name);
111 void Set_HName(const char * hname);
112
113 bool Import(const char *hierarchy_name, TextFileClass &text_desc);
114
115protected:
116
117 void Free(void);
118 void read_channel(ChunkLoadClass & cload,int channel);
119 void write_channel(ChunkSaveClass & csave,int channel);
120 void Resolve_Pivot_Channels(void);
121
125
126 int FrameCount; // number of frames in the animation
127 float FrameRate; // framerate for playback
128 int ChannelCount; // number of independent morphing channels
130
131 HAnimClass ** PoseData; // pointer to pose for each morph channel
132 TimeCodedMorphKeysClass * MorphKeyData; // morph keys for each channel
133 uint32 * PivotChannel; // controlling channel for each pivot/bone
134
135};
136
137
138/*********************************************************************************************
139**
140** TimeCodedMorphKeysClass
141** This class basically stores a vector of morph keys. An HMorphAnimClass contains
142** one of these for each independent morphing channel. For example, the facial animation
143** stuff generates HMorphAnims which contain 2 channels, one which specifies what the
144** "phoneme" bones are doing and one which specifies what the "expression" bones are doing.
145**
146*********************************************************************************************/
147
149{
150public:
151
154
155 bool Load_W3D(ChunkLoadClass & cload);
156 bool Save_W3D(ChunkSaveClass & csave);
157 void Get_Morph_Info(float morph_frame,int * pose_frame0,int * pose_frame1,float * fraction);
158
159 void Add_Key (uint32 morph_frame, uint32 pose_frame);
160
161private:
162
163 struct MorphKeyStruct
164 {
165 MorphKeyStruct (void)
166 : MorphFrame (0),
167 PoseFrame (0) {}
168
169 MorphKeyStruct (uint32 _morph, uint32 _pose)
170 : MorphFrame (_morph),
171 PoseFrame (_pose) {}
172
173 uint32 MorphFrame; // morph animation frame index
174 uint32 PoseFrame; // which pose frame to use at this time
175 };
176
177 SimpleDynVecClass<MorphKeyStruct> Keys; // morph key data
178 uint32 CachedIdx; // last accessed index
179
180 void Free(void);
181
182 uint32 get_index(float time);
183 uint32 binary_search_index(float time);
184
185 friend class HMorphAnimClass;
186};
187
188
189
190#endif
191
192
#define W3D_NAME_LEN
Definition w3d_file.h:319
unsigned long uint32
Definition bittype.h:46
HAnimClass(void)
Definition hanim.h:85
const char * Get_HName(void) const
Definition hmorphanim.h:91
void Free(void)
void Insert_Morph_Key(const int channel, uint32 morph_frame, uint32 pose_frame)
void Set_HName(const char *hname)
int Save_W3D(ChunkSaveClass &csave)
void Resolve_Pivot_Channels(void)
char AnimName[W3D_NAME_LEN]
Definition hmorphanim.h:123
void Free_Morph(void)
TimeCodedMorphKeysClass * MorphKeyData
Definition hmorphanim.h:132
char HierarchyName[W3D_NAME_LEN]
Definition hmorphanim.h:124
float Get_Frame_Rate()
Definition hmorphanim.h:94
bool Get_Visibility(int pividx, float frame)
Definition hmorphanim.h:102
bool Is_Node_Motion_Present(int pividx)
Definition hmorphanim.h:107
bool Import(const char *hierarchy_name, TextFileClass &text_desc)
void read_channel(ChunkLoadClass &cload, int channel)
int Load_W3D(ChunkLoadClass &cload)
char Name[2 *W3D_NAME_LEN]
Definition hmorphanim.h:122
int Get_Num_Pivots(void) const
Definition hmorphanim.h:108
float Get_Total_Time()
Definition hmorphanim.h:95
void Get_Transform(Matrix3D &transform, int pividx, float frame) const
const char * Get_Name(void) const
Definition hmorphanim.h:90
void Get_Translation(Vector3 &translation, int pividx, float frame) const
void write_channel(ChunkSaveClass &csave, int channel)
void Set_Name(const char *name)
uint32 * PivotChannel
Definition hmorphanim.h:133
int Get_Num_Frames(void)
Definition hmorphanim.h:93
HAnimClass ** PoseData
Definition hmorphanim.h:131
void Release_Keys(void)
void Get_Orientation(Quaternion &orientation, int pividx, float frame) const
int Create_New_Morph(const int channels, HAnimClass *anim[])
void Get_Morph_Info(float morph_frame, int *pose_frame0, int *pose_frame1, float *fraction)
void Add_Key(uint32 morph_frame, uint32 pose_frame)
friend class HMorphAnimClass
Definition hmorphanim.h:185
bool Load_W3D(ChunkLoadClass &cload)
bool Save_W3D(ChunkSaveClass &csave)