mirror of
https://github.com/openmoh/openmohaa.git
synced 2025-04-28 21:57:57 +03:00
Implemented TIKI_SwapSkel (used on Big-Endian systems)
This commit is contained in:
parent
28ea95b9ff
commit
a1e0bc5d7c
2 changed files with 170 additions and 0 deletions
|
@ -220,3 +220,172 @@ dtikianim_t *TIKI_FillTIKIStructureSkel(dloaddef_t *ld)
|
|||
|
||||
return TIKI_InitTiki(ld, PAD(animdefsize + defsize, sizeof(void *)));
|
||||
}
|
||||
|
||||
/*
|
||||
===============
|
||||
TIKI_SwapSkel
|
||||
|
||||
Swap the skeleton header on Big-Endian systems
|
||||
===============
|
||||
*/
|
||||
void TIKI_SwapSkel(skelHeader_t* pheader)
|
||||
{
|
||||
#ifdef Q3_BIG_ENDIAN
|
||||
skelSurface_t* pSurf;
|
||||
int i, j, k;
|
||||
|
||||
//pheader->ident = LittleLong(pheader->ident);
|
||||
pheader->version = LittleLong(pheader->version);
|
||||
pheader->numSurfaces = LittleLong(pheader->numSurfaces);
|
||||
pheader->numBones = LittleLong(pheader->numBones);
|
||||
pheader->ofsBones = LittleLong(pheader->ofsBones);
|
||||
pheader->ofsSurfaces = LittleLong(pheader->ofsSurfaces);
|
||||
pheader->ofsEnd = LittleLong(pheader->ofsEnd);
|
||||
|
||||
if (pheader->version >= TIKI_SKB_HEADER_VERSION) {
|
||||
for (i = 0; i < TIKI_SKEL_LOD_INDEXES; i++) {
|
||||
pheader->lodIndex[i] = LittleLong(pheader->lodIndex[i]);
|
||||
}
|
||||
|
||||
pheader->numBoxes = LittleLong(pheader->numBoxes);
|
||||
pheader->ofsBoxes = LittleLong(pheader->ofsBoxes);
|
||||
}
|
||||
|
||||
if (pheader->version >= TIKI_SKD_HEADER_OLD_VERSION) {
|
||||
pheader->numMorphTargets = LittleLong(pheader->numMorphTargets);
|
||||
pheader->ofsMorphTargets = LittleLong(pheader->ofsMorphTargets);
|
||||
}
|
||||
|
||||
if (pheader->version >= TIKI_SKD_HEADER_VERSION) {
|
||||
pheader->scale = LittleFloat(pheader->scale);
|
||||
}
|
||||
|
||||
if (pheader->version >= TIKI_SKD_HEADER_OLD_VERSION) {
|
||||
boneFileData_t* boneBuffer;
|
||||
|
||||
boneBuffer = (boneFileData_t*)((byte*)pheader + pheader->ofsBones);
|
||||
for (i = 0; i < pheader->numBones; i++) {
|
||||
boneBuffer->boneType = (boneType_t)LittleLong(boneBuffer->boneType);
|
||||
boneBuffer->ofsBaseData = LittleLong(boneBuffer->ofsBaseData);
|
||||
boneBuffer->ofsChannelNames = LittleLong(boneBuffer->ofsChannelNames);
|
||||
boneBuffer->ofsBoneNames = LittleLong(boneBuffer->ofsBoneNames);
|
||||
boneBuffer->ofsEnd = LittleLong(boneBuffer->ofsEnd);
|
||||
|
||||
boneBuffer = (boneFileData_t*)((byte*)boneBuffer + boneBuffer->ofsEnd);
|
||||
}
|
||||
} else {
|
||||
skelBoneName_t* TIKI_bones;
|
||||
|
||||
TIKI_bones = (skelBoneName_t*)((byte*)pheader + pheader->ofsBones);
|
||||
|
||||
for (i = 0; i < pheader->numBones; i++) {
|
||||
TIKI_bones->parent = LittleShort(TIKI_bones->parent);
|
||||
TIKI_bones->boxIndex = LittleShort(TIKI_bones->boxIndex);
|
||||
TIKI_bones->flags = LittleLong(TIKI_bones->flags);
|
||||
|
||||
TIKI_bones++;
|
||||
}
|
||||
}
|
||||
|
||||
pSurf = (skelSurface_t*)((byte*)pheader + pheader->ofsSurfaces);
|
||||
for (i = 0; i < pheader->numSurfaces; i++) {
|
||||
skeletorVertex_t* pVert;
|
||||
skeletorMorph_t* pMorph;
|
||||
skelWeight_t* pWeight;
|
||||
int* pTriangles;
|
||||
int* pCollapse, * pCollapseIndex;
|
||||
|
||||
pSurf->ident = LittleLong(pSurf->ident);
|
||||
pSurf->numTriangles = LittleLong(pSurf->numTriangles);
|
||||
pSurf->numVerts = LittleLong(pSurf->numVerts);
|
||||
pSurf->staticSurfProcessed = LittleLong(pSurf->staticSurfProcessed);
|
||||
pSurf->ofsTriangles = LittleLong(pSurf->ofsTriangles);
|
||||
pSurf->ofsVerts = LittleLong(pSurf->ofsVerts);
|
||||
pSurf->ofsCollapse = LittleLong(pSurf->ofsCollapse);
|
||||
pSurf->ofsEnd = LittleLong(pSurf->ofsEnd);
|
||||
|
||||
if (pheader->version >= TIKI_SKB_HEADER_VERSION) {
|
||||
pSurf->ofsCollapseIndex = LittleLong(pSurf->ofsCollapseIndex);
|
||||
}
|
||||
|
||||
pTriangles = (int*)((byte*)pSurf + pSurf->ofsTriangles);
|
||||
for (j = 0; j < pSurf->numTriangles; j++) {
|
||||
pTriangles[j * 3 + 0] = LittleLong(pTriangles[j * 3 + 0]);
|
||||
pTriangles[j * 3 + 1] = LittleLong(pTriangles[j * 3 + 1]);
|
||||
pTriangles[j * 3 + 2] = LittleLong(pTriangles[j * 3 + 2]);
|
||||
}
|
||||
|
||||
if (pheader->version >= TIKI_SKD_HEADER_OLD_VERSION) {
|
||||
pVert = (skeletorVertex_t*)((byte*)pSurf + pSurf->ofsVerts);
|
||||
|
||||
for (j = 0; j < pSurf->numVerts; j++) {
|
||||
pVert->normal[0] = LittleFloat(pVert->normal[0]);
|
||||
pVert->normal[1] = LittleFloat(pVert->normal[1]);
|
||||
pVert->normal[2] = LittleFloat(pVert->normal[2]);
|
||||
pVert->texCoords[0] = LittleFloat(pVert->texCoords[0]);
|
||||
pVert->texCoords[1] = LittleFloat(pVert->texCoords[1]);
|
||||
|
||||
pVert->numMorphs = LittleLong(pVert->numMorphs);
|
||||
pMorph = (skeletorMorph_t*)((byte*)pVert + sizeof(*pVert));
|
||||
|
||||
for (k = 0; k < pVert->numMorphs; k++, pMorph++) {
|
||||
pMorph->morphIndex = LittleLong(pMorph->morphIndex);
|
||||
pMorph->offset[0] = LittleFloat(pMorph->offset[0]);
|
||||
pMorph->offset[1] = LittleFloat(pMorph->offset[1]);
|
||||
pMorph->offset[2] = LittleFloat(pMorph->offset[2]);
|
||||
}
|
||||
|
||||
pVert->numWeights = LittleLong(pVert->numWeights);
|
||||
pWeight = (skelWeight_t*)pMorph;
|
||||
|
||||
for (k = 0; k < pVert->numWeights; k++, pWeight++) {
|
||||
pWeight->boneIndex = LittleLong(pWeight->boneIndex);
|
||||
pWeight->boneWeight = LittleFloat(pWeight->boneWeight);
|
||||
pWeight->offset[0] = LittleFloat(pWeight->offset[0]);
|
||||
pWeight->offset[1] = LittleFloat(pWeight->offset[1]);
|
||||
pWeight->offset[2] = LittleFloat(pWeight->offset[2]);
|
||||
}
|
||||
|
||||
pVert = (skeletorVertex_t*)pWeight;
|
||||
}
|
||||
} else {
|
||||
pVert = (skeletorVertex_t*)((byte*)pSurf + pSurf->ofsVerts);
|
||||
|
||||
for (j = 0; j < pSurf->numVerts; j++) {
|
||||
pVert->normal[0] = LittleFloat(pVert->normal[0]);
|
||||
pVert->normal[1] = LittleFloat(pVert->normal[1]);
|
||||
pVert->normal[2] = LittleFloat(pVert->normal[2]);
|
||||
pVert->texCoords[0] = LittleFloat(pVert->texCoords[0]);
|
||||
pVert->texCoords[1] = LittleFloat(pVert->texCoords[1]);
|
||||
pVert->numWeights = LittleLong(pVert->numWeights);
|
||||
|
||||
pWeight = (skelWeight_t*)((byte*)pVert + sizeof(*pVert));
|
||||
|
||||
for (k = 0; k < pVert->numWeights; k++, pWeight++) {
|
||||
pWeight->boneIndex = LittleLong(pWeight->boneIndex);
|
||||
pWeight->boneWeight = LittleFloat(pWeight->boneWeight);
|
||||
pWeight->offset[0] = LittleFloat(pWeight->offset[0]);
|
||||
pWeight->offset[1] = LittleFloat(pWeight->offset[1]);
|
||||
pWeight->offset[2] = LittleFloat(pWeight->offset[2]);
|
||||
}
|
||||
|
||||
pVert = (skeletorVertex_t*)pWeight;
|
||||
}
|
||||
}
|
||||
|
||||
pCollapse = (int*)((byte*)pSurf + pSurf->ofsCollapse);
|
||||
for (j = 0; j < pSurf->numVerts; j++) {
|
||||
pCollapse[j] = LittleLong(pCollapse[j]);
|
||||
}
|
||||
|
||||
if (pheader->version >= TIKI_SKB_HEADER_VERSION) {
|
||||
pCollapseIndex = (int*)((byte*)pSurf + pSurf->ofsCollapseIndex);
|
||||
for (j = 0; j < pSurf->numVerts; j++) {
|
||||
pCollapseIndex[j] = LittleLong(pCollapseIndex[j]);
|
||||
}
|
||||
}
|
||||
|
||||
pSurf = (skelSurface_t*)((byte*)pSurf + pSurf->ofsEnd);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -40,6 +40,7 @@ extern "C" {
|
|||
TIKI_SetupIndividualSurface(const char *filename, dtikisurface_t *surf, const char *name, dloadsurface_t *loadsurf);
|
||||
size_t TIKI_CalcAnimDefSize(dloaddef_t *ld);
|
||||
dtikianim_t *TIKI_FillTIKIStructureSkel(dloaddef_t *ld);
|
||||
void TIKI_SwapSkel(skelHeader_t* pheader);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue