removed stuff thats now in librwgta

This commit is contained in:
aap 2016-02-06 18:17:25 +01:00
parent ef58d76bc0
commit 8c70df06e4
26 changed files with 0 additions and 5885 deletions

View File

@ -1,169 +0,0 @@
#include "math/math.h"
#include "camera.h"
using namespace std;
void
Camera::look(void)
{
projMat = Mat4::perspective(fov, aspectRatio, n, f);
viewMat = Mat4::lookat(position, target, up);
// state->mat4(PMAT,true)->val = Mat4::perspective(fov, aspectRatio, n, f);
// Mat4 mv = Mat4::lookat(position, target, up);
// state->mat4(MVMAT, true)->val = mv;
// state->mat3(NORMALMAT, true)->val = Mat3(mv);
}
void
Camera::setPosition(Vec3 q)
{
position = q;
}
Vec3
Camera::getPosition(void)
{
return position;
}
void
Camera::setTarget(Vec3 q)
{
position -= target - q;
target = q;
}
Vec3
Camera::getTarget(void)
{
return target;
}
float
Camera::getHeading(void)
{
Vec3 dir = target - position;
float a = atan2(dir.y, dir.x)-PI/2.0f;
return local_up.z < 0.0f ? a-PI : a;
}
void
Camera::turn(float yaw, float pitch)
{
yaw /= 2.0f;
pitch /= 2.0f;
Quat dir = Quat(target - position);
Quat r(cos(yaw), 0.0f, 0.0f, sin(yaw));
dir = r*dir*r.K();
local_up = Vec3(r*Quat(local_up)*r.K());
Quat right = dir.wedge(Quat(local_up)).U();
r = Quat(cos(pitch), right*sin(pitch));
dir = r*dir*r.K();
local_up = Vec3(right.wedge(dir).U());
if(local_up.z >=0) up.z = 1;
else up.z = -1;
target = position + Vec3(dir);
}
void
Camera::orbit(float yaw, float pitch)
{
yaw /= 2.0f;
pitch /= 2.0f;
Quat dir = Quat(target - position);
Quat r(cos(yaw), 0.0f, 0.0f, sin(yaw));
dir = r*dir*r.K();
local_up = Vec3(r*Quat(local_up)*r.K());
Quat right = dir.wedge(Quat(local_up)).U();
r = Quat(cos(-pitch), right*sin(-pitch));
dir = r*dir*r.K();
local_up = Vec3(right.wedge(dir).U());
if(local_up.z >=0) up.z = 1;
else up.z = -1;
position = target - Vec3(dir);
}
void
Camera::dolly(float dist)
{
Vec3 dir = (target - position).normalized()*dist;
position += dir;
target += dir;
}
void
Camera::zoom(float dist)
{
Vec3 dir = target - position;
float curdist = dir.norm();
if(dist >= curdist)
dist = curdist-0.01f;
dir = dir.normalized()*dist;
position += dir;
}
void
Camera::pan(float x, float y)
{
Vec3 dir = (target-position).normalized();
Vec3 right = dir.cross(up).normalized();
// Vec3 local_up = right.cross(dir).normalized();
dir = right*x + local_up*y;
position += dir;
target += dir;
}
float
Camera::sqDistanceTo(Vec3 q)
{
return (position - q).normsq();
}
float
Camera::distanceTo(Vec3 q)
{
return (position - q).norm();
}
void
Camera::setFov(float f)
{
fov = f;
}
float
Camera::getFov(void)
{
return fov;
}
void
Camera::setAspectRatio(float r)
{
aspectRatio = r;
}
void
Camera::setNearFar(float n, float f)
{
this->n = n;
this->f = f;
}
Camera::Camera()
{
position = Vec3(0.0f, 6.0f, 0.0f);
target = Vec3(0.0f, 0.0f, 0.0f);
local_up = up = Vec3(0.0f, 0.0f, 1.0f);
fov = 70.0f;
aspectRatio = 1.0f;
n = 0.1f;
f = 100.0f;
}

View File

@ -1,37 +0,0 @@
class Camera
{
private:
Vec3 position;
Vec3 target;
Vec3 up;
Vec3 local_up;
float fov, aspectRatio;
float n, f;
public:
Mat4 projMat;
Mat4 viewMat;
void setPosition(Vec3 q);
Vec3 getPosition(void);
void setTarget(Vec3 q);
Vec3 getTarget(void);
float getHeading(void);
void turn(float yaw, float pitch);
void orbit(float yaw, float pitch);
void dolly(float dist);
void zoom(float dist);
void pan(float x, float y);
void setFov(float f);
float getFov(void);
void setAspectRatio(float r);
void setNearFar(float n, float f);
void look(void);
float distanceTo(Vec3 q);
float sqDistanceTo(Vec3 q);
Camera(void);
};

View File

