mirror of https://github.com/aap/librw.git
started tidying up
This commit is contained in:
parent
ee726b90a2
commit
30114667ed
3
Makefile
3
Makefile
|
@ -10,7 +10,8 @@ SRC := $(wildcard $(SRCDIR)/*.cpp)
|
||||||
OBJ := $(patsubst $(SRCDIR)/%.cpp,$(BUILDDIR)/%.o,$(SRC))
|
OBJ := $(patsubst $(SRCDIR)/%.cpp,$(BUILDDIR)/%.o,$(SRC))
|
||||||
DEP := $(patsubst $(SRCDIR)/%.cpp,$(BUILDDIR)/%.d,$(SRC))
|
DEP := $(patsubst $(SRCDIR)/%.cpp,$(BUILDDIR)/%.d,$(SRC))
|
||||||
INC := -I/usr/local/include
|
INC := -I/usr/local/include
|
||||||
CFLAGS=-Wall -Wextra -g $(BUILDDEF) -Wno-parentheses #-Wconversion
|
CFLAGS=-Wall -Wextra -g $(BUILDDEF) -Wno-parentheses -Wno-invalid-offsetof -fno-diagnostics-show-caret
|
||||||
|
#-Wconversion
|
||||||
LIB=librw-$(BUILD).a
|
LIB=librw-$(BUILD).a
|
||||||
|
|
||||||
$(LIB): $(OBJ)
|
$(LIB): $(OBJ)
|
||||||
|
|
5
rw.h
5
rw.h
|
@ -2,10 +2,13 @@
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
|
|
||||||
#include "src/rwbase.h"
|
#include "src/rwbase.h"
|
||||||
#include "src/rwplugin.h"
|
#include "src/rwplg.h"
|
||||||
#include "src/rwpipeline.h"
|
#include "src/rwpipeline.h"
|
||||||
#include "src/rwobjects.h"
|
#include "src/rwobjects.h"
|
||||||
|
#include "src/rwengine.h"
|
||||||
|
#include "src/rwplugins.h"
|
||||||
#include "src/rwps2.h"
|
#include "src/rwps2.h"
|
||||||
|
#include "src/rwps2plg.h"
|
||||||
#include "src/rwxbox.h"
|
#include "src/rwxbox.h"
|
||||||
#include "src/rwd3d.h"
|
#include "src/rwd3d.h"
|
||||||
#include "src/rwd3d8.h"
|
#include "src/rwd3d8.h"
|
||||||
|
|
|
@ -4,9 +4,10 @@
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
|
|
||||||
#include "rwbase.h"
|
#include "rwbase.h"
|
||||||
#include "rwplugin.h"
|
#include "rwplg.h"
|
||||||
#include "rwpipeline.h"
|
#include "rwpipeline.h"
|
||||||
#include "rwobjects.h"
|
#include "rwobjects.h"
|
||||||
|
#include "rwplugins.h"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
|
|
|
@ -5,9 +5,10 @@
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
|
|
||||||
#include "rwbase.h"
|
#include "rwbase.h"
|
||||||
#include "rwplugin.h"
|
#include "rwplg.h"
|
||||||
#include "rwpipeline.h"
|
#include "rwpipeline.h"
|
||||||
#include "rwobjects.h"
|
#include "rwobjects.h"
|
||||||
|
#include "rwengine.h"
|
||||||
#include "rwps2.h"
|
#include "rwps2.h"
|
||||||
#include "rwogl.h"
|
#include "rwogl.h"
|
||||||
#include "rwxbox.h"
|
#include "rwxbox.h"
|
||||||
|
@ -492,7 +493,7 @@ Clump::render(void)
|
||||||
Atomic *a;
|
Atomic *a;
|
||||||
FORLIST(lnk, this->atomics){
|
FORLIST(lnk, this->atomics){
|
||||||
a = Atomic::fromClump(lnk);
|
a = Atomic::fromClump(lnk);
|
||||||
if(a->object.flags & Atomic::RENDER)
|
if(a->object.object.flags & Atomic::RENDER)
|
||||||
a->render();
|
a->render();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -566,7 +567,7 @@ Atomic::create(void)
|
||||||
{
|
{
|
||||||
Atomic *atomic = (Atomic*)malloc(PluginBase::s_size);
|
Atomic *atomic = (Atomic*)malloc(PluginBase::s_size);
|
||||||
assert(atomic != NULL);
|
assert(atomic != NULL);
|
||||||
atomic->object.init(Atomic::ID, 0);
|
atomic->object.object.init(Atomic::ID, 0);
|
||||||
atomic->geometry = NULL;
|
atomic->geometry = NULL;
|
||||||
atomic->worldBoundingSphere.center.set(0.0f, 0.0f, 0.0f);
|
atomic->worldBoundingSphere.center.set(0.0f, 0.0f, 0.0f);
|
||||||
atomic->worldBoundingSphere.radius = 0.0f;
|
atomic->worldBoundingSphere.radius = 0.0f;
|
||||||
|
@ -574,7 +575,7 @@ Atomic::create(void)
|
||||||
atomic->clump = NULL;
|
atomic->clump = NULL;
|
||||||
atomic->pipeline = NULL;
|
atomic->pipeline = NULL;
|
||||||
atomic->renderCB = Atomic::defaultRenderCB;
|
atomic->renderCB = Atomic::defaultRenderCB;
|
||||||
atomic->object.flags = Atomic::COLLISIONTEST | Atomic::RENDER;
|
atomic->object.object.flags = Atomic::COLLISIONTEST | Atomic::RENDER;
|
||||||
atomic->constructPlugins();
|
atomic->constructPlugins();
|
||||||
return atomic;
|
return atomic;
|
||||||
}
|
}
|
||||||
|
@ -583,8 +584,8 @@ Atomic*
|
||||||
Atomic::clone()
|
Atomic::clone()
|
||||||
{
|
{
|
||||||
Atomic *atomic = Atomic::create();
|
Atomic *atomic = Atomic::create();
|
||||||
atomic->object.copy(&this->object);
|
atomic->object.object.copy(&this->object.object);
|
||||||
atomic->object.privateFlags |= 1;
|
atomic->object.object.privateFlags |= 1;
|
||||||
if(this->geometry){
|
if(this->geometry){
|
||||||
atomic->geometry = this->geometry;
|
atomic->geometry = this->geometry;
|
||||||
atomic->geometry->refCount++;
|
atomic->geometry->refCount++;
|
||||||
|
@ -611,14 +612,14 @@ Atomic::getWorldBoundingSphere(void)
|
||||||
{
|
{
|
||||||
Sphere *s = &this->worldBoundingSphere;
|
Sphere *s = &this->worldBoundingSphere;
|
||||||
if(!this->getFrame()->dirty() &&
|
if(!this->getFrame()->dirty() &&
|
||||||
(this->object.privateFlags & WORLDBOUNDDIRTY) == 0)
|
(this->object.object.privateFlags & WORLDBOUNDDIRTY) == 0)
|
||||||
return s;
|
return s;
|
||||||
Matrix *ltm = this->getFrame()->getLTM();
|
Matrix *ltm = this->getFrame()->getLTM();
|
||||||
// TODO: support scaling
|
// TODO: support scaling
|
||||||
// TODO: if we ever support morphing, fix this:
|
// TODO: if we ever support morphing, fix this:
|
||||||
s->center = ltm->transPoint(this->geometry->morphTargets[0].boundingSphere.center);
|
s->center = ltm->transPoint(this->geometry->morphTargets[0].boundingSphere.center);
|
||||||
s->radius = this->geometry->morphTargets[0].boundingSphere.radius;
|
s->radius = this->geometry->morphTargets[0].boundingSphere.radius;
|
||||||
this->object.privateFlags &= ~WORLDBOUNDDIRTY;
|
this->object.object.privateFlags &= ~WORLDBOUNDDIRTY;
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -639,7 +640,7 @@ Atomic::streamReadClump(Stream *stream,
|
||||||
atomic->geometry = Geometry::streamRead(stream);
|
atomic->geometry = Geometry::streamRead(stream);
|
||||||
}else
|
}else
|
||||||
atomic->geometry = geometryList[buf[1]];
|
atomic->geometry = geometryList[buf[1]];
|
||||||
atomic->object.flags = buf[2];
|
atomic->object.object.flags = buf[2];
|
||||||
|
|
||||||
atomicRights[0] = 0;
|
atomicRights[0] = 0;
|
||||||
atomic->streamReadPlugins(stream);
|
atomic->streamReadPlugins(stream);
|
||||||
|
@ -660,7 +661,7 @@ Atomic::streamWriteClump(Stream *stream, Frame **frameList, int32 numFrames)
|
||||||
buf[0] = findPointer(this->getFrame(), (void**)frameList, numFrames);
|
buf[0] = findPointer(this->getFrame(), (void**)frameList, numFrames);
|
||||||
|
|
||||||
if(version < 0x30400){
|
if(version < 0x30400){
|
||||||
buf[1] = this->object.flags;
|
buf[1] = this->object.object.flags;
|
||||||
stream->write(buf, sizeof(int[3]));
|
stream->write(buf, sizeof(int[3]));
|
||||||
this->geometry->streamWrite(stream);
|
this->geometry->streamWrite(stream);
|
||||||
}else{
|
}else{
|
||||||
|
@ -672,7 +673,7 @@ Atomic::streamWriteClump(Stream *stream, Frame **frameList, int32 numFrames)
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
foundgeo:
|
foundgeo:
|
||||||
buf[2] = this->object.flags;
|
buf[2] = this->object.object.flags;
|
||||||
stream->write(buf, sizeof(buf));
|
stream->write(buf, sizeof(buf));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -691,14 +692,12 @@ Atomic::streamGetSize(void)
|
||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
ObjPipeline *defaultPipelines[NUM_PLATFORMS];
|
|
||||||
|
|
||||||
ObjPipeline*
|
ObjPipeline*
|
||||||
Atomic::getPipeline(void)
|
Atomic::getPipeline(void)
|
||||||
{
|
{
|
||||||
return this->pipeline ?
|
return this->pipeline ?
|
||||||
this->pipeline :
|
this->pipeline :
|
||||||
defaultPipelines[platform];
|
engine[platform].defaultPipeline;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -754,15 +753,15 @@ Light::create(int32 type)
|
||||||
{
|
{
|
||||||
Light *light = (Light*)malloc(PluginBase::s_size);
|
Light *light = (Light*)malloc(PluginBase::s_size);
|
||||||
assert(light != NULL);
|
assert(light != NULL);
|
||||||
light->object.init(Light::ID, type);
|
light->object.object.init(Light::ID, type);
|
||||||
light->radius = 0.0f;
|
light->radius = 0.0f;
|
||||||
light->color.red = 1.0f;
|
light->color.red = 1.0f;
|
||||||
light->color.green = 1.0f;
|
light->color.green = 1.0f;
|
||||||
light->color.blue = 1.0f;
|
light->color.blue = 1.0f;
|
||||||
light->color.alpha = 1.0f;
|
light->color.alpha = 1.0f;
|
||||||
light->minusCosAngle = 1.0f;
|
light->minusCosAngle = 1.0f;
|
||||||
light->object.privateFlags = 1;
|
light->object.object.privateFlags = 1;
|
||||||
light->object.flags = LIGHTATOMICS | LIGHTWORLD;
|
light->object.object.flags = LIGHTATOMICS | LIGHTWORLD;
|
||||||
light->clump = NULL;
|
light->clump = NULL;
|
||||||
light->inClump.init();
|
light->inClump.init();
|
||||||
light->constructPlugins();
|
light->constructPlugins();
|
||||||
|
@ -796,7 +795,7 @@ Light::setColor(float32 r, float32 g, float32 b)
|
||||||
this->color.red = r;
|
this->color.red = r;
|
||||||
this->color.green = g;
|
this->color.green = g;
|
||||||
this->color.blue = b;
|
this->color.blue = b;
|
||||||
this->object.privateFlags = r == g && r == b;
|
this->object.object.privateFlags = r == g && r == b;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct LightChunkData
|
struct LightChunkData
|
||||||
|
@ -824,7 +823,7 @@ Light::streamRead(Stream *stream)
|
||||||
else
|
else
|
||||||
// tan -> -cos
|
// tan -> -cos
|
||||||
light->minusCosAngle = -1.0f/sqrt(a*a+1.0f);
|
light->minusCosAngle = -1.0f/sqrt(a*a+1.0f);
|
||||||
light->object.flags = (uint8)buf.flags;
|
light->object.object.flags = (uint8)buf.flags;
|
||||||
light->streamReadPlugins(stream);
|
light->streamReadPlugins(stream);
|
||||||
return light;
|
return light;
|
||||||
}
|
}
|
||||||
|
@ -843,8 +842,8 @@ Light::streamWrite(Stream *stream)
|
||||||
buf.minusCosAngle = this->minusCosAngle;
|
buf.minusCosAngle = this->minusCosAngle;
|
||||||
else
|
else
|
||||||
buf.minusCosAngle = tan(acos(-this->minusCosAngle));
|
buf.minusCosAngle = tan(acos(-this->minusCosAngle));
|
||||||
buf.flags = this->object.flags;
|
buf.flags = this->object.object.flags;
|
||||||
buf.type = this->object.subType;
|
buf.type = this->object.object.subType;
|
||||||
stream->write(&buf, sizeof(LightChunkData));
|
stream->write(&buf, sizeof(LightChunkData));
|
||||||
|
|
||||||
this->streamWritePlugins(stream);
|
this->streamWritePlugins(stream);
|
||||||
|
@ -865,7 +864,7 @@ Camera*
|
||||||
Camera::create(void)
|
Camera::create(void)
|
||||||
{
|
{
|
||||||
Camera *cam = (Camera*)malloc(PluginBase::s_size);
|
Camera *cam = (Camera*)malloc(PluginBase::s_size);
|
||||||
cam->object.init(Camera::ID, 0);
|
cam->object.object.init(Camera::ID, 0);
|
||||||
cam->viewWindow.set(1.0f, 1.0f);
|
cam->viewWindow.set(1.0f, 1.0f);
|
||||||
cam->viewOffset.set(0.0f, 0.0f);
|
cam->viewOffset.set(0.0f, 0.0f);
|
||||||
cam->nearPlane = 0.05f;
|
cam->nearPlane = 0.05f;
|
||||||
|
@ -882,7 +881,7 @@ Camera*
|
||||||
Camera::clone(void)
|
Camera::clone(void)
|
||||||
{
|
{
|
||||||
Camera *cam = Camera::create();
|
Camera *cam = Camera::create();
|
||||||
cam->object.copy(&this->object);
|
cam->object.object.copy(&this->object.object);
|
||||||
cam->setFrame(this->getFrame());
|
cam->setFrame(this->getFrame());
|
||||||
cam->viewWindow = this->viewWindow;
|
cam->viewWindow = this->viewWindow;
|
||||||
cam->viewOffset = this->viewOffset;
|
cam->viewOffset = this->viewOffset;
|
||||||
|
|
|
@ -6,9 +6,10 @@
|
||||||
#include <new>
|
#include <new>
|
||||||
|
|
||||||
#include "rwbase.h"
|
#include "rwbase.h"
|
||||||
#include "rwplugin.h"
|
#include "rwplg.h"
|
||||||
#include "rwpipeline.h"
|
#include "rwpipeline.h"
|
||||||
#include "rwobjects.h"
|
#include "rwobjects.h"
|
||||||
|
#include "rwengine.h"
|
||||||
#include "rwd3d.h"
|
#include "rwd3d.h"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
@ -593,8 +594,8 @@ registerNativeRaster(void)
|
||||||
createNativeRaster,
|
createNativeRaster,
|
||||||
destroyNativeRaster,
|
destroyNativeRaster,
|
||||||
copyNativeRaster);
|
copyNativeRaster);
|
||||||
Raster::nativeOffsets[PLATFORM_D3D8] = nativeRasterOffset;
|
engine[PLATFORM_D3D8].rasterNativeOffset = nativeRasterOffset;
|
||||||
Raster::nativeOffsets[PLATFORM_D3D9] = nativeRasterOffset;
|
engine[PLATFORM_D3D9].rasterNativeOffset = nativeRasterOffset;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
|
|
||||||
#include "rwbase.h"
|
#include "rwbase.h"
|
||||||
#include "rwplugin.h"
|
#include "rwplg.h"
|
||||||
#include "rwpipeline.h"
|
#include "rwpipeline.h"
|
||||||
#include "rwobjects.h"
|
#include "rwobjects.h"
|
||||||
#include "rwd3d.h"
|
#include "rwd3d.h"
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
|
|
||||||
#include "rwbase.h"
|
#include "rwbase.h"
|
||||||
#include "rwplugin.h"
|
#include "rwplg.h"
|
||||||
#include "rwpipeline.h"
|
#include "rwpipeline.h"
|
||||||
#include "rwobjects.h"
|
#include "rwobjects.h"
|
||||||
#include "rwd3d.h"
|
#include "rwd3d.h"
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
|
|
||||||
#include "rwbase.h"
|
#include "rwbase.h"
|
||||||
#include "rwplugin.h"
|
#include "rwplg.h"
|
||||||
#include "rwpipeline.h"
|
#include "rwpipeline.h"
|
||||||
#include "rwobjects.h"
|
#include "rwobjects.h"
|
||||||
#include "rwd3d.h"
|
#include "rwd3d.h"
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
|
|
||||||
#include "rwbase.h"
|
#include "rwbase.h"
|
||||||
#include "rwplugin.h"
|
#include "rwplg.h"
|
||||||
#include "rwpipeline.h"
|
#include "rwpipeline.h"
|
||||||
#include "rwobjects.h"
|
#include "rwobjects.h"
|
||||||
#include "rwd3d.h"
|
#include "rwd3d.h"
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
|
|
||||||
#include "rwbase.h"
|
#include "rwbase.h"
|
||||||
#include "rwplugin.h"
|
#include "rwplg.h"
|
||||||
#include "rwpipeline.h"
|
#include "rwpipeline.h"
|
||||||
#include "rwobjects.h"
|
#include "rwobjects.h"
|
||||||
#include "rwd3d.h"
|
#include "rwd3d.h"
|
||||||
|
|
|
@ -0,0 +1,49 @@
|
||||||
|
#include <cstdio>
|
||||||
|
#include <assert.h>
|
||||||
|
|
||||||
|
#include "rwbase.h"
|
||||||
|
#include "rwplg.h"
|
||||||
|
#include "rwpipeline.h"
|
||||||
|
#include "rwobjects.h"
|
||||||
|
#include "rwengine.h"
|
||||||
|
|
||||||
|
namespace rw {
|
||||||
|
|
||||||
|
Engine engines[NUM_PLATFORMS];
|
||||||
|
|
||||||
|
namespace null {
|
||||||
|
|
||||||
|
void
|
||||||
|
rasterCreate(Raster*)
|
||||||
|
{
|
||||||
|
assert(0 && "rasterCreate not implemented");
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8*
|
||||||
|
rasterLock(Raster*, int32)
|
||||||
|
{
|
||||||
|
assert(0 && "lockRaster not implemented");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
rasterUnlock(Raster*, int32)
|
||||||
|
{
|
||||||
|
assert(0 && "unlockRaster not implemented");
|
||||||
|
}
|
||||||
|
|
||||||
|
int32
|
||||||
|
rasterNumLevels(Raster*, int32)
|
||||||
|
{
|
||||||
|
assert(0 && "rasterNumLevels not implemented");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
rasterFromImage(Raster*, Image*)
|
||||||
|
{
|
||||||
|
assert(0 && "rasterFromImage not implemented");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -5,7 +5,7 @@
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
|
|
||||||
#include "rwbase.h"
|
#include "rwbase.h"
|
||||||
#include "rwplugin.h"
|
#include "rwplg.h"
|
||||||
#include "rwpipeline.h"
|
#include "rwpipeline.h"
|
||||||
#include "rwobjects.h"
|
#include "rwobjects.h"
|
||||||
|
|
||||||
|
|
|
@ -4,9 +4,10 @@
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
|
|
||||||
#include "rwbase.h"
|
#include "rwbase.h"
|
||||||
#include "rwplugin.h"
|
#include "rwplg.h"
|
||||||
#include "rwpipeline.h"
|
#include "rwpipeline.h"
|
||||||
#include "rwobjects.h"
|
#include "rwobjects.h"
|
||||||
|
#include "rwengine.h"
|
||||||
#include "rwps2.h"
|
#include "rwps2.h"
|
||||||
#include "rwd3d.h"
|
#include "rwd3d.h"
|
||||||
#include "rwxbox.h"
|
#include "rwxbox.h"
|
||||||
|
@ -628,8 +629,6 @@ writeTGA(Image *image, const char *filename)
|
||||||
// Raster
|
// Raster
|
||||||
//
|
//
|
||||||
|
|
||||||
int32 Raster::nativeOffsets[NUM_PLATFORMS];
|
|
||||||
|
|
||||||
Raster*
|
Raster*
|
||||||
Raster::create(int32 width, int32 height, int32 depth, int32 format, int32 platform)
|
Raster::create(int32 width, int32 height, int32 depth, int32 format, int32 platform)
|
||||||
{
|
{
|
||||||
|
@ -645,10 +644,13 @@ Raster::create(int32 width, int32 height, int32 depth, int32 format, int32 platf
|
||||||
raster->texels = raster->palette = NULL;
|
raster->texels = raster->palette = NULL;
|
||||||
raster->constructPlugins();
|
raster->constructPlugins();
|
||||||
|
|
||||||
int32 offset = nativeOffsets[raster->platform];
|
int32 offset = engine[raster->platform].rasterNativeOffset;
|
||||||
assert(offset != 0 && "unimplemented raster platform");
|
assert(offset != 0 && "unimplemented raster platform");
|
||||||
|
printf("%X %d\n", offset, raster->platform);
|
||||||
NativeRaster *nr = PLUGINOFFSET(NativeRaster, raster, offset);
|
NativeRaster *nr = PLUGINOFFSET(NativeRaster, raster, offset);
|
||||||
|
printf("%p\n", nr);
|
||||||
nr->create(raster);
|
nr->create(raster);
|
||||||
|
printf("created\n");
|
||||||
return raster;
|
return raster;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -664,7 +666,7 @@ Raster::destroy(void)
|
||||||
uint8*
|
uint8*
|
||||||
Raster::lock(int32 level)
|
Raster::lock(int32 level)
|
||||||
{
|
{
|
||||||
int32 offset = nativeOffsets[this->platform];
|
int32 offset = engine[this->platform].rasterNativeOffset;
|
||||||
assert(offset != 0 && "unimplemented raster platform");
|
assert(offset != 0 && "unimplemented raster platform");
|
||||||
NativeRaster *nr = PLUGINOFFSET(NativeRaster, this, offset);
|
NativeRaster *nr = PLUGINOFFSET(NativeRaster, this, offset);
|
||||||
return nr->lock(this, level);
|
return nr->lock(this, level);
|
||||||
|
@ -673,7 +675,7 @@ Raster::lock(int32 level)
|
||||||
void
|
void
|
||||||
Raster::unlock(int32 level)
|
Raster::unlock(int32 level)
|
||||||
{
|
{
|
||||||
int32 offset = nativeOffsets[this->platform];
|
int32 offset = engine[this->platform].rasterNativeOffset;
|
||||||
assert(offset != 0 && "unimplemented raster platform");
|
assert(offset != 0 && "unimplemented raster platform");
|
||||||
NativeRaster *nr = PLUGINOFFSET(NativeRaster, this, offset);
|
NativeRaster *nr = PLUGINOFFSET(NativeRaster, this, offset);
|
||||||
nr->unlock(this, level);
|
nr->unlock(this, level);
|
||||||
|
@ -682,7 +684,7 @@ Raster::unlock(int32 level)
|
||||||
int32
|
int32
|
||||||
Raster::getNumLevels(void)
|
Raster::getNumLevels(void)
|
||||||
{
|
{
|
||||||
int32 offset = nativeOffsets[this->platform];
|
int32 offset = engine[this->platform].rasterNativeOffset;
|
||||||
assert(offset != 0 && "unimplemented raster platform");
|
assert(offset != 0 && "unimplemented raster platform");
|
||||||
NativeRaster *nr = PLUGINOFFSET(NativeRaster, this, offset);
|
NativeRaster *nr = PLUGINOFFSET(NativeRaster, this, offset);
|
||||||
return nr->getNumLevels(this);
|
return nr->getNumLevels(this);
|
||||||
|
@ -703,7 +705,7 @@ Raster::createFromImage(Image *image)
|
||||||
{
|
{
|
||||||
Raster *raster = Raster::create(image->width, image->height,
|
Raster *raster = Raster::create(image->width, image->height,
|
||||||
image->depth, 4 | 0x80);
|
image->depth, 4 | 0x80);
|
||||||
int32 offset = nativeOffsets[raster->platform];
|
int32 offset = engine[raster->platform].rasterNativeOffset;
|
||||||
assert(offset != 0 && "unimplemented raster platform");
|
assert(offset != 0 && "unimplemented raster platform");
|
||||||
NativeRaster *nr = PLUGINOFFSET(NativeRaster, raster, offset);
|
NativeRaster *nr = PLUGINOFFSET(NativeRaster, raster, offset);
|
||||||
nr->fromImage(raster, image);
|
nr->fromImage(raster, image);
|
||||||
|
|
|
@ -4,9 +4,10 @@
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
|
|
||||||
#include "rwbase.h"
|
#include "rwbase.h"
|
||||||
#include "rwplugin.h"
|
#include "rwplg.h"
|
||||||
#include "rwpipeline.h"
|
#include "rwpipeline.h"
|
||||||
#include "rwobjects.h"
|
#include "rwobjects.h"
|
||||||
|
#include "rwplugins.h"
|
||||||
#include "rwogl.h"
|
#include "rwogl.h"
|
||||||
|
|
||||||
#ifdef RW_OPENGL
|
#ifdef RW_OPENGL
|
||||||
|
|
|
@ -4,10 +4,12 @@
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
|
|
||||||
#include "rwbase.h"
|
#include "rwbase.h"
|
||||||
#include "rwplugin.h"
|
#include "rwplg.h"
|
||||||
#include "rwpipeline.h"
|
#include "rwpipeline.h"
|
||||||
#include "rwobjects.h"
|
#include "rwobjects.h"
|
||||||
|
#include "rwplugins.h"
|
||||||
#include "rwps2.h"
|
#include "rwps2.h"
|
||||||
|
#include "rwps2plg.h"
|
||||||
|
|
||||||
namespace rw {
|
namespace rw {
|
||||||
namespace ps2 {
|
namespace ps2 {
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
|
|
||||||
#include "rwbase.h"
|
#include "rwbase.h"
|
||||||
#include "rwplugin.h"
|
#include "rwplg.h"
|
||||||
#include "rwpipeline.h"
|
#include "rwpipeline.h"
|
||||||
#include "rwobjects.h"
|
#include "rwobjects.h"
|
||||||
#include "rwps2.h"
|
#include "rwps2.h"
|
||||||
|
|
|
@ -4,10 +4,12 @@
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
|
|
||||||
#include "rwbase.h"
|
#include "rwbase.h"
|
||||||
#include "rwplugin.h"
|
#include "rwplg.h"
|
||||||
#include "rwpipeline.h"
|
#include "rwpipeline.h"
|
||||||
#include "rwobjects.h"
|
#include "rwobjects.h"
|
||||||
|
#include "rwplugins.h"
|
||||||
#include "rwps2.h"
|
#include "rwps2.h"
|
||||||
|
#include "rwps2plg.h"
|
||||||
#include "rwogl.h"
|
#include "rwogl.h"
|
||||||
#include "rwxbox.h"
|
#include "rwxbox.h"
|
||||||
#include "rwd3d8.h"
|
#include "rwd3d8.h"
|
||||||
|
|
|
@ -4,10 +4,12 @@
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
|
|
||||||
#include "rwbase.h"
|
#include "rwbase.h"
|
||||||
#include "rwplugin.h"
|
#include "rwplg.h"
|
||||||
#include "rwpipeline.h"
|
#include "rwpipeline.h"
|
||||||
#include "rwobjects.h"
|
#include "rwobjects.h"
|
||||||
|
#include "rwplugins.h"
|
||||||
#include "rwps2.h"
|
#include "rwps2.h"
|
||||||
|
#include "rwps2plg.h"
|
||||||
|
|
||||||
namespace rw {
|
namespace rw {
|
||||||
namespace ps2 {
|
namespace ps2 {
|
||||||
|
|
|
@ -6,9 +6,10 @@
|
||||||
#include <new>
|
#include <new>
|
||||||
|
|
||||||
#include "rwbase.h"
|
#include "rwbase.h"
|
||||||
#include "rwplugin.h"
|
#include "rwplg.h"
|
||||||
#include "rwpipeline.h"
|
#include "rwpipeline.h"
|
||||||
#include "rwobjects.h"
|
#include "rwobjects.h"
|
||||||
|
#include "rwengine.h"
|
||||||
#include "rwps2.h"
|
#include "rwps2.h"
|
||||||
|
|
||||||
#define max(a, b) ((a) > (b) ? (a) : (b))
|
#define max(a, b) ((a) > (b) ? (a) : (b))
|
||||||
|
@ -480,7 +481,7 @@ registerNativeRaster(void)
|
||||||
createNativeRaster,
|
createNativeRaster,
|
||||||
destroyNativeRaster,
|
destroyNativeRaster,
|
||||||
copyNativeRaster);
|
copyNativeRaster);
|
||||||
Raster::nativeOffsets[PLATFORM_PS2] = nativeRasterOffset;
|
engine[PLATFORM_PS2].rasterNativeOffset = nativeRasterOffset;
|
||||||
Texture::registerPlugin(0, ID_SKYMIPMAP, NULL, NULL, NULL);
|
Texture::registerPlugin(0, ID_SKYMIPMAP, NULL, NULL, NULL);
|
||||||
Texture::registerPluginStream(ID_SKYMIPMAP, readMipmap, writeMipmap, getSizeMipmap);
|
Texture::registerPluginStream(ID_SKYMIPMAP, readMipmap, writeMipmap, getSizeMipmap);
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,9 +6,11 @@
|
||||||
#include <cctype>
|
#include <cctype>
|
||||||
|
|
||||||
#include "rwbase.h"
|
#include "rwbase.h"
|
||||||
#include "rwplugin.h"
|
#include "rwplg.h"
|
||||||
#include "rwpipeline.h"
|
#include "rwpipeline.h"
|
||||||
#include "rwobjects.h"
|
#include "rwobjects.h"
|
||||||
|
#include "rwplugins.h"
|
||||||
|
#include "rwengine.h"
|
||||||
#include "rwps2.h"
|
#include "rwps2.h"
|
||||||
#include "rwogl.h"
|
#include "rwogl.h"
|
||||||
#include "rwxbox.h"
|
#include "rwxbox.h"
|
||||||
|
@ -50,19 +52,27 @@ static Matrix3 identMat3 = {
|
||||||
void
|
void
|
||||||
initialize(void)
|
initialize(void)
|
||||||
{
|
{
|
||||||
|
for(uint i = 0; i < NUM_PLATFORMS; i++){
|
||||||
|
engine[i].rasterCreate = null::rasterCreate;
|
||||||
|
engine[i].rasterLock = null::rasterLock;
|
||||||
|
engine[i].rasterUnlock = null::rasterUnlock;
|
||||||
|
engine[i].rasterNumLevels = null::rasterNumLevels;
|
||||||
|
engine[i].rasterFromImage = null::rasterFromImage;
|
||||||
|
}
|
||||||
|
|
||||||
// Atomic pipelines
|
// Atomic pipelines
|
||||||
ObjPipeline *defpipe = new ObjPipeline(PLATFORM_NULL);
|
ObjPipeline *defpipe = new ObjPipeline(PLATFORM_NULL);
|
||||||
for(uint i = 0; i < nelem(matFXGlobals.pipelines); i++)
|
for(uint i = 0; i < NUM_PLATFORMS; i++)
|
||||||
defaultPipelines[i] = defpipe;
|
engine[i].defaultPipeline = defpipe;
|
||||||
defaultPipelines[PLATFORM_PS2] =
|
engine[PLATFORM_PS2].defaultPipeline =
|
||||||
ps2::makeDefaultPipeline();
|
ps2::makeDefaultPipeline();
|
||||||
defaultPipelines[PLATFORM_OGL] =
|
engine[PLATFORM_OGL].defaultPipeline =
|
||||||
gl::makeDefaultPipeline();
|
gl::makeDefaultPipeline();
|
||||||
defaultPipelines[PLATFORM_XBOX] =
|
engine[PLATFORM_XBOX].defaultPipeline =
|
||||||
xbox::makeDefaultPipeline();
|
xbox::makeDefaultPipeline();
|
||||||
defaultPipelines[PLATFORM_D3D8] =
|
engine[PLATFORM_D3D8].defaultPipeline =
|
||||||
d3d8::makeDefaultPipeline();
|
d3d8::makeDefaultPipeline();
|
||||||
defaultPipelines[PLATFORM_D3D9] =
|
engine[PLATFORM_D3D9].defaultPipeline =
|
||||||
d3d9::makeDefaultPipeline();
|
d3d9::makeDefaultPipeline();
|
||||||
|
|
||||||
Frame::dirtyList.init();
|
Frame::dirtyList.init();
|
||||||
|
|
10
src/rwbase.h
10
src/rwbase.h
|
@ -160,6 +160,10 @@ struct Sphere
|
||||||
float32 radius;
|
float32 radius;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Streams
|
||||||
|
*/
|
||||||
|
|
||||||
class Stream
|
class Stream
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -223,7 +227,7 @@ enum Platform
|
||||||
{
|
{
|
||||||
PLATFORM_NULL = 0,
|
PLATFORM_NULL = 0,
|
||||||
// D3D7
|
// D3D7
|
||||||
PLATFORM_OGL = 2,
|
PLATFORM_OGL = 2, // TODO: remove, this is really WarDrum GL
|
||||||
// MAC
|
// MAC
|
||||||
PLATFORM_PS2 = 4,
|
PLATFORM_PS2 = 4,
|
||||||
PLATFORM_XBOX = 5,
|
PLATFORM_XBOX = 5,
|
||||||
|
@ -231,6 +235,10 @@ enum Platform
|
||||||
// SOFTRAS
|
// SOFTRAS
|
||||||
PLATFORM_D3D8 = 8,
|
PLATFORM_D3D8 = 8,
|
||||||
PLATFORM_D3D9 = 9,
|
PLATFORM_D3D9 = 9,
|
||||||
|
|
||||||
|
// non stock-RW platforms
|
||||||
|
|
||||||
|
PLATFORM_GL3 = 10,
|
||||||
NUM_PLATFORMS,
|
NUM_PLATFORMS,
|
||||||
|
|
||||||
FOURCC_PS2 = 0x00325350 // 'PS2\0'
|
FOURCC_PS2 = 0x00325350 // 'PS2\0'
|
||||||
|
|
|
@ -0,0 +1,25 @@
|
||||||
|
namespace rw {
|
||||||
|
|
||||||
|
struct Engine
|
||||||
|
{
|
||||||
|
ObjPipeline *defaultPipeline;
|
||||||
|
int32 rasterNativeOffset;
|
||||||
|
|
||||||
|
void (*rasterCreate)(Raster*);
|
||||||
|
uint8 *(*rasterLock)(Raster*, int32 level);
|
||||||
|
void (*rasterUnlock)(Raster*, int32 level);
|
||||||
|
int32 (*rasterNumLevels)(Raster*);
|
||||||
|
void (*rasterFromImage)(Raster*, Image*);
|
||||||
|
};
|
||||||
|
|
||||||
|
extern Engine engine[NUM_PLATFORMS];
|
||||||
|
|
||||||
|
namespace null {
|
||||||
|
void rasterCreate(Raster*);
|
||||||
|
uint8 *rasterLock(Raster*, int32 level);
|
||||||
|
void rasterUnlock(Raster*, int32 level);
|
||||||
|
int32 rasterNumLevels(Raster*);
|
||||||
|
void rasterFromImage(Raster*, Image*);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
170
src/rwobjects.h
170
src/rwobjects.h
|
@ -132,13 +132,14 @@ struct Frame : PluginBase<Frame>
|
||||||
|
|
||||||
Frame **makeFrameList(Frame *frame, Frame **flist);
|
Frame **makeFrameList(Frame *frame, Frame **flist);
|
||||||
|
|
||||||
struct ObjectWithFrame : Object
|
struct ObjectWithFrame
|
||||||
{
|
{
|
||||||
|
Object object;
|
||||||
LLLink inFrame;
|
LLLink inFrame;
|
||||||
void setFrame(Frame *f){
|
void setFrame(Frame *f){
|
||||||
if(this->parent)
|
if(this->object.parent)
|
||||||
this->inFrame.remove();
|
this->inFrame.remove();
|
||||||
this->parent = f;
|
this->object.parent = f;
|
||||||
if(f)
|
if(f)
|
||||||
f->objectList.add(&this->inFrame);
|
f->objectList.add(&this->inFrame);
|
||||||
}
|
}
|
||||||
|
@ -147,62 +148,6 @@ struct ObjectWithFrame : Object
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct HAnimKeyFrame
|
|
||||||
{
|
|
||||||
HAnimKeyFrame *prev;
|
|
||||||
float time;
|
|
||||||
float q[4];
|
|
||||||
float t[3];
|
|
||||||
};
|
|
||||||
|
|
||||||
struct HAnimNodeInfo
|
|
||||||
{
|
|
||||||
int32 id;
|
|
||||||
int32 index;
|
|
||||||
int32 flags;
|
|
||||||
Frame *frame;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct HAnimHierarchy
|
|
||||||
{
|
|
||||||
int32 flags;
|
|
||||||
int32 numNodes;
|
|
||||||
float *matrices;
|
|
||||||
float *matricesUnaligned;
|
|
||||||
HAnimNodeInfo *nodeInfo;
|
|
||||||
Frame *parentFrame;
|
|
||||||
HAnimHierarchy *parentHierarchy; // mostly unused
|
|
||||||
|
|
||||||
// temporary
|
|
||||||
int32 maxInterpKeyFrameSize;
|
|
||||||
|
|
||||||
static HAnimHierarchy *create(int32 numNodes, int32 *nodeFlags, int32 *nodeIDs, int32 flags, int32 maxKeySize);
|
|
||||||
void destroy(void);
|
|
||||||
void attachByIndex(int32 id);
|
|
||||||
void attach(void);
|
|
||||||
int32 getIndex(int32 id);
|
|
||||||
|
|
||||||
static HAnimHierarchy *get(Frame *f);
|
|
||||||
static HAnimHierarchy *find(Frame *f);
|
|
||||||
|
|
||||||
enum NodeFlag {
|
|
||||||
POP = 1,
|
|
||||||
PUSH
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
struct HAnimData
|
|
||||||
{
|
|
||||||
int32 id;
|
|
||||||
HAnimHierarchy *hierarchy;
|
|
||||||
|
|
||||||
static HAnimData *get(Frame *f);
|
|
||||||
};
|
|
||||||
|
|
||||||
extern int32 hAnimOffset;
|
|
||||||
extern bool32 hAnimDoStream;
|
|
||||||
void registerHAnimPlugin(void);
|
|
||||||
|
|
||||||
struct Image
|
struct Image
|
||||||
{
|
{
|
||||||
int32 flags;
|
int32 flags;
|
||||||
|
@ -250,8 +195,6 @@ struct Raster : PluginBase<Raster>
|
||||||
uint8 *texels;
|
uint8 *texels;
|
||||||
uint8 *palette;
|
uint8 *palette;
|
||||||
|
|
||||||
static int32 nativeOffsets[NUM_PLATFORMS];
|
|
||||||
|
|
||||||
static Raster *create(int32 width, int32 height, int32 depth, int32 format, int32 platform = 0);
|
static Raster *create(int32 width, int32 height, int32 depth, int32 format, int32 platform = 0);
|
||||||
void destroy(void);
|
void destroy(void);
|
||||||
static Raster *createFromImage(Image *image);
|
static Raster *createFromImage(Image *image);
|
||||||
|
@ -340,6 +283,7 @@ struct Texture : PluginBase<Texture>
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
struct SurfaceProperties
|
struct SurfaceProperties
|
||||||
{
|
{
|
||||||
float32 ambient;
|
float32 ambient;
|
||||||
|
@ -365,72 +309,6 @@ struct Material : PluginBase<Material>
|
||||||
|
|
||||||
void registerMaterialRightsPlugin(void);
|
void registerMaterialRightsPlugin(void);
|
||||||
|
|
||||||
struct MatFX
|
|
||||||
{
|
|
||||||
enum {
|
|
||||||
NOTHING = 0,
|
|
||||||
BUMPMAP,
|
|
||||||
ENVMAP,
|
|
||||||
BUMPENVMAP, // BUMP | ENV
|
|
||||||
DUAL,
|
|
||||||
UVTRANSFORM,
|
|
||||||
DUALUVTRANSFORM
|
|
||||||
};
|
|
||||||
struct Bump {
|
|
||||||
Frame *frame;
|
|
||||||
Texture *bumpedTex;
|
|
||||||
Texture *tex;
|
|
||||||
float coefficient;
|
|
||||||
};
|
|
||||||
struct Env {
|
|
||||||
Frame *frame;
|
|
||||||
Texture *tex;
|
|
||||||
float coefficient;
|
|
||||||
int32 fbAlpha;
|
|
||||||
};
|
|
||||||
struct Dual {
|
|
||||||
Texture *tex;
|
|
||||||
int32 srcBlend;
|
|
||||||
int32 dstBlend;
|
|
||||||
};
|
|
||||||
struct UVtransform {
|
|
||||||
float *baseTransform;
|
|
||||||
float *dualTransform;
|
|
||||||
};
|
|
||||||
struct {
|
|
||||||
uint32 type;
|
|
||||||
union {
|
|
||||||
Bump bump;
|
|
||||||
Env env;
|
|
||||||
Dual dual;
|
|
||||||
UVtransform uvtransform;
|
|
||||||
};
|
|
||||||
} fx[2];
|
|
||||||
uint32 type;
|
|
||||||
|
|
||||||
void setEffects(uint32 flags);
|
|
||||||
static uint32 getEffects(Material *m);
|
|
||||||
uint32 getEffectIndex(uint32 type);
|
|
||||||
void setBumpTexture(Texture *t);
|
|
||||||
void setBumpCoefficient(float32 coef);
|
|
||||||
void setEnvTexture(Texture *t);
|
|
||||||
void setEnvCoefficient(float32 coef);
|
|
||||||
void setDualTexture(Texture *t);
|
|
||||||
void setDualSrcBlend(int32 blend);
|
|
||||||
void setDualDestBlend(int32 blend);
|
|
||||||
|
|
||||||
static void enableEffects(Atomic *atomic);
|
|
||||||
};
|
|
||||||
|
|
||||||
struct MatFXGlobals
|
|
||||||
{
|
|
||||||
int32 atomicOffset;
|
|
||||||
int32 materialOffset;
|
|
||||||
ObjPipeline *pipelines[NUM_PLATFORMS];
|
|
||||||
};
|
|
||||||
extern MatFXGlobals matFXGlobals;
|
|
||||||
void registerMatFXPlugin(void);
|
|
||||||
|
|
||||||
struct Mesh
|
struct Mesh
|
||||||
{
|
{
|
||||||
uint16 *indices;
|
uint16 *indices;
|
||||||
|
@ -528,32 +406,6 @@ struct Geometry : PluginBase<Geometry>
|
||||||
void registerMeshPlugin(void);
|
void registerMeshPlugin(void);
|
||||||
void registerNativeDataPlugin(void);
|
void registerNativeDataPlugin(void);
|
||||||
|
|
||||||
struct Skin
|
|
||||||
{
|
|
||||||
int32 numBones;
|
|
||||||
int32 numUsedBones;
|
|
||||||
int32 numWeights;
|
|
||||||
uint8 *usedBones;
|
|
||||||
float *inverseMatrices;
|
|
||||||
uint8 *indices;
|
|
||||||
float *weights;
|
|
||||||
uint8 *data; // only used by delete
|
|
||||||
void *platformData; // a place to store platform specific stuff
|
|
||||||
|
|
||||||
void init(int32 numBones, int32 numUsedBones, int32 numVertices);
|
|
||||||
void findNumWeights(int32 numVertices);
|
|
||||||
void findUsedBones(int32 numVertices);
|
|
||||||
static void setPipeline(Atomic *a, int32 type);
|
|
||||||
};
|
|
||||||
|
|
||||||
struct SkinGlobals
|
|
||||||
{
|
|
||||||
int32 offset;
|
|
||||||
ObjPipeline *pipelines[NUM_PLATFORMS];
|
|
||||||
};
|
|
||||||
extern SkinGlobals skinGlobals;
|
|
||||||
void registerSkinPlugin(void);
|
|
||||||
|
|
||||||
struct Clump;
|
struct Clump;
|
||||||
|
|
||||||
struct Atomic : PluginBase<Atomic>
|
struct Atomic : PluginBase<Atomic>
|
||||||
|
@ -580,9 +432,9 @@ struct Atomic : PluginBase<Atomic>
|
||||||
void destroy(void);
|
void destroy(void);
|
||||||
void setFrame(Frame *f) {
|
void setFrame(Frame *f) {
|
||||||
this->object.setFrame(f);
|
this->object.setFrame(f);
|
||||||
this->object.privateFlags |= WORLDBOUNDDIRTY;
|
this->object.object.privateFlags |= WORLDBOUNDDIRTY;
|
||||||
}
|
}
|
||||||
Frame *getFrame(void) { return (Frame*)this->object.parent; }
|
Frame *getFrame(void) { return (Frame*)this->object.object.parent; }
|
||||||
static Atomic *fromClump(LLLink *lnk){
|
static Atomic *fromClump(LLLink *lnk){
|
||||||
return LLLinkGetData(lnk, Atomic, inClump); }
|
return LLLinkGetData(lnk, Atomic, inClump); }
|
||||||
ObjPipeline *getPipeline(void);
|
ObjPipeline *getPipeline(void);
|
||||||
|
@ -597,8 +449,6 @@ struct Atomic : PluginBase<Atomic>
|
||||||
static void defaultRenderCB(Atomic *atomic);
|
static void defaultRenderCB(Atomic *atomic);
|
||||||
};
|
};
|
||||||
|
|
||||||
extern ObjPipeline *defaultPipelines[NUM_PLATFORMS];
|
|
||||||
|
|
||||||
void registerAtomicRightsPlugin(void);
|
void registerAtomicRightsPlugin(void);
|
||||||
|
|
||||||
struct Light : PluginBase<Light>
|
struct Light : PluginBase<Light>
|
||||||
|
@ -616,13 +466,13 @@ struct Light : PluginBase<Light>
|
||||||
static Light *create(int32 type);
|
static Light *create(int32 type);
|
||||||
void destroy(void);
|
void destroy(void);
|
||||||
void setFrame(Frame *f) { this->object.setFrame(f); }
|
void setFrame(Frame *f) { this->object.setFrame(f); }
|
||||||
Frame *getFrame(void){ return (Frame*)this->object.parent; }
|
Frame *getFrame(void){ return (Frame*)this->object.object.parent; }
|
||||||
static Light *fromClump(LLLink *lnk){
|
static Light *fromClump(LLLink *lnk){
|
||||||
return LLLinkGetData(lnk, Light, inClump); }
|
return LLLinkGetData(lnk, Light, inClump); }
|
||||||
void setAngle(float32 angle);
|
void setAngle(float32 angle);
|
||||||
float32 getAngle(void);
|
float32 getAngle(void);
|
||||||
void setColor(float32 r, float32 g, float32 b);
|
void setColor(float32 r, float32 g, float32 b);
|
||||||
int32 getType(void){ return this->object.subType; }
|
int32 getType(void){ return this->object.object.subType; }
|
||||||
static Light *streamRead(Stream *stream);
|
static Light *streamRead(Stream *stream);
|
||||||
bool streamWrite(Stream *stream);
|
bool streamWrite(Stream *stream);
|
||||||
uint32 streamGetSize(void);
|
uint32 streamGetSize(void);
|
||||||
|
@ -660,7 +510,7 @@ struct Camera : PluginBase<Camera>
|
||||||
Camera *clone(void);
|
Camera *clone(void);
|
||||||
void destroy(void);
|
void destroy(void);
|
||||||
void setFrame(Frame *f) { this->object.setFrame(f); }
|
void setFrame(Frame *f) { this->object.setFrame(f); }
|
||||||
Frame *getFrame(void){ return (Frame*)this->object.parent; }
|
Frame *getFrame(void){ return (Frame*)this->object.object.parent; }
|
||||||
static Camera *fromClump(LLLink *lnk){
|
static Camera *fromClump(LLLink *lnk){
|
||||||
return LLLinkGetData(lnk, Camera, inClump); }
|
return LLLinkGetData(lnk, Camera, inClump); }
|
||||||
static Camera *streamRead(Stream *stream);
|
static Camera *streamRead(Stream *stream);
|
||||||
|
|
|
@ -0,0 +1,165 @@
|
||||||
|
namespace rw {
|
||||||
|
|
||||||
|
/*
|
||||||
|
* HAnim
|
||||||
|
*/
|
||||||
|
|
||||||
|
struct HAnimKeyFrame
|
||||||
|
{
|
||||||
|
HAnimKeyFrame *prev;
|
||||||
|
float time;
|
||||||
|
float q[4];
|
||||||
|
float t[3];
|
||||||
|
};
|
||||||
|
|
||||||
|
struct HAnimNodeInfo
|
||||||
|
{
|
||||||
|
int32 id;
|
||||||
|
int32 index;
|
||||||
|
int32 flags;
|
||||||
|
Frame *frame;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct HAnimHierarchy
|
||||||
|
{
|
||||||
|
int32 flags;
|
||||||
|
int32 numNodes;
|
||||||
|
float *matrices;
|
||||||
|
float *matricesUnaligned;
|
||||||
|
HAnimNodeInfo *nodeInfo;
|
||||||
|
Frame *parentFrame;
|
||||||
|
HAnimHierarchy *parentHierarchy; // mostly unused
|
||||||
|
|
||||||
|
// temporary
|
||||||
|
int32 maxInterpKeyFrameSize;
|
||||||
|
|
||||||
|
static HAnimHierarchy *create(int32 numNodes, int32 *nodeFlags, int32 *nodeIDs, int32 flags, int32 maxKeySize);
|
||||||
|
void destroy(void);
|
||||||
|
void attachByIndex(int32 id);
|
||||||
|
void attach(void);
|
||||||
|
int32 getIndex(int32 id);
|
||||||
|
|
||||||
|
static HAnimHierarchy *get(Frame *f);
|
||||||
|
static HAnimHierarchy *find(Frame *f);
|
||||||
|
|
||||||
|
enum NodeFlag {
|
||||||
|
POP = 1,
|
||||||
|
PUSH
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
struct HAnimData
|
||||||
|
{
|
||||||
|
int32 id;
|
||||||
|
HAnimHierarchy *hierarchy;
|
||||||
|
|
||||||
|
static HAnimData *get(Frame *f);
|
||||||
|
};
|
||||||
|
|
||||||
|
extern int32 hAnimOffset;
|
||||||
|
extern bool32 hAnimDoStream;
|
||||||
|
void registerHAnimPlugin(void);
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* MatFX
|
||||||
|
*/
|
||||||
|
|
||||||
|
struct MatFX
|
||||||
|
{
|
||||||
|
enum {
|
||||||
|
NOTHING = 0,
|
||||||
|
BUMPMAP,
|
||||||
|
ENVMAP,
|
||||||
|
BUMPENVMAP, // BUMP | ENV
|
||||||
|
DUAL,
|
||||||
|
UVTRANSFORM,
|
||||||
|
DUALUVTRANSFORM
|
||||||
|
};
|
||||||
|
struct Bump {
|
||||||
|
Frame *frame;
|
||||||
|
Texture *bumpedTex;
|
||||||
|
Texture *tex;
|
||||||
|
float coefficient;
|
||||||
|
};
|
||||||
|
struct Env {
|
||||||
|
Frame *frame;
|
||||||
|
Texture *tex;
|
||||||
|
float coefficient;
|
||||||
|
int32 fbAlpha;
|
||||||
|
};
|
||||||
|
struct Dual {
|
||||||
|
Texture *tex;
|
||||||
|
int32 srcBlend;
|
||||||
|
int32 dstBlend;
|
||||||
|
};
|
||||||
|
struct UVtransform {
|
||||||
|
float *baseTransform;
|
||||||
|
float *dualTransform;
|
||||||
|
};
|
||||||
|
struct {
|
||||||
|
uint32 type;
|
||||||
|
union {
|
||||||
|
Bump bump;
|
||||||
|
Env env;
|
||||||
|
Dual dual;
|
||||||
|
UVtransform uvtransform;
|
||||||
|
};
|
||||||
|
} fx[2];
|
||||||
|
uint32 type;
|
||||||
|
|
||||||
|
void setEffects(uint32 flags);
|
||||||
|
static uint32 getEffects(Material *m);
|
||||||
|
uint32 getEffectIndex(uint32 type);
|
||||||
|
void setBumpTexture(Texture *t);
|
||||||
|
void setBumpCoefficient(float32 coef);
|
||||||
|
void setEnvTexture(Texture *t);
|
||||||
|
void setEnvCoefficient(float32 coef);
|
||||||
|
void setDualTexture(Texture *t);
|
||||||
|
void setDualSrcBlend(int32 blend);
|
||||||
|
void setDualDestBlend(int32 blend);
|
||||||
|
|
||||||
|
static void enableEffects(Atomic *atomic);
|
||||||
|
};
|
||||||
|
|
||||||
|
struct MatFXGlobals
|
||||||
|
{
|
||||||
|
int32 atomicOffset;
|
||||||
|
int32 materialOffset;
|
||||||
|
ObjPipeline *pipelines[NUM_PLATFORMS];
|
||||||
|
};
|
||||||
|
extern MatFXGlobals matFXGlobals;
|
||||||
|
void registerMatFXPlugin(void);
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Skin
|
||||||
|
*/
|
||||||
|
|
||||||
|
struct Skin
|
||||||
|
{
|
||||||
|
int32 numBones;
|
||||||
|
int32 numUsedBones;
|
||||||
|
int32 numWeights;
|
||||||
|
uint8 *usedBones;
|
||||||
|
float *inverseMatrices;
|
||||||
|
uint8 *indices;
|
||||||
|
float *weights;
|
||||||
|
uint8 *data; // only used by delete
|
||||||
|
void *platformData; // a place to store platform specific stuff
|
||||||
|
|
||||||
|
void init(int32 numBones, int32 numUsedBones, int32 numVertices);
|
||||||
|
void findNumWeights(int32 numVertices);
|
||||||
|
void findUsedBones(int32 numVertices);
|
||||||
|
static void setPipeline(Atomic *a, int32 type);
|
||||||
|
};
|
||||||
|
|
||||||
|
struct SkinGlobals
|
||||||
|
{
|
||||||
|
int32 offset;
|
||||||
|
ObjPipeline *pipelines[NUM_PLATFORMS];
|
||||||
|
};
|
||||||
|
extern SkinGlobals skinGlobals;
|
||||||
|
void registerSkinPlugin(void);
|
||||||
|
|
||||||
|
}
|
16
src/rwps2.h
16
src/rwps2.h
|
@ -141,24 +141,8 @@ void skinInstanceCB(MatPipeline *, Geometry *g, Mesh *m, uint8 **data);
|
||||||
//void skinUninstanceCB(MatPipeline*, Geometry *geo, uint32 flags[], Mesh *mesh, uint8 *data[]);
|
//void skinUninstanceCB(MatPipeline*, Geometry *geo, uint32 flags[], Mesh *mesh, uint8 *data[]);
|
||||||
|
|
||||||
ObjPipeline *makeDefaultPipeline(void);
|
ObjPipeline *makeDefaultPipeline(void);
|
||||||
ObjPipeline *makeSkinPipeline(void);
|
|
||||||
ObjPipeline *makeMatFXPipeline(void);
|
|
||||||
void dumpPipeline(rw::Pipeline *pipe);
|
void dumpPipeline(rw::Pipeline *pipe);
|
||||||
|
|
||||||
// Skin plugin
|
|
||||||
|
|
||||||
void insertVertexSkin(Geometry *geo, int32 i, uint32 mask, Vertex *v);
|
|
||||||
int32 findVertexSkin(Geometry *g, uint32 flags[], uint32 mask, Vertex *v);
|
|
||||||
|
|
||||||
void readNativeSkin(Stream *stream, int32, void *object, int32 offset);
|
|
||||||
void writeNativeSkin(Stream *stream, int32 len, void *object, int32 offset);
|
|
||||||
int32 getSizeNativeSkin(void *object, int32 offset);
|
|
||||||
|
|
||||||
void instanceSkinData(Geometry *g, Mesh *m, Skin *skin, uint32 *data);
|
|
||||||
|
|
||||||
void skinPreCB(MatPipeline*, Geometry*);
|
|
||||||
void skinPostCB(MatPipeline*, Geometry*);
|
|
||||||
|
|
||||||
// ADC plugin
|
// ADC plugin
|
||||||
|
|
||||||
// Each element in adcBits corresponds to an index in Mesh->indices,
|
// Each element in adcBits corresponds to an index in Mesh->indices,
|
||||||
|
|
|
@ -0,0 +1,22 @@
|
||||||
|
namespace rw {
|
||||||
|
namespace ps2 {
|
||||||
|
|
||||||
|
ObjPipeline *makeSkinPipeline(void);
|
||||||
|
ObjPipeline *makeMatFXPipeline(void);
|
||||||
|
|
||||||
|
// Skin plugin
|
||||||
|
|
||||||
|
void insertVertexSkin(Geometry *geo, int32 i, uint32 mask, Vertex *v);
|
||||||
|
int32 findVertexSkin(Geometry *g, uint32 flags[], uint32 mask, Vertex *v);
|
||||||
|
|
||||||
|
void readNativeSkin(Stream *stream, int32, void *object, int32 offset);
|
||||||
|
void writeNativeSkin(Stream *stream, int32 len, void *object, int32 offset);
|
||||||
|
int32 getSizeNativeSkin(void *object, int32 offset);
|
||||||
|
|
||||||
|
void instanceSkinData(Geometry *g, Mesh *m, Skin *skin, uint32 *data);
|
||||||
|
|
||||||
|
void skinPreCB(MatPipeline*, Geometry*);
|
||||||
|
void skinPostCB(MatPipeline*, Geometry*);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -6,9 +6,11 @@
|
||||||
#include <new>
|
#include <new>
|
||||||
|
|
||||||
#include "rwbase.h"
|
#include "rwbase.h"
|
||||||
#include "rwplugin.h"
|
#include "rwplg.h"
|
||||||
#include "rwpipeline.h"
|
#include "rwpipeline.h"
|
||||||
#include "rwobjects.h"
|
#include "rwobjects.h"
|
||||||
|
#include "rwengine.h"
|
||||||
|
#include "rwplugins.h"
|
||||||
#include "rwxbox.h"
|
#include "rwxbox.h"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
@ -867,7 +869,7 @@ registerNativeRaster(void)
|
||||||
createNativeRaster,
|
createNativeRaster,
|
||||||
destroyNativeRaster,
|
destroyNativeRaster,
|
||||||
copyNativeRaster);
|
copyNativeRaster);
|
||||||
Raster::nativeOffsets[PLATFORM_XBOX] = nativeRasterOffset;
|
engine[PLATFORM_XBOX].rasterNativeOffset = nativeRasterOffset;
|
||||||
}
|
}
|
||||||
|
|
||||||
Texture*
|
Texture*
|
||||||
|
|
Loading…
Reference in New Issue