mirror of https://github.com/aap/librw.git
started implementing linked lists
This commit is contained in:
parent
0aadf8c3c9
commit
efd41771a0
|
@ -58,6 +58,7 @@ Global
|
|||
{30552BB0-3B19-49A4-ABF4-87CF68AF9E38}.Release|x64.ActiveCfg = Release|x64
|
||||
{30552BB0-3B19-49A4-ABF4-87CF68AF9E38}.Release|x64.Build.0 = Release|x64
|
||||
{B487F101-0C2B-4F99-A1E0-B0B0C0F3FE7E}.Debug - null|Win32.ActiveCfg = Debug - null|Win32
|
||||
{B487F101-0C2B-4F99-A1E0-B0B0C0F3FE7E}.Debug - null|Win32.Build.0 = Debug - null|Win32
|
||||
{B487F101-0C2B-4F99-A1E0-B0B0C0F3FE7E}.Debug - null|x64.ActiveCfg = Debug - null|x64
|
||||
{B487F101-0C2B-4F99-A1E0-B0B0C0F3FE7E}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{B487F101-0C2B-4F99-A1E0-B0B0C0F3FE7E}.Debug|x64.ActiveCfg = Debug|x64
|
||||
|
@ -66,6 +67,7 @@ Global
|
|||
{B487F101-0C2B-4F99-A1E0-B0B0C0F3FE7E}.Release|Win32.Build.0 = Release|Win32
|
||||
{B487F101-0C2B-4F99-A1E0-B0B0C0F3FE7E}.Release|x64.ActiveCfg = Release|x64
|
||||
{85F56A7D-6EA2-4B9B-806A-87AF6C577FDF}.Debug - null|Win32.ActiveCfg = Debug - null|Win32
|
||||
{85F56A7D-6EA2-4B9B-806A-87AF6C577FDF}.Debug - null|Win32.Build.0 = Debug - null|Win32
|
||||
{85F56A7D-6EA2-4B9B-806A-87AF6C577FDF}.Debug - null|x64.ActiveCfg = Debug - null|x64
|
||||
{85F56A7D-6EA2-4B9B-806A-87AF6C577FDF}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{85F56A7D-6EA2-4B9B-806A-87AF6C577FDF}.Debug|x64.ActiveCfg = Debug|x64
|
||||
|
@ -92,6 +94,7 @@ Global
|
|||
{E5D477C8-4CAF-43BF-B7E3-6689503D469F}.Release|Win32.Build.0 = Release|Win32
|
||||
{E5D477C8-4CAF-43BF-B7E3-6689503D469F}.Release|x64.ActiveCfg = Release|x64
|
||||
{403C35A9-6D06-4261-B305-9ED000F00136}.Debug - null|Win32.ActiveCfg = Debug - null|Win32
|
||||
{403C35A9-6D06-4261-B305-9ED000F00136}.Debug - null|Win32.Build.0 = Debug - null|Win32
|
||||
{403C35A9-6D06-4261-B305-9ED000F00136}.Debug - null|x64.ActiveCfg = Debug - null|x64
|
||||
{403C35A9-6D06-4261-B305-9ED000F00136}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{403C35A9-6D06-4261-B305-9ED000F00136}.Debug|x64.ActiveCfg = Debug|x64
|
||||
|
|
|
@ -21,7 +21,8 @@ namespace rw {
|
|||
|
||||
Frame::Frame(void)
|
||||
{
|
||||
this->parent = NULL;
|
||||
this->object.init(0, 0);
|
||||
this->objectList.init();
|
||||
this->child = NULL;
|
||||
this->next = NULL;
|
||||
this->root = NULL;
|
||||
|
@ -58,7 +59,7 @@ Frame::addChild(Frame *child)
|
|||
f->next = child;
|
||||
}
|
||||
child->next = NULL;
|
||||
child->parent = this;
|
||||
child->object.parent = this;
|
||||
child->root = this->root;
|
||||
return this;
|
||||
}
|
||||
|
@ -66,7 +67,7 @@ Frame::addChild(Frame *child)
|
|||
Frame*
|
||||
Frame::removeChild(void)
|
||||
{
|
||||
Frame *parent = (Frame*)this->parent;
|
||||
Frame *parent = (Frame*)this->object.parent;
|
||||
if(parent->child == this)
|
||||
parent->child = this->next;
|
||||
else{
|
||||
|
@ -78,7 +79,7 @@ Frame::removeChild(void)
|
|||
found:
|
||||
f->next = f->next->next;
|
||||
}
|
||||
this->parent = NULL;
|
||||
this->object.parent = NULL;
|
||||
this->next = this->root = NULL;
|
||||
return this;
|
||||
}
|
||||
|
@ -112,7 +113,7 @@ Frame::updateLTM(void)
|
|||
{
|
||||
if(!this->dirty)
|
||||
return;
|
||||
Frame *parent = (Frame*)this->parent;
|
||||
Frame *parent = (Frame*)this->object.parent;
|
||||
if(parent){
|
||||
parent->updateLTM();
|
||||
matrixMult(this->ltm, parent->ltm, this->matrix);
|
||||
|
@ -163,6 +164,7 @@ makeFrameList(Frame *frame, Frame **flist)
|
|||
|
||||
Clump::Clump(void)
|
||||
{
|
||||
this->object.init(2, 0);
|
||||
this->numAtomics = 0;
|
||||
this->numLights = 0;
|
||||
this->numCameras = 0;
|
||||
|
@ -206,7 +208,7 @@ Clump::streamRead(Stream *stream)
|
|||
Frame **frameList;
|
||||
int32 numFrames;
|
||||
clump->frameListStreamRead(stream, &frameList, &numFrames);
|
||||
clump->parent = (void*)frameList[0];
|
||||
clump->object.parent = (void*)frameList[0];
|
||||
|
||||
Geometry **geometryList = 0;
|
||||
if(version >= 0x30400){
|
||||
|
@ -242,7 +244,7 @@ Clump::streamRead(Stream *stream)
|
|||
frm = stream->readI32();
|
||||
assert(findChunk(stream, ID_LIGHT, NULL, NULL));
|
||||
clump->lightList[i] = Light::streamRead(stream);
|
||||
clump->lightList[i]->frame = frameList[frm];
|
||||
clump->lightList[i]->setFrame(frameList[frm]);
|
||||
clump->lightList[i]->clump = clump;
|
||||
}
|
||||
|
||||
|
@ -262,9 +264,9 @@ Clump::streamWrite(Stream *stream)
|
|||
writeChunkHeader(stream, ID_STRUCT, size);
|
||||
stream->write(buf, size);
|
||||
|
||||
int32 numFrames = ((Frame*)this->parent)->count();
|
||||
int32 numFrames = ((Frame*)this->object.parent)->count();
|
||||
Frame **flist = new Frame*[numFrames];
|
||||
makeFrameList((Frame*)this->parent, flist);
|
||||
makeFrameList((Frame*)this->object.parent, flist);
|
||||
|
||||
this->frameListStreamWrite(stream, flist, numFrames);
|
||||
|
||||
|
@ -285,7 +287,7 @@ Clump::streamWrite(Stream *stream)
|
|||
|
||||
for(int32 i = 0; i < this->numLights; i++){
|
||||
Light *l = this->lightList[i];
|
||||
int frm = findPointer((void*)l->frame, (void**)flist,numFrames);
|
||||
int frm = findPointer((void*)l->object.parent, (void**)flist,numFrames);
|
||||
if(frm < 0)
|
||||
return false;
|
||||
writeChunkHeader(stream, ID_STRUCT, 4);
|
||||
|
@ -317,9 +319,9 @@ Clump::streamGetSize(void)
|
|||
size += 8; // numLights, numCameras
|
||||
|
||||
// frame list
|
||||
int32 numFrames = ((Frame*)this->parent)->count();
|
||||
int32 numFrames = ((Frame*)this->object.parent)->count();
|
||||
size += 12 + 12 + 4 + numFrames*(sizeof(FrameStreamData)+12);
|
||||
sizeCB((Frame*)this->parent, (void*)&size);
|
||||
sizeCB((Frame*)this->object.parent, (void*)&size);
|
||||
|
||||
if(rw::version >= 0x30400){
|
||||
// geometry list
|
||||
|
@ -409,7 +411,7 @@ Clump::frameListStreamWrite(Stream *stream, Frame **frameList, int32 numFrames)
|
|||
buf.pos[0] = f->matrix[12];
|
||||
buf.pos[1] = f->matrix[13];
|
||||
buf.pos[2] = f->matrix[14];
|
||||
buf.parent = findPointer((void*)f->parent, (void**)frameList,
|
||||
buf.parent = findPointer((void*)f->object.parent, (void**)frameList,
|
||||
numFrames);
|
||||
buf.matflag = f->matflag;
|
||||
stream->write(&buf, sizeof(buf));
|
||||
|
@ -424,7 +426,7 @@ Clump::frameListStreamWrite(Stream *stream, Frame **frameList, int32 numFrames)
|
|||
|
||||
Atomic::Atomic(void)
|
||||
{
|
||||
this->frame = NULL;
|
||||
this->object.init(1, 0);
|
||||
this->geometry = NULL;
|
||||
this->pipeline = NULL;
|
||||
constructPlugins();
|
||||
|
@ -453,7 +455,7 @@ Atomic::streamReadClump(Stream *stream,
|
|||
assert(findChunk(stream, ID_STRUCT, NULL, &version));
|
||||
stream->read(buf, version < 0x30400 ? 12 : 16);
|
||||
Atomic *atomic = new Atomic;
|
||||
atomic->frame = frameList[buf[0]];
|
||||
atomic->setFrame(frameList[buf[0]]);
|
||||
if(version < 0x30400){
|
||||
assert(findChunk(stream, ID_GEOMETRY, NULL, NULL));
|
||||
atomic->geometry = Geometry::streamRead(stream);
|
||||
|
@ -476,7 +478,7 @@ Atomic::streamWriteClump(Stream *stream, Frame **frameList, int32 numFrames)
|
|||
return false;
|
||||
writeChunkHeader(stream, ID_ATOMIC, this->streamGetSize());
|
||||
writeChunkHeader(stream, ID_STRUCT, rw::version < 0x30400 ? 12 : 16);
|
||||
buf[0] = findPointer((void*)this->frame, (void**)frameList, numFrames);
|
||||
buf[0] = findPointer((void*)this->object.parent, (void**)frameList, numFrames);
|
||||
|
||||
if(version < 0x30400){
|
||||
stream->write(buf, sizeof(int[3]));
|
||||
|
@ -576,9 +578,18 @@ registerAtomicRightsPlugin(void)
|
|||
// Light
|
||||
//
|
||||
|
||||
Light::Light(void)
|
||||
Light::Light(int32 type)
|
||||
{
|
||||
this->frame = NULL;
|
||||
this->object.init(3, type);
|
||||
this->radius = 0.0f;
|
||||
this->color[0] = 1.0f;
|
||||
this->color[1] = 1.0f;
|
||||
this->color[2] = 1.0f;
|
||||
this->color[3] = 1.0f;
|
||||
this->minusCosAngle = 1.0f;
|
||||
this->object.privateFlags = 1;
|
||||
this->object.flags = 1 | 2;
|
||||
Clump *clump;
|
||||
constructPlugins();
|
||||
}
|
||||
|
||||
|
@ -607,16 +618,15 @@ Light::streamRead(Stream *stream)
|
|||
{
|
||||
LightChunkData buf;
|
||||
assert(findChunk(stream, ID_STRUCT, NULL, NULL));
|
||||
Light *light = new Light;
|
||||
stream->read(&buf, sizeof(LightChunkData));
|
||||
Light *light = new Light(buf.type);
|
||||
light->radius = buf.radius;
|
||||
light->color[0] = buf.red;
|
||||
light->color[1] = buf.green;
|
||||
light->color[2] = buf.blue;
|
||||
light->color[3] = 1.0f;
|
||||
light->minusCosAngle = buf.minusCosAngle;
|
||||
light->flags = (uint8)buf.flags;
|
||||
light->subType = (uint8)buf.type;
|
||||
light->object.flags = (uint8)buf.flags;
|
||||
|
||||
light->streamReadPlugins(stream);
|
||||
return light;
|
||||
|
@ -633,8 +643,8 @@ Light::streamWrite(Stream *stream)
|
|||
buf.green = this->color[1];
|
||||
buf.blue = this->color[2];
|
||||
buf.minusCosAngle = this->minusCosAngle;
|
||||
buf.flags = this->flags;
|
||||
buf.type = this->subType;
|
||||
buf.flags = this->object.flags;
|
||||
buf.type = this->object.subType;
|
||||
stream->write(&buf, sizeof(LightChunkData));
|
||||
|
||||
this->streamWritePlugins(stream);
|
||||
|
|
|
@ -17,6 +17,7 @@ namespace rw {
|
|||
|
||||
Geometry::Geometry(int32 numVerts, int32 numTris, uint32 flags)
|
||||
{
|
||||
this->object.init(8, 0);
|
||||
this->geoflags = flags & 0xFF00FFFF;
|
||||
this->numTexCoordSets = (flags & 0xFF0000) >> 16;
|
||||
if(this->numTexCoordSets == 0)
|
||||
|
|
|
@ -31,6 +31,7 @@ TexDictionary *currentTexDictionary;
|
|||
|
||||
TexDictionary::TexDictionary(void)
|
||||
{
|
||||
this->object.init(6, 0);
|
||||
this->first = NULL;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,17 +1,66 @@
|
|||
namespace rw {
|
||||
|
||||
struct LLLink
|
||||
{
|
||||
LLLink *next;
|
||||
LLLink *prev;
|
||||
void init(void){
|
||||
this->next = NULL;
|
||||
this->prev = NULL;
|
||||
}
|
||||
void remove(void){
|
||||
this->prev->next = this->next;
|
||||
this->next->prev = this->prev;
|
||||
}
|
||||
};
|
||||
|
||||
#define LLLinkGetData(linkvar,type,entry) \
|
||||
((type*)(((uint8*)(linkvar))-offsetof(type,entry)))
|
||||
|
||||
struct LinkList
|
||||
{
|
||||
LLLink link;
|
||||
void init(void){
|
||||
this->link.next = &this->link;
|
||||
this->link.prev = &this->link;
|
||||
}
|
||||
bool32 isEmpty(void){
|
||||
return this->link.next == &this->link;
|
||||
}
|
||||
void add(LLLink *link){
|
||||
link->next = this->link.next;
|
||||
link->prev = &this->link;
|
||||
this->link.next->prev = link;
|
||||
this->link.next = link;
|
||||
}
|
||||
LLLink *end(void){
|
||||
return &this->link;
|
||||
}
|
||||
};
|
||||
|
||||
struct Object
|
||||
{
|
||||
uint8 type;
|
||||
uint8 subType;
|
||||
uint8 flags;
|
||||
uint8 privateFlags;
|
||||
void *parent;
|
||||
|
||||
void init(uint8 type, uint8 subType){
|
||||
this->type = type;
|
||||
this->subType = subType;
|
||||
this->flags = 0;
|
||||
this->privateFlags = 0;
|
||||
this->parent = NULL;
|
||||
}
|
||||
};
|
||||
|
||||
// TODO: missing: list of attached objects
|
||||
struct Frame : PluginBase<Frame>, Object
|
||||
struct Frame : PluginBase<Frame>
|
||||
{
|
||||
typedef Frame *(*Callback)(Frame *f, void *data);
|
||||
|
||||
Object object;
|
||||
LinkList objectList;
|
||||
float32 matrix[16];
|
||||
float32 ltm[16];
|
||||
|
||||
|
@ -36,6 +85,18 @@ struct Frame : PluginBase<Frame>, Object
|
|||
|
||||
Frame **makeFrameList(Frame *frame, Frame **flist);
|
||||
|
||||
struct ObjectWithFrame : Object
|
||||
{
|
||||
LLLink inFrame;
|
||||
void setFrame(Frame *f){
|
||||
if(this->parent)
|
||||
this->inFrame.remove();
|
||||
this->parent = f;
|
||||
if(f)
|
||||
f->objectList.add(&this->inFrame);
|
||||
}
|
||||
};
|
||||
|
||||
struct HAnimKeyFrame
|
||||
{
|
||||
HAnimKeyFrame *prev;
|
||||
|
@ -168,10 +229,11 @@ struct NativeRaster
|
|||
// TODO: link into texdict
|
||||
struct Texture : PluginBase<Texture>
|
||||
{
|
||||
Raster *raster;
|
||||
// TODO: pointer to txd and link
|
||||
char name[32];
|
||||
char mask[32];
|
||||
uint32 filterAddressing; // VVVVUUUU FFFFFFFF
|
||||
Raster *raster;
|
||||
int32 refCount;
|
||||
|
||||
// temporary - pointer to next tex in dictionary
|
||||
|
@ -319,9 +381,10 @@ struct InstanceDataHeader
|
|||
uint32 platform;
|
||||
};
|
||||
|
||||
struct Geometry : PluginBase<Geometry>, Object
|
||||
struct Geometry : PluginBase<Geometry>
|
||||
{
|
||||
uint32 geoflags;
|
||||
Object object;
|
||||
uint32 geoflags; // TODO: rename
|
||||
int32 numTriangles;
|
||||
int32 numVertices;
|
||||
int32 numMorphTargets;
|
||||
|
@ -333,6 +396,7 @@ struct Geometry : PluginBase<Geometry>, Object
|
|||
|
||||
MorphTarget *morphTargets;
|
||||
|
||||
// TODO: struct
|
||||
int32 numMaterials;
|
||||
Material **materialList;
|
||||
|
||||
|
@ -399,25 +463,28 @@ void registerSkinPlugin(void);
|
|||
|
||||
struct Clump;
|
||||
|
||||
struct Light : PluginBase<Light>, Object
|
||||
struct Light : PluginBase<Light>
|
||||
{
|
||||
Frame *frame;
|
||||
ObjectWithFrame object;
|
||||
float32 radius;
|
||||
float32 color[4];
|
||||
float32 minusCosAngle;
|
||||
|
||||
// clump link handled by plugin in RW
|
||||
Clump *clump;
|
||||
|
||||
Light(void);
|
||||
Light(int32 type);
|
||||
Light(Light *l);
|
||||
~Light(void);
|
||||
void setFrame(Frame *f) { this->object.setFrame(f); }
|
||||
static Light *streamRead(Stream *stream);
|
||||
bool streamWrite(Stream *stream);
|
||||
uint32 streamGetSize(void);
|
||||
};
|
||||
|
||||
struct Atomic : PluginBase<Atomic>, Object
|
||||
struct Atomic : PluginBase<Atomic>
|
||||
{
|
||||
Frame *frame;
|
||||
ObjectWithFrame object;
|
||||
Geometry *geometry;
|
||||
Clump *clump;
|
||||
ObjPipeline *pipeline;
|
||||
|
@ -425,10 +492,11 @@ struct Atomic : PluginBase<Atomic>, Object
|
|||
Atomic(void);
|
||||
Atomic(Atomic *a);
|
||||
~Atomic(void);
|
||||
void setFrame(Frame *f) { this->object.setFrame(f); }
|
||||
static Atomic *streamReadClump(Stream *stream,
|
||||
Frame **frameList, Geometry **geometryList);
|
||||
Frame **frameList, Geometry **geometryList);
|
||||
bool streamWriteClump(Stream *stream,
|
||||
Frame **frameList, int32 numFrames);
|
||||
Frame **frameList, int32 numFrames);
|
||||
uint32 streamGetSize(void);
|
||||
ObjPipeline *getPipeline(void);
|
||||
|
||||
|
@ -439,8 +507,9 @@ extern ObjPipeline *defaultPipelines[NUM_PLATFORMS];
|
|||
|
||||
void registerAtomicRightsPlugin(void);
|
||||
|
||||
struct Clump : PluginBase<Clump>, Object
|
||||
struct Clump : PluginBase<Clump>
|
||||
{
|
||||
Object object;
|
||||
int32 numAtomics;
|
||||
Atomic **atomicList;
|
||||
int32 numLights;
|
||||
|
@ -461,6 +530,7 @@ struct Clump : PluginBase<Clump>, Object
|
|||
|
||||
struct TexDictionary : PluginBase<TexDictionary>
|
||||
{
|
||||
Object object;
|
||||
Texture *first;
|
||||
|
||||
TexDictionary(void);
|
||||
|
|
|
@ -11,37 +11,6 @@
|
|||
using namespace std;
|
||||
using namespace rw;
|
||||
|
||||
Frame*
|
||||
findHierCB(Frame *f, void *p)
|
||||
{
|
||||
HAnimData *hanim = PLUGINOFFSET(HAnimData, f, hAnimOffset);
|
||||
if(hanim->hierarchy){
|
||||
*(HAnimHierarchy**)p = hanim->hierarchy;
|
||||
return NULL;
|
||||
}
|
||||
f->forAllChildren(findHierCB, p);
|
||||
return f;
|
||||
}
|
||||
|
||||
HAnimHierarchy*
|
||||
getHierarchy(Clump *c)
|
||||
{
|
||||
HAnimHierarchy *hier = NULL;
|
||||
findHierCB((Frame*)c->parent, &hier);
|
||||
return hier;
|
||||
}
|
||||
|
||||
void
|
||||
fixLcsHier(HAnimHierarchy *hier)
|
||||
{
|
||||
hier->maxInterpKeyFrameSize = findAnimInterpolatorInfo(1)->keyFrameSize;
|
||||
for(int32 i = 0; i < hier->numNodes; i++){
|
||||
int32 id = hier->nodeInfo[i].id;
|
||||
if(id == 255) hier->nodeInfo[i].id = -1;
|
||||
else if(id > 0x80) hier->nodeInfo[i].id |= 0x1300;
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
|
@ -54,10 +23,6 @@ main(int argc, char *argv[])
|
|||
rw::platform = PLATFORM_D3D8;
|
||||
// rw::version = 0x30200;
|
||||
|
||||
int lcs = 1;
|
||||
matFXGlobals.hack = lcs;
|
||||
skinGlobals.forceSkipUsedBones = lcs;
|
||||
|
||||
gta::attachPlugins();
|
||||
|
||||
rw::Clump *c;
|
||||
|
@ -104,25 +69,10 @@ main(int argc, char *argv[])
|
|||
readChunkHeaderInfo(&in, &header);
|
||||
}
|
||||
assert(header.type == ID_CLUMP);
|
||||
if(lcs)
|
||||
c = clumpStreamReadRsl(&in);
|
||||
else
|
||||
c = Clump::streamRead(&in);
|
||||
c = Clump::streamRead(&in);
|
||||
assert(c != NULL);
|
||||
}
|
||||
|
||||
if(lcs){
|
||||
HAnimHierarchy *hier = getHierarchy(c);
|
||||
if(hier)
|
||||
fixLcsHier(hier);
|
||||
for(int32 i = 0; i < c->numAtomics; i++){
|
||||
Skin *skin = *PLUGINOFFSET(Skin*, c->atomicList[i]->geometry, skinGlobals.offset);
|
||||
convertRslGeometry(c->atomicList[i]->geometry);
|
||||
if(skin)
|
||||
c->atomicList[i]->pipeline = skinGlobals.pipelines[rw::platform];
|
||||
}
|
||||
}
|
||||
|
||||
if(rw::version == 0){
|
||||
rw::version = header.version;
|
||||
rw::build = header.build;
|
||||
|
@ -159,10 +109,7 @@ main(int argc, char *argv[])
|
|||
out.open(argv[2], "wb");
|
||||
else
|
||||
out.open("out.dff", "wb");
|
||||
// if(lcs)
|
||||
// clumpStreamWriteRsl(&out, c);
|
||||
// else
|
||||
c->streamWrite(&out);
|
||||
c->streamWrite(&out);
|
||||
out.close();
|
||||
}
|
||||
|
||||
|
|
|
@ -142,6 +142,7 @@
|
|||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
|
|
|
@ -28,17 +28,11 @@ RslMatrixSetIdentity(RslMatrix *matrix)
|
|||
void
|
||||
rslObjectHasFrameSetFrame(RslObjectHasFrame *object, RslFrame *f)
|
||||
{
|
||||
if(object->object.parent){
|
||||
object->lFrame.prev->next = object->lFrame.next;
|
||||
object->lFrame.next->prev = object->lFrame.prev;
|
||||
}
|
||||
object->object.parent = f;
|
||||
if(object->object.parent)
|
||||
rslLinkListRemoveLLLink(&object->lFrame);
|
||||
rslObjectSetParent(object, f);
|
||||
if(f){
|
||||
object->lFrame.prev = &f->objectList.link;
|
||||
object->lFrame.next = f->objectList.link.next;
|
||||
f->objectList.link.next->prev = &object->lFrame;
|
||||
f->objectList.link.next = &object->lFrame;
|
||||
|
||||
rslLinkListAddLLLink(&f->objectList, &object->lFrame);
|
||||
f->root->object.privateFlags |= 1;
|
||||
f->object.privateFlags |= 2;
|
||||
}
|
||||
|
@ -49,8 +43,7 @@ RslFrameCreate(void)
|
|||
{
|
||||
RslFrame *f = new RslFrame;
|
||||
rslObjectInitialize(&f->object, 0, 0);
|
||||
f->objectList.link.prev = &f->objectList.link;
|
||||
f->objectList.link.next = &f->objectList.link;
|
||||
rslLinkListInitialize(&f->objectList);
|
||||
RslMatrixSetIdentity(&f->modelling);
|
||||
RslMatrixSetIdentity(&f->ltm);
|
||||
f->child = NULL;
|
||||
|
@ -327,8 +320,7 @@ RslClumpCreate(void)
|
|||
{
|
||||
RslClump *clump = new RslClump;
|
||||
rslObjectInitialize(&clump->object, 2, 0);
|
||||
clump->atomicList.link.prev = &clump->atomicList.link;
|
||||
clump->atomicList.link.next = &clump->atomicList.link;
|
||||
rslLinkListInitialize(&clump->atomicList);
|
||||
return clump;
|
||||
}
|
||||
|
||||
|
@ -373,10 +365,7 @@ RslClumpStreamRead(Stream *stream)
|
|||
RslClump*
|
||||
RslClumpAddAtomic(RslClump *clump, RslAtomic *a)
|
||||
{
|
||||
a->inClumpLink.prev = &clump->atomicList.link;
|
||||
a->inClumpLink.next = clump->atomicList.link.next;
|
||||
clump->atomicList.link.next->prev = &a->inClumpLink;
|
||||
clump->atomicList.link.next = &a->inClumpLink;
|
||||
rslLinkListAddLLLink(&clump->atomicList, &a->inClumpLink);
|
||||
a->clump = clump;
|
||||
return clump;
|
||||
}
|
||||
|
@ -387,7 +376,7 @@ RslClumpForAllAtomics(RslClump *clump, RslAtomicCallBack callback, void *pData)
|
|||
RslAtomic *a;
|
||||
RslLLLink *link;
|
||||
for(link = rslLLLinkGetNext(&clump->atomicList.link);
|
||||
link != &clump->atomicList.link;
|
||||
link != rslLinkListGetTerminator(&clump->atomicList);
|
||||
link = link->next){
|
||||
a = rslLLLinkGetData(link, RslAtomic, inClumpLink);
|
||||
if(callback(a, pData) == NULL)
|
||||
|
@ -402,7 +391,7 @@ RslClumpGetNumAtomics(RslClump *clump)
|
|||
int32 n = 0;
|
||||
RslLLLink *link;
|
||||
for(link = rslLLLinkGetNext(&clump->atomicList.link);
|
||||
link != &clump->atomicList.link;
|
||||
link != rslLinkListGetTerminator(&clump->atomicList);
|
||||
link = link->next)
|
||||
n++;
|
||||
return n;
|
||||
|
@ -561,23 +550,17 @@ RslTexDictionaryCreate(void)
|
|||
RslTexDictionary *dict = new RslTexDictionary;
|
||||
memset(dict, 0, sizeof(RslTexDictionary));
|
||||
rslObjectInitialize(&dict->object, 6, 0);
|
||||
dict->texturesInDict.link.prev = &dict->texturesInDict.link;
|
||||
dict->texturesInDict.link.next = &dict->texturesInDict.link;
|
||||
rslLinkListInitialize(&dict->texturesInDict);
|
||||
return dict;
|
||||
}
|
||||
|
||||
RslTexture*
|
||||
RslTexDictionaryAddTexture(RslTexDictionary *dict, RslTexture *tex)
|
||||
{
|
||||
if(tex->dict){
|
||||
tex->lInDictionary.prev->next = tex->lInDictionary.next;
|
||||
tex->lInDictionary.next->prev = tex->lInDictionary.prev;
|
||||
}
|
||||
if(tex->dict)
|
||||
rslLinkListRemoveLLLink(&tex->lInDictionary);
|
||||
tex->dict = dict;
|
||||
tex->lInDictionary.prev = &dict->texturesInDict.link;
|
||||
tex->lInDictionary.next = dict->texturesInDict.link.next;
|
||||
dict->texturesInDict.link.next->prev = &tex->lInDictionary;
|
||||
dict->texturesInDict.link.next = &tex->lInDictionary;
|
||||
rslLinkListAddLLLink(&dict->texturesInDict, &tex->lInDictionary);
|
||||
return tex;
|
||||
}
|
||||
|
||||
|
@ -587,7 +570,7 @@ RslTexDictionaryForAllTextures(RslTexDictionary *dict, RslTextureCallBack fpCall
|
|||
RslTexture *t;
|
||||
RslLLLink *link;
|
||||
for(link = rslLLLinkGetNext(&dict->texturesInDict.link);
|
||||
link != &dict->texturesInDict.link;
|
||||
link != rslLinkListGetTerminator(&dict->texturesInDict);
|
||||
link = link->next){
|
||||
t = rslLLLinkGetData(link, RslTexture, lInDictionary);
|
||||
if(fpCallBack(t, pData) == NULL)
|
||||
|
|
|
@ -75,26 +75,43 @@ struct RslLLLink
|
|||
RslLLLink *prev;
|
||||
};
|
||||
|
||||
#define rslLLLinkGetData(linkvar,type,entry) \
|
||||
((type*)(((uint8*)(linkvar))-offsetof(type,entry)))
|
||||
#define rslLLLinkGetNext(linkvar) \
|
||||
((linkvar)->next)
|
||||
#define rslLLLinkGetPrevious(linkvar) \
|
||||
((linkvar)->prev)
|
||||
#define rslLLLinkInitialize(linkvar) \
|
||||
((linkvar)->prev = (RslLLLink*)NULL, \
|
||||
(linkvar)->next = (RslLLLink*)NULL)
|
||||
#define rslLLLinkAttached(linkvar) \
|
||||
((linkvar)->next)
|
||||
|
||||
struct RslLinkList
|
||||
{
|
||||
RslLLLink link;
|
||||
};
|
||||
|
||||
#define rslLLLinkGetData(linkvar,type,entry) \
|
||||
((type *)(((uint8 *)(linkvar))-offsetof(type,entry)))
|
||||
#define rslLinkListInitialize(list) \
|
||||
((list)->link.next = ((RslLLLink*)(list)), \
|
||||
(list)->link.prev = ((RslLLLink*)(list)))
|
||||
#define rslLinkListEmpty(list) \
|
||||
(((list)->link.next) == (&(list)->link))
|
||||
#define rslLinkListAddLLLink(list, linkvar) \
|
||||
((linkvar)->next = (list)->link.next, \
|
||||
(linkvar)->prev = (&(list)->link), \
|
||||
((list)->link.next)->prev = (linkvar), \
|
||||
(list)->link.next = (linkvar) )
|
||||
#define rslLinkListRemoveLLLink(linkvar) \
|
||||
(((linkvar)->prev)->next = (linkvar)->next, \
|
||||
((linkvar)->next)->prev = (linkvar)->prev)
|
||||
#define rslLinkListGetFirstLLLink(list) \
|
||||
((list)->link.next)
|
||||
#define rslLinkListGetLastLLLink(list) \
|
||||
((list)->link.prev)
|
||||
#define rslLinkListGetTerminator(list) \
|
||||
(&((list)->link))
|
||||
|
||||
#define rslLLLinkGetNext(linkvar) \
|
||||
((linkvar)->next)
|
||||
|
||||
#define rslLLLinkGetPrevious(linkvar) \
|
||||
((linkvar)->prev)
|
||||
|
||||
#define rslLLLinkInitialize(linkvar) \
|
||||
( (linkvar)->prev = (RslLLLink *)NULL, \
|
||||
(linkvar)->next = (RslLLLink *)NULL )
|
||||
|
||||
#define rslLLLinkAttached(linkvar) \
|
||||
((linkvar)->next)
|
||||
|
||||
struct RslObject {
|
||||
uint8 type;
|
||||
|
|
|
@ -407,7 +407,7 @@ convertClump(RslClump *c)
|
|||
if(parent >= 0)
|
||||
rwframes[parent]->addChild(rwf);
|
||||
}
|
||||
rwc->parent = rwframes[0];
|
||||
rwc->object.parent = rwframes[0];
|
||||
|
||||
rwc->numAtomics = RslClumpGetNumAtomics(c);
|
||||
rwc->atomicList = new Atomic*[rwc->numAtomics];
|
||||
|
@ -418,7 +418,7 @@ convertClump(RslClump *c)
|
|||
rwa = convertAtomic(alist[i]);
|
||||
rwc->atomicList[i] = rwa;
|
||||
int32 fi = findPointer(alist[i]->object.object.parent, (void**)frameList.frames, frameList.numFrames);
|
||||
rwa->frame = rwframes[fi];
|
||||
rwa->object.parent = rwframes[fi];
|
||||
rwa->clump = rwc;
|
||||
}
|
||||
|
||||
|
@ -823,14 +823,14 @@ main(int argc, char *argv[])
|
|||
rslstr->relocate();
|
||||
|
||||
bool32 largefile;
|
||||
largefile = rslstr->dataSize > 0x100000;
|
||||
largefile = rslstr->dataSize > 0x1000000;
|
||||
|
||||
if(rslstr->ident == WRLD_IDENT && largefile){ // hack
|
||||
world = (World*)rslstr->data;
|
||||
|
||||
int len = strlen(argv[1])+1;
|
||||
int len = strlen(argv[0])+1;
|
||||
char filename[1024];
|
||||
strncpy(filename, argv[1], len);
|
||||
strncpy(filename, argv[0], len);
|
||||
filename[len-3] = 'i';
|
||||
filename[len-2] = 'm';
|
||||
filename[len-1] = 'g';
|
||||
|
@ -874,16 +874,21 @@ main(int argc, char *argv[])
|
|||
stream.close();
|
||||
}else if(rslstr->ident == WRLD_IDENT){ // sector
|
||||
sector = (Sector*)rslstr->data;
|
||||
printf("resources\n");
|
||||
for(uint32 i = 0; i < sector->numResources; i++){
|
||||
OverlayResource *r = §or->resources[i];
|
||||
printf(" %d %p\n", r->id, r->raw);
|
||||
}
|
||||
printf("placement\n");
|
||||
fprintf(stderr, "%d\n",sector->unk1);
|
||||
//printf("resources\n");
|
||||
//for(uint32 i = 0; i < sector->numResources; i++){
|
||||
// OverlayResource *r = §or->resources[i];
|
||||
// printf(" %d %p\n", r->id, r->raw);
|
||||
//}
|
||||
//printf("placement\n");
|
||||
if(sector->unk1 == 0)
|
||||
return 0;
|
||||
Placement *p;
|
||||
for(p = sector->sectionA; p < sector->sectionEnd; p++){
|
||||
printf(" %d, %d, %f %f %f\n", p->id &0x7FFF, p->resId, p->matrix[12], p->matrix[13], p->matrix[14]);
|
||||
}
|
||||
//for(p = sector->sectionA; p < sector->sectionEnd; p++){
|
||||
// printf(" %d, %d, %f %f %f\n", p->id &0x7FFF, p->resId, p->matrix[12], p->matrix[13], p->matrix[14]);
|
||||
//}
|
||||
for(p = sector->sectionA; p < sector->sectionEnd; p++)
|
||||
printf("%f %f %f\n", p->matrix[12], p->matrix[13], p->matrix[14]);
|
||||
}else if(rslstr->ident == MDL_IDENT){
|
||||
uint8 *p;
|
||||
p = *rslstr->hashTab;
|
||||
|
|
Loading…
Reference in New Issue