@ -1,211 +0,0 @@
<?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 - null|x64">
<Configuration>Debug - null</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{E5D477C8-4CAF-43BF-B7E3-6689503D469F}</ProjectGuid>
<RootNamespace>d3d9</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|x64'" 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)'=='Debug - null|x64'" 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>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" 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|x64'" Label="PropertySheets">
<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 Condition="'$(Configuration)|$(Platform)'=='Debug - null|x64'" 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>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
<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|x64'">
<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)'=='Debug - null|x64'">
<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>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<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>
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;RW_D3D9;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>d3d9.lib;winmm.lib;librw.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;RW_D3D9;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>d3d9.lib;winmm.lib;librw.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug - null|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;RW_D3D9;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>d3d9.lib;winmm.lib;librw.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug - null|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;RW_D3D9;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>d3d9.lib;winmm.lib;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>
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;RW_D3D9;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<AdditionalDependencies>d3d9.lib;winmm.lib;librw.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;RW_D3D9;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<AdditionalDependencies>d3d9.lib;winmm.lib;librw.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="camera.cpp" />
<ClCompile Include="d3dInit.cpp" />
<ClCompile Include="d3dUtility.cpp" />
<ClCompile Include="math.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="camera.h" />
<ClInclude Include="d3dUtility.h" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@ -1,391 +0,0 @@
#include "d3dUtility.h"
#include <DirectXMath.h>
using namespace DirectX;
#include <rw.h>
#include <src/gtaplg.h>
#include "math/math.h"
#include "camera.h"
IDirect3DDevice9 *Device = 0;
Camera *camera;
namespace rw {
namespace d3d {
void
createTexture(Texture *tex)
{
D3dRaster *raster = PLUGINOFFSET(D3dRaster, tex->raster, nativeRasterOffset);
int32 w, h;
w = tex->raster->width;
h = tex->raster->height;
assert((tex->raster->format & 0xF00) == Raster::C8888);
IDirect3DTexture9 *texture;
Device->CreateTexture(w, h, 1, 0, D3DFMT_A8R8G8B8, D3DPOOL_MANAGED, &texture, NULL);
D3DLOCKED_RECT lr;
texture->LockRect(0, &lr, 0, 0);
DWORD *dst = (DWORD*)lr.pBits;
uint8 *src = tex->raster->texels;
for(int i = 0; i < h; i++){
for(int j = 0; j < w; j++){
dst[j] = D3DCOLOR_ARGB(src[3], src[0], src[1], src[2]);
src += 4;
}
dst += lr.Pitch/4;
}
texture->UnlockRect(0);
raster->texture = texture;
raster->format = D3DFMT_A8R8G8B8;
}
void
setTexture(Texture *tex)
{
static DWORD filternomip[] = {
0, D3DTEXF_POINT, D3DTEXF_LINEAR,
D3DTEXF_POINT, D3DTEXF_LINEAR,
D3DTEXF_POINT, D3DTEXF_LINEAR
};
static DWORD wrap[] = {
0, D3DTADDRESS_WRAP, D3DTADDRESS_MIRROR,
D3DTADDRESS_CLAMP, D3DTADDRESS_BORDER
};
D3dRaster *raster = PLUGINOFFSET(D3dRaster, tex->raster, nativeRasterOffset);
if(tex->raster){
if(raster->texture == NULL)
createTexture(tex);
Device->SetTexture(0, (IDirect3DTexture9*)raster->texture);
Device->SetSamplerState(0, D3DSAMP_MAGFILTER, filternomip[tex->filterAddressing & 0xFF]);
Device->SetSamplerState(0, D3DSAMP_MINFILTER, filternomip[tex->filterAddressing & 0xFF]);
Device->SetSamplerState(0, D3DSAMP_ADDRESSU, wrap[(tex->filterAddressing >> 8) & 0xF]);
Device->SetSamplerState(0, D3DSAMP_ADDRESSV, wrap[(tex->filterAddressing >> 12) & 0xF]);
}else
Device->SetTexture(0, NULL);
}
void
setMaterial(Material *mat)
{
D3DMATERIAL9 mat9;
D3DCOLORVALUE black = { 0, 0, 0, 0 };
float ambmult = mat->surfaceProps.ambient/255.0f;
float diffmult = mat->surfaceProps.diffuse/255.0f;
mat9.Ambient.r = mat->color[0]*ambmult;
mat9.Ambient.g = mat->color[1]*ambmult;
mat9.Ambient.b = mat->color[2]*ambmult;
mat9.Ambient.a = mat->color[3]*ambmult;
mat9.Diffuse.r = mat->color[0]*diffmult;
mat9.Diffuse.g = mat->color[1]*diffmult;
mat9.Diffuse.b = mat->color[2]*diffmult;
mat9.Diffuse.a = mat->color[3]*diffmult;
mat9.Power = 0.0f;
mat9.Emissive = black;
mat9.Specular = black;
Device->SetMaterial(&mat9);
}
}
namespace d3d9 {
using namespace d3d;
void
drawAtomic(Atomic *atomic)
{
Geometry *geo = atomic->geometry;
if((geo->geoflags & Geometry::NATIVE) == 0)
return;
InstanceDataHeader *header = (InstanceDataHeader*)geo->instData;
atomic->frame->updateLTM();
Device->SetTransform(D3DTS_WORLD, (D3DMATRIX*)atomic->frame->ltm);
Device->SetStreamSource(0, (IDirect3DVertexBuffer9*)header->vertexStream[0].vertexBuffer,
0, header->vertexStream[0].stride);
Device->SetIndices((IDirect3DIndexBuffer9*)header->indexBuffer);
Device->SetVertexDeclaration((IDirect3DVertexDeclaration9*)header->vertexDeclaration);
InstanceData *inst = header->inst;
for(uint32 i = 0; i < header->numMeshes; i++){
if(inst->material->texture)
setTexture(inst->material->texture);
else
Device->SetTexture(0, NULL);
setMaterial(inst->material);
Device->SetRenderState(D3DRS_AMBIENT, D3DCOLOR_ARGB(0xFF, 0x40, 0x40, 0x40));
Device->SetRenderState(D3DRS_AMBIENTMATERIALSOURCE, D3DMCS_MATERIAL);
Device->SetRenderState(D3DRS_DIFFUSEMATERIALSOURCE, D3DMCS_MATERIAL);
if(geo->geoflags & Geometry::PRELIT)
Device->SetRenderState(D3DRS_EMISSIVEMATERIALSOURCE, D3DMCS_COLOR1);
Device->DrawIndexedPrimitive((D3DPRIMITIVETYPE)header->primType, inst->baseIndex,
0, inst->numVertices,
inst->startIndex, inst->numPrimitives);
inst++;
}
}
}
namespace d3d8 {
using namespace d3d;
void
drawAtomic(Atomic *atomic)
{
Geometry *geo = atomic->geometry;
if((geo->geoflags & Geometry::NATIVE) == 0)
return;
InstanceDataHeader *header = (InstanceDataHeader*)geo->instData;
atomic->frame->updateLTM();
Device->SetTransform(D3DTS_WORLD, (D3DMATRIX*)atomic->frame->ltm);
InstanceData *inst = header->inst;
for(uint32 i = 0; i < header->numMeshes; i++){
if(inst->material->texture)
setTexture(inst->material->texture);
else
Device->SetTexture(0, NULL);
setMaterial(inst->material);
Device->SetRenderState(D3DRS_AMBIENT, D3DCOLOR_ARGB(0xFF, 0x40, 0x40, 0x40));
Device->SetRenderState(D3DRS_AMBIENTMATERIALSOURCE, D3DMCS_MATERIAL);
Device->SetRenderState(D3DRS_DIFFUSEMATERIALSOURCE, D3DMCS_MATERIAL);
if(geo->geoflags & Geometry::PRELIT)
Device->SetRenderState(D3DRS_EMISSIVEMATERIALSOURCE, D3DMCS_COLOR1);
Device->SetFVF(inst->vertexShader);
Device->SetStreamSource(0, (IDirect3DVertexBuffer9*)inst->vertexBuffer, 0, inst->stride);
Device->SetIndices((IDirect3DIndexBuffer9*)inst->indexBuffer);
uint32 numPrim = inst->primType == D3DPT_TRIANGLESTRIP ? inst->numIndices-2 : inst->numIndices/3;
Device->DrawIndexedPrimitive((D3DPRIMITIVETYPE)inst->primType, inst->baseIndex,
0, inst->numVertices, 0, numPrim);
inst++;
}
}
}
}
rw::Clump *clump;
void (*renderCB)(rw::Atomic*) = NULL;
void
initrw(void)
{
gta::attachPlugins();
rw::d3d::registerNativeRaster();
rw::currentTexDictionary = new rw::TexDictionary;
//rw::Image::setSearchPath("D:\\rockstargames\\ps2\\gta3\\MODELS\\gta3_archive\\txd_extracted\\;"
// "D:\\rockstargames\\ps2\\gtavc\\MODELS\\gta3_archive\\txd_extracted\\;"
// "D:\\rockstargames\\ps2\\gtasa\\models\\gta3_archive\\txd_extracted\\");
rw::platform = rw::PLATFORM_D3D8;
rw::d3d::device = Device;
if(0){
char *filename = "D:\\rockstargames\\pc\\gtavc\\models\\gta3_archive\\admiral.txd";
rw::StreamFile in;
if(in.open(filename, "rb") == NULL){
MessageBox(0, "couldn't open file\n", 0, 0);
printf("couldn't open file\n");
}
rw::findChunk(&in, rw::ID_TEXDICTIONARY, NULL, NULL);
rw::TexDictionary *txd;
txd = rw::TexDictionary::streamRead(&in);
assert(txd);
in.close();
rw::currentTexDictionary = txd;
rw::StreamFile out;
out.open("out.txd", "wb");
txd->streamWrite(&out);
out.close();
}
// char *filename = "D:\\rockstargames\\pc\\gtavc\\models\\gta3_archive\\admiral.dff";
// char *filename = "D:\\rockstargames\\pc\\gta3\\models\\gta3_archive\\kuruma.dff";
// char *filename = "D:\\rockstargames\\pc\\gtavc\\models\\gta3_archive\\player.dff";
// char *filename = "D:\\rockstargames\\pc\\gtavc\\models\\gta3_archive\\od_newscafe_dy.dff";
// char *filename = "D:\\rockstargames\\pc\\gtasa\\models\\gta3_archive\\admiral.dff";
char *filename = "D:\\rockstargames\\pc\\gtasa\\models\\gta3_archive\\lae2_roads89.dff";
// char *filename = "D:\\rockstargames\\pc\\gtasa\\models\\gta3_archive\\casinoblock41_nt.dff";
// char *filename = "D:\\rockstargames\\pc\\gtasa\\models\\cutscene_archive\\csremington92.dff";
// char *filename = "C:\\gtasa\\test\\hanger.dff";
// char *filename = "C:\\Users\\aap\\Desktop\\tmp\\out.dff";
// char *filename = "out2.dff";
// char *filename = "C:\\Users\\aap\\src\\librw\\tools\\insttest\\out.dff";
rw::StreamFile in;
if(in.open(filename, "rb") == NULL){
MessageBox(0, "couldn't open file\n", 0, 0);
printf("couldn't open file\n");
}
rw::findChunk(&in, rw::ID_CLUMP, NULL, NULL);
clump = rw::Clump::streamRead(&in);
assert(clump);
in.close();
for(int i = 0; i < clump->numAtomics; i++){
rw::Atomic *a = clump->atomicList[i];
if(a->pipeline && a->pipeline->platform == rw::PLATFORM_PS2)
a->pipeline = NULL;
a->getPipeline()->instance(a);
}
if(rw::platform == rw::PLATFORM_D3D8)
renderCB = rw::d3d8::drawAtomic;
else if(rw::platform == rw::PLATFORM_D3D9)
renderCB = rw::d3d9::drawAtomic;
rw::StreamFile out;
out.open("out.dff", "wb");
clump->streamWrite(&out);
out.close();
}
bool
Setup()
{
D3DLIGHT9 light;
light.Type = D3DLIGHT_DIRECTIONAL;
light.Diffuse = { 0.8f, 0.8f, 0.8f, 1.0f };
light.Specular = { 0.0f, 0.0f, 0.0f, 0.0f };
light.Ambient = { 0.0f, 0.0f, 0.0f, 0.0f };
light.Position = { 0.0f, 0.0f, 0.0f };
light.Direction = { 0.0f, 0.0f, -1.0f };
light.Range = 0.0f;
light.Falloff = 0.0f;
light.Attenuation0 = 0.0f;
light.Attenuation1 = 0.0f;
light.Attenuation2 = 0.0f;
light.Theta = 0.0f;
light.Phi = 0.0f;
initrw();
Device->SetRenderState(D3DRS_LIGHTING, true);
Device->SetLight(0, &light);
Device->LightEnable(0, 1);
Device->SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE);
Device->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
Device->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA);
Device->SetRenderState(D3DRS_ALPHABLENDENABLE, 1);
Device->SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_MODULATE);
camera = new Camera;
camera->setAspectRatio(640.0f/480.0f);
camera->setNearFar(0.1f, 450.0f);
camera->setTarget(Vec3(0.0f, 0.0f, 0.0f));
// camera->setPosition(Vec3(0.0f, 5.0f, 0.0f));
// camera->setPosition(Vec3(0.0f, -70.0f, 0.0f));
camera->setPosition(Vec3(0.0f, -10.0f, 0.0f));
// camera->setPosition(Vec3(0.0f, -1.0f, 3.0f));
return true;
}
void
Cleanup()
{
}
bool
Display(float timeDelta)
{
if(Device == NULL)
return true;
Device->Clear(0, 0, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER,
0xff808080, 1.0f, 0);
Device->BeginScene();
camera->look();
Device->SetTransform(D3DTS_VIEW, (D3DMATRIX*)camera->viewMat.cr);
Device->SetTransform(D3DTS_PROJECTION, (D3DMATRIX*)camera->projMat.cr);
for(rw::int32 i = 0; i < clump->numAtomics; i++){
char *name = PLUGINOFFSET(char, clump->atomicList[i]->frame,
gta::nodeNameOffset);
if(strstr(name, "_dam") || strstr(name, "_vlo"))
continue;
renderCB(clump->atomicList[i]);
}
Device->EndScene();
Device->Present(0, 0, 0, 0);
return true;
}
LRESULT CALLBACK
d3d::WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
switch(msg){
case WM_DESTROY:
PostQuitMessage(0);
break;
case WM_KEYDOWN:
switch(wParam){
case 'W':
camera->orbit(0.0f, 0.1f);
break;
case 'S':
camera->orbit(0.0f, -0.1f);
break;
case 'A':
camera->orbit(-0.1f, 0.0f);
break;
case 'D':
camera->orbit(0.1f, 0.0f);
break;
case 'R':
camera->zoom(0.1f);
break;
case 'F':
camera->zoom(-0.1f);
break;
case VK_ESCAPE:
DestroyWindow(hwnd);
break;
}
break;
case WM_CLOSE:
DestroyWindow(hwnd);
break;
}
return DefWindowProc(hwnd, msg, wParam, lParam);
}
int WINAPI
WinMain(HINSTANCE hinstance, HINSTANCE prevInstance,
PSTR cmdLine, int showCmd)
{
/* AllocConsole();
freopen("CONIN$", "r", stdin);
freopen("CONOUT$", "w", stdout);
freopen("CONOUT$", "w", stderr);*/
if(!d3d::InitD3D(hinstance, 640, 480, true, D3DDEVTYPE_HAL, &Device)){
MessageBox(0, "InitD3D() - FAILED", 0, 0);
return 0;
}
if(!Setup()){
MessageBox(0, "Setup() - FAILED", 0, 0);
return 0;
}
d3d::EnterMsgLoop(Display);
Cleanup();
Device->Release();
return 0;
}

View File

@ -1,111 +0,0 @@
#include "d3dUtility.h"
bool
d3d::InitD3D(HINSTANCE hInstance,
int width, int height,
bool windowed,
D3DDEVTYPE deviceType,
IDirect3DDevice9 **device)
{
WNDCLASS wc;
wc.style = CS_HREDRAW | CS_VREDRAW;
wc.lpfnWndProc = (WNDPROC)d3d::WndProc;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = hInstance;
wc.hIcon = LoadIcon(0, IDI_APPLICATION);
wc.hCursor = LoadCursor(0, IDC_ARROW);
wc.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
wc.lpszMenuName = 0;
wc.lpszClassName = "Direct3D9App";
if(!RegisterClass(&wc)){
MessageBox(0, "RegisterClass() - FAILED", 0, 0);
return false;
}
HWND hwnd = 0;
hwnd = CreateWindow("Direct3D9App", "Direct3D9App",
WS_BORDER | WS_CAPTION | WS_SYSMENU |
WS_MINIMIZEBOX | WS_MAXIMIZEBOX,
0, 0, width, height, 0, 0, hInstance, 0);
if(!hwnd){
MessageBox(0, "CreateWindow() - FAILED", 0, 0);
return false;
}
ShowWindow(hwnd, SW_SHOW);
UpdateWindow(hwnd);
HRESULT hr = 0;
IDirect3D9 *d3d9 = 0;
d3d9 = Direct3DCreate9(D3D_SDK_VERSION);
if(!d3d9){
MessageBox(0, "Direct3DCreate9() - FAILED", 0, 0);
return false;
}
D3DCAPS9 caps;
d3d9->GetDeviceCaps(D3DADAPTER_DEFAULT, deviceType, &caps);
int vp = 0;
if(caps.DevCaps & D3DDEVCAPS_HWTRANSFORMANDLIGHT)
vp = D3DCREATE_HARDWARE_VERTEXPROCESSING;
else
vp = D3DCREATE_SOFTWARE_VERTEXPROCESSING;
D3DPRESENT_PARAMETERS d3dpp;
d3dpp.BackBufferWidth = width;
d3dpp.BackBufferHeight = height;
d3dpp.BackBufferFormat = D3DFMT_A8R8G8B8;
d3dpp.BackBufferCount = 1;
d3dpp.MultiSampleType = D3DMULTISAMPLE_NONE;
d3dpp.MultiSampleQuality = 0;
d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
d3dpp.hDeviceWindow = hwnd;
d3dpp.Windowed = windowed;
d3dpp.EnableAutoDepthStencil = true;
d3dpp.AutoDepthStencilFormat = D3DFMT_D24S8;
d3dpp.Flags = 0;
d3dpp.FullScreen_RefreshRateInHz = D3DPRESENT_RATE_DEFAULT;
d3dpp.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE;
hr = d3d9->CreateDevice(D3DADAPTER_DEFAULT, deviceType, hwnd,
vp, &d3dpp, device);
if(FAILED(hr)){
// try again using a 16-bit depth buffer
d3dpp.AutoDepthStencilFormat = D3DFMT_D16;
hr = d3d9->CreateDevice(D3DADAPTER_DEFAULT, deviceType,
hwnd, vp, &d3dpp, device);
if(FAILED(hr)){
d3d9->Release();
MessageBox(0, "CreateDevice() - FAILED", 0, 0);
return false;
}
}
d3d9->Release();
return true;
}
int
d3d::EnterMsgLoop(bool (*ptr_display)(float timeDelta))
{
MSG msg;
ZeroMemory(&msg, sizeof(MSG));
static float lastTime = (float)timeGetTime();
while(msg.message != WM_QUIT){
if(PeekMessage(&msg, 0, 0, 0, PM_REMOVE)){
TranslateMessage(&msg);
DispatchMessage(&msg);
}else{
float currTime = (float)timeGetTime();
float timeDelta = (currTime - lastTime)*0.001f;
ptr_display(timeDelta);
lastTime = currTime;
}
}
return msg.wParam;
}

