mirror of
https://github.com/HarbourMasters/Shipwright.git
synced 2025-08-14 10:37:17 -07:00
git subrepo clone https://github.com/HarbourMasters/ZAPDTR.git
subrepo: subdir: "ZAPDTR" merged: "a53a53ea4" upstream: origin: "https://github.com/HarbourMasters/ZAPDTR.git" branch: "master" commit: "a53a53ea4" git-subrepo: version: "0.4.1" origin: "???" commit: "???"
This commit is contained in:
parent
f52a2a6406
commit
5dda5762ba
217 changed files with 47152 additions and 0 deletions
74
ZAPDTR/ExporterTest/CollisionExporter.cpp
Normal file
74
ZAPDTR/ExporterTest/CollisionExporter.cpp
Normal file
|
@ -0,0 +1,74 @@
|
|||
#include "CollisionExporter.h"
|
||||
|
||||
void ExporterExample_Collision::Save(ZResource* res, [[maybe_unused]] fs::path outPath,
|
||||
BinaryWriter* writer)
|
||||
{
|
||||
ZCollisionHeader* col = (ZCollisionHeader*)res;
|
||||
|
||||
writer->Write(col->absMinX);
|
||||
writer->Write(col->absMinY);
|
||||
writer->Write(col->absMinZ);
|
||||
|
||||
writer->Write(col->absMaxX);
|
||||
writer->Write(col->absMaxY);
|
||||
writer->Write(col->absMaxZ);
|
||||
|
||||
writer->Write(col->numVerts);
|
||||
writer->Write(col->vtxAddress);
|
||||
|
||||
writer->Write(col->numPolygons);
|
||||
writer->Write(col->polyAddress);
|
||||
writer->Write(col->polyTypeDefAddress);
|
||||
writer->Write(col->camDataAddress);
|
||||
|
||||
writer->Write(col->numWaterBoxes);
|
||||
writer->Write(col->waterBoxAddress);
|
||||
|
||||
writer->Write(col->vtxSegmentOffset);
|
||||
writer->Write(col->polySegmentOffset);
|
||||
writer->Write(col->polyTypeDefSegmentOffset);
|
||||
writer->Write(col->camDataSegmentOffset);
|
||||
writer->Write(col->waterBoxSegmentOffset);
|
||||
|
||||
uint32_t oldOffset = writer->GetBaseAddress();
|
||||
|
||||
writer->Seek(col->vtxSegmentOffset, SeekOffsetType::Start);
|
||||
|
||||
for (uint16_t i = 0; i < col->vertices.size(); i++)
|
||||
{
|
||||
for (uint32_t j = 0; j < col->vertices[i].dimensions; j++)
|
||||
{
|
||||
writer->Write(col->vertices[i].scalars[j].scalarData.s16);
|
||||
}
|
||||
}
|
||||
|
||||
writer->Seek(col->polySegmentOffset, SeekOffsetType::Start);
|
||||
|
||||
for (uint16_t i = 0; i < col->polygons.size(); i++)
|
||||
{
|
||||
writer->Write(col->polygons[i].type);
|
||||
writer->Write(col->polygons[i].vtxA);
|
||||
writer->Write(col->polygons[i].vtxB);
|
||||
writer->Write(col->polygons[i].vtxC);
|
||||
writer->Write(col->polygons[i].a);
|
||||
writer->Write(col->polygons[i].b);
|
||||
writer->Write(col->polygons[i].c);
|
||||
writer->Write(col->polygons[i].d);
|
||||
}
|
||||
|
||||
writer->Seek(col->polyTypeDefSegmentOffset, SeekOffsetType::Start);
|
||||
|
||||
for (uint16_t i = 0; i < col->polygonTypes.size(); i++)
|
||||
writer->Write(col->polygonTypes[i]);
|
||||
|
||||
writer->Seek(col->camDataSegmentOffset, SeekOffsetType::Start);
|
||||
|
||||
for (auto entry : col->camData->entries)
|
||||
{
|
||||
writer->Write(entry->cameraSType);
|
||||
writer->Write(entry->numData);
|
||||
writer->Write(entry->cameraPosDataSeg);
|
||||
}
|
||||
|
||||
writer->Seek(oldOffset, SeekOffsetType::Start);
|
||||
}
|
10
ZAPDTR/ExporterTest/CollisionExporter.h
Normal file
10
ZAPDTR/ExporterTest/CollisionExporter.h
Normal file
|
@ -0,0 +1,10 @@
|
|||
#pragma once
|
||||
|
||||
#include "ZCollision.h"
|
||||
#include "ZResource.h"
|
||||
|
||||
class ExporterExample_Collision : public ZResourceExporter
|
||||
{
|
||||
public:
|
||||
void Save(ZResource* res, fs::path outPath, BinaryWriter* writer) override;
|
||||
};
|
160
ZAPDTR/ExporterTest/ExporterTest.vcxproj
Normal file
160
ZAPDTR/ExporterTest/ExporterTest.vcxproj
Normal file
|
@ -0,0 +1,160 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Debug|x64">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|x64">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<VCProjectVersion>16.0</VCProjectVersion>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
<ProjectGuid>{65608eb0-1a47-45ad-ab66-192fb64c762c}</ProjectGuid>
|
||||
<RootNamespace>ExporterTest</RootNamespace>
|
||||
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
|
||||
<ProjectName>ExporterExample</ProjectName>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="Shared">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
<IncludePath>$(ProjectDir)..\ZAPD\;$(ProjectDir)..\ZAPDUtils;$(ProjectDir)..\lib\tinyxml2;$(ProjectDir)..\lib\libgfxd;$(ProjectDir)..\lib\elfio;$(ProjectDir)..\lib\stb;$(ProjectDir);$(IncludePath)</IncludePath>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>_DEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<LanguageStandard>stdcpp17</LanguageStandard>
|
||||
<LanguageStandard_C>stdc11</LanguageStandard_C>
|
||||
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="CollisionExporter.h" />
|
||||
<ClInclude Include="TextureExporter.h" />
|
||||
<ClInclude Include="RoomExporter.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="CollisionExporter.cpp" />
|
||||
<ClCompile Include="TextureExporter.cpp" />
|
||||
<ClCompile Include="Main.cpp" />
|
||||
<ClCompile Include="RoomExporter.cpp" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
42
ZAPDTR/ExporterTest/ExporterTest.vcxproj.filters
Normal file
42
ZAPDTR/ExporterTest/ExporterTest.vcxproj.filters
Normal file
|
@ -0,0 +1,42 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<Filter Include="Source Files">
|
||||
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
|
||||
<Extensions>cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Header Files">
|
||||
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
|
||||
<Extensions>h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Resource Files">
|
||||
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
|
||||
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="TextureExporter.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="RoomExporter.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="CollisionExporter.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="TextureExporter.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Main.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="RoomExporter.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="CollisionExporter.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
</Project>
|
79
ZAPDTR/ExporterTest/Main.cpp
Normal file
79
ZAPDTR/ExporterTest/Main.cpp
Normal file
|
@ -0,0 +1,79 @@
|
|||
#include "CollisionExporter.h"
|
||||
#include "Globals.h"
|
||||
#include "RoomExporter.h"
|
||||
#include "TextureExporter.h"
|
||||
|
||||
enum class ExporterFileMode
|
||||
{
|
||||
ModeExample1 = (int)ZFileMode::Custom + 1,
|
||||
ModeExample2 = (int)ZFileMode::Custom + 2,
|
||||
ModeExample3 = (int)ZFileMode::Custom + 3,
|
||||
};
|
||||
|
||||
static void ExporterParseFileMode(const std::string& buildMode, ZFileMode& fileMode)
|
||||
{
|
||||
if (buildMode == "me1")
|
||||
fileMode = (ZFileMode)ExporterFileMode::ModeExample1;
|
||||
else if (buildMode == "me2")
|
||||
fileMode = (ZFileMode)ExporterFileMode::ModeExample2;
|
||||
else if (buildMode == "me3")
|
||||
fileMode = (ZFileMode)ExporterFileMode::ModeExample3;
|
||||
}
|
||||
|
||||
static void ExporterParseArgs([[maybe_unused]] int argc, char* argv[], int& i)
|
||||
{
|
||||
std::string arg = argv[i];
|
||||
|
||||
if (arg == "--do-x")
|
||||
{
|
||||
}
|
||||
else if (arg == "--do-y")
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
static bool ExporterProcessFileMode(ZFileMode fileMode)
|
||||
{
|
||||
// Do whatever work is associated with these custom file modes...
|
||||
// Return true to indicate one of our own file modes is being processed
|
||||
if (fileMode == (ZFileMode)ExporterFileMode::ModeExample1)
|
||||
return true;
|
||||
else if (fileMode == (ZFileMode)ExporterFileMode::ModeExample2)
|
||||
return true;
|
||||
else if (fileMode == (ZFileMode)ExporterFileMode::ModeExample3)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
static void ExporterFileBegin(ZFile* file)
|
||||
{
|
||||
printf("ExporterFileBegin() called on ZFile %s.\n", file->GetName().c_str());
|
||||
}
|
||||
|
||||
static void ExporterFileEnd(ZFile* file)
|
||||
{
|
||||
printf("ExporterFileEnd() called on ZFile %s.\n", file->GetName().c_str());
|
||||
}
|
||||
|
||||
static void ImportExporters()
|
||||
{
|
||||
// In this example we set up a new exporter called "EXAMPLE".
|
||||
// By running ZAPD with the argument -se EXAMPLE, we tell it that we want to use this exporter
|
||||
// for our resources.
|
||||
ExporterSet* exporterSet = new ExporterSet();
|
||||
exporterSet->processFileModeFunc = ExporterProcessFileMode;
|
||||
exporterSet->parseFileModeFunc = ExporterParseFileMode;
|
||||
exporterSet->parseArgsFunc = ExporterParseArgs;
|
||||
exporterSet->beginFileFunc = ExporterFileBegin;
|
||||
exporterSet->endFileFunc = ExporterFileEnd;
|
||||
exporterSet->exporters[ZResourceType::Texture] = new ExporterExample_Texture();
|
||||
exporterSet->exporters[ZResourceType::Room] = new ExporterExample_Room();
|
||||
exporterSet->exporters[ZResourceType::CollisionHeader] = new ExporterExample_Collision();
|
||||
|
||||
Globals::AddExporter("EXAMPLE", exporterSet);
|
||||
}
|
||||
|
||||
// When ZAPD starts up, it will automatically call the below function, which in turn sets up our
|
||||
// exporters.
|
||||
REGISTER_EXPORTER(ImportExporters);
|
28
ZAPDTR/ExporterTest/Makefile
Normal file
28
ZAPDTR/ExporterTest/Makefile
Normal file
|
@ -0,0 +1,28 @@
|
|||
# Only used for standalone compilation, usually inherits these from the main makefile
|
||||
CXXFLAGS ?= -Wall -Wextra -O2 -g -std=c++17
|
||||
|
||||
SRC_DIRS := $(shell find . -type d -not -path "*build*")
|
||||
CPP_FILES := $(foreach dir,$(SRC_DIRS),$(wildcard $(dir)/*.cpp))
|
||||
H_FILES := $(foreach dir,$(SRC_DIRS),$(wildcard $(dir)/*.h))
|
||||
|
||||
O_FILES := $(foreach f,$(CPP_FILES:.cpp=.o),build/$f)
|
||||
LIB := ExporterTest.a
|
||||
|
||||
# create build directories
|
||||
$(shell mkdir -p $(foreach dir,$(SRC_DIRS),build/$(dir)))
|
||||
|
||||
all: $(LIB)
|
||||
|
||||
clean:
|
||||
rm -rf build $(LIB)
|
||||
|
||||
format:
|
||||
clang-format-11 -i $(CPP_FILES) $(H_FILES)
|
||||
|
||||
.PHONY: all clean format
|
||||
|
||||
build/%.o: %.cpp
|
||||
$(CXX) $(CXXFLAGS) $(OPTFLAGS) -I ./ -I ../ZAPD -I ../ZAPDUtils -I ../lib/tinyxml2 -c $(OUTPUT_OPTION) $<
|
||||
|
||||
$(LIB): $(O_FILES)
|
||||
$(AR) rcs $@ $^
|
372
ZAPDTR/ExporterTest/RoomExporter.cpp
Normal file
372
ZAPDTR/ExporterTest/RoomExporter.cpp
Normal file
|
@ -0,0 +1,372 @@
|
|||
#include "RoomExporter.h"
|
||||
#include "CollisionExporter.h"
|
||||
#include "Utils/BinaryWriter.h"
|
||||
#include "Utils/File.h"
|
||||
#include "Utils/MemoryStream.h"
|
||||
#include "ZRoom/Commands/SetCameraSettings.h"
|
||||
#include "ZRoom/Commands/SetCollisionHeader.h"
|
||||
#include "ZRoom/Commands/SetCsCamera.h"
|
||||
#include "ZRoom/Commands/SetEchoSettings.h"
|
||||
#include "ZRoom/Commands/SetEntranceList.h"
|
||||
#include "ZRoom/Commands/SetLightingSettings.h"
|
||||
#include "ZRoom/Commands/SetMesh.h"
|
||||
#include "ZRoom/Commands/SetRoomBehavior.h"
|
||||
#include "ZRoom/Commands/SetRoomList.h"
|
||||
#include "ZRoom/Commands/SetSkyboxModifier.h"
|
||||
#include "ZRoom/Commands/SetSkyboxSettings.h"
|
||||
#include "ZRoom/Commands/SetSoundSettings.h"
|
||||
#include "ZRoom/Commands/SetSpecialObjects.h"
|
||||
#include "ZRoom/Commands/SetStartPositionList.h"
|
||||
#include "ZRoom/Commands/SetTimeSettings.h"
|
||||
#include "ZRoom/Commands/SetWind.h"
|
||||
|
||||
void ExporterExample_Room::Save(ZResource* res, fs::path outPath, BinaryWriter* writer)
|
||||
{
|
||||
ZRoom* room = dynamic_cast<ZRoom*>(res);
|
||||
|
||||
// MemoryStream* memStream = new MemoryStream();
|
||||
// BinaryWriter* writer = new BinaryWriter(memStream);
|
||||
|
||||
for (size_t i = 0; i < room->commands.size() * 8; i++)
|
||||
writer->Write((uint8_t)0);
|
||||
|
||||
for (size_t i = 0; i < room->commands.size(); i++)
|
||||
{
|
||||
ZRoomCommand* cmd = room->commands[i];
|
||||
|
||||
writer->Seek(i * 8, SeekOffsetType::Start);
|
||||
|
||||
writer->Write((uint8_t)cmd->cmdID);
|
||||
|
||||
switch (cmd->cmdID)
|
||||
{
|
||||
case RoomCommand::SetWind:
|
||||
{
|
||||
SetWind* cmdSetWind = (SetWind*)cmd;
|
||||
|
||||
writer->Write((uint8_t)0); // 0x01
|
||||
writer->Write((uint8_t)0); // 0x02
|
||||
writer->Write((uint8_t)0); // 0x03
|
||||
|
||||
writer->Write(cmdSetWind->windWest); // 0x04
|
||||
writer->Write(cmdSetWind->windVertical); // 0x05
|
||||
writer->Write(cmdSetWind->windSouth); // 0x06
|
||||
writer->Write(cmdSetWind->clothFlappingStrength); // 0x07
|
||||
}
|
||||
break;
|
||||
case RoomCommand::SetTimeSettings:
|
||||
{
|
||||
SetTimeSettings* cmdTime = (SetTimeSettings*)cmd;
|
||||
|
||||
writer->Write((uint8_t)0); // 0x01
|
||||
writer->Write((uint8_t)0); // 0x02
|
||||
writer->Write((uint8_t)0); // 0x03
|
||||
|
||||
writer->Write(cmdTime->hour); // 0x04
|
||||
writer->Write(cmdTime->min); // 0x05
|
||||
writer->Write(cmdTime->unk); // 0x06
|
||||
writer->Write((uint8_t)0); // 0x07
|
||||
}
|
||||
break;
|
||||
case RoomCommand::SetSkyboxModifier:
|
||||
{
|
||||
SetSkyboxModifier* cmdSkybox = (SetSkyboxModifier*)cmd;
|
||||
|
||||
writer->Write((uint8_t)0); // 0x01
|
||||
writer->Write((uint8_t)0); // 0x02
|
||||
writer->Write((uint8_t)0); // 0x03
|
||||
|
||||
writer->Write(cmdSkybox->disableSky); // 0x04
|
||||
writer->Write(cmdSkybox->disableSunMoon); // 0x05
|
||||
writer->Write((uint8_t)0); // 0x06
|
||||
writer->Write((uint8_t)0); // 0x07
|
||||
}
|
||||
break;
|
||||
case RoomCommand::SetEchoSettings:
|
||||
{
|
||||
SetEchoSettings* cmdEcho = (SetEchoSettings*)cmd;
|
||||
|
||||
writer->Write((uint8_t)0); // 0x01
|
||||
writer->Write((uint8_t)0); // 0x02
|
||||
writer->Write((uint8_t)0); // 0x03
|
||||
writer->Write((uint8_t)0); // 0x04
|
||||
writer->Write((uint8_t)0); // 0x05
|
||||
writer->Write((uint8_t)0); // 0x06
|
||||
writer->Write((uint8_t)cmdEcho->echo); // 0x07
|
||||
}
|
||||
break;
|
||||
case RoomCommand::SetSoundSettings:
|
||||
{
|
||||
SetSoundSettings* cmdSound = (SetSoundSettings*)cmd;
|
||||
|
||||
writer->Write((uint8_t)cmdSound->reverb); // 0x01
|
||||
writer->Write((uint8_t)0); // 0x02
|
||||
writer->Write((uint8_t)0); // 0x03
|
||||
writer->Write((uint8_t)0); // 0x04
|
||||
writer->Write((uint8_t)0); // 0x05
|
||||
|
||||
writer->Write(cmdSound->nightTimeSFX); // 0x06
|
||||
writer->Write(cmdSound->musicSequence); // 0x07
|
||||
}
|
||||
break;
|
||||
case RoomCommand::SetSkyboxSettings:
|
||||
{
|
||||
SetSkyboxSettings* cmdSkybox = (SetSkyboxSettings*)cmd;
|
||||
|
||||
writer->Write((uint8_t)cmdSkybox->unk1); // 0x01
|
||||
writer->Write((uint8_t)0); // 0x02
|
||||
writer->Write((uint8_t)0); // 0x03
|
||||
writer->Write((uint8_t)cmdSkybox->skyboxNumber); // 0x04
|
||||
writer->Write((uint8_t)cmdSkybox->cloudsType); // 0x05
|
||||
writer->Write((uint8_t)cmdSkybox->isIndoors); // 0x06
|
||||
}
|
||||
break;
|
||||
case RoomCommand::SetRoomBehavior:
|
||||
{
|
||||
SetRoomBehavior* cmdRoom = (SetRoomBehavior*)cmd;
|
||||
|
||||
writer->Write((uint8_t)cmdRoom->gameplayFlags); // 0x01
|
||||
writer->Write((uint8_t)0); // 0x02
|
||||
writer->Write((uint8_t)0); // 0x03
|
||||
writer->Write(cmdRoom->gameplayFlags2); // 0x04
|
||||
}
|
||||
break;
|
||||
case RoomCommand::SetCsCamera:
|
||||
{
|
||||
SetCsCamera* cmdCsCam = (SetCsCamera*)cmd;
|
||||
|
||||
writer->Write((uint8_t)cmdCsCam->cameras.size()); // 0x01
|
||||
writer->Write((uint8_t)0); // 0x02
|
||||
writer->Write((uint8_t)0); // 0x03
|
||||
|
||||
writer->Write(cmdCsCam->segmentOffset); // 0x04
|
||||
}
|
||||
break;
|
||||
case RoomCommand::SetMesh:
|
||||
{
|
||||
SetMesh* cmdMesh = (SetMesh*)cmd;
|
||||
|
||||
int baseStreamEnd = writer->GetStream().get()->GetLength();
|
||||
|
||||
writer->Write((uint8_t)cmdMesh->data); // 0x01
|
||||
writer->Write((uint8_t)0); // 0x02
|
||||
writer->Write((uint8_t)0); // 0x03
|
||||
|
||||
writer->Write(baseStreamEnd); // 0x04
|
||||
|
||||
uint32_t oldOffset = writer->GetBaseAddress();
|
||||
writer->Seek(baseStreamEnd, SeekOffsetType::Start);
|
||||
|
||||
// TODO: NOT DONE
|
||||
|
||||
writer->Write(cmdMesh->meshHeaderType);
|
||||
|
||||
if (cmdMesh->meshHeaderType == 0)
|
||||
{
|
||||
// writer->Write(cmdMesh->)
|
||||
}
|
||||
else if (cmdMesh->meshHeaderType == 1)
|
||||
{
|
||||
}
|
||||
else if (cmdMesh->meshHeaderType == 2)
|
||||
{
|
||||
}
|
||||
|
||||
writer->Seek(oldOffset, SeekOffsetType::Start);
|
||||
}
|
||||
break;
|
||||
case RoomCommand::SetCameraSettings:
|
||||
{
|
||||
SetCameraSettings* cmdCam = (SetCameraSettings*)cmd;
|
||||
|
||||
writer->Write((uint8_t)cmdCam->cameraMovement); // 0x01
|
||||
writer->Write((uint8_t)0); // 0x02
|
||||
writer->Write((uint8_t)0); // 0x03
|
||||
writer->Write(cmdCam->mapHighlight); // 0x04
|
||||
}
|
||||
break;
|
||||
case RoomCommand::SetLightingSettings:
|
||||
{
|
||||
SetLightingSettings* cmdLight = (SetLightingSettings*)cmd;
|
||||
|
||||
writer->Write((uint8_t)cmdLight->settings.size()); // 0x01
|
||||
writer->Write((uint8_t)0); // 0x02
|
||||
writer->Write((uint8_t)0); // 0x03
|
||||
writer->Write(cmdLight->segmentOffset); // 0x04
|
||||
|
||||
uint32_t oldOffset = writer->GetBaseAddress();
|
||||
writer->Seek(cmdLight->segmentOffset, SeekOffsetType::Start);
|
||||
|
||||
for (LightingSettings setting : cmdLight->settings)
|
||||
{
|
||||
writer->Write(setting.ambientClrR);
|
||||
writer->Write(setting.ambientClrG);
|
||||
writer->Write(setting.ambientClrB);
|
||||
|
||||
writer->Write(setting.diffuseClrA_R);
|
||||
writer->Write(setting.diffuseClrA_G);
|
||||
writer->Write(setting.diffuseClrA_B);
|
||||
|
||||
writer->Write(setting.diffuseDirA_X);
|
||||
writer->Write(setting.diffuseDirA_Y);
|
||||
writer->Write(setting.diffuseDirA_Z);
|
||||
|
||||
writer->Write(setting.diffuseClrB_R);
|
||||
writer->Write(setting.diffuseClrB_G);
|
||||
writer->Write(setting.diffuseClrB_B);
|
||||
|
||||
writer->Write(setting.diffuseDirB_X);
|
||||
writer->Write(setting.diffuseDirB_Y);
|
||||
writer->Write(setting.diffuseDirB_Z);
|
||||
|
||||
writer->Write(setting.fogClrR);
|
||||
writer->Write(setting.fogClrG);
|
||||
writer->Write(setting.fogClrB);
|
||||
|
||||
writer->Write(setting.unk);
|
||||
writer->Write(setting.drawDistance);
|
||||
}
|
||||
|
||||
writer->Seek(oldOffset, SeekOffsetType::Start);
|
||||
}
|
||||
break;
|
||||
case RoomCommand::SetRoomList:
|
||||
{
|
||||
SetRoomList* cmdRoom = (SetRoomList*)cmd;
|
||||
|
||||
writer->Write((uint8_t)cmdRoom->romfile->rooms.size()); // 0x01
|
||||
writer->Write((uint8_t)0); // 0x02
|
||||
writer->Write((uint8_t)0); // 0x03
|
||||
|
||||
auto baseStreamEnd = writer->GetLength();
|
||||
writer->Write(baseStreamEnd); // 0x04
|
||||
|
||||
uint32_t oldOffset = writer->GetBaseAddress();
|
||||
writer->Seek(baseStreamEnd, SeekOffsetType::Start);
|
||||
|
||||
for (const auto& entry : cmdRoom->romfile->rooms)
|
||||
{
|
||||
writer->Write(entry.virtualAddressStart);
|
||||
writer->Write(entry.virtualAddressEnd);
|
||||
}
|
||||
|
||||
writer->Seek(oldOffset, SeekOffsetType::Start);
|
||||
}
|
||||
break;
|
||||
case RoomCommand::SetCollisionHeader:
|
||||
{
|
||||
SetCollisionHeader* cmdCollHeader = (SetCollisionHeader*)cmd;
|
||||
|
||||
int streamEnd = writer->GetStream().get()->GetLength();
|
||||
|
||||
writer->Write((uint8_t)0); // 0x01
|
||||
writer->Write((uint8_t)0); // 0x02
|
||||
writer->Write((uint8_t)0); // 0x03
|
||||
writer->Write(streamEnd); // 0x04
|
||||
|
||||
// TODO: NOT DONE
|
||||
|
||||
uint32_t oldOffset = writer->GetBaseAddress();
|
||||
writer->Seek(streamEnd, SeekOffsetType::Start);
|
||||
|
||||
ExporterExample_Collision colExp = ExporterExample_Collision();
|
||||
|
||||
colExp.Save(cmdCollHeader->collisionHeader, outPath, writer);
|
||||
|
||||
writer->Seek(oldOffset, SeekOffsetType::Start);
|
||||
}
|
||||
break;
|
||||
case RoomCommand::SetEntranceList:
|
||||
{
|
||||
SetEntranceList* cmdEntrance = (SetEntranceList*)cmd;
|
||||
|
||||
uint32_t baseStreamEnd = writer->GetStream().get()->GetLength();
|
||||
|
||||
writer->Write((uint8_t)0); // 0x01
|
||||
writer->Write((uint8_t)0); // 0x02
|
||||
writer->Write((uint8_t)0); // 0x03
|
||||
writer->Write(baseStreamEnd); // 0x04
|
||||
|
||||
uint32_t oldOffset = writer->GetBaseAddress();
|
||||
writer->Seek(baseStreamEnd, SeekOffsetType::Start);
|
||||
|
||||
for (EntranceEntry entry : cmdEntrance->entrances)
|
||||
{
|
||||
writer->Write((uint8_t)entry.startPositionIndex);
|
||||
writer->Write((uint8_t)entry.roomToLoad);
|
||||
}
|
||||
|
||||
writer->Seek(oldOffset, SeekOffsetType::Start);
|
||||
}
|
||||
break;
|
||||
case RoomCommand::SetSpecialObjects:
|
||||
{
|
||||
SetSpecialObjects* cmdSpecObj = (SetSpecialObjects*)cmd;
|
||||
|
||||
writer->Write((uint8_t)cmdSpecObj->elfMessage); // 0x01
|
||||
writer->Write((uint8_t)0); // 0x02
|
||||
writer->Write((uint8_t)0); // 0x03
|
||||
writer->Write((uint8_t)0); // 0x04
|
||||
writer->Write((uint8_t)0); // 0x05
|
||||
writer->Write((uint16_t)cmdSpecObj->globalObject); // 0x06
|
||||
}
|
||||
break;
|
||||
case RoomCommand::SetStartPositionList:
|
||||
{
|
||||
SetStartPositionList* cmdStartPos = (SetStartPositionList*)cmd;
|
||||
|
||||
uint32_t baseStreamEnd = writer->GetStream().get()->GetLength();
|
||||
|
||||
writer->Write((uint8_t)cmdStartPos->actors.size()); // 0x01
|
||||
writer->Write((uint8_t)0); // 0x02
|
||||
writer->Write((uint8_t)0); // 0x03
|
||||
writer->Write(baseStreamEnd); // 0x04
|
||||
|
||||
uint32_t oldOffset = writer->GetBaseAddress();
|
||||
writer->Seek(baseStreamEnd, SeekOffsetType::Start);
|
||||
|
||||
for (ActorSpawnEntry entry : cmdStartPos->actors)
|
||||
{
|
||||
writer->Write(entry.actorNum);
|
||||
writer->Write(entry.posX);
|
||||
writer->Write(entry.posY);
|
||||
writer->Write(entry.posZ);
|
||||
writer->Write(entry.rotX);
|
||||
writer->Write(entry.rotY);
|
||||
writer->Write(entry.rotZ);
|
||||
writer->Write(entry.initVar);
|
||||
}
|
||||
|
||||
writer->Seek(oldOffset, SeekOffsetType::Start);
|
||||
}
|
||||
break;
|
||||
case RoomCommand::EndMarker:
|
||||
{
|
||||
writer->Write((uint8_t)0); // 0x01
|
||||
writer->Write((uint8_t)0); // 0x02
|
||||
writer->Write((uint8_t)0); // 0x03
|
||||
writer->Write((uint8_t)0); // 0x04
|
||||
writer->Write((uint8_t)0); // 0x05
|
||||
writer->Write((uint8_t)0); // 0x06
|
||||
writer->Write((uint8_t)0); // 0x07
|
||||
}
|
||||
break;
|
||||
default:
|
||||
printf("UNIMPLEMENTED COMMAND: %i\n", (int)cmd->cmdID);
|
||||
|
||||
writer->Write((uint8_t)0); // 0x01
|
||||
writer->Write((uint8_t)0); // 0x02
|
||||
writer->Write((uint8_t)0); // 0x03
|
||||
writer->Write((uint8_t)0); // 0x04
|
||||
writer->Write((uint8_t)0); // 0x05
|
||||
writer->Write((uint8_t)0); // 0x06
|
||||
writer->Write((uint8_t)0); // 0x07
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// writer->Close();
|
||||
// File::WriteAllBytes(StringHelper::Sprintf("%s", res->GetName().c_str()),
|
||||
// memStream->ToVector());
|
||||
}
|
10
ZAPDTR/ExporterTest/RoomExporter.h
Normal file
10
ZAPDTR/ExporterTest/RoomExporter.h
Normal file
|
@ -0,0 +1,10 @@
|
|||
#pragma once
|
||||
|
||||
#include "ZResource.h"
|
||||
#include "ZRoom/ZRoom.h"
|
||||
|
||||
class ExporterExample_Room : public ZResourceExporter
|
||||
{
|
||||
public:
|
||||
void Save(ZResource* res, fs::path outPath, BinaryWriter* writer) override;
|
||||
};
|
14
ZAPDTR/ExporterTest/TextureExporter.cpp
Normal file
14
ZAPDTR/ExporterTest/TextureExporter.cpp
Normal file
|
@ -0,0 +1,14 @@
|
|||
#include "TextureExporter.h"
|
||||
#include "../ZAPD/ZFile.h"
|
||||
|
||||
void ExporterExample_Texture::Save(ZResource* res, [[maybe_unused]] fs::path outPath,
|
||||
BinaryWriter* writer)
|
||||
{
|
||||
ZTexture* tex = (ZTexture*)res;
|
||||
|
||||
auto data = tex->parent->GetRawData();
|
||||
|
||||
for (offset_t i = tex->GetRawDataIndex(); i < tex->GetRawDataIndex() + tex->GetRawDataSize();
|
||||
i++)
|
||||
writer->Write(data[i]);
|
||||
}
|
11
ZAPDTR/ExporterTest/TextureExporter.h
Normal file
11
ZAPDTR/ExporterTest/TextureExporter.h
Normal file
|
@ -0,0 +1,11 @@
|
|||
#pragma once
|
||||
|
||||
#include "Utils/BinaryWriter.h"
|
||||
#include "ZResource.h"
|
||||
#include "ZTexture.h"
|
||||
|
||||
class ExporterExample_Texture : public ZResourceExporter
|
||||
{
|
||||
public:
|
||||
void Save(ZResource* res, fs::path outPath, BinaryWriter* writer) override;
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue