2
0
mirror of https://github.com/Laupetin/OpenAssetTools.git synced 2026-06-06 16:52:35 +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
+36
View File
@@ -0,0 +1,36 @@
#include "StreamUtils.h"
#include <cstring>
#include <sstream>
#include <string>
namespace stream
{
size_t Read(std::istream& stream, void* out, const size_t outSize)
{
stream.read(static_cast<char*>(out), static_cast<std::streamsize>(outSize));
return static_cast<size_t>(stream.gcount());
}
std::string ReadCString(std::istream& stream)
{
std::string result;
std::getline(stream, result, '\0');
return result;
}
void Write(std::ostream& stream, const void* in, const size_t inSize)
{
stream.write(static_cast<const char*>(in), static_cast<std::streamsize>(inSize));
}
void WriteCString(std::ostream& stream, const std::string& value)
{
stream.write(value.c_str(), static_cast<std::streamsize>(value.size() + 1));
}
void WriteCString(std::ostream& stream, const char* value)
{
stream.write(value, static_cast<std::streamsize>(std::strlen(value) + 1));
}
} // namespace stream
+34
View File
@@ -0,0 +1,34 @@
#pragma once
#include <iostream>
#include <string>
namespace stream
{
size_t Read(std::istream& stream, void* out, size_t outSize);
template<typename T> T ReadValue(std::istream& stream)
{
T value{};
stream.read(reinterpret_cast<char*>(&value), static_cast<std::streamsize>(sizeof(value)));
return value;
}
template<typename T> void ReadValue(std::istream& stream, T& value)
{
stream.read(reinterpret_cast<char*>(&value), static_cast<std::streamsize>(sizeof(value)));
}
std::string ReadCString(std::istream& stream);
void Write(std::ostream& stream, const void* in, size_t inSize);
template<typename T> void WriteValue(std::ostream& stream, const T& value)
{
stream.write(reinterpret_cast<const char*>(&value), static_cast<std::streamsize>(sizeof(value)));
}
void WriteCString(std::ostream& stream, const std::string& value);
void WriteCString(std::ostream& stream, const char* value);
} // namespace stream