View File

@ -1,31 +0,0 @@
#include <d3d9.h>
#include <string>
namespace d3d
{
bool InitD3D(HINSTANCE hInstance, int width, int height, bool windowed,
D3DDEVTYPE deviceType, IDirect3DDevice9 **device);
int EnterMsgLoop(bool (*ptr_display)(float timeDelta));
LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
/*
template<class T> void Release(T t)
{
if(t){
t->Release();
t = 0;
}
}
template<class T> void Delete(T t)
{
if(t){
delete t;
t = 0;
}
}
*/
}

File diff suppressed because it is too large Load Diff

View File

@ -1,93 +0,0 @@
#ifndef MATH_CONVERSION_H
#define MATH_CONVERSION_H
Vec3::Vec3(const Vec4 &v)
: x(v.x), y(v.y), z(v.z)
{
}
Vec3::Vec3(const Quat &q)
: x(q.x), y(q.y), z(q.z)
{
}
Vec4::Vec4(const Vec3 &v, float w)
: x(v.x), y(v.y), z(v.z), w(w)
{
}
Vec4::Vec4(const Quat &q)
: x(q.x), y(q.y), z(q.z), w(q.w)
{
}
Quat::Quat(const Vec3 &v)
: x(v.x), y(v.y), z(v.z)
{
}
Quat::Quat(float w, const Vec3 &v)
: w(w), x(v.x), y(v.y), z(v.z)
{
}
Quat::Quat(const Vec4 &v)
: w(v.w), x(v.x), y(v.y), z(v.z)
{
}
Mat3::Mat3(const Mat4 &m)
{
for(int i = 0; i < 3; i++)
for(int j = 0; j < 3; j++)
this->e[i][j] = m.e[i][j];
}
Mat4::Mat4(const Mat3 &m)
{
for(int i = 0; i < 3; i++)
for(int j = 0; j < 3; j++)
this->e[i][j] = m.e[i][j];
this->e[0][3] = 0.0f;
this->e[1][3] = 0.0f;
this->e[2][3] = 0.0f;
this->e[3][3] = 1.0f;
this->e[3][2] = 0.0f;
this->e[3][1] = 0.0f;
this->e[3][0] = 0.0f;
}
Mat4
Mat4::rotation(const Quat &v)
{
Mat4 m(1.0f);
m.e[0][0] = v.w*v.w + v.x*v.x - v.y*v.y - v.z*v.z;
m.e[1][0] = 2*v.x*v.y - 2*v.w*v.z;
m.e[2][0] = 2*v.w*v.y + 2*v.x*v.z;
m.e[0][1] = 2*v.w*v.z + 2*v.x*v.y;
m.e[1][1] = v.w*v.w - v.x*v.x + v.y*v.y - v.z*v.z;
m.e[2][1] = 2*v.y*v.z - 2*v.w*v.x;
m.e[0][2] = 2*v.x*v.z - 2*v.w*v.y;
m.e[1][2] = 2*v.w*v.x + 2*v.y*v.z;
m.e[2][2] = v.w*v.w - v.x*v.x - v.y*v.y + v.z*v.z;
return m;
}
Mat3
Mat3::rotation(const Quat &v)
{
Mat3 m(1.0f);
m.e[0][0] = v.w*v.w + v.x*v.x - v.y*v.y - v.z*v.z;
m.e[1][0] = 2*v.x*v.y - 2*v.w*v.z;
m.e[2][0] = 2*v.w*v.y + 2*v.x*v.z;
m.e[0][1] = 2*v.w*v.z + 2*v.x*v.y;
m.e[1][1] = v.w*v.w - v.x*v.x + v.y*v.y - v.z*v.z;
m.e[2][1] = 2*v.y*v.z - 2*v.w*v.x;
m.e[0][2] = 2*v.x*v.z - 2*v.w*v.y;
m.e[1][2] = 2*v.w*v.x + 2*v.y*v.z;
m.e[2][2] = v.w*v.w - v.x*v.x - v.y*v.y + v.z*v.z;
return m;
}
#endif

View File

@ -1,45 +0,0 @@
#ifndef MATH_DQUAT_H
#define MATH_DQUAT_H
#include <iostream>
#include <cmath>
class Vec3;
class Vec4;
class DQuat {
public:
Quat q1, q2;
DQuat(void);
DQuat(const Quat &q1, const Quat &q2);
DQuat operator-(void) const;
DQuat operator+(const DQuat &rhs) const;
DQuat operator-(const DQuat &rhs) const;
DQuat operator*(const DQuat &rhs) const;
DQuat operator*(float rhs) const;
DQuat operator/(float rhs) const;
DQuat &operator+=(const DQuat &rhs);
DQuat &operator-=(const DQuat &rhs);
DQuat &operator*=(const DQuat &rhs);
DQuat &operator*=(float rhs);
DQuat &operator/=(float rhs);
bool operator==(const DQuat &rhs) const;
bool operator!=(const DQuat &rhs) const;
// DQuat inv(void) const;
DQuat K(void) const; /* conjugate */
// DQuat S(void) const; /* scalar */
// DQuat V(void) const; /* vector */
// float T(void) const; /* tensor */
// float N(void) const; /* norm = tensor^2 */
// DQuat U(void) const; /* versor */
// DQuat wedge(const Quat &rhs) const;
// float inner(const Quat &rhs) const;
// DQuat slerp(const Quat &rhs, float t) const;
void print(std::ostream &of) const;
};
#endif

View File

@ -1,43 +0,0 @@
#ifndef MATH_MATRIX3_H
#define MATH_MATRIX3_H
#include <iostream>
#include <cmath>
class Mat4;
class Mat3 {
public:
union {
float e[3][3];
float cr[9];
};
Mat3(void);
Mat3(float f);
Mat3(float *f);
Mat3(float e00, float e10, float e20,
float e01, float e11, float e21,
float e02, float e12, float e22);
Mat3(const Mat4 &m);
float *ptr(void);
static Mat3 rotation(float theta, const Vec3 &v);
static Mat3 rotation(const Quat &v);
static Mat3 scale(const Vec3 &v);
Mat3 transpose(void) const;
Mat3 operator+(const Mat3 &rhs) const;
Mat3 operator-(const Mat3 &rhs) const;
Mat3 operator*(float rhs) const;
Mat3 operator/(float rhs) const;
Mat3 operator*(const Mat3 &rhs) const;
Vec3 operator*(const Vec3 &rhs) const;
Mat3 &operator+=(const Mat3 &rhs);
Mat3 &operator-=(const Mat3 &rhs);
Mat3 &operator*=(float rhs);
Mat3 &operator/=(float rhs);
Mat3 &operator*=(const Mat3 &rhs);
void print(std::ostream &of) const;
};
#endif

View File

@ -1,52 +0,0 @@
#ifndef MATH_MATRIX4_H
#define MATH_MATRIX4_H
#include <iostream>
#include <cmath>
class Mat3;
class Mat4 {
public:
union {
float e[4][4];
float cr[16];
};
Mat4(void);
Mat4(float f);
Mat4(float *f);
Mat4(float e00, float e10, float e20, float e30,
float e01, float e11, float e21, float e31,
float e02, float e12, float e22, float e32,
float e03, float e13, float e23, float e33);
Mat4(const Mat3 &m);
float *ptr(void);
static Mat4 perspective(float fov, float aspect, float n, float f);
static Mat4 frustum(float l, float r, float b, float t,
float n, float f);
static Mat4 ortho(float l, float r, float b, float t,
float n, float f);
static Mat4 lookat(const Vec3 &pos, const Vec3 &target, const Vec3 &up);
static Mat4 translation(const Vec3 &v);
static Mat4 rotation(float theta, const Vec3 &v);
static Mat4 rotation(const Quat &q);
static Mat4 transrot(const DQuat &q);
static Mat4 scale(const Vec3 &v);
Mat4 transpose(void) const;
Mat4 operator+(const Mat4 &rhs) const;
Mat4 operator-(const Mat4 &rhs) const;
Mat4 operator*(float rhs) const;
Mat4 operator/(float rhs) const;
Mat4 operator*(const Mat4 &rhs) const;
Vec4 operator*(const Vec4 &rhs) const;
Mat4 &operator+=(const Mat4 &rhs);
Mat4 &operator-=(const Mat4 &rhs);
Mat4 &operator*=(float rhs);
Mat4 &operator/=(float rhs);
Mat4 &operator*=(const Mat4 &rhs);
void print(std::ostream &of) const;
};
#endif

View File

@ -1,21 +0,0 @@
#ifndef MATH_H
#define MATH_H
#include "vec3.h"
#include "vec4.h"
#include "quat.h"
#include "dquat.h"
#include "mat3.h"
#include "mat4.h"
std::ostream &operator<<(std::ostream& of, const Vec3 &v);
std::ostream &operator<<(std::ostream& of, const Vec4 &v);
std::ostream &operator<<(std::ostream& of, const Quat &v);
std::ostream &operator<<(std::ostream& of, const DQuat &v);
std::ostream &operator<<(std::ostream& of, const Mat3 &v);
std::ostream &operator<<(std::ostream& of, const Mat4 &v);
#define PI 3.14159265359f
#endif

View File

