mirror of
https://github.com/aap/librw.git
synced 2025-12-18 16:39:51 +00:00
changed project structure, made VS projects, added d3d9 support and viewer, worked on xbox instancing
This commit is contained in:
142
tools/dumprwtree/dumprwtree.cpp
Normal file
142
tools/dumprwtree/dumprwtree.cpp
Normal file
@@ -0,0 +1,142 @@
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
#include <cassert>
|
||||
#include <new>
|
||||
|
||||
#include <rw.h>
|
||||
|
||||
using namespace std;
|
||||
using namespace rw;
|
||||
|
||||
const char *chunks[] = { "None", "Struct", "String", "Extension", "Unknown",
|
||||
"Camera", "Texture", "Material", "Material List", "Atomic Section",
|
||||
"Plane Section", "World", "Spline", "Matrix", "Frame List",
|
||||
"Geometry", "Clump", "Unknown", "Light", "Unicode String", "Atomic",
|
||||
"Texture Native", "Texture Dictionary", "Animation Database",
|
||||
"Image", "Skin Animation", "Geometry List", "Anim Animation",
|
||||
"Team", "Crowd", "Delta Morph Animation", "Right To Render",
|
||||
"MultiTexture Effect Native", "MultiTexture Effect Dictionary",
|
||||
"Team Dictionary", "Platform Independet Texture Dictionary",
|
||||
"Table of Contents", "Particle Standard Global Data", "AltPipe",
|
||||
"Platform Independet Peds", "Patch Mesh", "Chunk Group Start",
|
||||
"Chunk Group End", "UV Animation Dictionary", "Coll Tree"
|
||||
};
|
||||
|
||||
/* From 0x0101 through 0x0135 */
|
||||
const char *toolkitchunks0[] = { "Metrics PLG", "Spline PLG", "Stereo PLG",
|
||||
"VRML PLG", "Morph PLG", "PVS PLG", "Memory Leak PLG", "Animation PLG",
|
||||
"Gloss PLG", "Logo PLG", "Memory Info PLG", "Random PLG",
|
||||
"PNG Image PLG", "Bone PLG", "VRML Anim PLG", "Sky Mipmap Val",
|
||||
"MRM PLG", "LOD Atomic PLG", "ME PLG", "Lightmap PLG",
|
||||
"Refine PLG", "Skin PLG", "Label PLG", "Particles PLG", "GeomTX PLG",
|
||||
"Synth Core PLG", "STQPP PLG",
|
||||
"Part PP PLG", "Collision PLG", "HAnim PLG", "User Data PLG",
|
||||
"Material Effects PLG", "Particle System PLG", "Delta Morph PLG",
|
||||
"Patch PLG", "Team PLG", "Crowd PP PLG", "Mip Split PLG",
|
||||
"Anisotrophy PLG", "Not used", "GCN Material PLG", "Geometric PVS PLG",
|
||||
"XBOX Material PLG", "Multi Texture PLG", "Chain PLG", "Toon PLG",
|
||||
"PTank PLG", "Particle Standard PLG", "PDS PLG", "PrtAdv PLG",
|
||||
"Normal Map PLG", "ADC PLG", "UV Animation PLG"
|
||||
};
|
||||
|
||||
/* From 0x0180 through 0x01c1 */
|
||||
const char *toolkitchunks1[] = {
|
||||
"Character Set PLG", "NOHS World PLG", "Import Util PLG",
|
||||
"Slerp PLG", "Optim PLG", "TL World PLG", "Database PLG",
|
||||
"Raytrace PLG", "Ray PLG", "Library PLG",
|
||||
"Not used", "Not used", "Not used", "Not used", "Not used", "Not used",
|
||||
"2D PLG", "Tile Render PLG", "JPEG Image PLG", "TGA Image PLG",
|
||||
"GIF Image PLG", "Quat PLG", "Spline PVS PLG", "Mipmap PLG",
|
||||
"MipmapK PLG", "2D Font", "Intersection PLG", "TIFF Image PLG",
|
||||
"Pick PLG", "BMP Image PLG", "RAS Image PLG", "Skin FX PLG",
|
||||
"VCAT PLG", "2D Path", "2D Brush", "2D Object", "2D Shape", "2D Scene",
|
||||
"2D Pick Region", "2D Object String", "2D Animation PLG",
|
||||
"2D Animation",
|
||||
"Not used", "Not used", "Not used", "Not used", "Not used", "Not used",
|
||||
"2D Keyframe", "2D Maestro", "Barycentric",
|
||||
"Platform Independent Texture Dictionary TK", "TOC TK", "TPL TK",
|
||||
"AltPipe TK", "Animation TK", "Skin Split Tookit", "Compressed Key TK",
|
||||
"Geometry Conditioning PLG", "Wing PLG", "Generic Pipeline TK",
|
||||
"Lightmap Conversion TK", "Filesystem PLG", "Dictionary TK",
|
||||
"UV Animation Linear", "UV Animation Parameter"
|
||||
};
|
||||
|
||||
const char *RSchunks[] = { "Unused 1", "Unused 2", "Extra Normals",
|
||||
"Pipeline Set", "Unused 5", "Unused 6", "Specular Material",
|
||||
"Unused 8", "2dfx", "Extra Colors", "Collision Model",
|
||||
"Unused 12", "Environment Material", "Breakable", "Node Name",
|
||||
"Unused 16"
|
||||
};
|
||||
|
||||
const char*
|
||||
getChunkName(uint32 id)
|
||||
{
|
||||
switch(id){
|
||||
case 0x50E:
|
||||
return "Bin Mesh PLG";
|
||||
case 0x510:
|
||||
return "Native Data PLG";
|
||||
case 0x511:
|
||||
return "Vertex Format PLG";
|
||||
case 0xF21E:
|
||||
return "ZModeler Lock";
|
||||
}
|
||||
|
||||
if(id <= 45)
|
||||
return chunks[id];
|
||||
else if(id <= 0x0253F2FF && id >= 0x0253F2F0)
|
||||
return RSchunks[id-0x0253F2F0];
|
||||
else if(id <= 0x0135 && id >= 0x0101)
|
||||
return toolkitchunks0[id-0x0101];
|
||||
else if(id <= 0x01C0 && id >= 0x0181)
|
||||
return toolkitchunks1[id-0x0181];
|
||||
else
|
||||
return "Unknown";
|
||||
}
|
||||
|
||||
void
|
||||
readchunk(StreamFile *s, ChunkHeaderInfo *h, int level)
|
||||
{
|
||||
for(int i = 0; i < level; i++)
|
||||
printf(" ");
|
||||
const char *name = getChunkName(h->type);
|
||||
printf("%s (%x bytes @ 0x%x/0x%x) - [0x%x]\n",
|
||||
name, h->length, s->tell()-12, s->tell(), h->type);
|
||||
|
||||
uint32 end = s->tell() + h->length;
|
||||
while(s->tell() < end){
|
||||
ChunkHeaderInfo nh;
|
||||
readChunkHeaderInfo(s, &nh);
|
||||
if(nh.version == h->version && nh.build == h->build){
|
||||
readchunk(s, &nh, level+1);
|
||||
if(h->type == 0x510)
|
||||
s->seek(end, 0);
|
||||
}else{
|
||||
s->seek(h->length-12);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
if(argc < 2){
|
||||
fprintf(stderr, "usage: %s rwStreamFile\n", argv[0]);
|
||||
return 0;
|
||||
}
|
||||
StreamFile s;
|
||||
s.open(argv[1], "rb");
|
||||
|
||||
ChunkHeaderInfo header;
|
||||
readChunkHeaderInfo(&s, &header);
|
||||
if(argc == 2)
|
||||
readchunk(&s, &header, 0);
|
||||
|
||||
printf("%x %x %x\n", header.version, header.build,
|
||||
libraryIDPack(header.version, header.build));
|
||||
|
||||
s.close();
|
||||
return 0;
|
||||
}
|
||||
109
tools/dumprwtree/dumprwtree.vcxproj
Normal file
109
tools/dumprwtree/dumprwtree.vcxproj
Normal file
@@ -0,0 +1,109 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug - null|Win32">
|
||||
<Configuration>Debug - null</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>{B487F101-0C2B-4F99-A1E0-B0B0C0F3FE7E}</ProjectGuid>
|
||||
<RootNamespace>dumprwtree</RootNamespace>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v120</PlatformToolset>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug - null|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v120</PlatformToolset>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v120</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</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 Condition="'$(Configuration)|$(Platform)'=='Debug - null|Win32'" Label="PropertySheets">
|
||||
<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>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<IncludePath>$(VC_IncludePath);$(WindowsSDK_IncludePath);$(SolutionDir)</IncludePath>
|
||||
<LibraryPath>$(VC_LibraryPath_x86);$(WindowsSDK_LibraryPath_x86);$(SolutionDir)$(Configuration)\</LibraryPath>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug - null|Win32'">
|
||||
<IncludePath>$(VC_IncludePath);$(WindowsSDK_IncludePath);$(SolutionDir)</IncludePath>
|
||||
<LibraryPath>$(VC_LibraryPath_x86);$(WindowsSDK_LibraryPath_x86);$(SolutionDir)$(Configuration)\</LibraryPath>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<IncludePath>$(VC_IncludePath);$(WindowsSDK_IncludePath);$(SolutionDir)</IncludePath>
|
||||
<LibraryPath>$(VC_LibraryPath_x86);$(WindowsSDK_LibraryPath_x86);$(SolutionDir)$(Configuration)\</LibraryPath>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<AdditionalDependencies>librw.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug - null|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<AdditionalDependencies>librw.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<AdditionalDependencies>librw.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="dumprwtree.cpp" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
Reference in New Issue
Block a user