Add T5 model dumping

This commit is contained in:
Jan
2021-08-14 13:57:32 +02:00
parent f052a97886
commit ee22face41
7 changed files with 785 additions and 51 deletions

View File

@ -2,7 +2,11 @@
#include <cctype>
int CommonT5::Com_HashKey(const char* str, const int maxLen)
#include "Utils/Pack.h"
using namespace T5;
int Common::Com_HashKey(const char* str, const int maxLen)
{
if (str == nullptr)
return 0;
@ -19,7 +23,7 @@ int CommonT5::Com_HashKey(const char* str, const int maxLen)
return hash ^ ((hash ^ (hash >> 10)) >> 10);
}
int CommonT5::Com_HashString(const char* str)
int Common::Com_HashString(const char* str)
{
if (!str)
return 0;
@ -35,7 +39,7 @@ int CommonT5::Com_HashString(const char* str)
return result;
}
int CommonT5::Com_HashString(const char* str, const int len)
int Common::Com_HashString(const char* str, const int len)
{
if (!str)
return 0;
@ -52,4 +56,34 @@ int CommonT5::Com_HashString(const char* str, const int len)
}
return result;
}
}
PackedTexCoords Common::Vec2PackTexCoords(const vec2_t* in)
{
return PackedTexCoords{Pack32::Vec2PackTexCoords(reinterpret_cast<const float*>(in))};
}
PackedUnitVec Common::Vec3PackUnitVec(const vec3_t* in)
{
return PackedUnitVec{Pack32::Vec3PackUnitVec(reinterpret_cast<const float*>(in))};
}
GfxColor Common::Vec4PackGfxColor(const vec4_t* in)
{
return GfxColor{Pack32::Vec4PackGfxColor(reinterpret_cast<const float*>(in))};
}
void Common::Vec2UnpackTexCoords(const PackedTexCoords& in, vec2_t* out)
{
Pack32::Vec2UnpackTexCoords(in.packed, reinterpret_cast<float*>(out));
}
void Common::Vec3UnpackUnitVec(const PackedUnitVec& in, vec3_t* out)
{
Pack32::Vec3UnpackUnitVec(in.packed, reinterpret_cast<float*>(out));
}
void Common::Vec4UnpackGfxColor(const GfxColor& in, vec4_t* out)
{
Pack32::Vec4UnpackGfxColor(in.packed, reinterpret_cast<float*>(out));
}

View File

@ -1,9 +1,21 @@
#pragma once
class CommonT5
#include "T5.h"
namespace T5
{
public:
static int Com_HashKey(const char* str, int maxLen);
static int Com_HashString(const char* str);
static int Com_HashString(const char* str, int len);
};
class Common
{
public:
static int Com_HashKey(const char* str, int maxLen);
static int Com_HashString(const char* str);
static int Com_HashString(const char* str, int len);
static PackedTexCoords Vec2PackTexCoords(const vec2_t* in);
static PackedUnitVec Vec3PackUnitVec(const vec3_t* in);
static GfxColor Vec4PackGfxColor(const vec4_t* in);
static void Vec2UnpackTexCoords(const PackedTexCoords& in, vec2_t* out);
static void Vec3UnpackUnitVec(const PackedUnitVec& in, vec3_t* out);
static void Vec4UnpackGfxColor(const GfxColor& in, vec4_t* out);
};
}

View File

@ -413,6 +413,12 @@ namespace T5
XAnimDeltaPart* deltaPart;
};
struct DObjSkelMat
{
float axis[3][4];
float origin[4];
};
struct DObjAnimMat
{
float quat[4];
@ -496,7 +502,7 @@ namespace T5
struct XSurface
{
char tileMode;
char vertListCount;
unsigned char vertListCount;
uint16_t flags;
uint16_t vertCount;
uint16_t triCount;
@ -637,14 +643,14 @@ namespace T5
float radius;
float mins[3];
float maxs[3];
int16_t numLods;
int16_t collLod;
uint16_t numLods;
uint16_t collLod;
XModelStreamInfo streamInfo;
int memUsage;
int flags;
bool bad;
PhysPreset* physPreset;
char numCollmaps;
unsigned char numCollmaps;
Collmap* collmaps;
PhysConstraints* physConstraints;
};
@ -748,12 +754,12 @@ namespace T5
{
MaterialInfo info;
char stateBitsEntry[130];
char textureCount;
char constantCount;
char stateBitsCount;
unsigned char textureCount;
unsigned char constantCount;
unsigned char stateBitsCount;
char stateFlags;
char cameraRegion;
char maxStreamedMips;
unsigned char maxStreamedMips;
MaterialTechniqueSet* techniqueSet;
MaterialTextureDef* textureTable;
MaterialConstantDef* constantTable;