@ -1,54 +0,0 @@
#ifndef MATH_QUAT_H
#define MATH_QUAT_H
#include <iostream>
#include <cmath>
class Vec3;
class Vec4;
class Mat3;
/* Hamilton style */
class Quat {
public:
float w, x, y, z;
Quat(void);
Quat(float w);
Quat(float x, float y, float z);
Quat(float w, float x, float y, float z);
Quat(float w, const Vec3 &v);
Quat(const Vec3 &v);
Quat(const Vec4 &v);
Quat(const Mat3 &m);
float *ptr(void);
Quat operator-(void) const;
Quat operator+(const Quat &rhs) const;
Quat operator-(const Quat &rhs) const;
Quat operator*(const Quat &rhs) const;
Quat operator*(float rhs) const;
Quat operator/(float rhs) const;
Quat &operator+=(const Quat &rhs);
Quat &operator-=(const Quat &rhs);
Quat &operator*=(const Quat &rhs);
Quat &operator*=(float rhs);
Quat &operator/=(float rhs);
bool operator==(const Quat &rhs) const;
bool operator!=(const Quat &rhs) const;
Quat inv(void) const;
Quat K(void) const; /* conjugate */
Quat S(void) const; /* scalar */
Quat V(void) const; /* vector */
float T(void) const; /* tensor */
float N(void) const; /* norm = tensor^2 */
Quat U(void) const; /* versor */
Quat wedge(const Quat &rhs) const;
float inner(const Quat &rhs) const;
Quat lerp(const Quat &rhs, float t) const;
Quat slerp(const Quat &rhs, float t) const;
void print(std::ostream &of) const;
};
#endif

View File

@ -1,40 +0,0 @@
#ifndef MATH_VECTOR3_H
#define MATH_VECTOR3_H
#include <iostream>
#include <cmath>
class Vec4;
class Quat;
class Vec3 {
public:
float x, y, z;
Vec3(void);
Vec3(float x, float y, float z);
Vec3(float *v);
Vec3(const Vec4 &v);
Vec3(const Quat &q);
float *ptr(void);
Vec3 operator-(void) const;
Vec3 operator+(const Vec3 &rhs) const;
Vec3 operator-(const Vec3 &rhs) const;
Vec3 operator*(float rhs) const;
Vec3 operator/(float rhs) const;
Vec3 &operator+=(const Vec3 &rhs);
Vec3 &operator-=(const Vec3 &rhs);
Vec3 &operator*=(float rhs);
Vec3 &operator/=(float rhs);
bool operator==(const Vec3 &rhs) const;
bool operator!=(const Vec3 &rhs) const;
float norm(void) const;
float normsq(void) const;
Vec3 normalized(void) const;
float dot(const Vec3 &rhs) const;
Vec3 cross(const Vec3 &rhs) const;
void print(std::ostream &of) const;
};
#endif

View File

@ -1,39 +0,0 @@
#ifndef MATH_VECTOR4_H
#define MATH_VECTOR4_H
#include <iostream>
#include <cmath>
class Vec3;
class Quat;
class Vec4 {
public:
float x, y, z, w;
Vec4(void);
Vec4(float x, float y, float z, float w);
Vec4(float *v);
Vec4(const Vec3 &v, float w = 0.0f);
Vec4(const Quat &w);
float *ptr(void);
Vec4 operator-(void) const;
Vec4 operator+(const Vec4 &rhs) const;
Vec4 operator-(const Vec4 &rhs) const;
Vec4 operator*(float rhs) const;
Vec4 operator/(float rhs) const;
Vec4 &operator+=(const Vec4 &rhs);
Vec4 &operator-=(const Vec4 &rhs);
Vec4 &operator*=(float rhs);
Vec4 &operator/=(float rhs);
bool operator==(const Vec4 &rhs) const;
bool operator!=(const Vec4 &rhs) const;
float norm(void) const;
float normsq(void) const;
Vec4 normalized(void) const;
float dot(const Vec4 &rhs) const;
void print(std::ostream &of) const;
};
#endif

View File

@ -1,120 +0,0 @@
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <ctype.h>
#include <new>
#include <rw.h>
#include <src/gtaplg.h>
using namespace std;
using namespace rw;
int
main(int argc, char *argv[])
{
// rw::version = 0x31000;
// rw::build = 0;
// rw::version = 0;
// rw::version = 0x32000;
rw::version = 0x33002;
rw::platform = PLATFORM_D3D8;
// rw::version = 0x30200;
gta::attachPlugins();
rw::Clump *c;
if(argc < 2){
printf("usage: %s input.dff [output.dff]\n", argv[0]);
return 0;
}
// rw::StreamFile in;
// in.open(argv[1], "rb");
ChunkHeaderInfo header;
if(0){
FILE *cf = fopen(argv[1], "rb");
assert(cf != NULL);
fseek(cf, 0, SEEK_END);
rw::uint32 len = ftell(cf);
fseek(cf, 0, SEEK_SET);
rw::uint8 *data = new rw::uint8[len];
fread(data, len, 1, cf);
fclose(cf);
rw::StreamMemory in;
in.open(data, len);
rw::findChunk(&in, rw::ID_CLUMP, NULL, NULL);
rw::debugFile = argv[1];
c = rw::Clump::streamRead(&in);
assert(c != NULL);
in.close();
delete[] data;
}else{
rw::StreamFile in;
if(in.open(argv[1], "rb") == NULL){
printf("couldn't open file\n");
return 1;
}
debugFile = argv[1];
readChunkHeaderInfo(&in, &header);
if(header.type == ID_UVANIMDICT){
UVAnimDictionary *dict = UVAnimDictionary::streamRead(&in);
currentUVAnimDictionary = dict;
readChunkHeaderInfo(&in, &header);
}
assert(header.type == ID_CLUMP);
c = Clump::streamRead(&in);
assert(c != NULL);
}
if(rw::version == 0){
rw::version = header.version;
rw::build = header.build;
}
// rw::Image::setSearchPath("./;/home/aap/gamedata/ps2/gtavc/MODELS/gta3_archive/txd_extracted/");
/*
// rw::Image *tga = rw::readTGA("b.tga");
rw::Image *tga = rw::readTGA("player.tga");
assert(tga != NULL);
rw::writeTGA(tga, "out.tga");
*/
// for(rw::int32 i = 0; i < c->numAtomics; i++)
// rw::Gl::Instance(c->atomicList[i]);
if(0){
uint8 *data = new rw::uint8[1024*1024];
rw::StreamMemory out;
out.open(data, 0, 1024*1024);
c->streamWrite(&out);
FILE *cf = fopen(argv[2], "wb");
assert(cf != NULL);
fwrite(data, out.getLength(), 1, cf);
fclose(cf);
out.close();
delete[] data;
}else{
rw::StreamFile out;
if(argc > 2)
out.open(argv[2], "wb");
else
out.open("out.dff", "wb");
c->streamWrite(&out);
out.close();
}
delete c;
return 0;
}

View File

@ -1,212 +0,0 @@
<?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 - null|x64">
<Configuration>Debug - null</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{85F56A7D-6EA2-4B9B-806A-87AF6C577FDF}</ProjectGuid>
<RootNamespace>dffwrite</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|x64'" 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)'=='Debug - null|x64'" 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>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" 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|x64'" Label="PropertySheets">
<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 Condition="'$(Configuration)|$(Platform)'=='Debug - null|x64'" 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>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
<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|x64'">
<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)'=='Debug - null|x64'">
<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>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<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>
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>librw.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</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>
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>librw.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
<PostBuildEvent>
<Command>copy /y "$(TargetPath)" "C:\Users\aap\bin\"</Command>
</PostBuildEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug - null|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>librw.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
<PostBuildEvent>
<Command>copy /y "$(TargetPath)" "C:\Users\aap\bin\"</Command>
</PostBuildEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<AdditionalDependencies>librw.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<AdditionalDependencies>librw.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="dffwrite.cpp" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@ -1,16 +0,0 @@
# null, opengl
BUILD=null
# e.g. null -> -DRW_NULL
BUILDDEF:=$(shell echo $(BUILD) | tr a-z A-Z | sed 's/^/-DRW_/')
SRC := insttest.cpp
OUT := insttest
INC := -I/usr/local/include -I../..
CFLAGS=-Wall -Wextra -g $(BUILDDEF) -Wno-parentheses -Wno-write-strings #-Wconversion
LIB=../../librw-$(BUILD).a
$(OUT): $(SRC) $(LIB)
$(CXX) $(CFLAGS) $(INC) $(SRC) $(LIB) -o $(OUT)
clean:
rm -f $(OUT)

View File

