[XModel] Adapt structure

This commit is contained in:
momo5502 2016-12-20 18:15:28 +01:00
parent 8ec4369ba3
commit 1c82e29871
4 changed files with 16 additions and 16 deletions

View File

@ -1,6 +1,6 @@
#include <STDInclude.hpp> #include <STDInclude.hpp>
#define IW4X_MODEL_VERSION 1 #define IW4X_MODEL_VERSION 2
namespace Assets namespace Assets
{ {
@ -91,12 +91,13 @@ namespace Assets
surface->deformed = reader.read<char>(); surface->deformed = reader.read<char>();
surface->streamHandle = reader.read<unsigned char>(); surface->streamHandle = reader.read<unsigned char>();
surface->flags = reader.read<unsigned short>(); surface->partBits[0] = reader.read<int>();
surface->something = reader.read<short>(); surface->partBits[1] = reader.read<int>();
surface->something2 = reader.read<int>(); surface->partBits[2] = reader.read<int>();
surface->partBits[3] = reader.read<int>();
surface->pad2 = reader.read<char>(); surface->baseTriIndex = reader.read<unsigned __int16>();
surface->pad3 = reader.read<int>(); surface->baseVertIndex = reader.read<unsigned __int16>();
surface->numVertices = reader.read<unsigned short>(); surface->numVertices = reader.read<unsigned short>();
surface->numPrimitives = reader.read<unsigned short>(); surface->numPrimitives = reader.read<unsigned short>();

View File

@ -132,7 +132,7 @@ namespace Components
std::memcpy(&tempSurfaces[i], source, 12); std::memcpy(&tempSurfaces[i], source, 12);
std::memcpy(&tempSurfaces[i].indexBuffer, source + 16, 20); std::memcpy(&tempSurfaces[i].indexBuffer, source + 16, 20);
std::memcpy(&tempSurfaces[i].numCT, source + 40, 8); std::memcpy(&tempSurfaces[i].numCT, source + 40, 8);
std::memcpy(&tempSurfaces[i].something, source + 52, 24); std::memcpy(&tempSurfaces[i].partBits, source + 52, 24);
tempSurfaces[i].streamHandle = 0xFF; // Fake handle for buffer interception tempSurfaces[i].streamHandle = 0xFF; // Fake handle for buffer interception
} }
@ -164,7 +164,7 @@ namespace Components
surfs->numSurfaces = newSurfs->numSurfaces; surfs->numSurfaces = newSurfs->numSurfaces;
model->lods[i].surfs = newSurfs->surfaces; model->lods[i].surfs = newSurfs->surfaces;
std::memcpy(&model->lods[i].partBits, newSurfs->pad, 24); std::memcpy(&model->lods[i].partBits, newSurfs->partBits, 24);
short numSurfs = static_cast<short>(newSurfs->numSurfaces); short numSurfs = static_cast<short>(newSurfs->numSurfaces);
model->lods[i].numSurfs = numSurfs; model->lods[i].numSurfs = numSurfs;

View File

@ -167,7 +167,7 @@ namespace Components
std::memcpy(&tempSurfaces[i], source, 12); std::memcpy(&tempSurfaces[i], source, 12);
std::memcpy(&tempSurfaces[i].indexBuffer, source + 16, 20); std::memcpy(&tempSurfaces[i].indexBuffer, source + 16, 20);
std::memcpy(&tempSurfaces[i].numCT, source + 40, 8); std::memcpy(&tempSurfaces[i].numCT, source + 40, 8);
std::memcpy(&tempSurfaces[i].something, source + 52, 24); std::memcpy(&tempSurfaces[i].partBits, source + 52, 24);
if (Zones::ZoneVersion >= 332) if (Zones::ZoneVersion >= 332)
{ {

View File

@ -1472,8 +1472,8 @@ namespace Game
unsigned short numVertices; // +2 unsigned short numVertices; // +2
unsigned short numPrimitives; // +4 unsigned short numPrimitives; // +4
unsigned char streamHandle; // something to do with buffers, +6 unsigned char streamHandle; // something to do with buffers, +6
char pad2; // +7 unsigned __int16 baseTriIndex;
int pad3; // +8 unsigned __int16 baseVertIndex;
Face* indexBuffer; // +12 Face* indexBuffer; // +12
short blendNum1; // +16 short blendNum1; // +16
short blendNum2; // +18 short blendNum2; // +18
@ -1483,10 +1483,8 @@ namespace Game
GfxPackedVertex* vertexBuffer; // +28 GfxPackedVertex* vertexBuffer; // +28
int numCT; // +32 int numCT; // +32
XRigidVertList* ct; // +36 XRigidVertList* ct; // +36
short something; int partBits[4];
unsigned short flags; char pad5[8]; // +40
int something2;
char pad5[16]; // +40
// pad5 matches XModelSurfaces pad // pad5 matches XModelSurfaces pad
// total size, 64 // total size, 64
}; };
@ -1496,7 +1494,8 @@ namespace Game
const char* name; const char* name;
XSurface* surfaces; XSurface* surfaces;
int numSurfaces; int numSurfaces;
char pad[24]; int partBits[4];
char pad[8];
}; };
struct XModelLodInfo struct XModelLodInfo