changed project structure, made VS projects, added d3d9 support and viewer, worked on xbox instancing
This commit is contained in:
169
tools/d3d9/camera.cpp
Normal file
169
tools/d3d9/camera.cpp
Normal file
@ -0,0 +1,169 @@
|
||||
#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;
|
||||
}
|
||||
|
37
tools/d3d9/camera.h
Normal file
37
tools/d3d9/camera.h
Normal file
@ -0,0 +1,37 @@
|
||||
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);
|
||||
};
|
119
tools/d3d9/d3d9.vcxproj
Normal file
119
tools/d3d9/d3d9.vcxproj
Normal file
@ -0,0 +1,119 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug - null|Win32">
|
||||
<Configuration>Debug - null</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>{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 - null|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v120</PlatformToolset>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v120</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug - null|Win32'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<IncludePath>$(VC_IncludePath);$(WindowsSDK_IncludePath);$(SolutionDir)</IncludePath>
|
||||
<LibraryPath>$(VC_LibraryPath_x86);$(WindowsSDK_LibraryPath_x86);$(SolutionDir)$(Configuration)</LibraryPath>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug - null|Win32'">
|
||||
<IncludePath>$(VC_IncludePath);$(WindowsSDK_IncludePath);$(SolutionDir)</IncludePath>
|
||||
<LibraryPath>$(VC_LibraryPath_x86);$(WindowsSDK_LibraryPath_x86);$(SolutionDir)$(Configuration)</LibraryPath>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<IncludePath>$(VC_IncludePath);$(WindowsSDK_IncludePath);$(SolutionDir)</IncludePath>
|
||||
<LibraryPath>$(VC_LibraryPath_x86);$(WindowsSDK_LibraryPath_x86);$(SolutionDir)$(Configuration)</LibraryPath>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<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)'=='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>
|
||||
<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>
|
362
tools/d3d9/d3dInit.cpp
Normal file
362
tools/d3d9/d3dInit.cpp
Normal file
@ -0,0 +1,362 @@
|
||||
#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 d3d9 {
|
||||
|
||||
int32 nativeRasterOffset;
|
||||
|
||||
struct D3d9Raster {
|
||||
IDirect3DTexture9 *texture;
|
||||
};
|
||||
|
||||
static void*
|
||||
createNativeRaster(void *object, int32 offset, int32)
|
||||
{
|
||||
D3d9Raster *raster = PLUGINOFFSET(D3d9Raster, object, offset);
|
||||
raster->texture = NULL;
|
||||
return object;
|
||||
}
|
||||
|
||||
static void*
|
||||
destroyNativeRaster(void *object, int32 offset, int32)
|
||||
{
|
||||
// TODO:
|
||||
return object;
|
||||
}
|
||||
|
||||
static void*
|
||||
copyNativeRaster(void *dst, void *, int32 offset, int32)
|
||||
{
|
||||
D3d9Raster *raster = PLUGINOFFSET(D3d9Raster, dst, offset);
|
||||
raster->texture = NULL;
|
||||
return dst;
|
||||
}
|
||||
|
||||
void
|
||||
registerNativeRaster(void)
|
||||
{
|
||||
nativeRasterOffset = Raster::registerPlugin(sizeof(D3d9Raster),
|
||||
0x12340002,
|
||||
createNativeRaster,
|
||||
destroyNativeRaster,
|
||||
copyNativeRaster);
|
||||
}
|
||||
|
||||
void
|
||||
createTexture(Texture *tex)
|
||||
{
|
||||
D3d9Raster *raster = PLUGINOFFSET(D3d9Raster, 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;
|
||||
}
|
||||
|
||||
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
|
||||
};
|
||||
|
||||
D3d9Raster *raster = PLUGINOFFSET(D3d9Raster, tex->raster, nativeRasterOffset);
|
||||
if(tex->raster){
|
||||
if(raster->texture == NULL)
|
||||
createTexture(tex);
|
||||
Device->SetTexture(0, 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[0]/255.0f;
|
||||
float diffmult = mat->surfaceProps[2]/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);
|
||||
}
|
||||
|
||||
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->minVert*/, inst->numVertices,
|
||||
inst->startIndex, inst->numPrimitives);
|
||||
inst++;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
rw::Clump *clump;
|
||||
|
||||
void
|
||||
initrw(void)
|
||||
{
|
||||
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\\");
|
||||
|
||||
gta::registerEnvSpecPlugin();
|
||||
rw::registerMatFXPlugin();
|
||||
rw::registerMaterialRightsPlugin();
|
||||
rw::registerAtomicRightsPlugin();
|
||||
rw::registerHAnimPlugin();
|
||||
gta::registerNodeNamePlugin();
|
||||
gta::registerExtraNormalsPlugin();
|
||||
gta::registerBreakableModelPlugin();
|
||||
gta::registerExtraVertColorPlugin();
|
||||
rw::ps2::registerADCPlugin();
|
||||
rw::ps2::registerPDSPlugin();
|
||||
rw::registerSkinPlugin();
|
||||
rw::xbox::registerVertexFormatPlugin();
|
||||
rw::registerNativeDataPlugin();
|
||||
rw::registerMeshPlugin();
|
||||
rw::Atomic::init();
|
||||
rw::d3d9::registerNativeRaster();
|
||||
|
||||
rw::d3d9::device = Device;
|
||||
|
||||
char *filename = "D:\\rockstargames\\pc\\gtavc\\models\\gta3_archive\\admiral.dff";
|
||||
// char *filename = "D:\\rockstargames\\pc\\gtavc\\models\\gta3_archive\\player.dff";
|
||||
// char *filename = "C:\\gtasa\\test\\hanger.dff";
|
||||
// char *filename = "C:\\Users\\aap\\Desktop\\tmp\\out.dff";
|
||||
// char *filename = "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];
|
||||
a->getPipeline()->instance(a);
|
||||
}
|
||||
|
||||
// rw::StreamFile out;
|
||||
// out.open("out2.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, 250.0f);
|
||||
camera->setTarget(Vec3(0.0f, 0.0f, 0.0f));
|
||||
// camera->setPosition(Vec3(0.0f, 5.0f, 0.0f));
|
||||
camera->setPosition(Vec3(0.0f, -5.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;
|
||||
rw::d3d9::drawAtomic(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;
|
||||
}
|
111
tools/d3d9/d3dUtility.cpp
Normal file
111
tools/d3d9/d3dUtility.cpp
Normal file
@ -0,0 +1,111 @@
|
||||
#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;
|
||||
}
|
31
tools/d3d9/d3dUtility.h
Normal file
31
tools/d3d9/d3dUtility.h
Normal file
@ -0,0 +1,31 @@
|
||||
#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;
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
}
|
1237
tools/d3d9/math.cpp
Normal file
1237
tools/d3d9/math.cpp
Normal file
File diff suppressed because it is too large
Load Diff
93
tools/d3d9/math/conversion.h
Normal file
93
tools/d3d9/math/conversion.h
Normal file
@ -0,0 +1,93 @@
|
||||
#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
|
||||
|
45
tools/d3d9/math/dquat.h
Normal file
45
tools/d3d9/math/dquat.h
Normal file
@ -0,0 +1,45 @@
|
||||
#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
|
||||
|
43
tools/d3d9/math/mat3.h
Normal file
43
tools/d3d9/math/mat3.h
Normal file
@ -0,0 +1,43 @@
|
||||
#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
|
||||
|
52
tools/d3d9/math/mat4.h
Normal file
52
tools/d3d9/math/mat4.h
Normal file
@ -0,0 +1,52 @@
|
||||
#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
|
||||
|
21
tools/d3d9/math/math.h
Normal file
21
tools/d3d9/math/math.h
Normal file
@ -0,0 +1,21 @@
|
||||
#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
|
54
tools/d3d9/math/quat.h
Normal file
54
tools/d3d9/math/quat.h
Normal file
@ -0,0 +1,54 @@
|
||||
#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
|
||||
|
40
tools/d3d9/math/vec3.h
Normal file
40
tools/d3d9/math/vec3.h
Normal file
@ -0,0 +1,40 @@
|
||||
#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
|
||||
|
39
tools/d3d9/math/vec4.h
Normal file
39
tools/d3d9/math/vec4.h
Normal file
@ -0,0 +1,39 @@
|
||||
#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
|
||||
|
@ -4,8 +4,8 @@
|
||||
#include <cassert>
|
||||
#include <new>
|
||||
|
||||
#include "../rw.h"
|
||||
#include "../src/gtaplg.h"
|
||||
#include <rw.h>
|
||||
#include <src/gtaplg.h>
|
||||
|
||||
using namespace std;
|
||||
|
||||
@ -15,6 +15,7 @@ main(int argc, char *argv[])
|
||||
// rw::version = 0x31000;
|
||||
// rw::build = 0;
|
||||
|
||||
// rw::version = 0x32000;
|
||||
// rw::version = 0x33002;
|
||||
// rw::version = 0x30200;
|
||||
|
||||
@ -75,9 +76,9 @@ main(int argc, char *argv[])
|
||||
// ofstream out(argv[2], ios::binary);
|
||||
// rw::StreamFile out;
|
||||
// out.open(argv[2], "wb");
|
||||
data = new rw::uint8[256*1024];
|
||||
data = new rw::uint8[1024*1024];
|
||||
rw::StreamMemory out;
|
||||
out.open(data, 0, 256*1024);
|
||||
out.open(data, 0, 1024*1024);
|
||||
c->streamWrite(&out);
|
||||
|
||||
cf = fopen(argv[2], "wb");
|
112
tools/dffwrite/dffwrite.vcxproj
Normal file
112
tools/dffwrite/dffwrite.vcxproj
Normal file
@ -0,0 +1,112 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug - null|Win32">
|
||||
<Configuration>Debug - null</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>{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 - null|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v120</PlatformToolset>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v120</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug - null|Win32'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<IncludePath>$(VC_IncludePath);$(WindowsSDK_IncludePath);$(SolutionDir)</IncludePath>
|
||||
<LibraryPath>$(VC_LibraryPath_x86);$(WindowsSDK_LibraryPath_x86);$(SolutionDir)$(Configuration)\</LibraryPath>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug - null|Win32'">
|
||||
<IncludePath>$(VC_IncludePath);$(WindowsSDK_IncludePath);$(SolutionDir)</IncludePath>
|
||||
<LibraryPath>$(VC_LibraryPath_x86);$(WindowsSDK_LibraryPath_x86);$(SolutionDir)$(Configuration)\</LibraryPath>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<IncludePath>$(VC_IncludePath);$(WindowsSDK_IncludePath);$(SolutionDir)</IncludePath>
|
||||
<LibraryPath>$(VC_LibraryPath_x86);$(WindowsSDK_LibraryPath_x86);$(SolutionDir)$(Configuration)\</LibraryPath>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<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>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<AdditionalDependencies>librw.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<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>
|
@ -4,7 +4,7 @@
|
||||
#include <cassert>
|
||||
#include <new>
|
||||
|
||||
#include "../rw.h"
|
||||
#include <rw.h>
|
||||
|
||||
using namespace std;
|
||||
using namespace rw;
|
109
tools/dumprwtree/dumprwtree.vcxproj
Normal file
109
tools/dumprwtree/dumprwtree.vcxproj
Normal file
@ -0,0 +1,109 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug - null|Win32">
|
||||
<Configuration>Debug - null</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>{B487F101-0C2B-4F99-A1E0-B0B0C0F3FE7E}</ProjectGuid>
|
||||
<RootNamespace>dumprwtree</RootNamespace>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v120</PlatformToolset>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug - null|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v120</PlatformToolset>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v120</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug - null|Win32'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<IncludePath>$(VC_IncludePath);$(WindowsSDK_IncludePath);$(SolutionDir)</IncludePath>
|
||||
<LibraryPath>$(VC_LibraryPath_x86);$(WindowsSDK_LibraryPath_x86);$(SolutionDir)$(Configuration)\</LibraryPath>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug - null|Win32'">
|
||||
<IncludePath>$(VC_IncludePath);$(WindowsSDK_IncludePath);$(SolutionDir)</IncludePath>
|
||||
<LibraryPath>$(VC_LibraryPath_x86);$(WindowsSDK_LibraryPath_x86);$(SolutionDir)$(Configuration)\</LibraryPath>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<IncludePath>$(VC_IncludePath);$(WindowsSDK_IncludePath);$(SolutionDir)</IncludePath>
|
||||
<LibraryPath>$(VC_LibraryPath_x86);$(WindowsSDK_LibraryPath_x86);$(SolutionDir)$(Configuration)\</LibraryPath>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<AdditionalDependencies>librw.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug - null|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<AdditionalDependencies>librw.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<AdditionalDependencies>librw.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="dumprwtree.cpp" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
15
tools/insttest.cpp → tools/insttest/insttest.cpp
Executable file → Normal file
15
tools/insttest.cpp → tools/insttest/insttest.cpp
Executable file → Normal file
@ -4,8 +4,8 @@
|
||||
#include <cassert>
|
||||
#include <new>
|
||||
|
||||
#include "../rw.h"
|
||||
#include "../src/gtaplg.h"
|
||||
#include <rw.h>
|
||||
#include <src/gtaplg.h>
|
||||
|
||||
using namespace std;
|
||||
using namespace rw;
|
||||
@ -31,13 +31,14 @@ main(int argc, char *argv[])
|
||||
rw::Atomic::init();
|
||||
|
||||
// rw::platform = rw::PLATFORM_PS2;
|
||||
rw::platform = rw::PLATFORM_OGL;
|
||||
// rw::platform = rw::PLATFORM_OGL;
|
||||
rw::platform = rw::PLATFORM_XBOX;
|
||||
|
||||
int uninstance = 0;
|
||||
int arg = 1;
|
||||
|
||||
if(argc < 2){
|
||||
printf("usage: %s [-u] ps2.dff\n", argv[0]);
|
||||
printf("usage: %s [-u] in.dff\n", argv[0]);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -45,7 +46,7 @@ main(int argc, char *argv[])
|
||||
uninstance++;
|
||||
arg++;
|
||||
if(argc < 3){
|
||||
printf("usage: %s [-u] ps2.dff\n", argv[0]);
|
||||
printf("usage: %s [-u] in.dff\n", argv[0]);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@ -85,9 +86,9 @@ main(int argc, char *argv[])
|
||||
p->instance(a);
|
||||
}
|
||||
|
||||
data = new rw::uint8[512*1024];
|
||||
data = new rw::uint8[1024*1024];
|
||||
rw::StreamMemory out;
|
||||
out.open(data, 0, 512*1024);
|
||||
out.open(data, 0, 1024*1024);
|
||||
c->streamWrite(&out);
|
||||
|
||||
FILE *cf = fopen("out.dff", "wb");
|
112
tools/insttest/insttest.vcxproj
Normal file
112
tools/insttest/insttest.vcxproj
Normal file
@ -0,0 +1,112 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug - null|Win32">
|
||||
<Configuration>Debug - null</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>{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 - null|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v120</PlatformToolset>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v120</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug - null|Win32'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<IncludePath>$(VC_IncludePath);$(WindowsSDK_IncludePath);$(SolutionDir)</IncludePath>
|
||||
<LibraryPath>$(VC_LibraryPath_x86);$(WindowsSDK_LibraryPath_x86);$(SolutionDir)$(Configuration)</LibraryPath>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug - null|Win32'">
|
||||
<IncludePath>$(VC_IncludePath);$(WindowsSDK_IncludePath);$(SolutionDir)</IncludePath>
|
||||
<LibraryPath>$(VC_LibraryPath_x86);$(WindowsSDK_LibraryPath_x86);$(SolutionDir)$(Configuration)</LibraryPath>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<IncludePath>$(VC_IncludePath);$(WindowsSDK_IncludePath);$(SolutionDir)</IncludePath>
|
||||
<LibraryPath>$(VC_LibraryPath_x86);$(WindowsSDK_LibraryPath_x86);$(SolutionDir)$(Configuration)</LibraryPath>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<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>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<AdditionalDependencies>librw.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<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="insttest.cpp" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
Reference in New Issue
Block a user