@ -1,265 +0,0 @@
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <rw.h>
#include <args.h>
#include <src/gtaplg.h>
using namespace std;
using namespace rw;
static struct {
char *str;
uint32 val;
} platforms[] = {
{ "mobile", PLATFORM_OGL },
{ "ps2", PLATFORM_PS2 },
{ "xbox", PLATFORM_XBOX },
{ "d3d8", PLATFORM_D3D8 },
{ "d3d9", PLATFORM_D3D9 },
{ NULL, 0 }
};
char *argv0;
void
usage(void)
{
fprintf(stderr, "usage: %s [-u] [-i] [-s] [-v version] [-o platform] in.dff [out.dff]\n", argv0);
fprintf(stderr, "\t-u uninstance\n");
fprintf(stderr, "\t-i instance\n");
fprintf(stderr, "\t-v RW version, e.g. 33004 for 3.3.0.4\n");
fprintf(stderr, "\t-o output platform. ps2, xbox, mobile, d3d8, d3d9\n");
exit(1);
}
void
dumpUVAnim(Animation *anim)
{
UVAnimCustomData *cust = (UVAnimCustomData*)anim->customData;
printf(" %s", cust->name);
for(int i = 0; i < 8; i++)
printf(" %d", cust->nodeToUVChannel[i]);
printf("\n %d %x\n", anim->numFrames, anim->interpInfo->id);
UVAnimKeyFrame *kf = (UVAnimKeyFrame*)anim->keyframes;
for(int i = 0; i < anim->numFrames; i++){
printf(" %f\n", kf->time);
printf(" %f %f %f %f %f %f\n", kf->uv[0], kf->uv[1], kf->uv[2], kf->uv[3], kf->uv[4], kf->uv[5]);
kf++;
}
}
void
dumpFrameHier(Frame *frame, int ind = 0)
{
for(int i = 0; i < ind; i++)
printf(" ");
char *name = gta::getNodeName(frame);
HAnimData *hanim = HAnimData::get(frame);
printf("*%s %d %d %s\n", name[0] ? name : "---", frame->objectList.count(), hanim->id, hanim->hierarchy ? "HIERARCHY" : "");
if(hanim->hierarchy){
HAnimHierarchy *h = hanim->hierarchy;
for(int i = 0; i < h->numNodes; i++){
name = h->nodeInfo[i].frame ? gta::getNodeName(h->nodeInfo[i].frame) : "";
printf("\t\t%d %d\t%p %s\n", h->nodeInfo[i].id, h->nodeInfo[i].flags, h->nodeInfo[i].frame, name);
{
h->nodeInfo[i].frame->updateLTM();
float *mat = h->nodeInfo[i].frame->ltm;
printf("[ [ %8.4f, %8.4f, %8.4f, %8.4f ]\n"
" [ %8.4f, %8.4f, %8.4f, %8.4f ]\n"
" [ %8.4f, %8.4f, %8.4f, %8.4f ]\n"
" [ %8.4f, %8.4f, %8.4f, %8.4f ] ]\n",
mat[0], mat[4], mat[8], mat[12],
mat[1], mat[5], mat[9], mat[13],
mat[2], mat[6], mat[10], mat[14],
mat[3], mat[7], mat[11], mat[15]);
}
}
}
for(Frame *child = frame->child;
child; child = child->next)
dumpFrameHier(child, ind+1);
}
int
main(int argc, char *argv[])
{
gta::attachPlugins();
rw::version = 0;
// rw::version = 0x34003;
// rw::version = 0x33002;
// rw::platform = rw::PLATFORM_PS2;
// rw::platform = rw::PLATFORM_OGL;
// rw::platform = rw::PLATFORM_XBOX;
rw::platform = rw::PLATFORM_D3D8;
// rw::platform = rw::PLATFORM_D3D9;
int uninstance = 0;
int instance = 0;
int outplatform = rw::PLATFORM_D3D8;
char *s;
ARGBEGIN{
case 'u':
uninstance++;
break;
case 'i':
instance++;
break;
case 'v':
sscanf(EARGF(usage()), "%x", &rw::version);
break;
case 'o':
s = EARGF(usage());
for(int i = 0; platforms[i].str; i++){
if(strcmp(platforms[i].str, s) == 0){
outplatform = platforms[i].val;
goto found;
}
}
printf("unknown platform %s\n", s);
outplatform = PLATFORM_D3D8;
found:
break;
default:
usage();
}ARGEND;
if(uninstance && instance){
fprintf(stderr, "cannot both instance and uninstance, choose one!\n");
return 1;
}
if(argc < 1)
usage();
Clump *c;
//uint32 len;
//uint8 *data = getFileContents(argv[0], &len);
//assert(data != NULL);
//StreamMemory in;
//in.open(data, len);
StreamFile in;
in.open(argv[0], "rb");
currentUVAnimDictionary = NULL;
currentTexDictionary = TexDictionary::create();
ChunkHeaderInfo header;
readChunkHeaderInfo(&in, &header);
if(header.type == ID_UVANIMDICT){
UVAnimDictionary *dict = UVAnimDictionary::streamRead(&in);
currentUVAnimDictionary = dict;
readChunkHeaderInfo(&in, &header);
}
if(header.type != ID_CLUMP){
in.close();
return 0;
}
debugFile = argv[0];
c = Clump::streamRead(&in);
assert(c != NULL);
in.close();
// printf("%s\n", argv[arg]);
/*
for(int32 i = 0; i < c->numAtomics; i++){
Atomic *a = c->atomicList[i];
Pipeline *ap = a->pipeline;
Geometry *g = a->geometry;
for(int32 j = 0; j < g->numMaterials; j++){
Pipeline *mp = g->materialList[j]->pipeline;
if(ap && mp)
printf("%s %x %x\n", argv[arg], ap->pluginData, mp->pluginData);
}
}
*/
//FORLIST(lnk, c->lights){
// Light *l = Light::fromClump(lnk);
// printf("%p %p\n", l, lnk);
// printf("%d %f %f %f\n", l->getType(), l->color.red, l->color.green, l->color.blue);
//}
HAnimHierarchy *hier = HAnimHierarchy::find(c->getFrame());
if(hier)
hier->attach();
dumpFrameHier(c->getFrame());
//if(currentUVAnimDictionary){
// FORLIST(lnk, currentUVAnimDictionary->animations){
// UVAnimDictEntry *de = UVAnimDictEntry::fromDict(lnk);
// Animation *anim = de->anim;
// dumpUVAnim(anim);
// }
//}
int32 platform = findPlatform(c);
if(platform){
rw::platform = platform;
switchPipes(c, rw::platform);
}
if(uninstance)
FORLIST(lnk, c->atomics){
Atomic *a = Atomic::fromClump(lnk);
ObjPipeline *p = a->getPipeline();
p->uninstance(a);
if(outplatform != PLATFORM_PS2)
ps2::unconvertADC(a->geometry);
}
rw::platform = outplatform;
switchPipes(c, rw::platform);
if(instance)
FORLIST(lnk, c->atomics){
Atomic *a = Atomic::fromClump(lnk);
ObjPipeline *p = a->getPipeline();
p->instance(a);
if(outplatform != PLATFORM_PS2)
ps2::convertADC(a->geometry);
}
if(rw::version == 0){
rw::version = header.version;
rw::build = header.build;
}
StreamFile out;
if(argc > 1)
assert(out.open(argv[1], "wb"));
else
assert(out.open("out.dff", "wb"));
if(currentUVAnimDictionary)
currentUVAnimDictionary->streamWrite(&out);
c->streamWrite(&out);
out.close();
// data = new rw::uint8[1024*1024];
// rw::StreamMemory out;
// out.open(data, 0, 1024*1024);
// if(currentUVAnimDictionary)
// currentUVAnimDictionary->streamWrite(&out);
// c->streamWrite(&out);
//
// FILE *cf;
// if(argc > 1)
// cf = fopen(argv[1], "wb");
// else
// cf = fopen("out.dff", "wb");
// assert(cf != NULL);
// fwrite(data, out.getLength(), 1, cf);
// fclose(cf);
// out.close();
// delete[] data;
c->destroy();
if(currentUVAnimDictionary)
currentUVAnimDictionary->destroy();
currentTexDictionary->destroy();
return 0;
}

View File

@ -1,215 +0,0 @@
<?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 - null|x64">
<Configuration>Debug - null</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{2592ED29-F258-4949-AB45-7B873BF697F7}</ProjectGuid>
<RootNamespace>insttest</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|x64'" 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)'=='Debug - null|x64'" 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>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" 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|x64'" Label="PropertySheets">
<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 Condition="'$(Configuration)|$(Platform)'=='Debug - null|x64'" 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>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
<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|x64'">
<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)'=='Debug - null|x64'">
<IncludePath>$(VC_IncludePath);$(WindowsSDK_IncludePath);$(SolutionDir)</IncludePath>
<LibraryPath>$(VC_LibraryPath_x64);$(WindowsSDK_LibraryPath_x64);$(SolutionDir)$(Platform)\$(Configuration);$(LibraryPath)</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>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<IncludePath>$(VC_IncludePath);$(WindowsSDK_IncludePath);$(SolutionDir)</IncludePath>
<LibraryPath>$(VC_LibraryPath_x64);$(WindowsSDK_LibraryPath_x64);$(SolutionDir)$(Platform)\$(Configuration)</LibraryPath>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>librw.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</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>
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>librw.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
<PostBuildEvent>
<Command>copy /y "$(TargetPath)" "C:\Users\aap\bin\"</Command>
</PostBuildEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug - null|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>librw.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
<PostBuildEvent>
<Command>copy /y "$(TargetPath)" "C:\Users\aap\bin\"</Command>
</PostBuildEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<AdditionalDependencies>librw.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<AdditionalDependencies>librw.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
<PostBuildEvent>
<Command>copy /y "$(TargetPath)" "C:\Users\aap\bin\"</Command>
</PostBuildEvent>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="insttest.cpp" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@ -1,16 +0,0 @@
# null, opengl
BUILD=null
# e.g. null -> -DRW_NULL
BUILDDEF:=$(shell echo $(BUILD) | tr a-z A-Z | sed 's/^/-DRW_/')
SRC := rsl.cpp rsltest.cpp
OUT := rsltest
INC := -I/usr/local/include -I../..
CFLAGS=-Wall -Wextra -g $(BUILDDEF) -Wno-parentheses -Wno-write-strings #-Wconversion
LIB=../../librw-$(BUILD).a
$(OUT): $(SRC) $(LIB)
$(CXX) $(CFLAGS) $(INC) $(SRC) $(LIB) -o $(OUT)
clean:
rm -f $(OUT)

View File

