2
0
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:
mo
2026-06-01 21:52:49 +01:00
committed by GitHub
parent f7be1ac9c1
commit 0c22dddd0e
19 changed files with 2044 additions and 55 deletions
+28 -12
View File
@@ -267,7 +267,7 @@ namespace IW4
union XAnimIndices
{
char* _1;
unsigned char* _1;
uint16_t* _2;
void* data;
};
@@ -289,14 +289,14 @@ namespace IW4
union XAnimDynamicIndicesTrans
{
char _1[1];
unsigned char _1[1];
uint16_t _2[1];
};
struct type_align32(4) XAnimPartTransFrames
{
float mins[3];
float size[3];
vec3_t mins;
vec3_t size;
XAnimDynamicFrames frames;
XAnimDynamicIndicesTrans indices;
};
@@ -310,13 +310,13 @@ namespace IW4
struct XAnimPartTrans
{
uint16_t size;
char smallTrans;
unsigned char smallTrans;
XAnimPartTransData u;
};
union XAnimDynamicIndicesQuat2
{
char _1[1];
unsigned char _1[1];
uint16_t _2[1];
};
@@ -345,7 +345,7 @@ namespace IW4
union XAnimDynamicIndicesQuat
{
char _1[1];
unsigned char _1[1];
uint16_t _2[1];
};
@@ -379,6 +379,22 @@ namespace IW4
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;
@@ -389,20 +405,20 @@ namespace IW4
uint16_t randomDataIntCount;
uint16_t numframes;
char flags;
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;