-
Notifications
You must be signed in to change notification settings - Fork 0
/
IFPLoader.h
234 lines (190 loc) · 4.26 KB
/
IFPLoader.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
#pragma once
#ifndef IFPLOADER_H
#define IFPLOADER_H
#include "wrapper.h"
#include "FileLoader.h"
#include <vector>
#define ROUNDSIZE(x) if((x) & 3) (x) += 4 - ((x)&3) // credits to github.com/aap for the great macro
#define IFP_TOTAL_SEQUENCES 32 // 32 because there are 32 bones in a ped model
struct IFP_BASE
{
char FourCC[4];
uint32_t Size;
};
struct IFP_INFO
{
IFP_BASE Base;
int32_t Entries;
char Name[24];
};
struct IFP_ANPK
{
IFP_BASE Base;
IFP_INFO Info;
};
struct IFP_NAME
{
IFP_BASE Base;
};
struct IFP_DGAN
{
IFP_BASE Base;
IFP_INFO Info;
};
struct IFP_CPAN
{
IFP_BASE Base;
};
struct IFP_ANIM
{
IFP_BASE Base;
char Name[28];
int32_t Frames;
int32_t Unk;
int32_t Next;
int32_t Previous;
// According to https://www.gtamodding.com/wiki/IFP, Unk2 should not exist, but for some reason, it's there
// I don't know why. Let's just go with the flow and ignore it. The value "seems" to be always zero.
int32_t Unk2;
};
struct IFP_KFRM
{
IFP_BASE Base;
};
struct Quaternion
{
float X, Y, Z, W;
};
struct CVector
{
float X, Y, Z;
};
struct IFP_KR00
{
Quaternion Rotation;
float Time;
};
struct IFP_KRT0
{
Quaternion Rotation;
CVector Translation;
float Time;
};
struct IFP_KRTS
{
Quaternion Rotation;
CVector Translation;
CVector Scale;
float Time;
};
struct CompressedQuaternion
{
int16_t X, Y, Z, W;
};
struct CompressedCVector
{
int16_t X, Y, Z;
};
struct IFP_Compressed_KR00
{
CompressedQuaternion Rotation;
int16_t Time;
};
struct IFP_Compressed_KRT0 : IFP_Compressed_KR00
{
CompressedCVector Translation;
};
enum IFP_FrameType
{
UNKNOWN_FRAME = -1,
KR00 = 0,
KRT0 = 1,
KRTS = 2
};
struct IFPHeaderV2
{
int32_t OffsetEOF;
char InternalFileName[24];
int32_t TotalAnimations;
};
struct IFP : FileLoader
{
bool isVersion1;
IFPHeaderV2 HeaderV2;
std::vector <CAnimBlendHierarchy> AnimationHierarchies;
std::vector <CAnimBlendSequence> AnimationSequences;
unsigned char * KeyFramesArray;
};
struct Animation
{
// 24 + 4 + 4 + 4 = 36 bytes
char Name[24];
int32_t TotalObjects;
int32_t FrameSize;
int32_t isCompressed; // The value is always 1
};
struct Object
{
// 24 + 4 + 4 + 4 = 36 bytes
char Name[24];
int32_t FrameType;
int32_t TotalFrames;
int32_t BoneID;
};
struct IFP2_ChildFrame
{
int16_t x, y, z, w, time;
};
enum BoneType
{
NORMAL = 0, // Normal or Root, both are same
PELVIS = 1,
SPINE = 2,
SPINE1 = 3,
NECK = 4,
HEAD = 5,
JAW = 8,
L_BROW = 6,
R_BROW = 7,
L_CLAVICLE = 31,
L_UPPER_ARM = 32,
L_FORE_ARM = 33,
L_HAND = 34,
L_FINGER = 35,
L_FINGER_01 = 36,
R_CLAVICLE = 21,
R_UPPER_ARM = 22,
R_FORE_ARM = 23,
R_HAND = 24,
R_FINGER = 25,
R_FINGER_01 = 26,
L_BREAST = 302,
R_BREAST = 301,
BELLY = 201,
L_THIGH = 41,
L_CALF = 42,
L_FOOT = 43,
L_TOE_0 = 44,
R_THIGH = 51,
R_CALF = 52,
R_FOOT = 53,
R_TOE_0 = 54
};
typedef void *(__cdecl* hCMemoryMgr_Malloc)
(
size_t TotalBytesToAllocate
);
void LoadIFPFile(const char * FilePath);
void ReadIFPVersion1(IFP * IFPElement);
void ReadIFPVersion2(IFP * IFPElement, bool anp3);
void insertAnimDummySequence(bool anp3, CAnimBlendHierarchy * pAnimHierarchy, size_t SequenceIndex);
int32_t getBoneIDFromName(std::string const& BoneName);
std::string getCorrectBoneNameFromName(std::string const& BoneName);
std::string getCorrectBoneNameFromID(int32_t & BoneID);
size_t getCorrectBoneIndexFromID(int32_t & BoneID);
void CAnimBlendHierarchy_Constructor(CAnimBlendHierarchy * pAnimHierarchy);
void CAnimBlendSequence_Constructor(CAnimBlendSequence * pSequence);
// -------------------------------------- For Hierarchy ----------------------------------------------------
void Call_CAnimBlendHierarchy_RemoveQuaternionFlips(CAnimBlendHierarchy * pAnimHierarchy);
void Call_CAnimBlendHierarchy_CalcTotalTime(CAnimBlendHierarchy * pAnimHierarchy);
#endif