@ -1,701 +0,0 @@
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <new>
#include <stddef.h>
#include <args.h>
#include <rw.h>
#include <src/gtaplg.h>
using namespace std;
using namespace rw;
#include "rsl.h"
static void matfxRead(Stream *stream, RslMaterial *mat);
static void hanimRead(Stream *stream, RslFrame *f);
void
RslMatrixSetIdentity(RslMatrix *matrix)
{
memset(matrix, 0, sizeof(RslMatrix));
matrix->right.x = 1.0f;
matrix->up.y = 1.0f;
matrix->at.z = 1.0f;
}
void
rslObjectHasFrameSetFrame(RslObjectHasFrame *object, RslFrame *f)
{
if(object->object.parent)
rslLinkListRemoveLLLink(&object->lFrame);
rslObjectSetParent(object, f);
if(f){
rslLinkListAddLLLink(&f->objectList, &object->lFrame);
f->root->object.privateFlags |= 1;
f->object.privateFlags |= 2;
}
}
RslFrame*
RslFrameCreate(void)
{
RslFrame *f = new RslFrame;
rslObjectInitialize(&f->object, 0, 0);
rslLinkListInitialize(&f->objectList);
RslMatrixSetIdentity(&f->modelling);
RslMatrixSetIdentity(&f->ltm);
f->child = NULL;
f->next = NULL;
f->root = f;
f->nodeId = -1;
f->hier = NULL;
f->name = NULL;
f->hierId = 0;
return f;
}
RslFrame*
RslFrameAddChild(RslFrame *parent, RslFrame *child)
{
RslFrame *p = (RslFrame*)child->object.parent;
assert(p == NULL);
child->next = parent->child;
parent->child = child;
child->object.parent = parent;
child->root = parent->root;
child->root->object.privateFlags |= 1;
child->object.privateFlags |= 2;
return parent;
}
int32
RslFrameCount(RslFrame *f)
{
int32 n = 1;
for(RslFrame *c = f->child; c; c = c->next)
n += RslFrameCount(c);
return n;
}
RslFrame*
RslFrameForAllChildren(RslFrame *frame, RslFrameCallBack callBack, void *data)
{
for(RslFrame *child = frame->child;
child;
child = child->next)
if(callBack(child, data) == NULL)
break;
return frame;
}
struct StreamFrame
{
RslV3d right, up, at, pos;
int32 parent;
int32 flags;
};
void
rslFrameListStreamRead(Stream *stream, rslFrameList *framelist)
{
uint32 length;
StreamFrame strfrm;
RslFrame *f;
assert(findChunk(stream, ID_STRUCT, NULL, NULL));
stream->read(&framelist->numFrames, 4);
framelist->frames = new RslFrame*[framelist->numFrames];
for(int32 i = 0; i < framelist->numFrames; i++){
stream->read(&strfrm, sizeof(strfrm));
f = RslFrameCreate();
f->modelling.right = strfrm.right;
f->modelling.up = strfrm.up;
f->modelling.at = strfrm.at;
f->modelling.pos = strfrm.pos;
framelist->frames[i] = f;
if(strfrm.parent >= 0)
RslFrameAddChild(framelist->frames[strfrm.parent], f);
}
ChunkHeaderInfo header;
for(int32 i = 0; i < framelist->numFrames; i++){
f = framelist->frames[i];
assert(findChunk(stream, ID_EXTENSION, &length, NULL));
while(length){
readChunkHeaderInfo(stream, &header);
if(header.type == ID_HANIMPLUGIN){
hanimRead(stream, f);
}else if(header.type == gta::ID_NODENAME){
f->name = new char[header.length+1];
memset(f->name, 0, header.length+1);
stream->read(f->name, header.length);
f->name[header.length] = '\0';
}else{
stream->seek(header.length);
}
length -= 12 + header.length;
}
}
}
static RslFrame**
rslFrameListFill(RslFrame *f, RslFrame **flist)
{
*flist++ = f;
if(f->next)
flist = rslFrameListFill(f->next, flist);
if(f->child)
flist = rslFrameListFill(f->child, flist);
return flist;
}
void
rslFrameListInitialize(rslFrameList *frameList, RslFrame *root)
{
frameList->numFrames = RslFrameCount(root);
frameList->frames = new RslFrame*[frameList->numFrames];
rslFrameListFill(root, frameList->frames);
}
RslHAnimHierarchy*
RslHAnimHierarchyCreate(int32 numNodes, uint32 *nodeFlags, int32 *nodeIDs, int32 flags, int32 maxKeySize)
{
RslHAnimHierarchy *hier = new RslHAnimHierarchy;
memset(hier, 0, sizeof(RslHAnimHierarchy));
if(maxKeySize < 0x24)
maxKeySize = 0x24;
hier->flags = flags;
hier->numNodes = numNodes;
hier->parentFrame = 0;
hier->maxKeyFrameSize = maxKeySize;
hier->currentKeyFrameSize = 0x24;
int32 msz = numNodes*0x40 + 0x3f;
uint8 *p = new uint8[msz];
memset(p, 0, msz);
hier->pMatrixArrayUnaligned = p;
uintptr ip = (uintptr)p;
ip &= ~0x3f;
hier->pMatrixArray = (float32*)ip;
hier->pNodeInfo = new RslHAnimNodeInfo[numNodes];
for(int32 i = 0; i < numNodes; i++){
hier->pNodeInfo[i].id = nodeIDs[i];
hier->pNodeInfo[i].index = i;
hier->pNodeInfo[i].flags = nodeFlags[i];
hier->pNodeInfo[i].frame = NULL;
}
hier->parentHierarchy = hier;
return hier;
}
static void
hanimRead(Stream *stream, RslFrame *f)
{
int32 version;
int32 id;
int32 numNodes;
int32 flags;
int32 maxKeySize;
uint32 *nodeFlags;
int32 *nodeIDs;
version = stream->readI32();
assert(version == 0x100);
id = stream->readI32();
f->nodeId = id;
numNodes = stream->readI32();
if(numNodes == 0)
return;
flags = stream->readI32();
maxKeySize = stream->readI32();
nodeFlags = new uint32[numNodes];
nodeIDs = new int32[numNodes];
memset(nodeFlags, 0, numNodes*4);
memset(nodeIDs, 0, numNodes*4);
for(int32 i = 0; i < numNodes; i++){
nodeIDs[i] = stream->readI32();
stream->readI32();
nodeFlags[i] = stream->readI32();
}
f->hier = RslHAnimHierarchyCreate(numNodes, nodeFlags,
nodeIDs, flags, maxKeySize);
delete[] nodeFlags;
delete[] nodeIDs;
}
RslAtomic*
RslAtomicCreate(void)
{
RslAtomic *a = new RslAtomic;
memset(a, 0, sizeof(RslAtomic));
rslObjectInitialize(&a->object, 1, 0);
a->object.object.flags = 5;
a->object.object.privateFlags |= 1;
rslObjectHasFrameSetFrame(&a->object, NULL);
return a;
}
RslAtomic*
RslAtomicSetFrame(RslAtomic *atomic, RslFrame *frame)
{
rslObjectHasFrameSetFrame(&atomic->object, frame);
return atomic;
}
RslAtomic*
RslAtomicStreamRead(Stream *stream, rslFrameList *framelist)
{
uint32 length;
int32 buf[4];
RslAtomic *a;
assert(findChunk(stream, ID_STRUCT, NULL, NULL));
stream->read(buf, 16);
a = RslAtomicCreate();
a->object.object.flags = buf[2];
assert(findChunk(stream, ID_GEOMETRY, NULL, NULL));
RslPS2ResEntryHeader res, *rp;
stream->read(&res, sizeof(RslPS2ResEntryHeader));
RslGeometry *g = RslGeometryCreatePS2(res.size & 0xFFFFF);
rp = (RslPS2ResEntryHeader*)(g+1);
*rp++ = res;
stream->read(rp, (res.size&0xFFFFF)-sizeof(RslPS2ResEntryHeader));
rslMaterialListStreamRead(stream, &g->matList);
a->geometry = g;
RslAtomicSetFrame(a, framelist->frames[buf[0]]);
// This is not how it's done in LCS, they got extensions wrong :(
// Geometry
ChunkHeaderInfo header;
assert(findChunk(stream, ID_EXTENSION, &length, NULL));
while(length){
readChunkHeaderInfo(stream, &header);
if(header.type == ID_SKIN){
g->skin = RslSkinStreamRead(stream, g);
}else
stream->seek(header.length);
length -= 12 + header.length;
}
// Atomic
assert(findChunk(stream, ID_EXTENSION, &length, NULL));
while(length){
readChunkHeaderInfo(stream, &header);
stream->seek(header.length);
length -= 12 + header.length;
}
return a;
}
RslSkin*
RslSkinStreamRead(Stream *stream, RslGeometry *g)
{
uint32 info;
RslSkin *skin = new RslSkin;
memset(skin, 0, sizeof(RslSkin));
info = stream->readU32();
// LCS is different here, doesn't matter
info &= 0xFF;
skin->numBones = info;
skin->numUsedBones = info;
skin->invMatrices = new float[skin->numBones*16];
stream->read(skin->invMatrices, skin->numBones*16*4);
// TODO: allocate...if we'd really care
(void)g;
return skin;
}
RslClump*
RslClumpCreate(void)
{
RslClump *clump = new RslClump;
rslObjectInitialize(&clump->object, 2, 0);
rslLinkListInitialize(&clump->atomicList);
return clump;
}
RslClump*
RslClumpStreamRead(Stream *stream)
{
uint32 version, length;
int32 buf[3];
int32 numAtomics;
rslFrameList framelist;
RslClump *clump;
assert(findChunk(stream, ID_STRUCT, NULL, &version));
if(version > 0x33000){
stream->read(buf, 12);
numAtomics = buf[0];
}else
stream->read(&numAtomics, 4);
clump = RslClumpCreate();
assert(findChunk(stream, ID_FRAMELIST, NULL, NULL));
rslFrameListStreamRead(stream, &framelist);
clump->object.parent = framelist.frames[0];
for(int32 i = 0; i < numAtomics; i++){
assert(findChunk(stream, ID_ATOMIC, NULL, &version));
RslAtomic *a = RslAtomicStreamRead(stream, &framelist);
RslClumpAddAtomic(clump, a);
}
ChunkHeaderInfo header;
assert(findChunk(stream, ID_EXTENSION, &length, NULL));
while(length){
readChunkHeaderInfo(stream, &header);
stream->seek(header.length);
length -= 12 + header.length;
}
delete[] framelist.frames;
return clump;
}
RslClump*
RslClumpAddAtomic(RslClump *clump, RslAtomic *a)
{
rslLinkListAddLLLink(&clump->atomicList, &a->inClumpLink);
a->clump = clump;
return clump;
}
RslClump*
RslClumpForAllAtomics(RslClump *clump, RslAtomicCallBack callback, void *pData)
{
RslAtomic *a;
RslLLLink *link;
for(link = rslLLLinkGetNext(&clump->atomicList.link);
link != rslLinkListGetTerminator(&clump->atomicList);
link = link->next){
a = rslLLLinkGetData(link, RslAtomic, inClumpLink);
if(callback(a, pData) == NULL)
break;
}
return clump;
}
int32
RslClumpGetNumAtomics(RslClump *clump)
{
int32 n = 0;
RslLLLink *link;
for(link = rslLLLinkGetNext(&clump->atomicList.link);
link != rslLinkListGetTerminator(&clump->atomicList);
link = link->next)
n++;
return n;
}
RslGeometry*
RslGeometryCreatePS2(uint32 sz)
{
sz += sizeof(RslGeometry);
RslGeometry *g = (RslGeometry*)new uint8[sz];
memset(g, 0, sz);
rslObjectInitialize(&g->object, 8, 0);
g->refCount = 1;
return g;
}
RslGeometry*
RslGeometryForAllMaterials(RslGeometry *geometry, RslMaterialCallBack fpCallBack, void *pData)
{
for(int32 i = 0; i < geometry->matList.numMaterials; i++)
if(fpCallBack(geometry->matList.materials[i], pData) == NULL)
break;
return geometry;
}
struct RslMaterialChunkInfo
{
int32 flags;
RGBA color; // used
int32 unused;
bool32 textured; // used
SurfaceProperties surfaceProps;
};
RslMaterial*
RslMaterialCreate(void)
{
RslMaterial *mat = new RslMaterial;
mat->texture = NULL;
mat->color.red = 255;
mat->color.green = 255;
mat->color.blue = 255;
mat->color.alpha = 255;
mat->refCount = 1;
mat->matfx = NULL;
return mat;
}
RslMaterial*
RslMaterialStreamRead(Stream *stream)
{
uint32 length;
RslMaterialChunkInfo chunk;
assert(findChunk(stream, ID_STRUCT, NULL, NULL));
stream->read(&chunk, sizeof(chunk));
RslMaterial *mat = RslMaterialCreate();
mat->color = chunk.color;
if(chunk.textured)
mat->texture = RslTextureStreamRead(stream);
ChunkHeaderInfo header;
assert(findChunk(stream, ID_EXTENSION, &length, NULL));
while(length){
readChunkHeaderInfo(stream, &header);
if(header.type == ID_MATFX)
matfxRead(stream, mat);
else
stream->seek(header.length);
length -= 12 + header.length;
}
return mat;
}
void
RslMatFXMaterialSetEffects(RslMaterial *mat, int32 effect)
{
if(effect != MatFX::NOTHING){
if(mat->matfx == NULL){
mat->matfx = new RslMatFX;
memset(mat->matfx, 0, sizeof(RslMatFX));
}
mat->matfx->effectType = effect;
}else{
RslMatFX *matfx = mat->matfx;
if(matfx->env.texture)
RslTextureDestroy(matfx->env.texture);
delete matfx;
mat->matfx = NULL;
}
}
static void
matfxRead(Stream *stream, RslMaterial *mat)
{
int32 effect = stream->readI32();
RslMatFXMaterialSetEffects(mat, effect);
if(effect == MatFX::BUMPMAP){
stream->seek(12);
return;
}
RslMatFX *mfx = mat->matfx;
int32 type = stream->readI32();
float32 coef;
int32 fbalpha;
switch(type){
case MatFX::ENVMAP:
coef = stream->readF32();
fbalpha = stream->readI32();
(void)fbalpha;
mfx->env.frame = NULL;
mfx->env.texture = RslTextureStreamRead(stream);
mfx->env.intensity = coef;
break;
case MatFX::BUMPMAP:
coef = stream->readF32();
break;
}
}
void
rpMaterialListAppendMaterial(RslMaterialList *matlist, RslMaterial *mat)
{
if(matlist->space <= matlist->numMaterials){
RslMaterial **mats = matlist->materials;
matlist->materials = new RslMaterial*[matlist->space+16];
if(matlist->space)
memcpy(matlist->materials, mats, matlist->space*sizeof(RslMaterial*));
matlist->space += 16;
delete[] mats;
}
matlist->materials[matlist->numMaterials++] = mat;
}
void
rslMaterialListStreamRead(Stream *stream, RslMaterialList *matlist)
{
int32 numMaterials;
RslMaterial *mat;
assert(findChunk(stream, ID_MATLIST, NULL, NULL));
assert(findChunk(stream, ID_STRUCT, NULL, NULL));
numMaterials = stream->readI32();
int32 *refs = new int32[numMaterials];
stream->read(refs, 4*numMaterials);
for(int32 i = 0; i < numMaterials; i++){
assert(refs[i] < 0);
assert(findChunk(stream, ID_MATERIAL, NULL, NULL));
mat = RslMaterialStreamRead(stream);
rpMaterialListAppendMaterial(matlist, mat);
}
delete[] refs;
}
RslTexDictionary*
RslTexDictionaryCreate(void)
{
RslTexDictionary *dict = new RslTexDictionary;
memset(dict, 0, sizeof(RslTexDictionary));
rslObjectInitialize(&dict->object, 6, 0);
rslLinkListInitialize(&dict->texturesInDict);
return dict;
}
RslTexture*
RslTexDictionaryAddTexture(RslTexDictionary *dict, RslTexture *tex)
{
if(tex->dict)
rslLinkListRemoveLLLink(&tex->lInDictionary);
tex->dict = dict;
rslLinkListAddLLLink(&dict->texturesInDict, &tex->lInDictionary);
return tex;
}
RslTexDictionary*
RslTexDictionaryForAllTextures(RslTexDictionary *dict, RslTextureCallBack fpCallBack, void *pData)
{
RslTexture *t;
RslLLLink *link;
for(link = rslLLLinkGetNext(&dict->texturesInDict.link);
link != rslLinkListGetTerminator(&dict->texturesInDict);
link = link->next){
t = rslLLLinkGetData(link, RslTexture, lInDictionary);
if(fpCallBack(t, pData) == NULL)
break;
}
return dict;
}
// TODO!
void
RslTextureDestroy(RslTexture *texture)
{
delete texture;
}
RslTexture*
RslTextureCreate(RslRaster *raster)
{
RslTexture *tex = new RslTexture;
memset(tex, 0, sizeof(RslTexture));
tex->raster = raster;
return tex;
}
RslTexture*
RslTextureStreamRead(Stream *stream)
{
uint32 length;
RslTexture *tex = RslTextureCreate(NULL);
assert(findChunk(stream, ID_TEXTURE, NULL, NULL));
assert(findChunk(stream, ID_STRUCT, NULL, NULL));
stream->readI32(); // filter addressing
assert(findChunk(stream, ID_STRING, &length, NULL));
stream->read(tex->name, length);
assert(findChunk(stream, ID_STRING, &length, NULL));
stream->read(tex->mask, length);
ChunkHeaderInfo header;
assert(findChunk(stream, ID_EXTENSION, &length, NULL));
while(length){
readChunkHeaderInfo(stream, &header);
stream->seek(header.length);
length -= 12 + header.length;
}
return tex;
}
static uint32
guessSwizzling(uint32 w, uint32 h, uint32 d, uint32 mipmaps)
{
uint32 swiz = 0;
for(uint32 i = 0; i < mipmaps; i++){
switch(d){
case 4:
if(w >= 32 && h >= 16)
swiz |= 1<<i;
break;
case 8:
if(w >= 16 && h >= 4)
swiz |= 1<<i;
break;
}
w /= 2;
h /= 2;
}
return swiz;
}
RslRaster*
RslCreateRasterPS2(uint32 w, uint32 h, uint32 d, uint32 mipmaps)
{
RslRasterPS2 *r;
r = new RslRasterPS2;
uint32 tmp, logw = 0, logh = 0;
for(tmp = 1; tmp < w; tmp <<= 1)
logw++;
for(tmp = 1; tmp < h; tmp <<= 1)
logh++;
r->flags = 0;
r->flags |= logw&0x3F;
r->flags |= (logh&0x3F)<<6;
r->flags |= d << 12;
r->flags |= mipmaps << 20;
uint32 swiz = guessSwizzling(w, h, d, mipmaps);
r->flags |= swiz << 24;
return (RslRaster*)r;
}
RslTexture*
RslReadNativeTexturePS2(Stream *stream)
{
RslPs2StreamRaster rasterInfo;
uint32 len;
uint32 buf[2];
RslTexture *tex = RslTextureCreate(NULL);
assert(findChunk(stream, ID_STRUCT, NULL, NULL));
stream->read(buf, sizeof(buf));
assert(buf[0] == 0x00505350); /* "PSP\0" */
assert(findChunk(stream, ID_STRING, &len, NULL));
stream->read(tex->name, len);
assert(findChunk(stream, ID_STRING, &len, NULL));
stream->read(tex->mask, len);
assert(findChunk(stream, ID_STRUCT, NULL, NULL));
assert(findChunk(stream, ID_STRUCT, &len, NULL));
stream->read(&rasterInfo, sizeof(rasterInfo));
assert(findChunk(stream, ID_STRUCT, &len, NULL));
tex->raster = RslCreateRasterPS2(rasterInfo.width,
rasterInfo.height, rasterInfo.depth, rasterInfo.mipmaps);
tex->raster->ps2.data = new uint8[len];
stream->read(tex->raster->ps2.data, len);
assert(findChunk(stream, ID_EXTENSION, &len, NULL));
stream->seek(len);
return tex;
}
RslTexDictionary*
RslTexDictionaryStreamRead(Stream *stream)
{
assert(findChunk(stream, ID_STRUCT, NULL, NULL));
int32 numTex = stream->readI32();
RslTexDictionary *txd = RslTexDictionaryCreate();
for(int32 i = 0; i < numTex; i++){
assert(findChunk(stream, ID_TEXTURENATIVE, NULL, NULL));
RslTexture *tex = RslReadNativeTexturePS2(stream);
RslTexDictionaryAddTexture(txd, tex);
}
return txd;
}

