mirror of
https://github.com/HarbourMasters/Shipwright.git
synced 2024-11-12 04:25:12 -05:00
09432ee7f4
* Initial Linux/GCC support commit * Add instructins for linux in the README * apply suggestions by @Erotemic and @Emill * Fix python 3.10 symlink line * Fix func_80041E80 type mismatch (#3) Type mismatch functions.h:664 * Makefile: clean OTRExporter/libultraship/ZAPDTR with distclean and fix CXX_FILES * Makefile: find C/CXX_FILES automatically * Makefile: remove ugly conditions in find commands * cleanup _MSC_VER usage * fix Windows build * cleanup extraction scripts * fix Windows build * Fix Windows path separator issue * fix rumble support for linux * use glew-cmake in dockerfile * add pulseaudio backend * fix ZAPDTR linkage * Check for "soh.elf" in directory (#6) hide second button if `soh.exe` or `soh.elf` is present * Fix hardcoded segment addresses (#5) * fix condition * hack lus -> soh dep for ZAPDTR Co-authored-by: sholdee <102821812+sholdee@users.noreply.github.com> Co-authored-by: qurious-pixel <62252937+qurious-pixel@users.noreply.github.com> Co-authored-by: GaryOderNichts <12049776+GaryOderNichts@users.noreply.github.com>
108 lines
2.9 KiB
C++
108 lines
2.9 KiB
C++
#include "ArrayExporter.h"
|
|
#include "VtxExporter.h"
|
|
#include <ZVector.h>
|
|
void OTRExporter_Array::Save(ZResource* res, const fs::path& outPath, BinaryWriter* writer)
|
|
{
|
|
ZArray* arr = (ZArray*)res;
|
|
|
|
WriteHeader(res, outPath, writer, Ship::ResourceType::Array);
|
|
|
|
writer->Write((uint32_t)arr->resList[0]->GetResourceType());
|
|
writer->Write((uint32_t)arr->arrayCnt);
|
|
|
|
for (size_t i = 0; i < arr->arrayCnt; i++)
|
|
{
|
|
if (arr->resList[i]->GetResourceType() == ZResourceType::Vertex)
|
|
{
|
|
ZVtx* vtx = (ZVtx*)arr->resList[i];
|
|
writer->Write(vtx->x);
|
|
writer->Write(vtx->y);
|
|
writer->Write(vtx->z);
|
|
writer->Write(vtx->flag);
|
|
writer->Write(vtx->s);
|
|
writer->Write(vtx->t);
|
|
writer->Write(vtx->r);
|
|
writer->Write(vtx->g);
|
|
writer->Write(vtx->b);
|
|
writer->Write(vtx->a);
|
|
}
|
|
else if (arr->resList[i]->GetResourceType() == ZResourceType::Vector)
|
|
{
|
|
ZVector* vec = (ZVector*)arr->resList[i];
|
|
writer->Write((uint32_t)vec->scalarType);
|
|
writer->Write((uint32_t)vec->dimensions);
|
|
|
|
for (size_t k = 0; k < vec->dimensions; k++)
|
|
{
|
|
// OTRTODO: Duplicate code here. Cleanup at a later date...
|
|
switch (vec->scalarType)
|
|
{
|
|
case ZScalarType::ZSCALAR_U8:
|
|
writer->Write(vec->scalars[k].scalarData.u8);
|
|
break;
|
|
case ZScalarType::ZSCALAR_S8:
|
|
writer->Write(vec->scalars[k].scalarData.s8);
|
|
break;
|
|
case ZScalarType::ZSCALAR_U16:
|
|
writer->Write(vec->scalars[k].scalarData.u16);
|
|
break;
|
|
case ZScalarType::ZSCALAR_S16:
|
|
writer->Write(vec->scalars[k].scalarData.s16);
|
|
break;
|
|
case ZScalarType::ZSCALAR_S32:
|
|
writer->Write(vec->scalars[k].scalarData.s32);
|
|
break;
|
|
case ZScalarType::ZSCALAR_U32:
|
|
writer->Write(vec->scalars[k].scalarData.u32);
|
|
break;
|
|
case ZScalarType::ZSCALAR_S64:
|
|
writer->Write(vec->scalars[k].scalarData.s64);
|
|
break;
|
|
case ZScalarType::ZSCALAR_U64:
|
|
writer->Write(vec->scalars[k].scalarData.u64);
|
|
break;
|
|
// OTRTODO: ADD OTHER TYPES
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
ZScalar* scal = (ZScalar*)arr->resList[i];
|
|
|
|
writer->Write((uint32_t)scal->scalarType);
|
|
|
|
switch (scal->scalarType)
|
|
{
|
|
case ZScalarType::ZSCALAR_U8:
|
|
writer->Write(scal->scalarData.u8);
|
|
break;
|
|
case ZScalarType::ZSCALAR_S8:
|
|
writer->Write(scal->scalarData.s8);
|
|
break;
|
|
case ZScalarType::ZSCALAR_U16:
|
|
writer->Write(scal->scalarData.u16);
|
|
break;
|
|
case ZScalarType::ZSCALAR_S16:
|
|
writer->Write(scal->scalarData.s16);
|
|
break;
|
|
case ZScalarType::ZSCALAR_S32:
|
|
writer->Write(scal->scalarData.s32);
|
|
break;
|
|
case ZScalarType::ZSCALAR_U32:
|
|
writer->Write(scal->scalarData.u32);
|
|
break;
|
|
case ZScalarType::ZSCALAR_S64:
|
|
writer->Write(scal->scalarData.s64);
|
|
break;
|
|
case ZScalarType::ZSCALAR_U64:
|
|
writer->Write(scal->scalarData.u64);
|
|
break;
|
|
// OTRTODO: ADD OTHER TYPES
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
} |