mirror of
https://github.com/aap/librw.git
synced 2025-12-18 16:39:51 +00:00
Changed naming convention and clean up somewhat. ps2 test no longer links :(
This commit is contained in:
@@ -11,7 +11,7 @@
|
||||
|
||||
using namespace std;
|
||||
|
||||
namespace Rw {
|
||||
namespace rw {
|
||||
|
||||
Frame::Frame(void)
|
||||
{
|
||||
@@ -196,7 +196,7 @@ Clump::streamRead(Stream *stream)
|
||||
uint32 length, version;
|
||||
int32 buf[3];
|
||||
Clump *clump;
|
||||
assert(FindChunk(stream, ID_STRUCT, &length, &version));
|
||||
assert(findChunk(stream, ID_STRUCT, &length, &version));
|
||||
clump = new Clump;
|
||||
stream->read(buf, length);
|
||||
clump->numAtomics = buf[0];
|
||||
@@ -215,14 +215,14 @@ Clump::streamRead(Stream *stream)
|
||||
|
||||
// Geometry list
|
||||
int32 numGeometries = 0;
|
||||
assert(FindChunk(stream, ID_GEOMETRYLIST, NULL, NULL));
|
||||
assert(FindChunk(stream, ID_STRUCT, NULL, NULL));
|
||||
assert(findChunk(stream, ID_GEOMETRYLIST, NULL, NULL));
|
||||
assert(findChunk(stream, ID_STRUCT, NULL, NULL));
|
||||
numGeometries = stream->readI32();
|
||||
Geometry **geometryList = 0;
|
||||
if(numGeometries)
|
||||
geometryList = new Geometry*[numGeometries];
|
||||
for(int32 i = 0; i < numGeometries; i++){
|
||||
assert(FindChunk(stream, ID_GEOMETRY, NULL, NULL));
|
||||
assert(findChunk(stream, ID_GEOMETRY, NULL, NULL));
|
||||
geometryList[i] = Geometry::streamRead(stream);
|
||||
}
|
||||
|
||||
@@ -230,7 +230,7 @@ Clump::streamRead(Stream *stream)
|
||||
if(clump->numAtomics)
|
||||
clump->atomicList = new Atomic*[clump->numAtomics];
|
||||
for(int32 i = 0; i < clump->numAtomics; i++){
|
||||
assert(FindChunk(stream, ID_ATOMIC, NULL, NULL));
|
||||
assert(findChunk(stream, ID_ATOMIC, NULL, NULL));
|
||||
clump->atomicList[i] = Atomic::streamReadClump(stream,
|
||||
frameList, geometryList);
|
||||
clump->atomicList[i]->clump = clump;
|
||||
@@ -241,9 +241,9 @@ Clump::streamRead(Stream *stream)
|
||||
clump->lightList = new Light*[clump->numLights];
|
||||
for(int32 i = 0; i < clump->numLights; i++){
|
||||
int32 frm;
|
||||
assert(FindChunk(stream, ID_STRUCT, NULL, NULL));
|
||||
assert(findChunk(stream, ID_STRUCT, NULL, NULL));
|
||||
frm = stream->readI32();
|
||||
assert(FindChunk(stream, ID_LIGHT, NULL, NULL));
|
||||
assert(findChunk(stream, ID_LIGHT, NULL, NULL));
|
||||
clump->lightList[i] = Light::streamRead(stream);
|
||||
clump->lightList[i]->frame = frameList[frm];
|
||||
clump->lightList[i]->clump = clump;
|
||||
@@ -259,10 +259,10 @@ bool
|
||||
Clump::streamWrite(Stream *stream)
|
||||
{
|
||||
int size = this->streamGetSize();
|
||||
WriteChunkHeader(stream, ID_CLUMP, size);
|
||||
writeChunkHeader(stream, ID_CLUMP, size);
|
||||
int buf[3] = { this->numAtomics, this->numLights, this->numCameras };
|
||||
size = Version >= 0x33000 ? 12 : 4;
|
||||
WriteChunkHeader(stream, ID_STRUCT, size);
|
||||
size = version >= 0x33000 ? 12 : 4;
|
||||
writeChunkHeader(stream, ID_STRUCT, size);
|
||||
stream->write(buf, size);
|
||||
|
||||
int32 numFrames = ((Frame*)this->parent)->count();
|
||||
@@ -274,8 +274,8 @@ Clump::streamWrite(Stream *stream)
|
||||
size = 12+4;
|
||||
for(int32 i = 0; i < this->numAtomics; i++)
|
||||
size += 12 + this->atomicList[i]->geometry->streamGetSize();
|
||||
WriteChunkHeader(stream, ID_GEOMETRYLIST, size);
|
||||
WriteChunkHeader(stream, ID_STRUCT, 4);
|
||||
writeChunkHeader(stream, ID_GEOMETRYLIST, size);
|
||||
writeChunkHeader(stream, ID_STRUCT, 4);
|
||||
stream->writeI32(this->numAtomics); // same as numGeometries
|
||||
for(int32 i = 0; i < this->numAtomics; i++)
|
||||
this->atomicList[i]->geometry->streamWrite(stream);
|
||||
@@ -288,7 +288,7 @@ Clump::streamWrite(Stream *stream)
|
||||
int frm = findPointer((void*)l->frame, (void**)flist,numFrames);
|
||||
if(frm < 0)
|
||||
return false;
|
||||
WriteChunkHeader(stream, ID_STRUCT, 4);
|
||||
writeChunkHeader(stream, ID_STRUCT, 4);
|
||||
stream->writeI32(frm);
|
||||
l->streamWrite(stream);
|
||||
}
|
||||
@@ -313,7 +313,7 @@ Clump::streamGetSize(void)
|
||||
uint32 size = 0;
|
||||
size += 12; // Struct
|
||||
size += 4; // numAtomics
|
||||
if(Version >= 0x33000)
|
||||
if(version >= 0x33000)
|
||||
size += 8; // numLights, numCameras
|
||||
|
||||
// frame list
|
||||
@@ -344,8 +344,8 @@ Clump::frameListStreamRead(Stream *stream, Frame ***flp, int32 *nf)
|
||||
{
|
||||
FrameStreamData buf;
|
||||
int32 numFrames = 0;
|
||||
assert(FindChunk(stream, ID_FRAMELIST, NULL, NULL));
|
||||
assert(FindChunk(stream, ID_STRUCT, NULL, NULL));
|
||||
assert(findChunk(stream, ID_FRAMELIST, NULL, NULL));
|
||||
assert(findChunk(stream, ID_STRUCT, NULL, NULL));
|
||||
numFrames = stream->readI32();
|
||||
Frame **frameList = new Frame*[numFrames];
|
||||
for(int32 i = 0; i < numFrames; i++){
|
||||
@@ -389,8 +389,8 @@ Clump::frameListStreamWrite(Stream *stream, Frame **frameList, int32 numFrames)
|
||||
for(int32 i = 0; i < numFrames; i++)
|
||||
size += 12 + frameList[i]->streamGetPluginSize();
|
||||
|
||||
WriteChunkHeader(stream, ID_FRAMELIST, size);
|
||||
WriteChunkHeader(stream, ID_STRUCT, structsize);
|
||||
writeChunkHeader(stream, ID_FRAMELIST, size);
|
||||
writeChunkHeader(stream, ID_STRUCT, structsize);
|
||||
stream->writeU32(numFrames);
|
||||
for(int32 i = 0; i < numFrames; i++){
|
||||
Frame *f = frameList[i];
|
||||
@@ -445,7 +445,7 @@ Atomic::streamReadClump(Stream *stream,
|
||||
Frame **frameList, Geometry **geometryList)
|
||||
{
|
||||
int32 buf[4];
|
||||
assert(FindChunk(stream, ID_STRUCT, NULL, NULL));
|
||||
assert(findChunk(stream, ID_STRUCT, NULL, NULL));
|
||||
stream->read(buf, 16);
|
||||
Atomic *atomic = new Atomic;
|
||||
atomic->frame = frameList[buf[0]];
|
||||
@@ -465,8 +465,8 @@ Atomic::streamWriteClump(Stream *stream, Frame **frameList, int32 numFrames)
|
||||
Clump *c = this->clump;
|
||||
if(c == NULL)
|
||||
return false;
|
||||
WriteChunkHeader(stream, ID_ATOMIC, this->streamGetSize());
|
||||
WriteChunkHeader(stream, ID_STRUCT, 16);
|
||||
writeChunkHeader(stream, ID_ATOMIC, this->streamGetSize());
|
||||
writeChunkHeader(stream, ID_STRUCT, 16);
|
||||
buf[0] = findPointer((void*)this->frame, (void**)frameList, numFrames);
|
||||
|
||||
// TODO
|
||||
@@ -515,7 +515,7 @@ getSizeAtomicRights(void *object, int32, int32)
|
||||
}
|
||||
|
||||
void
|
||||
RegisterAtomicRightsPlugin(void)
|
||||
registerAtomicRightsPlugin(void)
|
||||
{
|
||||
Atomic::registerPlugin(0, ID_RIGHTTORENDER, NULL, NULL, NULL);
|
||||
Atomic::registerPluginStream(ID_RIGHTTORENDER,
|
||||
@@ -559,7 +559,7 @@ Light*
|
||||
Light::streamRead(Stream *stream)
|
||||
{
|
||||
LightChunkData buf;
|
||||
assert(FindChunk(stream, ID_STRUCT, NULL, NULL));
|
||||
assert(findChunk(stream, ID_STRUCT, NULL, NULL));
|
||||
Light *light = new Light;
|
||||
stream->read(&buf, sizeof(LightChunkData));
|
||||
light->radius = buf.radius;
|
||||
@@ -579,8 +579,8 @@ bool
|
||||
Light::streamWrite(Stream *stream)
|
||||
{
|
||||
LightChunkData buf;
|
||||
WriteChunkHeader(stream, ID_LIGHT, this->streamGetSize());
|
||||
WriteChunkHeader(stream, ID_STRUCT, sizeof(LightChunkData));
|
||||
writeChunkHeader(stream, ID_LIGHT, this->streamGetSize());
|
||||
writeChunkHeader(stream, ID_STRUCT, sizeof(LightChunkData));
|
||||
buf.radius = this->radius;
|
||||
buf.red = this->color[0];
|
||||
buf.green = this->color[1];
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
|
||||
using namespace std;
|
||||
|
||||
namespace Rw {
|
||||
namespace rw {
|
||||
|
||||
Geometry::Geometry(int32 numVerts, int32 numTris, uint32 flags)
|
||||
{
|
||||
@@ -103,7 +103,7 @@ Geometry::streamRead(Stream *stream)
|
||||
{
|
||||
uint32 version;
|
||||
GeoStreamData buf;
|
||||
assert(FindChunk(stream, ID_STRUCT, NULL, &version));
|
||||
assert(findChunk(stream, ID_STRUCT, NULL, &version));
|
||||
stream->read(&buf, sizeof(buf));
|
||||
Geometry *geo = new Geometry(buf.numVertices,
|
||||
buf.numTriangles, buf.flags);
|
||||
@@ -132,13 +132,13 @@ Geometry::streamRead(Stream *stream)
|
||||
stream->read(m->normals, 3*geo->numVertices*4);
|
||||
}
|
||||
|
||||
assert(FindChunk(stream, ID_MATLIST, NULL, NULL));
|
||||
assert(FindChunk(stream, ID_STRUCT, NULL, NULL));
|
||||
assert(findChunk(stream, ID_MATLIST, NULL, NULL));
|
||||
assert(findChunk(stream, ID_STRUCT, NULL, NULL));
|
||||
geo->numMaterials = stream->readI32();
|
||||
geo->materialList = new Material*[geo->numMaterials];
|
||||
stream->seek(geo->numMaterials*4); // unused (-1)
|
||||
for(int32 i = 0; i < geo->numMaterials; i++){
|
||||
assert(FindChunk(stream, ID_MATERIAL, NULL, NULL));
|
||||
assert(findChunk(stream, ID_MATERIAL, NULL, NULL));
|
||||
geo->materialList[i] = Material::streamRead(stream);
|
||||
}
|
||||
|
||||
@@ -152,7 +152,7 @@ geoStructSize(Geometry *geo)
|
||||
{
|
||||
uint32 size = 0;
|
||||
size += sizeof(GeoStreamData);
|
||||
if(Version < 0x34000)
|
||||
if(version < 0x34000)
|
||||
size += 12; // surface properties
|
||||
if(!(geo->geoflags & Geometry::NATIVE)){
|
||||
if(geo->geoflags&geo->PRELIT)
|
||||
@@ -181,15 +181,15 @@ Geometry::streamWrite(Stream *stream)
|
||||
uint32 size;
|
||||
static float32 fbuf[3] = { 1.0f, 1.0f, 1.0f };
|
||||
|
||||
WriteChunkHeader(stream, ID_GEOMETRY, this->streamGetSize());
|
||||
WriteChunkHeader(stream, ID_STRUCT, geoStructSize(this));
|
||||
writeChunkHeader(stream, ID_GEOMETRY, this->streamGetSize());
|
||||
writeChunkHeader(stream, ID_STRUCT, geoStructSize(this));
|
||||
|
||||
buf.flags = this->geoflags | this->numTexCoordSets << 16;
|
||||
buf.numTriangles = this->numTriangles;
|
||||
buf.numVertices = this->numVertices;
|
||||
buf.numMorphTargets = this->numMorphTargets;
|
||||
stream->write(&buf, sizeof(buf));
|
||||
if(Version < 0x34000)
|
||||
if(version < 0x34000)
|
||||
stream->write(fbuf, sizeof(fbuf));
|
||||
|
||||
if(!(this->geoflags & NATIVE)){
|
||||
@@ -222,8 +222,8 @@ Geometry::streamWrite(Stream *stream)
|
||||
size = 12 + 4;
|
||||
for(int32 i = 0; i < this->numMaterials; i++)
|
||||
size += 4 + 12 + this->materialList[i]->streamGetSize();
|
||||
WriteChunkHeader(stream, ID_MATLIST, size);
|
||||
WriteChunkHeader(stream, ID_STRUCT, 4 + this->numMaterials*4);
|
||||
writeChunkHeader(stream, ID_MATLIST, size);
|
||||
writeChunkHeader(stream, ID_STRUCT, 4 + this->numMaterials*4);
|
||||
stream->writeI32(this->numMaterials);
|
||||
for(int32 i = 0; i < this->numMaterials; i++)
|
||||
stream->writeI32(-1);
|
||||
@@ -330,7 +330,7 @@ Material::streamRead(Stream *stream)
|
||||
{
|
||||
uint32 length;
|
||||
MatStreamData buf;
|
||||
assert(FindChunk(stream, ID_STRUCT, NULL, NULL));
|
||||
assert(findChunk(stream, ID_STRUCT, NULL, NULL));
|
||||
stream->read(&buf, sizeof(buf));
|
||||
Material *mat = new Material;
|
||||
mat->color[0] = buf.color[0];
|
||||
@@ -342,7 +342,7 @@ Material::streamRead(Stream *stream)
|
||||
mat->surfaceProps[2] = buf.surfaceProps[2];
|
||||
|
||||
if(buf.textured){
|
||||
assert(FindChunk(stream, ID_TEXTURE, &length, NULL));
|
||||
assert(findChunk(stream, ID_TEXTURE, &length, NULL));
|
||||
mat->texture = Texture::streamRead(stream);
|
||||
}
|
||||
|
||||
@@ -358,8 +358,8 @@ Material::streamWrite(Stream *stream)
|
||||
{
|
||||
MatStreamData buf;
|
||||
|
||||
WriteChunkHeader(stream, ID_MATERIAL, this->streamGetSize());
|
||||
WriteChunkHeader(stream, ID_STRUCT, sizeof(MatStreamData));
|
||||
writeChunkHeader(stream, ID_MATERIAL, this->streamGetSize());
|
||||
writeChunkHeader(stream, ID_STRUCT, sizeof(MatStreamData));
|
||||
|
||||
buf.color[0] = this->color[0];
|
||||
buf.color[1] = this->color[1];
|
||||
@@ -420,7 +420,7 @@ getSizeMaterialRights(void *object, int32, int32)
|
||||
}
|
||||
|
||||
void
|
||||
RegisterMaterialRightsPlugin(void)
|
||||
registerMaterialRightsPlugin(void)
|
||||
{
|
||||
Material::registerPlugin(0, ID_RIGHTTORENDER, NULL, NULL, NULL);
|
||||
Material::registerPluginStream(ID_RIGHTTORENDER,
|
||||
|
||||
@@ -2,9 +2,6 @@
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
#include <cassert>
|
||||
|
||||
//#include <iostream>
|
||||
//#include <fstream>
|
||||
#include <new>
|
||||
|
||||
#include "rwbase.h"
|
||||
@@ -14,7 +11,7 @@
|
||||
|
||||
using namespace std;
|
||||
|
||||
namespace Rw {
|
||||
namespace gta {
|
||||
|
||||
//
|
||||
// Frame
|
||||
@@ -22,7 +19,7 @@ namespace Rw {
|
||||
|
||||
// Node Name
|
||||
|
||||
int32 NodeNameOffset;
|
||||
int32 nodeNameOffset;
|
||||
|
||||
static void*
|
||||
createNodeName(void *object, int32 offset, int32)
|
||||
@@ -72,9 +69,9 @@ getSizeNodeName(void *object, int32 offset, int32)
|
||||
|
||||
|
||||
void
|
||||
RegisterNodeNamePlugin(void)
|
||||
registerNodeNamePlugin(void)
|
||||
{
|
||||
NodeNameOffset = Frame::registerPlugin(24, ID_NODENAME,
|
||||
nodeNameOffset = Frame::registerPlugin(24, ID_NODENAME,
|
||||
createNodeName,
|
||||
destroyNodeName,
|
||||
copyNodeName);
|
||||
@@ -90,7 +87,7 @@ RegisterNodeNamePlugin(void)
|
||||
|
||||
// Breakable Model
|
||||
|
||||
int32 BreakableOffset;
|
||||
int32 breakableOffset;
|
||||
|
||||
static void*
|
||||
createBreakableModel(void *object, int32 offset, int32)
|
||||
@@ -178,9 +175,9 @@ getSizeBreakableModel(void *object, int32 offset, int32)
|
||||
}
|
||||
|
||||
void
|
||||
RegisterBreakableModelPlugin(void)
|
||||
registerBreakableModelPlugin(void)
|
||||
{
|
||||
BreakableOffset = Geometry::registerPlugin(sizeof(Breakable*),
|
||||
breakableOffset = Geometry::registerPlugin(sizeof(Breakable*),
|
||||
ID_BREAKABLE,
|
||||
createBreakableModel,
|
||||
destroyBreakableModel, NULL);
|
||||
@@ -192,7 +189,7 @@ RegisterBreakableModelPlugin(void)
|
||||
|
||||
// Extra colors
|
||||
|
||||
int32 ExtraVertColorOffset;
|
||||
int32 extraVertColorOffset;
|
||||
|
||||
static void*
|
||||
createExtraVertColors(void *object, int32 offset, int32)
|
||||
@@ -258,9 +255,9 @@ getSizeExtraVertColors(void *object, int32 offset, int32)
|
||||
}
|
||||
|
||||
void
|
||||
RegisterExtraVertColorPlugin(void)
|
||||
registerExtraVertColorPlugin(void)
|
||||
{
|
||||
ExtraVertColorOffset = Geometry::registerPlugin(sizeof(ExtraVertColors),
|
||||
extraVertColorOffset = Geometry::registerPlugin(sizeof(ExtraVertColors),
|
||||
ID_EXTRAVERTCOLORS,
|
||||
createExtraVertColors,
|
||||
destroyExtraVertColors,
|
||||
@@ -273,7 +270,7 @@ RegisterExtraVertColorPlugin(void)
|
||||
|
||||
// Environment mat
|
||||
|
||||
int32 EnvMatOffset;
|
||||
int32 envMatOffset;
|
||||
|
||||
static void*
|
||||
createEnvMat(void *object, int32 offset, int32)
|
||||
@@ -353,7 +350,7 @@ getSizeEnvMat(void *object, int32 offset, int32)
|
||||
|
||||
// Specular mat
|
||||
|
||||
int32 SpecMatOffset;
|
||||
int32 specMatOffset;
|
||||
|
||||
static void*
|
||||
createSpecMat(void *object, int32 offset, int32)
|
||||
@@ -422,16 +419,16 @@ getSizeSpecMat(void *object, int32 offset, int32)
|
||||
}
|
||||
|
||||
void
|
||||
RegisterEnvSpecPlugin(void)
|
||||
registerEnvSpecPlugin(void)
|
||||
{
|
||||
SpecMatOffset = Material::registerPlugin(sizeof(SpecMat*), ID_SPECMAT,
|
||||
specMatOffset = Material::registerPlugin(sizeof(SpecMat*), ID_SPECMAT,
|
||||
createSpecMat,
|
||||
destroySpecMat,
|
||||
copySpecMat);
|
||||
Material::registerPluginStream(ID_SPECMAT, readSpecMat,
|
||||
writeSpecMat,
|
||||
getSizeSpecMat);
|
||||
EnvMatOffset = Material::registerPlugin(sizeof(EnvMat*), ID_ENVMAT,
|
||||
envMatOffset = Material::registerPlugin(sizeof(EnvMat*), ID_ENVMAT,
|
||||
createEnvMat,
|
||||
destroyEnvMat,
|
||||
copyEnvMat);
|
||||
|
||||
21
src/gtaplg.h
21
src/gtaplg.h
@@ -1,4 +1,5 @@
|
||||
namespace Rw {
|
||||
namespace gta {
|
||||
using namespace rw;
|
||||
|
||||
enum
|
||||
{
|
||||
@@ -11,8 +12,8 @@ enum
|
||||
|
||||
// Node name
|
||||
|
||||
extern int32 NodeNameOffset;
|
||||
void RegisterNodeNamePlugin(void);
|
||||
extern int32 nodeNameOffset;
|
||||
void registerNodeNamePlugin(void);
|
||||
|
||||
// Breakable model
|
||||
|
||||
@@ -33,8 +34,8 @@ struct Breakable
|
||||
float32 (*surfaceProps)[3];
|
||||
};
|
||||
|
||||
extern int32 BreakableOffset;
|
||||
void RegisterBreakableModelPlugin(void);
|
||||
extern int32 breakableOffset;
|
||||
void registerBreakableModelPlugin(void);
|
||||
|
||||
// Extra vert colors
|
||||
|
||||
@@ -45,8 +46,8 @@ struct ExtraVertColors
|
||||
float balance;
|
||||
};
|
||||
|
||||
extern int32 ExtraVertColorOffset;
|
||||
void RegisterExtraVertColorPlugin(void);
|
||||
extern int32 extraVertColorOffset;
|
||||
void registerExtraVertColorPlugin(void);
|
||||
|
||||
// Environment mat
|
||||
|
||||
@@ -58,7 +59,7 @@ struct EnvMat
|
||||
Texture *texture;
|
||||
};
|
||||
|
||||
extern int32 EnvMatOffset;
|
||||
extern int32 envMatOffset;
|
||||
|
||||
// Specular mat
|
||||
|
||||
@@ -68,8 +69,8 @@ struct SpecMat
|
||||
Texture *texture;
|
||||
};
|
||||
|
||||
extern int32 SpecMatOffset;
|
||||
extern int32 specMatOffset;
|
||||
|
||||
void RegisterEnvSpecPlugin(void);
|
||||
void registerEnvSpecPlugin(void);
|
||||
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
|
||||
using namespace std;
|
||||
|
||||
namespace Rw {
|
||||
namespace rw {
|
||||
|
||||
uint8
|
||||
readUInt8(istream &rw)
|
||||
@@ -33,7 +33,7 @@ writeUInt8(uint8 tmp, ostream &rw)
|
||||
// TexDictionary
|
||||
//
|
||||
|
||||
TexDictionary *CurrentTexDictionary;
|
||||
TexDictionary *currentTexDictionary;
|
||||
|
||||
TexDictionary::TexDictionary(void)
|
||||
{
|
||||
@@ -92,7 +92,7 @@ Texture::read(const char *name, const char *mask)
|
||||
Raster *raster = NULL;
|
||||
Texture *tex;
|
||||
|
||||
if((tex = CurrentTexDictionary->find(name)))
|
||||
if((tex = currentTexDictionary->find(name)))
|
||||
return tex;
|
||||
tex = new Texture;
|
||||
strncpy(tex->name, name, 32);
|
||||
@@ -107,7 +107,7 @@ Texture::read(const char *name, const char *mask)
|
||||
delete img;
|
||||
}
|
||||
tex->raster = raster;
|
||||
CurrentTexDictionary->add(tex);
|
||||
currentTexDictionary->add(tex);
|
||||
return tex;
|
||||
}
|
||||
|
||||
@@ -116,15 +116,15 @@ Texture::streamRead(Stream *stream)
|
||||
{
|
||||
uint32 length;
|
||||
char name[32], mask[32];
|
||||
assert(FindChunk(stream, ID_STRUCT, NULL, NULL));
|
||||
assert(findChunk(stream, ID_STRUCT, NULL, NULL));
|
||||
uint32 filterAddressing = stream->readU16();
|
||||
// TODO: what is this? (mipmap? i think)
|
||||
stream->seek(2);
|
||||
|
||||
assert(FindChunk(stream, ID_STRING, &length, NULL));
|
||||
assert(findChunk(stream, ID_STRING, &length, NULL));
|
||||
stream->read(name, length);
|
||||
|
||||
assert(FindChunk(stream, ID_STRING, &length, NULL));
|
||||
assert(findChunk(stream, ID_STRING, &length, NULL));
|
||||
stream->read(mask, length);
|
||||
|
||||
Texture *tex = Texture::read(name, mask);
|
||||
@@ -140,17 +140,17 @@ bool
|
||||
Texture::streamWrite(Stream *stream)
|
||||
{
|
||||
int size;
|
||||
WriteChunkHeader(stream, ID_TEXTURE, this->streamGetSize());
|
||||
WriteChunkHeader(stream, ID_STRUCT, 4);
|
||||
writeChunkHeader(stream, ID_TEXTURE, this->streamGetSize());
|
||||
writeChunkHeader(stream, ID_STRUCT, 4);
|
||||
stream->writeU32(this->filterAddressing);
|
||||
|
||||
// TODO: length can't be > 32
|
||||
size = strlen(this->name)+4 & ~3;
|
||||
WriteChunkHeader(stream, ID_STRING, size);
|
||||
writeChunkHeader(stream, ID_STRING, size);
|
||||
stream->write(this->name, size);
|
||||
|
||||
size = strlen(this->mask)+4 & ~3;
|
||||
WriteChunkHeader(stream, ID_STRING, size);
|
||||
writeChunkHeader(stream, ID_STRING, size);
|
||||
stream->write(this->mask, size);
|
||||
|
||||
this->streamWritePlugins(stream);
|
||||
|
||||
38
src/ogl.cpp
38
src/ogl.cpp
@@ -16,8 +16,8 @@
|
||||
|
||||
using namespace std;
|
||||
|
||||
namespace Rw {
|
||||
namespace Gl {
|
||||
namespace rw {
|
||||
namespace gl {
|
||||
|
||||
// VC
|
||||
// 8733 0 0 0 3
|
||||
@@ -54,7 +54,7 @@ printAttribInfo(AttribDesc *attribs, int n)
|
||||
*/
|
||||
|
||||
void*
|
||||
DestroyNativeData(void *object, int32, int32)
|
||||
destroyNativeData(void *object, int32, int32)
|
||||
{
|
||||
Geometry *geometry = (Geometry*)object;
|
||||
assert(geometry->instData->platform == PLATFORM_OGL);
|
||||
@@ -67,7 +67,7 @@ DestroyNativeData(void *object, int32, int32)
|
||||
}
|
||||
|
||||
void
|
||||
ReadNativeData(Stream *stream, int32, void *object, int32, int32)
|
||||
readNativeData(Stream *stream, int32, void *object, int32, int32)
|
||||
{
|
||||
Geometry *geometry = (Geometry*)object;
|
||||
InstanceDataHeader *header = new InstanceDataHeader;
|
||||
@@ -85,7 +85,7 @@ ReadNativeData(Stream *stream, int32, void *object, int32, int32)
|
||||
}
|
||||
|
||||
void
|
||||
WriteNativeData(Stream *stream, int32, void *object, int32, int32)
|
||||
writeNativeData(Stream *stream, int32, void *object, int32, int32)
|
||||
{
|
||||
Geometry *geometry = (Geometry*)object;
|
||||
assert(geometry->instData->platform == PLATFORM_OGL);
|
||||
@@ -97,7 +97,7 @@ WriteNativeData(Stream *stream, int32, void *object, int32, int32)
|
||||
}
|
||||
|
||||
int32
|
||||
GetSizeNativeData(void *object, int32, int32)
|
||||
getSizeNativeData(void *object, int32, int32)
|
||||
{
|
||||
Geometry *geometry = (Geometry*)object;
|
||||
assert(geometry->instData->platform == PLATFORM_OGL);
|
||||
@@ -166,7 +166,7 @@ packattrib(uint8 *dst, float32 *src, AttribDesc *a, float32 scale=1.0f)
|
||||
|
||||
// TODO: make pipeline dependent (skin data, night colors)
|
||||
void
|
||||
Instance(Atomic *atomic)
|
||||
instance(Atomic *atomic)
|
||||
{
|
||||
Geometry *geo = atomic->geometry;
|
||||
InstanceDataHeader *header = new InstanceDataHeader;
|
||||
@@ -283,7 +283,7 @@ Instance(Atomic *atomic)
|
||||
|
||||
#ifdef RW_OPENGL
|
||||
void
|
||||
UploadGeo(Geometry *geo)
|
||||
uploadGeo(Geometry *geo)
|
||||
{
|
||||
InstanceDataHeader *inst = (InstanceDataHeader*)geo->instData;
|
||||
MeshHeader *meshHeader = geo->meshHeader;
|
||||
@@ -308,7 +308,7 @@ UploadGeo(Geometry *geo)
|
||||
}
|
||||
|
||||
void
|
||||
SetAttribPointers(InstanceDataHeader *inst)
|
||||
setAttribPointers(InstanceDataHeader *inst)
|
||||
{
|
||||
static GLenum attribType[] = {
|
||||
GL_FLOAT,
|
||||
@@ -328,12 +328,12 @@ SetAttribPointers(InstanceDataHeader *inst)
|
||||
// Skin
|
||||
|
||||
void
|
||||
ReadNativeSkin(Stream *stream, int32, void *object, int32 offset)
|
||||
readNativeSkin(Stream *stream, int32, void *object, int32 offset)
|
||||
{
|
||||
uint8 header[4];
|
||||
uint32 vers;
|
||||
Geometry *geometry = (Geometry*)object;
|
||||
assert(FindChunk(stream, ID_STRUCT, NULL, &vers));
|
||||
assert(findChunk(stream, ID_STRUCT, NULL, &vers));
|
||||
assert(stream->readU32() == PLATFORM_OGL);
|
||||
stream->read(header, 4);
|
||||
Skin *skin = new Skin;
|
||||
@@ -364,11 +364,11 @@ ReadNativeSkin(Stream *stream, int32, void *object, int32 offset)
|
||||
}
|
||||
|
||||
void
|
||||
WriteNativeSkin(Stream *stream, int32 len, void *object, int32 offset)
|
||||
writeNativeSkin(Stream *stream, int32 len, void *object, int32 offset)
|
||||
{
|
||||
uint8 header[4];
|
||||
|
||||
WriteChunkHeader(stream, ID_STRUCT, len-12);
|
||||
writeChunkHeader(stream, ID_STRUCT, len-12);
|
||||
stream->writeU32(PLATFORM_OGL);
|
||||
Skin *skin = *PLUGINOFFSET(Skin*, object, offset);
|
||||
header[0] = skin->numBones;
|
||||
@@ -380,7 +380,7 @@ WriteNativeSkin(Stream *stream, int32 len, void *object, int32 offset)
|
||||
}
|
||||
|
||||
int32
|
||||
GetSizeNativeSkin(void *object, int32 offset)
|
||||
getSizeNativeSkin(void *object, int32 offset)
|
||||
{
|
||||
Skin *skin = *PLUGINOFFSET(Skin*, object, offset);
|
||||
if(skin == NULL)
|
||||
@@ -391,7 +391,7 @@ GetSizeNativeSkin(void *object, int32 offset)
|
||||
|
||||
// Raster
|
||||
|
||||
int32 NativeRasterOffset;
|
||||
int32 nativeRasterOffset;
|
||||
|
||||
#ifdef RW_OPENGL
|
||||
struct GlRaster {
|
||||
@@ -422,9 +422,9 @@ copyNativeRaster(void *dst, void *, int32 offset, int32)
|
||||
}
|
||||
|
||||
void
|
||||
RegisterNativeRaster(void)
|
||||
registerNativeRaster(void)
|
||||
{
|
||||
NativeRasterOffset = Raster::registerPlugin(sizeof(GlRaster),
|
||||
nativeRasterOffset = Raster::registerPlugin(sizeof(GlRaster),
|
||||
0x12340001,
|
||||
createNativeRaster,
|
||||
destroyNativeRaster,
|
||||
@@ -477,7 +477,7 @@ Texture::upload(void)
|
||||
break;
|
||||
}
|
||||
glBindTexture(GL_TEXTURE_2D, 0);
|
||||
GlRaster *glr = PLUGINOFFSET(GlRaster, r, NativeRasterOffset);
|
||||
GlRaster *glr = PLUGINOFFSET(GlRaster, r, nativeRasterOffset);
|
||||
glr->id = id;
|
||||
}
|
||||
|
||||
@@ -485,7 +485,7 @@ void
|
||||
Texture::bind(int n)
|
||||
{
|
||||
Raster *r = this->raster;
|
||||
GlRaster *glr = PLUGINOFFSET(GlRaster, r, NativeRasterOffset);
|
||||
GlRaster *glr = PLUGINOFFSET(GlRaster, r, nativeRasterOffset);
|
||||
glActiveTexture(GL_TEXTURE0+n);
|
||||
if(r){
|
||||
if(glr->id == 0)
|
||||
|
||||
104
src/plugins.cpp
104
src/plugins.cpp
@@ -12,13 +12,13 @@
|
||||
|
||||
using namespace std;
|
||||
|
||||
namespace Rw {
|
||||
namespace rw {
|
||||
|
||||
//
|
||||
// HAnim
|
||||
//
|
||||
|
||||
int32 HAnimOffset;
|
||||
int32 hAnimOffset;
|
||||
|
||||
static void*
|
||||
createHAnim(void *object, int32 offset, int32)
|
||||
@@ -124,9 +124,9 @@ getSizeHAnim(void *object, int32 offset, int32)
|
||||
}
|
||||
|
||||
void
|
||||
RegisterHAnimPlugin(void)
|
||||
registerHAnimPlugin(void)
|
||||
{
|
||||
HAnimOffset = Frame::registerPlugin(sizeof(HAnimData), ID_HANIMPLUGIN,
|
||||
hAnimOffset = Frame::registerPlugin(sizeof(HAnimData), ID_HANIMPLUGIN,
|
||||
createHAnim,
|
||||
destroyHAnim, copyHAnim);
|
||||
Frame::registerPluginStream(ID_HANIMPLUGIN,
|
||||
@@ -238,14 +238,11 @@ getSizeMesh(void *object, int32)
|
||||
return size;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
RegisterMeshPlugin(void)
|
||||
registerMeshPlugin(void)
|
||||
{
|
||||
Geometry::registerPlugin(0, 0x50E, NULL, NULL, NULL);
|
||||
Geometry::registerPluginStream(0x50E, (StreamRead)readMesh,
|
||||
(StreamWrite)writeMesh,
|
||||
(StreamGetSize)getSizeMesh);
|
||||
Geometry::registerPluginStream(0x50E, readMesh, writeMesh, getSizeMesh);
|
||||
}
|
||||
|
||||
// Native Data
|
||||
@@ -257,9 +254,9 @@ destroyNativeData(void *object, int32 offset, int32 size)
|
||||
if(geometry->instData == NULL)
|
||||
return object;
|
||||
if(geometry->instData->platform == PLATFORM_PS2)
|
||||
return Ps2::DestroyNativeData(object, offset, size);
|
||||
return ps2::destroyNativeData(object, offset, size);
|
||||
if(geometry->instData->platform == PLATFORM_OGL)
|
||||
return Gl::DestroyNativeData(object, offset, size);
|
||||
return gl::destroyNativeData(object, offset, size);
|
||||
return object;
|
||||
}
|
||||
|
||||
@@ -272,19 +269,19 @@ readNativeData(Stream *stream, int32 len, void *object, int32 o, int32 s)
|
||||
// ugly hack to find out platform
|
||||
stream->seek(-4);
|
||||
libid = stream->readU32();
|
||||
ReadChunkHeaderInfo(stream, &header);
|
||||
readChunkHeaderInfo(stream, &header);
|
||||
if(header.type == ID_STRUCT &&
|
||||
LibraryIDPack(header.version, header.build) == libid){
|
||||
libraryIDPack(header.version, header.build) == libid){
|
||||
// must be PS2 or Xbox
|
||||
platform = stream->readU32();
|
||||
stream->seek(-16);
|
||||
if(platform == PLATFORM_PS2)
|
||||
Ps2::ReadNativeData(stream, len, object, o, s);
|
||||
ps2::readNativeData(stream, len, object, o, s);
|
||||
else if(platform == PLATFORM_XBOX)
|
||||
stream->seek(len);
|
||||
}else{
|
||||
stream->seek(-12);
|
||||
Gl::ReadNativeData(stream, len, object, o, s);
|
||||
gl::readNativeData(stream, len, object, o, s);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -295,9 +292,9 @@ writeNativeData(Stream *stream, int32 len, void *object, int32 o, int32 s)
|
||||
if(geometry->instData == NULL)
|
||||
return;
|
||||
if(geometry->instData->platform == PLATFORM_PS2)
|
||||
Ps2::WriteNativeData(stream, len, object, o, s);
|
||||
ps2::writeNativeData(stream, len, object, o, s);
|
||||
else if(geometry->instData->platform == PLATFORM_OGL)
|
||||
Gl::WriteNativeData(stream, len, object, o, s);
|
||||
gl::writeNativeData(stream, len, object, o, s);
|
||||
}
|
||||
|
||||
static int32
|
||||
@@ -307,30 +304,30 @@ getSizeNativeData(void *object, int32 offset, int32 size)
|
||||
if(geometry->instData == NULL)
|
||||
return -1;
|
||||
if(geometry->instData->platform == PLATFORM_PS2)
|
||||
return Ps2::GetSizeNativeData(object, offset, size);
|
||||
return ps2::getSizeNativeData(object, offset, size);
|
||||
else if(geometry->instData->platform == PLATFORM_XBOX)
|
||||
return -1;
|
||||
else if(geometry->instData->platform == PLATFORM_OGL)
|
||||
return Gl::GetSizeNativeData(object, offset, size);
|
||||
return gl::getSizeNativeData(object, offset, size);
|
||||
return -1;
|
||||
}
|
||||
|
||||
void
|
||||
RegisterNativeDataPlugin(void)
|
||||
registerNativeDataPlugin(void)
|
||||
{
|
||||
Geometry::registerPlugin(0, ID_NATIVEDATA,
|
||||
NULL, destroyNativeData, NULL);
|
||||
Geometry::registerPluginStream(ID_NATIVEDATA,
|
||||
(StreamRead)readNativeData,
|
||||
(StreamWrite)writeNativeData,
|
||||
(StreamGetSize)getSizeNativeData);
|
||||
readNativeData,
|
||||
writeNativeData,
|
||||
getSizeNativeData);
|
||||
}
|
||||
|
||||
//
|
||||
// Skin
|
||||
//
|
||||
|
||||
SkinGlobals_ SkinGlobals = { 0, NULL };
|
||||
SkinGlobals skinGlobals = { 0, NULL };
|
||||
|
||||
static void*
|
||||
createSkin(void *object, int32 offset, int32)
|
||||
@@ -406,9 +403,9 @@ readSkin(Stream *stream, int32 len, void *object, int32 offset, int32)
|
||||
|
||||
if(geometry->instData){
|
||||
if(geometry->instData->platform == PLATFORM_PS2)
|
||||
Ps2::ReadNativeSkin(stream, len, object, offset);
|
||||
ps2::readNativeSkin(stream, len, object, offset);
|
||||
else if(geometry->instData->platform == PLATFORM_OGL)
|
||||
Gl::ReadNativeSkin(stream, len, object, offset);
|
||||
gl::readNativeSkin(stream, len, object, offset);
|
||||
else
|
||||
assert(0 && "unsupported native skin platform");
|
||||
return;
|
||||
@@ -480,16 +477,16 @@ writeSkin(Stream *stream, int32 len, void *object, int32 offset, int32)
|
||||
|
||||
if(geometry->instData){
|
||||
if(geometry->instData->platform == PLATFORM_PS2)
|
||||
Ps2::WriteNativeSkin(stream, len, object, offset);
|
||||
ps2::writeNativeSkin(stream, len, object, offset);
|
||||
else if(geometry->instData->platform == PLATFORM_OGL)
|
||||
Gl::WriteNativeSkin(stream, len, object, offset);
|
||||
gl::writeNativeSkin(stream, len, object, offset);
|
||||
else
|
||||
assert(0 && "unsupported native skin platform");
|
||||
return;
|
||||
}
|
||||
|
||||
Skin *skin = *PLUGINOFFSET(Skin*, object, offset);
|
||||
bool oldFormat = Version < 0x34003;
|
||||
bool oldFormat = version < 0x34003;
|
||||
header[0] = skin->numBones;
|
||||
header[1] = skin->numUsedBones;
|
||||
header[2] = skin->maxIndex;
|
||||
@@ -521,9 +518,9 @@ getSizeSkin(void *object, int32 offset, int32)
|
||||
|
||||
if(geometry->instData){
|
||||
if(geometry->instData->platform == PLATFORM_PS2)
|
||||
return Ps2::GetSizeNativeSkin(object, offset);
|
||||
return ps2::getSizeNativeSkin(object, offset);
|
||||
if(geometry->instData->platform == PLATFORM_OGL)
|
||||
return Gl::GetSizeNativeSkin(object, offset);
|
||||
return gl::getSizeNativeSkin(object, offset);
|
||||
assert(0 && "unsupported native skin platform");
|
||||
}
|
||||
|
||||
@@ -534,7 +531,7 @@ getSizeSkin(void *object, int32 offset, int32)
|
||||
int32 size = 4 + geometry->numVertices*(16+4) +
|
||||
skin->numBones*64;
|
||||
// not sure which version introduced the new format
|
||||
if(Version < 0x34003)
|
||||
if(version < 0x34003)
|
||||
size += skin->numBones*4;
|
||||
else
|
||||
size += skin->numUsedBones + 12;
|
||||
@@ -544,22 +541,23 @@ getSizeSkin(void *object, int32 offset, int32)
|
||||
static void
|
||||
skinRights(void *object, int32, int32, uint32 data)
|
||||
{
|
||||
((Atomic*)object)->pipeline = SkinGlobals.pipeline;
|
||||
((Atomic*)object)->pipeline = skinGlobals.pipeline;
|
||||
}
|
||||
|
||||
void
|
||||
RegisterSkinPlugin(void)
|
||||
registerSkinPlugin(void)
|
||||
{
|
||||
SkinGlobals.pipeline = new Pipeline;
|
||||
SkinGlobals.pipeline->pluginID = ID_SKIN;
|
||||
SkinGlobals.pipeline->pluginData = 1;
|
||||
skinGlobals.pipeline = new Pipeline;
|
||||
skinGlobals.pipeline->pluginID = ID_SKIN;
|
||||
skinGlobals.pipeline->pluginData = 1;
|
||||
|
||||
SkinGlobals.offset = Geometry::registerPlugin(sizeof(Skin*), ID_SKIN,
|
||||
createSkin, destroySkin, copySkin);
|
||||
skinGlobals.offset = Geometry::registerPlugin(sizeof(Skin*), ID_SKIN,
|
||||
createSkin,
|
||||
destroySkin,
|
||||
copySkin);
|
||||
Geometry::registerPluginStream(ID_SKIN,
|
||||
readSkin, writeSkin, getSizeSkin);
|
||||
Atomic::registerPlugin(0, ID_SKIN,
|
||||
NULL, NULL, NULL);
|
||||
Atomic::registerPlugin(0, ID_SKIN, NULL, NULL, NULL);
|
||||
Atomic::setStreamRightsCallback(ID_SKIN, skinRights);
|
||||
}
|
||||
|
||||
@@ -590,7 +588,7 @@ readAtomicMatFX(Stream *stream, int32, void *object, int32 offset, int32)
|
||||
stream->read(&flag, 4);
|
||||
*PLUGINOFFSET(int32, object, offset) = flag;
|
||||
if(flag)
|
||||
((Atomic*)object)->pipeline = MatFXGlobals.pipeline;
|
||||
((Atomic*)object)->pipeline = matFXGlobals.pipeline;
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -611,7 +609,7 @@ getSizeAtomicMatFX(void *object, int32 offset, int32)
|
||||
|
||||
// Material
|
||||
|
||||
MatFXGlobals_ MatFXGlobals = { 0, 0, NULL };
|
||||
MatFXGlobals matFXGlobals = { 0, 0, NULL };
|
||||
|
||||
// TODO: Frames and Matrices?
|
||||
static void
|
||||
@@ -745,12 +743,12 @@ readMaterialMatFX(Stream *stream, int32, void *object, int32 offset, int32)
|
||||
coefficient = stream->readF32();
|
||||
bumpedTex = tex = NULL;
|
||||
if(stream->readI32()){
|
||||
assert(FindChunk(stream, ID_TEXTURE,
|
||||
assert(findChunk(stream, ID_TEXTURE,
|
||||
NULL, NULL));
|
||||
bumpedTex = Texture::streamRead(stream);
|
||||
}
|
||||
if(stream->readI32()){
|
||||
assert(FindChunk(stream, ID_TEXTURE,
|
||||
assert(findChunk(stream, ID_TEXTURE,
|
||||
NULL, NULL));
|
||||
tex = Texture::streamRead(stream);
|
||||
}
|
||||
@@ -766,7 +764,7 @@ readMaterialMatFX(Stream *stream, int32, void *object, int32 offset, int32)
|
||||
fbAlpha = stream->readI32();
|
||||
tex = NULL;
|
||||
if(stream->readI32()){
|
||||
assert(FindChunk(stream, ID_TEXTURE,
|
||||
assert(findChunk(stream, ID_TEXTURE,
|
||||
NULL, NULL));
|
||||
tex = Texture::streamRead(stream);
|
||||
}
|
||||
@@ -782,7 +780,7 @@ readMaterialMatFX(Stream *stream, int32, void *object, int32 offset, int32)
|
||||
dstBlend = stream->readI32();
|
||||
tex = NULL;
|
||||
if(stream->readI32()){
|
||||
assert(FindChunk(stream, ID_TEXTURE,
|
||||
assert(findChunk(stream, ID_TEXTURE,
|
||||
NULL, NULL));
|
||||
tex = Texture::streamRead(stream);
|
||||
}
|
||||
@@ -872,13 +870,13 @@ getSizeMaterialMatFX(void *object, int32 offset, int32)
|
||||
}
|
||||
|
||||
void
|
||||
RegisterMatFXPlugin(void)
|
||||
registerMatFXPlugin(void)
|
||||
{
|
||||
MatFXGlobals.pipeline = new Pipeline;
|
||||
MatFXGlobals.pipeline->pluginID = ID_MATFX;
|
||||
MatFXGlobals.pipeline->pluginData = 0;
|
||||
matFXGlobals.pipeline = new Pipeline;
|
||||
matFXGlobals.pipeline->pluginID = ID_MATFX;
|
||||
matFXGlobals.pipeline->pluginData = 0;
|
||||
|
||||
MatFXGlobals.atomicOffset =
|
||||
matFXGlobals.atomicOffset =
|
||||
Atomic::registerPlugin(sizeof(int32), ID_MATFX,
|
||||
createAtomicMatFX, NULL, copyAtomicMatFX);
|
||||
Atomic::registerPluginStream(ID_MATFX,
|
||||
@@ -886,7 +884,7 @@ RegisterMatFXPlugin(void)
|
||||
writeAtomicMatFX,
|
||||
getSizeAtomicMatFX);
|
||||
|
||||
MatFXGlobals.materialOffset =
|
||||
matFXGlobals.materialOffset =
|
||||
Material::registerPlugin(sizeof(MatFX*), ID_MATFX,
|
||||
createMaterialMatFX, destroyMaterialMatFX,
|
||||
copyMaterialMatFX);
|
||||
|
||||
50
src/ps2.cpp
50
src/ps2.cpp
@@ -12,11 +12,11 @@
|
||||
|
||||
using namespace std;
|
||||
|
||||
namespace Rw {
|
||||
namespace Ps2 {
|
||||
namespace rw {
|
||||
namespace ps2 {
|
||||
|
||||
void*
|
||||
DestroyNativeData(void *object, int32, int32)
|
||||
destroyNativeData(void *object, int32, int32)
|
||||
{
|
||||
Geometry *geometry = (Geometry*)object;
|
||||
assert(geometry->instData->platform == PLATFORM_PS2);
|
||||
@@ -29,10 +29,10 @@ DestroyNativeData(void *object, int32, int32)
|
||||
}
|
||||
|
||||
void
|
||||
ReadNativeData(Stream *stream, int32, void *object, int32, int32)
|
||||
readNativeData(Stream *stream, int32, void *object, int32, int32)
|
||||
{
|
||||
Geometry *geometry = (Geometry*)object;
|
||||
assert(FindChunk(stream, ID_STRUCT, NULL, NULL));
|
||||
assert(findChunk(stream, ID_STRUCT, NULL, NULL));
|
||||
assert(stream->readU32() == PLATFORM_PS2);
|
||||
InstanceDataHeader *header = new InstanceDataHeader;
|
||||
geometry->instData = header;
|
||||
@@ -58,10 +58,10 @@ ReadNativeData(Stream *stream, int32, void *object, int32, int32)
|
||||
}
|
||||
|
||||
void
|
||||
WriteNativeData(Stream *stream, int32 len, void *object, int32, int32)
|
||||
writeNativeData(Stream *stream, int32 len, void *object, int32, int32)
|
||||
{
|
||||
Geometry *geometry = (Geometry*)object;
|
||||
WriteChunkHeader(stream, ID_STRUCT, len-12);
|
||||
writeChunkHeader(stream, ID_STRUCT, len-12);
|
||||
assert(geometry->instData->platform == PLATFORM_PS2);
|
||||
stream->writeU32(PLATFORM_PS2);
|
||||
assert(geometry->instData != NULL);
|
||||
@@ -79,7 +79,7 @@ WriteNativeData(Stream *stream, int32 len, void *object, int32, int32)
|
||||
}
|
||||
|
||||
int32
|
||||
GetSizeNativeData(void *object, int32, int32)
|
||||
getSizeNativeData(void *object, int32, int32)
|
||||
{
|
||||
Geometry *geometry = (Geometry*)object;
|
||||
int32 size = 16;
|
||||
@@ -95,14 +95,14 @@ GetSizeNativeData(void *object, int32, int32)
|
||||
}
|
||||
|
||||
void
|
||||
RegisterNativeDataPlugin(void)
|
||||
registerNativeDataPlugin(void)
|
||||
{
|
||||
Geometry::registerPlugin(0, ID_NATIVEDATA,
|
||||
NULL, DestroyNativeData, NULL);
|
||||
NULL, destroyNativeData, NULL);
|
||||
Geometry::registerPluginStream(ID_NATIVEDATA,
|
||||
(StreamRead)ReadNativeData,
|
||||
(StreamWrite)WriteNativeData,
|
||||
(StreamGetSize)GetSizeNativeData);
|
||||
readNativeData,
|
||||
writeNativeData,
|
||||
getSizeNativeData);
|
||||
}
|
||||
|
||||
#ifdef RW_PS2
|
||||
@@ -184,12 +184,12 @@ unfixDmaOffsets(InstanceData *inst)
|
||||
// Skin
|
||||
|
||||
void
|
||||
ReadNativeSkin(Stream *stream, int32, void *object, int32 offset)
|
||||
readNativeSkin(Stream *stream, int32, void *object, int32 offset)
|
||||
{
|
||||
uint8 header[4];
|
||||
uint32 vers;
|
||||
Geometry *geometry = (Geometry*)object;
|
||||
assert(FindChunk(stream, ID_STRUCT, NULL, &vers));
|
||||
assert(findChunk(stream, ID_STRUCT, NULL, &vers));
|
||||
assert(stream->readU32() == PLATFORM_PS2);
|
||||
stream->read(header, 4);
|
||||
Skin *skin = new Skin;
|
||||
@@ -230,14 +230,14 @@ ReadNativeSkin(Stream *stream, int32, void *object, int32 offset)
|
||||
}
|
||||
|
||||
void
|
||||
WriteNativeSkin(Stream *stream, int32 len, void *object, int32 offset)
|
||||
writeNativeSkin(Stream *stream, int32 len, void *object, int32 offset)
|
||||
{
|
||||
uint8 header[4];
|
||||
|
||||
WriteChunkHeader(stream, ID_STRUCT, len-12);
|
||||
writeChunkHeader(stream, ID_STRUCT, len-12);
|
||||
stream->writeU32(PLATFORM_PS2);
|
||||
Skin *skin = *PLUGINOFFSET(Skin*, object, offset);
|
||||
bool oldFormat = Version < 0x34003;
|
||||
bool oldFormat = version < 0x34003;
|
||||
header[0] = skin->numBones;
|
||||
header[1] = skin->numUsedBones;
|
||||
header[2] = skin->maxIndex;
|
||||
@@ -258,14 +258,14 @@ WriteNativeSkin(Stream *stream, int32 len, void *object, int32 offset)
|
||||
}
|
||||
|
||||
int32
|
||||
GetSizeNativeSkin(void *object, int32 offset)
|
||||
getSizeNativeSkin(void *object, int32 offset)
|
||||
{
|
||||
Skin *skin = *PLUGINOFFSET(Skin*, object, offset);
|
||||
if(skin == NULL)
|
||||
return -1;
|
||||
int32 size = 12 + 4 + 4 + skin->numBones*64;
|
||||
// not sure which version introduced the new format
|
||||
if(Version >= 0x34003)
|
||||
if(version >= 0x34003)
|
||||
size += skin->numUsedBones + 16 + 12;
|
||||
return size;
|
||||
}
|
||||
@@ -304,7 +304,7 @@ readADC(Stream *stream, int32, void *object, int32 offset, int32)
|
||||
static void
|
||||
writeADC(Stream *stream, int32, void *, int32, int32)
|
||||
{
|
||||
WriteChunkHeader(stream, ID_ADC, 4);
|
||||
writeChunkHeader(stream, ID_ADC, 4);
|
||||
stream->writeI32(0);
|
||||
}
|
||||
|
||||
@@ -316,14 +316,14 @@ getSizeADC(void *object, int32 offset, int32)
|
||||
}
|
||||
|
||||
void
|
||||
RegisterADCPlugin(void)
|
||||
registerADCPlugin(void)
|
||||
{
|
||||
Geometry::registerPlugin(sizeof(ADCData), ID_ADC,
|
||||
createADC, NULL, copyADC);
|
||||
Geometry::registerPluginStream(ID_ADC,
|
||||
(StreamRead)readADC,
|
||||
(StreamWrite)writeADC,
|
||||
(StreamGetSize)getSizeADC);
|
||||
readADC,
|
||||
writeADC,
|
||||
getSizeADC);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -10,11 +10,11 @@
|
||||
|
||||
using namespace std;
|
||||
|
||||
namespace Rw {
|
||||
namespace rw {
|
||||
|
||||
int Version = 0x36003;
|
||||
int Build = 0xFFFF;
|
||||
char *DebugFile = NULL;
|
||||
int version = 0x36003;
|
||||
int build = 0xFFFF;
|
||||
char *debugFile = NULL;
|
||||
|
||||
int32
|
||||
Stream::writeI8(int8 val)
|
||||
@@ -249,19 +249,19 @@ StreamFile::eof(void)
|
||||
}
|
||||
|
||||
bool
|
||||
WriteChunkHeader(Stream *s, int32 type, int32 size)
|
||||
writeChunkHeader(Stream *s, int32 type, int32 size)
|
||||
{
|
||||
struct {
|
||||
int32 type, size;
|
||||
uint32 id;
|
||||
} buf = { type, size, LibraryIDPack(Version, Build) };
|
||||
} buf = { type, size, libraryIDPack(version, build) };
|
||||
//printf("- write chunk %x @ %x\n", buf.type, s->tell());
|
||||
s->write(&buf, 12);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
ReadChunkHeaderInfo(Stream *s, ChunkHeaderInfo *header)
|
||||
readChunkHeaderInfo(Stream *s, ChunkHeaderInfo *header)
|
||||
{
|
||||
struct {
|
||||
int32 type, size;
|
||||
@@ -273,16 +273,16 @@ ReadChunkHeaderInfo(Stream *s, ChunkHeaderInfo *header)
|
||||
assert(header != NULL);
|
||||
header->type = buf.type;
|
||||
header->length = buf.size;
|
||||
header->version = LibraryIDUnpackVersion(buf.id);
|
||||
header->build = LibraryIDUnpackBuild(buf.id);
|
||||
header->version = libraryIDUnpackVersion(buf.id);
|
||||
header->build = libraryIDUnpackBuild(buf.id);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
FindChunk(Stream *s, uint32 type, uint32 *length, uint32 *version)
|
||||
findChunk(Stream *s, uint32 type, uint32 *length, uint32 *version)
|
||||
{
|
||||
ChunkHeaderInfo header;
|
||||
while(ReadChunkHeaderInfo(s, &header)){
|
||||
while(readChunkHeaderInfo(s, &header)){
|
||||
if(header.type == ID_NAOBJECT)
|
||||
return false;
|
||||
if(header.type == type){
|
||||
|
||||
20
src/rwbase.h
20
src/rwbase.h
@@ -1,4 +1,4 @@
|
||||
namespace Rw {
|
||||
namespace rw {
|
||||
|
||||
typedef char int8;
|
||||
typedef short int16;
|
||||
@@ -118,12 +118,12 @@ enum PluginID
|
||||
ID_NATIVEDATA = 0x510,
|
||||
};
|
||||
|
||||
extern int Version;
|
||||
extern int Build;
|
||||
extern char *DebugFile;
|
||||
extern int version;
|
||||
extern int build;
|
||||
extern char *debugFile;
|
||||
|
||||
inline uint32
|
||||
LibraryIDPack(int version, int build)
|
||||
libraryIDPack(int version, int build)
|
||||
{
|
||||
// TODO: check version in if statement
|
||||
if(build){
|
||||
@@ -135,7 +135,7 @@ LibraryIDPack(int version, int build)
|
||||
}
|
||||
|
||||
inline int
|
||||
LibraryIDUnpackVersion(uint32 libid)
|
||||
libraryIDUnpackVersion(uint32 libid)
|
||||
{
|
||||
if(libid & 0xFFFF0000)
|
||||
return (libid>>14 & 0x3FF00) |
|
||||
@@ -146,7 +146,7 @@ LibraryIDUnpackVersion(uint32 libid)
|
||||
}
|
||||
|
||||
inline int
|
||||
LibraryIDUnpackBuild(uint32 libid)
|
||||
libraryIDUnpackBuild(uint32 libid)
|
||||
{
|
||||
if(libid & 0xFFFF0000)
|
||||
return libid & 0xFFFF;
|
||||
@@ -162,9 +162,9 @@ struct ChunkHeaderInfo
|
||||
};
|
||||
|
||||
// TODO?: make these methods of ChunkHeaderInfo?
|
||||
bool WriteChunkHeader(Stream *s, int32 type, int32 size);
|
||||
bool ReadChunkHeaderInfo(Stream *s, ChunkHeaderInfo *header);
|
||||
bool FindChunk(Stream *s, uint32 type, uint32 *length, uint32 *version);
|
||||
bool writeChunkHeader(Stream *s, int32 type, int32 size);
|
||||
bool readChunkHeaderInfo(Stream *s, ChunkHeaderInfo *header);
|
||||
bool findChunk(Stream *s, uint32 type, uint32 *length, uint32 *version);
|
||||
|
||||
int32 findPointer(void *p, void **list, int32 num);
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
namespace Rw {
|
||||
namespace rw {
|
||||
|
||||
// TODO: mostly a stub right now
|
||||
struct Pipeline
|
||||
@@ -68,8 +68,8 @@ struct HAnimData
|
||||
HAnimHierarchy *hierarchy;
|
||||
};
|
||||
|
||||
extern int32 HAnimOffset;
|
||||
void RegisterHAnimPlugin(void);
|
||||
extern int32 hAnimOffset;
|
||||
void registerHAnimPlugin(void);
|
||||
|
||||
struct Image
|
||||
{
|
||||
@@ -180,7 +180,7 @@ struct Material : PluginBase<Material>
|
||||
uint32 streamGetSize(void);
|
||||
};
|
||||
|
||||
void RegisterMaterialRightsPlugin(void);
|
||||
void registerMaterialRightsPlugin(void);
|
||||
|
||||
struct MatFX
|
||||
{
|
||||
@@ -229,14 +229,14 @@ struct MatFX
|
||||
int32 getEffectIndex(uint32 type);
|
||||
};
|
||||
|
||||
struct MatFXGlobals_
|
||||
struct MatFXGlobals
|
||||
{
|
||||
int32 atomicOffset;
|
||||
int32 materialOffset;
|
||||
Pipeline *pipeline;
|
||||
};
|
||||
extern MatFXGlobals_ MatFXGlobals;
|
||||
void RegisterMatFXPlugin(void);
|
||||
extern MatFXGlobals matFXGlobals;
|
||||
void registerMatFXPlugin(void);
|
||||
|
||||
struct Mesh
|
||||
{
|
||||
@@ -312,8 +312,8 @@ struct Geometry : PluginBase<Geometry>, Object
|
||||
};
|
||||
};
|
||||
|
||||
void RegisterMeshPlugin(void);
|
||||
void RegisterNativeDataPlugin(void);
|
||||
void registerMeshPlugin(void);
|
||||
void registerNativeDataPlugin(void);
|
||||
|
||||
struct Skin
|
||||
{
|
||||
@@ -327,13 +327,13 @@ struct Skin
|
||||
uint8 *data; // only used by delete
|
||||
};
|
||||
|
||||
struct SkinGlobals_
|
||||
struct SkinGlobals
|
||||
{
|
||||
int32 offset;
|
||||
Pipeline *pipeline;
|
||||
};
|
||||
extern SkinGlobals_ SkinGlobals;
|
||||
void RegisterSkinPlugin(void);
|
||||
extern SkinGlobals skinGlobals;
|
||||
void registerSkinPlugin(void);
|
||||
|
||||
struct Clump;
|
||||
|
||||
@@ -370,7 +370,7 @@ struct Atomic : PluginBase<Atomic>, Object
|
||||
uint32 streamGetSize(void);
|
||||
};
|
||||
|
||||
void RegisterAtomicRightsPlugin(void);
|
||||
void registerAtomicRightsPlugin(void);
|
||||
|
||||
struct Clump : PluginBase<Clump>, Object
|
||||
{
|
||||
@@ -402,6 +402,6 @@ struct TexDictionary
|
||||
Texture *find(const char *name);
|
||||
};
|
||||
|
||||
extern TexDictionary *CurrentTexDictionary;
|
||||
extern TexDictionary *currentTexDictionary;
|
||||
|
||||
}
|
||||
|
||||
32
src/rwogl.h
32
src/rwogl.h
@@ -1,5 +1,5 @@
|
||||
namespace Rw {
|
||||
namespace Gl {
|
||||
namespace rw {
|
||||
namespace gl {
|
||||
|
||||
struct AttribDesc
|
||||
{
|
||||
@@ -14,7 +14,7 @@ struct AttribDesc
|
||||
uint32 offset;
|
||||
};
|
||||
|
||||
struct InstanceDataHeader : Rw::InstanceDataHeader
|
||||
struct InstanceDataHeader : rw::InstanceDataHeader
|
||||
{
|
||||
int32 numAttribs;
|
||||
AttribDesc *attribs;
|
||||
@@ -26,33 +26,33 @@ struct InstanceDataHeader : Rw::InstanceDataHeader
|
||||
uint32 ibo;
|
||||
};
|
||||
|
||||
void *DestroyNativeData(void *object, int32, int32);
|
||||
void ReadNativeData(Stream *stream, int32 len, void *object, int32, int32);
|
||||
void WriteNativeData(Stream *stream, int32 len, void *object, int32, int32);
|
||||
int32 GetSizeNativeData(void *object, int32, int32);
|
||||
void *destroyNativeData(void *object, int32, int32);
|
||||
void readNativeData(Stream *stream, int32 len, void *object, int32, int32);
|
||||
void writeNativeData(Stream *stream, int32 len, void *object, int32, int32);
|
||||
int32 getSizeNativeData(void *object, int32, int32);
|
||||
|
||||
void Instance(Atomic *atomic);
|
||||
void instance(Atomic *atomic);
|
||||
|
||||
// only RW_OPENGL
|
||||
void UploadGeo(Geometry *geo);
|
||||
void SetAttribPointers(InstanceDataHeader *inst);
|
||||
void uploadGeo(Geometry *geo);
|
||||
void setAttribPointers(InstanceDataHeader *inst);
|
||||
|
||||
// Skin plugin
|
||||
|
||||
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 readNativeSkin(Stream *stream, int32, void *object, int32 offset);
|
||||
void writeNativeSkin(Stream *stream, int32 len, void *object, int32 offset);
|
||||
int32 getSizeNativeSkin(void *object, int32 offset);
|
||||
|
||||
// Raster
|
||||
|
||||
struct Texture : Rw::Texture
|
||||
struct Texture : rw::Texture
|
||||
{
|
||||
void upload(void);
|
||||
void bind(int n);
|
||||
};
|
||||
|
||||
extern int32 NativeRasterOffset;
|
||||
void RegisterNativeRaster(void);
|
||||
extern int32 nativeRasterOffset;
|
||||
void registerNativeRaster(void);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
namespace Rw {
|
||||
namespace rw {
|
||||
|
||||
#define PLUGINOFFSET(type, base, offset) \
|
||||
((type*)((char*)(base) + (offset)))
|
||||
@@ -85,11 +85,11 @@ template <typename T> void
|
||||
PluginBase<T>::streamReadPlugins(Stream *stream)
|
||||
{
|
||||
int32 length;
|
||||
Rw::ChunkHeaderInfo header;
|
||||
if(!Rw::FindChunk(stream, Rw::ID_EXTENSION, (uint32*)&length, NULL))
|
||||
ChunkHeaderInfo header;
|
||||
if(!findChunk(stream, ID_EXTENSION, (uint32*)&length, NULL))
|
||||
return;
|
||||
while(length > 0){
|
||||
Rw::ReadChunkHeaderInfo(stream, &header);
|
||||
readChunkHeaderInfo(stream, &header);
|
||||
length -= 12;
|
||||
for(Plugin *p = this->s_plugins; p; p = p->next)
|
||||
if(p->id == header.type){
|
||||
@@ -107,12 +107,12 @@ template <typename T> void
|
||||
PluginBase<T>::streamWritePlugins(Stream *stream)
|
||||
{
|
||||
int size = this->streamGetPluginSize();
|
||||
Rw::WriteChunkHeader(stream, Rw::ID_EXTENSION, size);
|
||||
writeChunkHeader(stream, ID_EXTENSION, size);
|
||||
for(Plugin *p = this->s_plugins; p; p = p->next){
|
||||
if(p->getSize == NULL ||
|
||||
(size = p->getSize(this, p->offset, p->size)) < 0)
|
||||
continue;
|
||||
Rw::WriteChunkHeader(stream, p->id, size);
|
||||
writeChunkHeader(stream, p->id, size);
|
||||
p->write(stream, size, this, p->offset, p->size);
|
||||
}
|
||||
}
|
||||
|
||||
24
src/rwps2.h
24
src/rwps2.h
@@ -1,5 +1,5 @@
|
||||
namespace Rw {
|
||||
namespace Ps2 {
|
||||
namespace rw {
|
||||
namespace ps2 {
|
||||
|
||||
struct InstanceData
|
||||
{
|
||||
@@ -13,17 +13,17 @@ struct InstanceData
|
||||
Material *material;
|
||||
};
|
||||
|
||||
struct InstanceDataHeader : Rw::InstanceDataHeader
|
||||
struct InstanceDataHeader : rw::InstanceDataHeader
|
||||
{
|
||||
uint32 numMeshes;
|
||||
InstanceData *instanceMeshes;
|
||||
};
|
||||
|
||||
void *DestroyNativeData(void *object, int32, int32);
|
||||
void ReadNativeData(Stream *stream, int32 len, void *object, int32, int32);
|
||||
void WriteNativeData(Stream *stream, int32 len, void *object, int32, int32);
|
||||
int32 GetSizeNativeData(void *object, int32, int32);
|
||||
void RegisterNativeDataPlugin(void);
|
||||
void *destroyNativeData(void *object, int32, int32);
|
||||
void readNativeData(Stream *stream, int32 len, void *object, int32, int32);
|
||||
void writeNativeData(Stream *stream, int32 len, void *object, int32, int32);
|
||||
int32 getSizeNativeData(void *object, int32, int32);
|
||||
void registerNativeDataPlugin(void);
|
||||
|
||||
void walkDMA(InstanceData *inst, void (*f)(uint32 *data, int32 size));
|
||||
void sizedebug(InstanceData *inst);
|
||||
@@ -34,9 +34,9 @@ void unfixDmaOffsets(InstanceData *inst);
|
||||
|
||||
// Skin plugin
|
||||
|
||||
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 readNativeSkin(Stream *stream, int32, void *object, int32 offset);
|
||||
void writeNativeSkin(Stream *stream, int32 len, void *object, int32 offset);
|
||||
int32 getSizeNativeSkin(void *object, int32 offset);
|
||||
|
||||
// ADC plugin
|
||||
|
||||
@@ -48,7 +48,7 @@ struct ADCData
|
||||
uint32 adcFormatted;
|
||||
};
|
||||
|
||||
void RegisterADCPlugin(void);
|
||||
void registerADCPlugin(void);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user