View File

@ -1,481 +0,0 @@
enum {
TEX_IDENT = 0x00746578,
MDL_IDENT = 0x006D646C,
WRLD_IDENT = 0x57524C44
};
struct RslStream {
uint32 ident;
bool32 isMulti;
uint32 fileSize;
uint32 dataSize;
uint8 ***reloc;
uint32 relocSize;
uint8 **hashTab; // ??
uint16 hashTabSize;
uint16 numAtomics;
uint8 *data;
void relocate(void);
};
struct RslObject;
struct RslObjectHasFrame;
struct RslClump;
struct RslAtomic;
struct RslFrame;
struct RslNativeGeometry;
struct RslNativeMesh;
struct RslGeometry;
struct RslSkin;
struct RslMaterial;
struct RslHAnimHierarchy;
struct RslHAnimNode;
struct RslPS2ResEntryHeader;
struct RslPS2InstanceData;
struct RslTexDictionary;
struct RslTexture;
typedef RslFrame *(*RslFrameCallBack)(RslFrame *frame, void *data);
typedef RslClump *(*RslClumpCallBack)(RslClump *clump, void *data);
typedef RslAtomic *(*RslAtomicCallBack)(RslAtomic *atomic, void *data);
typedef RslMaterial *(*RslMaterialCallBack)(RslMaterial *material, void *data);
typedef RslTexture *(*RslTextureCallBack)(RslTexture *texture, void *pData);
struct RslV3d
{
float32 x, y, z;
};
struct RslMatrix
{
RslV3d right;
uint32 flags;
RslV3d up;
uint32 pad1;
RslV3d at;
uint32 pad2;
RslV3d pos;
uint32 pad3;
};
void RslMatrixSetIdentity(RslMatrix *matrix);
struct RslLLLink
{
RslLLLink *next;
RslLLLink *prev;
};
#define rslLLLinkGetData(linkvar,type,entry) \
((type*)(((uint8*)(linkvar))-offsetof(type,entry)))
#define rslLLLinkGetNext(linkvar) \
((linkvar)->next)
#define rslLLLinkGetPrevious(linkvar) \
((linkvar)->prev)
#define rslLLLinkInitialize(linkvar) \
((linkvar)->prev = (RslLLLink*)NULL, \
(linkvar)->next = (RslLLLink*)NULL)
#define rslLLLinkAttached(linkvar) \
((linkvar)->next)
struct RslLinkList
{
RslLLLink link;
};
#define rslLinkListInitialize(list) \
((list)->link.next = ((RslLLLink*)(list)), \
(list)->link.prev = ((RslLLLink*)(list)))
#define rslLinkListEmpty(list) \
(((list)->link.next) == (&(list)->link))
#define rslLinkListAddLLLink(list, linkvar) \
((linkvar)->next = (list)->link.next, \
(linkvar)->prev = (&(list)->link), \
((list)->link.next)->prev = (linkvar), \
(list)->link.next = (linkvar) )
#define rslLinkListRemoveLLLink(linkvar) \
(((linkvar)->prev)->next = (linkvar)->next, \
((linkvar)->next)->prev = (linkvar)->prev)
#define rslLinkListGetFirstLLLink(list) \
((list)->link.next)
#define rslLinkListGetLastLLLink(list) \
((list)->link.prev)
#define rslLinkListGetTerminator(list) \
(&((list)->link))
struct RslObject {
uint8 type;
uint8 subType;
uint8 flags;
uint8 privateFlags;
void *parent;
};
#define rslObjectInitialize(o, t, s) \
{ \
((RslObject*)(o))->type = (uint8)(t); \
((RslObject*)(o))->subType = (uint8)(s); \
((RslObject*)(o))->flags = 0; \
((RslObject*)(o))->privateFlags = 0; \
((RslObject*)(o))->parent = NULL; \
}
#define rslObjectGetParent(object) (((RslObject*)(object))->parent)
#define rslObjectSetParent(c,p) (((RslObject*)(c))->parent) = (void*)(p)
struct RslObjectHasFrame {
RslObject object;
RslLLLink lFrame;
void (*sync)();
};
void rslObjectHasFrameSetFrame(RslObjectHasFrame *object, RslFrame *f);
struct RslRasterPS2 {
uint8 *data;
uint32 flags;
};
struct RslRasterPSP {
uint32 unk1;
uint8 *data;
uint16 flags1;
uint8 width; // log of width
uint8 height; // log of height
uint32 flags2;
};
struct RslPs2StreamRaster {
uint32 width;
uint32 height;
uint32 depth;
uint32 mipmaps;
uint32 unused;
};
union RslRaster {
RslRasterPS2 ps2;
RslRasterPSP psp;
};
RslRaster *RslCreateRasterPS2(uint32 w, uint32 h, uint32 d, uint32 mipmaps);
struct RslTexDictionary {
RslObject object;
RslLinkList texturesInDict;
RslLLLink lInInstance;
};
RslTexDictionary *RslTexDictionaryStreamRead(Stream *stream);
RslTexDictionary *RslTexDictionaryCreate(void);
RslTexture *RslTexDictionaryAddTexture(RslTexDictionary *dict, RslTexture *tex);
RslTexDictionary *RslTexDictionaryForAllTextures(RslTexDictionary *dict, RslTextureCallBack fpCallBack, void *pData);
struct RslTexture {
RslRaster *raster;
RslTexDictionary *dict;
RslLLLink lInDictionary;
char name[32];
char mask[32];
};
RslTexture *RslTextureCreate(RslRaster *raster);
void RslTextureDestroy(RslTexture *texture);
RslTexture *RslTextureStreamRead(Stream *stream);
RslTexture *RslReadNativeTexturePS2(Stream *stream);
struct RslFrame {
RslObject object;
RslLinkList objectList;
RslMatrix modelling;
RslMatrix ltm;
RslFrame *child;
RslFrame *next;
RslFrame *root;
// RwHAnimFrameExtension
int32 nodeId;
RslHAnimHierarchy *hier;
// R* Node name
char *name;
// R* Visibility
int32 hierId;
};
RslFrame *RslFrameCreate(void);
RslFrame *RslFrameAddChild(RslFrame *parent, RslFrame *child);
int32 RslFrameCount(RslFrame *f);
RslFrame *RslFrameForAllChildren(RslFrame *frame, RslFrameCallBack callBack, void *data);
struct rslFrameList
{
RslFrame **frames;
int32 numFrames;
};
void rslFrameListStreamRead(Stream *stream, rslFrameList *framelist);
void rslFrameListInitialize(rslFrameList *frameList, RslFrame *root);
struct RslClump {
RslObject object;
RslLinkList atomicList;
};
#define RslClumpGetFrame(_clump) \
((RslFrame*)rslObjectGetParent(_clump))
#define RslClumpSetFrame(_clump, _frame) \
(rslObjectSetParent(_clump, _frame), \
(_clump))
RslClump *RslClumpCreate(void);
RslClump *RslClumpStreamRead(Stream *stream);
RslClump *RslClumpAddAtomic(RslClump *clump, RslAtomic *a);
int32 RslClumpGetNumAtomics(RslClump *clump);
RslClump *RslClumpForAllAtomics(RslClump *clump, RslAtomicCallBack callback, void *pData);
struct RslAtomic {
RslObjectHasFrame object;
RslGeometry *geometry;
RslClump *clump;
RslLLLink inClumpLink;
// what's this? rpWorldObj?
uint32 unk1;
uint16 unk2;
uint16 unk3;
// RpSkin
RslHAnimHierarchy *hier;
// what about visibility? matfx?
int32 pad; // 0xAAAAAAAA
};
#define RslAtomicGetFrame(_atomic) \
((RslFrame*)rslObjectGetParent(_atomic))
RslAtomic *RslAtomicCreate(void);
RslAtomic *RslAtomicSetFrame(RslAtomic *atomic, RslFrame *frame);
RslAtomic *RslAtomicStreamRead(Stream *stream, rslFrameList *framelist);
struct RslMaterialList {
RslMaterial **materials;
int32 numMaterials;
int32 space;
};
void rslMaterialListStreamRead(Stream *stream, RslMaterialList *matlist);
struct RslGeometry {
RslObject object;
int16 refCount;
int16 pad1;
RslMaterialList matList;
RslSkin *skin;
uint32 pad2; // 0xAAAAAAAA
};
RslGeometry *RslGeometryCreatePS2(uint32 sz);
RslGeometry *RslGeometryForAllMaterials(RslGeometry *geometry, RslMaterialCallBack fpCallBack, void *pData);
struct RslMatFXEnv {
RslFrame *frame;
union {
char *texname;
RslTexture *texture;
};
float32 intensity;
};
struct RslMatFX {
union {
RslMatFXEnv env;
};
int32 effectType;
};
struct RslMaterial {
union {
char *texname;
RslTexture *texture;
};
RGBA color;
uint32 refCount;
RslMatFX *matfx;
};
RslMaterial *RslMaterialCreate(void);
RslMaterial *RslMaterialStreamRead(Stream *stream);
struct RslHAnimNodeInfo {
int8 id;
int8 index;
int8 flags;
RslFrame *frame;
};
struct RslHAnimHierarchy {
int32 flags;
int32 numNodes;
void *pCurrentAnim;
float32 currentTime;
void *pNextFrame;
void (*pAnimCallBack)();
void *pAnimCallBackData;
float32 animCallBackTime;
void (*pAnimLoopCallBack)();
void *pAnimLoopCallBackData;
float32 *pMatrixArray;
void *pMatrixArrayUnaligned;
RslHAnimNodeInfo *pNodeInfo;
RslFrame *parentFrame;
int32 maxKeyFrameSize;
int32 currentKeyFrameSize;
void (*keyFrameToMatrixCB)();
void (*keyFrameBlendCB)();
void (*keyFrameInterpolateCB)();
void (*keyFrameAddCB)();
RslHAnimHierarchy *parentHierarchy;
int32 offsetInParent;
int32 rootParentOffset;
};
struct RslSkin {
uint32 numBones;
uint32 numUsedBones; // == numBones
uint8 *usedBones; // NULL
float32 *invMatrices;
int32 numWeights; // 0
uint8 *indices; // NULL
float32 *weights; // NULL
uint32 unk1; // 0
uint32 unk2; // 0
uint32 unk3; // 0
uint32 unk4; // 0
uint32 unk5; // 0
void *data; // NULL
};
RslSkin *RslSkinStreamRead(Stream *stream, RslGeometry *g);
struct RslPS2ResEntryHeader {
float32 bound[4];
uint32 size; // and numMeshes
int32 flags;
uint32 unk1;
uint32 unk2;
uint32 unk3;
uint32 unk4;
float32 scale[3];
float32 pos[3];
};
struct RslPS2InstanceData {
float32 bound[4];
float32 uvScale[2];
int32 unknown;
uint32 dmaPacket;
uint16 numTriangles;
int16 matID;
int16 min[3]; // bounding box
int16 max[3];
};
struct RslStreamHeader {
uint32 ident;
uint32 unk;
uint32 fileEnd; //
uint32 dataEnd; // relative to beginning of header
uint32 reloc; //
uint32 relocSize;
uint32 root; // absolute
uint16 zero;
uint16 numAtomics;
};
struct RslWorldGeometry {
uint16 numMeshes;
uint16 size;
// array of numMeshes RslWorldMesh
// dma data
};
struct RslWorldMesh {
uint16 texID; // index into resource table
uint16 dmaSize;
uint16 uvScale[2]; // half precision float
uint16 unk1;
int16 min[3]; // bounding box
int16 max[3];
};
struct Resource {
union {
RslRaster *raster;
RslWorldGeometry *geometry;
uint8 *raw;
};
uint32 *dma;
};
struct OverlayResource {
int32 id;
union {
RslRaster *raster;
RslWorldGeometry *geometry;
uint8 *raw;
};
};
struct Placement {
uint16 id;
uint16 resId;
int16 bound[4];
int32 pad;
float matrix[16];
};
struct Sector {
OverlayResource *resources;
uint16 numResources;
uint16 unk1;
Placement *sectionA;
Placement *sectionB;
Placement *sectionC;
Placement *sectionD;
Placement *sectionE;
Placement *sectionF;
Placement *sectionG;
Placement *sectionEnd;
uint16 unk2;
uint16 unk3;
uint32 unk4;
};
struct SectorEntry {
RslStreamHeader *sector;
uint32 num;
};
struct World {
Resource *resources;
SectorEntry sectors[47];
uint32 numResources;
uint8 pad[0x180];
uint32 numX;
void *tabX; // size 0x4
uint32 numY;
void *tabY; // size 0x30
uint32 numZ;
void *tabZ; // size 0x6
uint32 numTextures;
RslStreamHeader *textures; // stream headers
};

