mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2026-06-03 07:12:33 +00:00
feat: IW3 xanim dumping/loading in CoD4 Mod Tools raw binary format (#768)
* feat: IW3 dump xanim to cod4 mod tools compatible binary * chore: add XAnimPartType enum to game headers * chore: use XAnimPartType in XAnimDumperIW3 * chore: extract xanim filename into XAnimCommon * chore: prefer emplace_back over push_back * chore: small code style improvements * chore: use proper unsigned types for XAnimParts structs * chore: use better understandable calculations for bitfields * chore: use game names for parts * chore: rename method to WriteNoteTracks * chore: adds comments and improve clearity of what the game does * chore: extract stream writing methods into StreamUtils * chore: use vec3 for XAnimPartTransFrames mins and size * chore: properly differ between XQuat and XQuat2 structs * chore: use constants for xanim flags * chore: use optional for delta track quats and trans * chore: split delta track writing methods into quat and trans * chore: add assertion for bDelta * chore: simplify quat frame encoding indexing * chore: simplify float to int bit casting * chore: do not throw exception on failing to reconstruct bone tracks * feat: add xanim loader for iw3 * fix: make sure to sort quats and trans like the game * chore: prevent empty dumped files on bad xanim data * chore: ensure no exception on zero frames in xanim notifies * test: add system test for iw3 xanims --------- Co-authored-by: Jan Laupetin <jan@laupetin.net>
This commit is contained in:
@@ -181,7 +181,7 @@ namespace IW3
|
||||
|
||||
union XAnimIndices
|
||||
{
|
||||
char* _1;
|
||||
unsigned char* _1;
|
||||
uint16_t* _2;
|
||||
void* data;
|
||||
};
|
||||
@@ -197,7 +197,7 @@ namespace IW3
|
||||
|
||||
union XAnimDynamicIndicesTrans
|
||||
{
|
||||
char _1[1];
|
||||
unsigned char _1[1];
|
||||
uint16_t _2[1];
|
||||
};
|
||||
|
||||
@@ -209,8 +209,8 @@ namespace IW3
|
||||
|
||||
struct XAnimPartTransFrames
|
||||
{
|
||||
float mins[3];
|
||||
float size[3];
|
||||
vec3_t mins;
|
||||
vec3_t size;
|
||||
XAnimDynamicFrames frames;
|
||||
XAnimDynamicIndicesTrans indices;
|
||||
};
|
||||
@@ -224,31 +224,36 @@ namespace IW3
|
||||
struct XAnimPartTrans
|
||||
{
|
||||
uint16_t size;
|
||||
char smallTrans;
|
||||
unsigned char smallTrans;
|
||||
XAnimPartTransData u;
|
||||
};
|
||||
|
||||
struct type_align(4) XQuat
|
||||
{
|
||||
int16_t value[4];
|
||||
};
|
||||
|
||||
struct type_align(4) XQuat2
|
||||
{
|
||||
int16_t value[2];
|
||||
};
|
||||
|
||||
union XAnimDynamicIndicesQuat
|
||||
{
|
||||
char _1[1];
|
||||
unsigned char _1[1];
|
||||
uint16_t _2[1];
|
||||
};
|
||||
|
||||
struct XAnimDeltaPartQuatDataFrames
|
||||
{
|
||||
XQuat* frames;
|
||||
XQuat2* frames;
|
||||
XAnimDynamicIndicesQuat indices;
|
||||
};
|
||||
|
||||
union XAnimDeltaPartQuatData
|
||||
{
|
||||
XAnimDeltaPartQuatDataFrames frames;
|
||||
XQuat frame0;
|
||||
XQuat2 frame0;
|
||||
};
|
||||
|
||||
struct XAnimDeltaPartQuat
|
||||
@@ -263,6 +268,22 @@ namespace IW3
|
||||
XAnimDeltaPartQuat* quat;
|
||||
};
|
||||
|
||||
enum XAnimPartType
|
||||
{
|
||||
PART_TYPE_NO_QUAT = 0x0,
|
||||
PART_TYPE_HALF_QUAT = 0x1,
|
||||
PART_TYPE_FULL_QUAT = 0x2,
|
||||
PART_TYPE_HALF_QUAT_NO_SIZE = 0x3,
|
||||
PART_TYPE_FULL_QUAT_NO_SIZE = 0x4,
|
||||
PART_TYPE_SMALL_TRANS = 0x5,
|
||||
PART_TYPE_TRANS = 0x6,
|
||||
PART_TYPE_TRANS_NO_SIZE = 0x7,
|
||||
PART_TYPE_NO_TRANS = 0x8,
|
||||
PART_TYPE_ALL = 0x9,
|
||||
|
||||
PART_TYPE_COUNT
|
||||
};
|
||||
|
||||
struct XAnimParts
|
||||
{
|
||||
const char* name;
|
||||
@@ -274,20 +295,20 @@ namespace IW3
|
||||
uint16_t numframes;
|
||||
bool bLoop;
|
||||
bool bDelta;
|
||||
unsigned char boneCount[10];
|
||||
char notifyCount;
|
||||
char assetType;
|
||||
unsigned char boneCount[PART_TYPE_COUNT];
|
||||
unsigned char notifyCount;
|
||||
unsigned char assetType;
|
||||
bool isDefault;
|
||||
unsigned int randomDataShortCount;
|
||||
unsigned int indexCount;
|
||||
float framerate;
|
||||
float frequency;
|
||||
ScriptString* names;
|
||||
char* dataByte;
|
||||
unsigned char* dataByte;
|
||||
int16_t* dataShort;
|
||||
int* dataInt;
|
||||
int16_t* randomDataShort;
|
||||
char* randomDataByte;
|
||||
unsigned char* randomDataByte;
|
||||
int* randomDataInt;
|
||||
XAnimIndices indices;
|
||||
XAnimNotifyInfo* notify;
|
||||
|
||||
Reference in New Issue
Block a user