File diff suppressed because it is too large Load Diff

View File

@ -1,92 +0,0 @@
<?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="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{27ECE916-900F-49B2-8E9F-95E6B347E161}</ProjectGuid>
<RootNamespace>rsltest</RootNamespace>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<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 - null|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>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug - null|Win32'">
<IncludePath>$(SolutionDir);$(IncludePath)</IncludePath>
<LibraryPath>$(SolutionDir)$(Configuration);$(LibraryPath)</LibraryPath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LibraryPath>$(SolutionDir)$(Configuration);$(LibraryPath)</LibraryPath>
<IncludePath>$(SolutionDir);$(IncludePath)</IncludePath>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug - null|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>librw.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
<PostBuildEvent>
<Command>copy /y "$(TargetPath)" "C:\Users\aap\bin\"</Command>
</PostBuildEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<AdditionalDependencies>librw.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="rsl.cpp" />
<ClCompile Include="rsltest.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="rsl.h" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@ -1,164 +0,0 @@
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <new>
#include <rw.h>
#include <args.h>
#include <src/gtaplg.h>
char *argv0;
using namespace std;
using namespace rw;
struct {
char *str;
uint32 val;
} platforms[] = {
{ "ps2", PLATFORM_PS2 },
{ "xbox", PLATFORM_XBOX },
{ "d3d8", PLATFORM_D3D8 },
{ "d3d9", PLATFORM_D3D9 },
{ NULL, 0 }
};
Raster*
xboxToD3d8(Raster *raster)
{
using namespace xbox;
Raster *newras;
if(raster->platform != PLATFORM_XBOX)
return raster;
XboxRaster *ras = PLUGINOFFSET(XboxRaster, raster, nativeRasterOffset);
int32 numLevels = raster->getNumLevels();
int32 format = raster->format;
// format &= ~Raster::MIPMAP;
if(ras->format){
newras = Raster::create(raster->width, raster->height, raster->depth,
format | raster->type | 0x80, PLATFORM_D3D8);
int32 dxt = 0;
switch(ras->format){
case D3DFMT_DXT1:
dxt = 1;
break;
case D3DFMT_DXT3:
dxt = 3;
break;
case D3DFMT_DXT5:
dxt = 5;
break;
}
d3d::allocateDXT(newras, dxt, numLevels, ras->hasAlpha);
}else{
printf("swizzled!\n");
newras = Raster::create(raster->width, raster->height, raster->depth,
format | raster->type, PLATFORM_D3D8);
}
if(raster->format & Raster::PAL4)
d3d::setPalette(newras, ras->palette, 32);
else if(raster->format & Raster::PAL8)
d3d::setPalette(newras, ras->palette, 256);
uint8 *data;
for(int32 i = 0; i < numLevels; i++){
if(i >= newras->getNumLevels())
break;
data = raster->lock(i);
d3d::setTexels(newras, data, i);
raster->unlock(i);
}
delete raster;
return newras;
}
void
usage(void)
{
fprintf(stderr, "usage: %s [-v version] [-o platform] in.txd [out.txd]\n", argv0);
fprintf(stderr, "\t-v RW version, e.g. 33004 for 3.3.0.4\n");
fprintf(stderr, "\t-o output platform. ps2, xbox, mobile, d3d8, d3d9\n");
exit(1);
}
int
main(int argc, char *argv[])
{
gta::attachPlugins();
rw::version = 0;
rw::platform = rw::PLATFORM_PS2;
// rw::platform = rw::PLATFORM_OGL;
// rw::platform = rw::PLATFORM_XBOX;
// rw::platform = rw::PLATFORM_D3D8;
// rw::platform = rw::PLATFORM_D3D9;
int outplatform = rw::PLATFORM_XBOX;
char *s;
ARGBEGIN{
case 'v':
sscanf(EARGF(usage()), "%x", &rw::version);
break;
case 'o':
s = EARGF(usage());
for(int i = 0; platforms[i].str; i++){
if(strcmp(platforms[i].str, s) == 0){
outplatform = platforms[i].val;
goto found;
}
}
printf("unknown platform %s\n", s);
outplatform = PLATFORM_D3D8;
found:
break;
default:
usage();
}ARGEND;
if(argc < 1)
usage();
rw::StreamFile in;
if(in.open(argv[0], "rb") == NULL){
printf("couldn't open file %s\n", argv[1]);
return 1;
}
ChunkHeaderInfo header;
readChunkHeaderInfo(&in, &header);
assert(header.type == ID_TEXDICTIONARY);
rw::TexDictionary *txd;
txd = rw::TexDictionary::streamRead(&in);
assert(txd);
in.close();
rw::currentTexDictionary = txd;
if(rw::version == 0){
rw::version = header.version;
rw::build = header.build;
}
if(outplatform == PLATFORM_D3D8)
FORLIST(lnk, txd->textures){
Texture *tex = Texture::fromDict(lnk);
tex->raster = xboxToD3d8(tex->raster);
}
// for(Texture *tex = txd->first; tex; tex = tex->next)
// tex->filterAddressing = (tex->filterAddressing&~0xF) | 0x2;
rw::platform = outplatform;
rw::StreamFile out;
if(argc > 1)
out.open(argv[1], "wb");
else
out.open("out.txd", "wb");
txd->streamWrite(&out);
out.close();
return 0;
}