diff --git a/TR5Main/Specific/newlevel.cpp b/TR5Main/Specific/levelloader.cpp similarity index 70% rename from TR5Main/Specific/newlevel.cpp rename to TR5Main/Specific/levelloader.cpp index a3f8594db..29a54faef 100644 --- a/TR5Main/Specific/newlevel.cpp +++ b/TR5Main/Specific/levelloader.cpp @@ -1,14 +1,16 @@ #include "framework.h" -#include "newlevel.h" +#include "levelloader.h" #include "ChunkId.h" #include "ChunkReader.h" +#include "level.h" +#include -TrLevel::TrLevel(string filename) +LevelLoader::LevelLoader(string filename) { m_filename = filename; } -TrLevel::~TrLevel() +LevelLoader::~LevelLoader() { delete m_chunkTextureAtlas; delete m_chunkTextureColor; @@ -57,9 +59,10 @@ TrLevel::~TrLevel() delete m_chunkDummy; delete m_chunkAnimatedTextureSequence; delete m_chunkAnimatedTextureFrame; + delete m_chunkFloorData; } -bool TrLevel::Load() +bool LevelLoader::Load() { m_stream = new FileStream((char*)m_filename.c_str(), true, false); m_reader = new ChunkReader(m_magicNumber, m_stream); @@ -72,6 +75,22 @@ bool TrLevel::Load() return readAnimatedTextureSequence(); else if (id->EqualsTo(m_chunkRoom)) return readRoom(); + else if (id->EqualsTo(m_chunkFloorData)) + return readRoom(); + else if (id->EqualsTo(m_chunkMesh)) + return readMesh(); + else if (id->EqualsTo(m_chunkBone)) + return readBone(); + else if (id->EqualsTo(m_chunkStateChange)) + return readChange(); + else if (id->EqualsTo(m_chunkAnimDispatch)) + return readDispatch(); + else if (id->EqualsTo(m_chunkKeyFrame)) + return readKeyFrame(); + else if (id->EqualsTo(m_chunkAnimCommand)) + return readCommand(); + else if (id->EqualsTo(m_chunkAnimation)) + return readAnimation(); else if (id->EqualsTo(m_chunkMoveable)) return readMoveable(); else if (id->EqualsTo(m_chunkStatic)) @@ -94,8 +113,12 @@ bool TrLevel::Load() return readSoundMap(); else if (id->EqualsTo(m_chunkSoundDetail)) return readSoundDetail(); + else if (id->EqualsTo(m_chunkSample)) + return readSample(); else if (id->EqualsTo(m_chunkBox)) return readBox(); + else if (id->EqualsTo(m_chunkOverlap)) + return readOverlap(); else if (id->EqualsTo(m_chunkZone)) return readZones(); else @@ -111,7 +134,7 @@ bool TrLevel::Load() ChunkReader* m_reader; -bool TrLevel::readTexture() +bool LevelLoader::readTexture() { TrTexturePage texture; @@ -135,11 +158,12 @@ bool TrLevel::readTexture() } }, 0); - textures.push_back(texture); + m_level.textures.push_back(texture); + return true; } -bool TrLevel::readAnimatedTextureSequence() +bool LevelLoader::readAnimatedTextureSequence() { TrAnimatedTexturesSequence sequence; @@ -170,11 +194,12 @@ bool TrLevel::readAnimatedTextureSequence() } }, 0); - animatedTextures.push_back(sequence); + m_level.animatedTextures.push_back(sequence); + return true; } -bool TrLevel::readRoom() +bool LevelLoader::readRoom() { TrRoom room; @@ -238,7 +263,10 @@ bool TrLevel::readRoom() else if (id->EqualsTo(m_chunkRoomSector)) { TrSector sector; - m_stream->ReadInt32(§or.boxIndex); + + m_stream->ReadInt32(§or.floorDataIndex); + m_stream->ReadInt32(§or.floorDataCount); + m_stream->ReadInt32(§or.box); m_stream->ReadInt32(§or.pathfindingFlags); m_stream->ReadInt32(§or.stepSound); m_stream->ReadInt32(§or.roomBelow); @@ -265,7 +293,7 @@ bool TrLevel::readRoom() return true; } -bool TrLevel::readBucket(TrBucket* bucket) +bool LevelLoader::readBucket(TrBucket* bucket) { m_reader->ReadChunks([this, bucket](ChunkId * id, long size, int arg) { if (id->EqualsTo(m_chunkMaterial)) @@ -371,15 +399,30 @@ bool TrLevel::readBucket(TrBucket* bucket) return true; } -bool TrLevel::readMesh(TrMesh* mesh) +bool LevelLoader::readFloorData() { - m_stream->ReadBoundingSphere(&mesh->sphere); - m_reader->ReadChunks([this, mesh](ChunkId * id, long size, int arg) { + int count; + m_stream->ReadInt32(&count); + for (int i = 0; i < count; i++) + { + int data; + m_stream->ReadInt32(&data); + m_level.floorData.push_back(data); + } + return true; +} + +bool LevelLoader::readMesh() +{ + TrMesh mesh; + + m_stream->ReadBoundingSphere(&mesh.sphere); + m_reader->ReadChunks([this, &mesh](ChunkId * id, long size, int arg) { if (id->EqualsTo(m_chunkBucket)) { TrBucket bucket; readBucket(&bucket); - mesh->buckets.push_back(bucket); + mesh.buckets.push_back(bucket); return true; } else @@ -387,23 +430,36 @@ bool TrLevel::readMesh(TrMesh* mesh) return false; } }, 0); + m_level.meshes.push_back(mesh); + return true; } -bool TrLevel::readAnimation(TrAnimation* animation) +bool LevelLoader::readAnimation() { - m_stream->ReadInt32(&animation->framerate); - m_stream->ReadInt32(&animation->state); - m_stream->ReadInt32(&animation->nextAnimation); - m_stream->ReadInt32(&animation->nextFrame); - m_stream->ReadInt32(&animation->frameStart); - m_stream->ReadInt32(&animation->frameEnd); - m_stream->ReadFloat(&animation->speed); - m_stream->ReadFloat(&animation->acceleration); - m_stream->ReadFloat(&animation->lateralSpeed); - m_stream->ReadFloat(&animation->lateralAcceleration); + TrAnimation animation; - m_reader->ReadChunks([this, animation](ChunkId * id, long size, int arg) { + m_stream->ReadInt32(&animation.framerate); + m_stream->ReadInt32(&animation.state); + m_stream->ReadInt32(&animation.nextAnimation); + m_stream->ReadInt32(&animation.nextFrame); + m_stream->ReadInt32(&animation.frameBase); + m_stream->ReadInt32(&animation.frameEnd); + m_stream->ReadFloat(&animation.speed); + m_stream->ReadFloat(&animation.acceleration); + m_stream->ReadFloat(&animation.lateralSpeed); + m_stream->ReadFloat(&animation.lateralAcceleration); + m_stream->ReadInt32(&animation.framesIndex); + m_stream->ReadInt32(&animation.framesCount); + m_stream->ReadInt32(&animation.changesIndex); + m_stream->ReadInt32(&animation.changesCount); + m_stream->ReadInt32(&animation.commandsIndex); + m_stream->ReadInt32(&animation.commandsCount); + + m_reader->ReadChunks([this, &animation](ChunkId * id, long size, int arg) { + return false; + + /* if (id->EqualsTo(m_chunkKeyFrame)) { TrKeyFrame kf; @@ -470,20 +526,112 @@ bool TrLevel::readAnimation(TrAnimation* animation) else { return false; - } + }*/ }, 0); + m_level.animations.push_back(animation); + return true; } -bool TrLevel::readMoveable() +bool LevelLoader::readChange() +{ + TrStateChange change; + + m_stream->ReadInt32(&change.state); + m_stream->ReadInt32(&change.dispatchIndex); + m_stream->ReadInt32(&change.dispatchCount); + + m_reader->ReadChunks([this, &change](ChunkId * id, long size, int arg) { + return false; + }, 0); + + m_level.changes.push_back(change); + + return true; +} + +bool LevelLoader::readDispatch() +{ + TrAnimDispatch dispatch; + + m_stream->ReadInt32(&dispatch.inFrame); + m_stream->ReadInt32(&dispatch.outFrame); + m_stream->ReadInt32(&dispatch.nextAnimation); + m_stream->ReadInt32(&dispatch.nextFrame); + + m_level.dispatches.push_back(dispatch); + + return true; +} + +bool LevelLoader::readBone() +{ + TrBone bone; + + m_stream->ReadInt32(&bone.opcode); + m_stream->ReadVector3(&bone.offset); + + m_level.bones.push_back(bone); + + return true; +} + +bool LevelLoader::readCommand() +{ + TrAnimCommand cmd; + + m_stream->ReadInt32(&cmd.type); + m_stream->ReadInt32(&cmd.frame); + int count = 0; + m_stream->ReadInt32(&count); + for (int i = 0; i < count; i++) + { + int p; + m_stream->ReadInt32(&p); + cmd.params.push_back(p); + } + + m_level.commands.push_back(cmd); + + return true; +} + +bool LevelLoader::readKeyFrame() +{ + TrKeyFrame kf; + + m_stream->ReadVector3(&kf.origin); + m_stream->ReadBoundingBox(&kf.boundingBox); + int count = 0; + m_stream->ReadInt32(&count); + for (int i = 0; i < count; i++) + { + Quaternion q; + m_stream->ReadQuaternion(&q); + kf.angles.push_back(q); + } + + m_level.frames.push_back(kf); + + return true; +} + +bool LevelLoader::readMoveable() { TrMoveable moveable; m_stream->ReadInt32(&moveable.id); + m_stream->ReadInt32(&moveable.meshIndex); + m_stream->ReadInt32(&moveable.meshCount); + m_stream->ReadInt32(&moveable.bonesIndex); + m_stream->ReadInt32(&moveable.bonesCount); + m_stream->ReadInt32(&moveable.animationIndex); + m_stream->ReadInt32(&moveable.animationCount); m_reader->ReadChunks([this, &moveable](ChunkId * id, long size, int arg) { - if (id->EqualsTo(m_chunkMesh)) + return false; + /*if (id->EqualsTo(m_chunkMesh)) { TrMesh mesh; readMesh(&mesh); @@ -508,23 +656,26 @@ bool TrLevel::readMoveable() else { return false; - } + }*/ }, 0); - moveables.push_back(moveable); + m_level.moveables.push_back(moveable); return true; } -bool TrLevel::readStatic() +bool LevelLoader::readStatic() { TrStatic st; m_stream->ReadInt32(&st.id); m_stream->ReadBoundingBox(&st.visibilityBox); m_stream->ReadBoundingBox(&st.collisionBox); + m_stream->ReadInt32(&st.meshNumber); + m_stream->ReadInt32(&st.meshCount); + m_reader->ReadChunks([this, &st](ChunkId * id, long size, int arg) { - if (id->EqualsTo(m_chunkMesh)) + /*if (id->EqualsTo(m_chunkMesh)) { TrMesh mesh; readMesh(&mesh); @@ -534,22 +685,26 @@ bool TrLevel::readStatic() else { return false; - } + }*/ + return false; }, 0); - statics.push_back(st); + m_level.statics.push_back(st); return true; } -bool TrLevel::readSpriteSequence() +bool LevelLoader::readSpriteSequence() { TrSpriteSequence sequence; m_stream->ReadInt32(&sequence.id); + m_stream->ReadInt32(&sequence.spritesIndex); + m_stream->ReadInt32(&sequence.spritesCount); + m_reader->ReadChunks([this, &sequence](ChunkId * id, long size, int arg) { - if (id->EqualsTo(m_chunkSprite)) + /*if (id->EqualsTo(m_chunkSprite)) { TrSprite sprite; @@ -568,51 +723,55 @@ bool TrLevel::readSpriteSequence() else { return false; - } + }*/ + + return false; }, 0); - spriteSequences.push_back(sequence); + m_level.spriteSequences.push_back(sequence); return true; } -bool TrLevel::readItem() +bool LevelLoader::readItem() { TrItem item; m_stream->ReadString(&item.name); m_stream->ReadVector3(&item.position); m_stream->ReadQuaternion(&item.rotation); + m_stream->ReadFloat(&item.angle); m_stream->ReadVector3(&item.scale); m_stream->ReadVector3(&item.color); m_stream->ReadInt32(&item.roomNumber); m_stream->ReadInt32(&item.objectNumber); m_stream->ReadString(&item.script); - items.push_back(item); + m_level.items.push_back(item); return true; } -bool TrLevel::readAiItem() +bool LevelLoader::readAiItem() { TrItem item; m_stream->ReadString(&item.name); m_stream->ReadVector3(&item.position); m_stream->ReadQuaternion(&item.rotation); + m_stream->ReadFloat(&item.angle); m_stream->ReadVector3(&item.scale); m_stream->ReadVector3(&item.color); m_stream->ReadInt32(&item.roomNumber); m_stream->ReadInt32(&item.objectNumber); m_stream->ReadString(&item.script); - aiItems.push_back(item); + m_level.aiItems.push_back(item); return true; } -bool TrLevel::readSink() +bool LevelLoader::readSink() { TrSink sink; @@ -624,12 +783,12 @@ bool TrLevel::readSink() m_reader->ReadChunks([this, sink](ChunkId * id, long size, int arg) { return false; }, 0); - sinks.push_back(sink); + m_level.sinks.push_back(sink); return true; } -bool TrLevel::readCamera() +bool LevelLoader::readCamera() { TrCamera camera; @@ -642,12 +801,12 @@ bool TrLevel::readCamera() m_reader->ReadChunks([this, camera](ChunkId * id, long size, int arg) { return false; }, 0); - cameras.push_back(camera); + m_level.cameras.push_back(camera); return true; } -bool TrLevel::readFlybyCamera() +bool LevelLoader::readFlybyCamera() { TrFlybyCamera camera; @@ -666,12 +825,12 @@ bool TrLevel::readFlybyCamera() m_reader->ReadChunks([this, camera](ChunkId * id, long size, int arg) { return false; }, 0); - flybyCameras.push_back(camera); + m_level.flybyCameras.push_back(camera); return true; } -bool TrLevel::readSoundSource() +bool LevelLoader::readSoundSource() { TrSoundSource soundSource; @@ -683,12 +842,12 @@ bool TrLevel::readSoundSource() m_reader->ReadChunks([this, soundSource](ChunkId * id, long size, int arg) { return false; }, 0); - soundSources.push_back(soundSource); + m_level.soundSources.push_back(soundSource); return true; } -bool TrLevel::readBox() +bool LevelLoader::readBox() { TrBox box; @@ -714,26 +873,26 @@ bool TrLevel::readBox() } }, 0); - boxes.push_back(box); + m_level.boxes.push_back(box); return true; } -bool TrLevel::readZones() +bool LevelLoader::readZones() { - for (int z = 0; z < 5; z++) - for (int a = 0; a < 2; a++) - for (int b = 0; b < boxes.size(); b++) + for (int a = 0; a < 2; a++) + for (int z = 0; z < 5; z++) + for (int b = 0; b < m_level.boxes.size(); b++) { int zone; m_stream->ReadInt32(&zone); - zones.push_back(zone); + m_level.zones[z][a].push_back(zone); } return true; } -bool TrLevel::readSoundMap() +bool LevelLoader::readSoundMap() { int count; m_stream->ReadInt32(&count); @@ -741,13 +900,13 @@ bool TrLevel::readSoundMap() { int sound; m_stream->ReadInt32(&sound); - soundMap.push_back(sound); + m_level.soundMap.push_back(sound); } return true; } -bool TrLevel::readSoundDetail() +bool LevelLoader::readSoundDetail() { TrSoundDetails detail; @@ -761,7 +920,7 @@ bool TrLevel::readSoundDetail() m_stream->ReadByte(&detail.loop); m_reader->ReadChunks([this, &detail](ChunkId * id, long size, int arg) { - if (id->EqualsTo(m_chunkSample)) + /*if (id->EqualsTo(m_chunkSample)) { TrSample sample; @@ -777,10 +936,40 @@ bool TrLevel::readSoundDetail() else { return false; - } + }*/ + return false; }, 0); - soundDetails.push_back(detail); + m_level.soundDetails.push_back(detail); return true; } + +bool LevelLoader::readSample() +{ + TrSample sample; + + m_stream->ReadInt32(&sample.uncompressedSize); + m_stream->ReadInt32(&sample.compressedSize); + sample.data = (byte*)malloc(sample.compressedSize); + m_stream->ReadBytes(sample.data, sample.compressedSize); + + Sound_LoadSample((char*)sample.data, sample.compressedSize, sample.uncompressedSize, m_numSamples); + m_numSamples++; + + return true; +} + +bool LevelLoader::readOverlap() +{ + TrOverlap overlap; + + m_stream->ReadInt32(&overlap.box); + m_stream->ReadInt32(&overlap.flags); + + m_reader->ReadChunks([this, &overlap](ChunkId * id, long size, int arg) { return false; }, 0); + + m_level.overlaps.push_back(overlap); + + return true; +} \ No newline at end of file diff --git a/TR5Main/Specific/levelloader.h b/TR5Main/Specific/levelloader.h new file mode 100644 index 000000000..b61c8ea06 --- /dev/null +++ b/TR5Main/Specific/levelloader.h @@ -0,0 +1,100 @@ +#pragma once +#include "framework.h" +#include "sound.h" +#include "Streams.h" +#include "newtypes.h" +#include "ChunkId.h" +#include "ChunkReader.h" + +class LevelLoader +{ +private: + ChunkId* m_chunkTextureAtlas = ChunkId::FromString("T5MTex"); + ChunkId* m_chunkTextureColor = ChunkId::FromString("T5MTexColMap"); + ChunkId* m_chunkTextureNormalMap = ChunkId::FromString("T5MTexNrmMap"); + ChunkId* m_chunkRoom = ChunkId::FromString("T5MRoom"); + ChunkId* m_chunkRoomInfo = ChunkId::FromString("T5MRoomInfo"); + ChunkId* m_chunkBucket = ChunkId::FromString("T5MBckt"); + ChunkId* m_chunkRoomLight = ChunkId::FromString("T5MLight"); + ChunkId* m_chunkRoomStatic = ChunkId::FromString("T5MRoomSt"); + ChunkId* m_chunkRoomPortal = ChunkId::FromString("T5MPortal"); + ChunkId* m_chunkRoomSector = ChunkId::FromString("T5MSector"); + ChunkId* m_chunkRoomTriggerVolume = ChunkId::FromString("T5MTrigVol"); + ChunkId* m_chunkRoomClimbVolume = ChunkId::FromString("T5MClimbVol"); + ChunkId* m_chunkMaterial = ChunkId::FromString("T5MMat"); + ChunkId* m_chunkVerticesPositions = ChunkId::FromString("T5MVrtPos"); + ChunkId* m_chunkVerticesNormals = ChunkId::FromString("T5MVrtN"); + ChunkId* m_chunkVerticesTextureCoords = ChunkId::FromString("T5MVrtUV"); + ChunkId* m_chunkVerticesColors = ChunkId::FromString("T5MVrtCol"); + ChunkId* m_chunkVerticesEffects = ChunkId::FromString("T5MVrtFX"); + ChunkId* m_chunkVerticesBones = ChunkId::FromString("T5MVrtB"); + ChunkId* m_chunkPolygon = ChunkId::FromString("T5MPoly"); + ChunkId* m_chunkMesh = ChunkId::FromString("T5MMesh"); + ChunkId* m_chunkBone = ChunkId::FromString("T5MBone"); + ChunkId* m_chunkKeyFrame = ChunkId::FromString("T5MKf"); + ChunkId* m_chunkAnimCommand = ChunkId::FromString("T5MAnCmd"); + ChunkId* m_chunkStateChange = ChunkId::FromString("T5MStCh"); + ChunkId* m_chunkAnimDispatch = ChunkId::FromString("T5MAnDisp"); + ChunkId* m_chunkAnimation = ChunkId::FromString("T5MAnim"); + ChunkId* m_chunkMoveable = ChunkId::FromString("T5MMoveable"); + ChunkId* m_chunkStatic = ChunkId::FromString("T5MStatic"); + ChunkId* m_chunkItem = ChunkId::FromString("T5MItem"); + ChunkId* m_chunkAiItem = ChunkId::FromString("T5MAiItem"); + ChunkId* m_chunkCamera = ChunkId::FromString("T5MCamera"); + ChunkId* m_chunkSink = ChunkId::FromString("T5MSink"); + ChunkId* m_chunkFlybyCamera = ChunkId::FromString("T5MFlyBy"); + ChunkId* m_chunkSoundSource = ChunkId::FromString("T5MSndSrc"); + ChunkId* m_chunkBox = ChunkId::FromString("T5MBox"); + ChunkId* m_chunkOverlap = ChunkId::FromString("T5MOv"); + ChunkId* m_chunkZone = ChunkId::FromString("T5MZone"); + ChunkId* m_chunkSoundMap = ChunkId::FromString("T5MSoundMap"); + ChunkId* m_chunkSoundDetail = ChunkId::FromString("T5MSndDet"); + ChunkId* m_chunkSample = ChunkId::FromString("T5MSam"); + ChunkId* m_chunkLeelScript = ChunkId::FromString("T5MScript"); + ChunkId* m_chunkSprite = ChunkId::FromString("T5MSpr"); + ChunkId* m_chunkSpriteSequence = ChunkId::FromString("T5MSprSeq"); + ChunkId* m_chunkDummy = ChunkId::FromString("T5MDummy"); + ChunkId* m_chunkAnimatedTextureSequence = ChunkId::FromString("T5MAnTxSeq"); + ChunkId* m_chunkAnimatedTextureFrame = ChunkId::FromString("T5MAnTxFr"); + ChunkId* m_chunkFloorData = ChunkId::FromString("T5MFloorData"); + + int m_magicNumber = 0x4D355254; + string m_filename; + ChunkReader* m_reader; + FileStream* m_stream; + int m_numSamples = 0; + TrLevel m_level; + + bool readTexture(); + bool readAnimatedTextureSequence(); + bool readRoom(); + bool readBucket(TrBucket* bucket); + bool readMesh(); + bool readAnimation(); + bool readChange(); + bool readDispatch(); + bool readBone(); + bool readKeyFrame(); + bool readCommand(); + bool readOverlap(); + bool readFloorData(); + bool readMoveable(); + bool readStatic(); + bool readSpriteSequence(); + bool readItem(); + bool readAiItem(); + bool readSink(); + bool readCamera(); + bool readFlybyCamera(); + bool readSoundSource(); + bool readBox(); + bool readZones(); + bool readSoundMap(); + bool readSoundDetail(); + bool readSample(); + +public: + LevelLoader(string filename); + ~LevelLoader(); + bool Load(); +}; \ No newline at end of file diff --git a/TR5Main/Specific/newlevel.h b/TR5Main/Specific/newtypes.h similarity index 50% rename from TR5Main/Specific/newlevel.h rename to TR5Main/Specific/newtypes.h index 8382911c8..918121ea3 100644 --- a/TR5Main/Specific/newlevel.h +++ b/TR5Main/Specific/newtypes.h @@ -1,10 +1,7 @@ #pragma once -#include "sound.h" -#include "ChunkId.h" -#include "ChunkReader.h" -#include "Streams.h" +#include "framework.h" -struct TrTexturePage +struct TrTexturePage { int width; int height; @@ -21,14 +18,14 @@ struct TrPolygon int frame; }; -struct TrMaterial +struct TrMaterial { int texture; byte blendMode; bool animated; }; -struct TrBucket +struct TrBucket { TrMaterial material; vector positions; @@ -40,7 +37,7 @@ struct TrBucket vector polygons; }; -struct TrVolume +struct TrVolume { int type; Vector3 position; @@ -62,7 +59,9 @@ struct TrTriggerVolume : TrVolume struct TrSector { - int boxIndex; + int floorDataIndex; + int floorDataCount; + int box; int pathfindingFlags; int stepSound; int roomBelow; @@ -72,7 +71,7 @@ struct TrSector vector floorData; }; -struct TrLight +struct TrLight { Vector3 position; Vector3 color; @@ -87,7 +86,7 @@ struct TrLight int flags; }; -struct TrRoomStatic +struct TrRoomStatic { string name; Vector3 position; @@ -131,9 +130,11 @@ struct TrRoom vector portals; vector triggers; vector climbVolumes; + int itemNumber; + int fxNumber; }; -struct TrMesh +struct TrMesh { BoundingSphere sphere; vector buckets; @@ -145,7 +146,7 @@ struct TrBone Vector3 offset; }; -struct TrKeyFrame +struct TrKeyFrame { Vector3 origin; BoundingBox boundingBox; @@ -159,7 +160,7 @@ struct TrAnimCommand vector params; }; -struct TrAnimDispatch +struct TrAnimDispatch { int inFrame; int outFrame; @@ -167,9 +168,11 @@ struct TrAnimDispatch int nextFrame; }; -struct TrStateChange +struct TrStateChange { int state; + int dispatchIndex; + int dispatchCount; vector dispatches; }; @@ -179,30 +182,44 @@ struct TrAnimation int state; int nextAnimation; int nextFrame; - int frameStart; + int frameBase; int frameEnd; float speed; float acceleration; float lateralSpeed; float lateralAcceleration; + int framesIndex; + int framesCount; + int changesIndex; + int changesCount; + int commandsIndex; + int commandsCount; vector keyframes; vector changes; vector commands; }; -struct TrMoveable +struct TrMoveable { int id; + int animationIndex; + int animationCount; + int meshIndex; + int meshCount; + int bonesIndex; + int bonesCount; vector meshes; vector bones; vector animations; }; -struct TrStatic +struct TrStatic { int id; BoundingBox visibilityBox; BoundingBox collisionBox; + int meshNumber; + int meshCount; vector meshes; }; @@ -212,7 +229,7 @@ struct TrAnimatedTexturesFrame vector textureCoords; }; -struct TrAnimatedTexturesSequence +struct TrAnimatedTexturesSequence { byte animationType; float fps; @@ -225,6 +242,7 @@ struct TrItem string name; Vector3 position; Quaternion rotation; + float angle; Vector3 scale; Vector3 color; int roomNumber; @@ -232,7 +250,7 @@ struct TrItem string script; }; -struct TrCamera +struct TrCamera { string name; Vector3 position; @@ -242,7 +260,7 @@ struct TrCamera string script; }; -struct TrSoundSource +struct TrSoundSource { string name; Vector3 position; @@ -252,7 +270,7 @@ struct TrSoundSource int playMode; }; -struct TrSink +struct TrSink { string name; Vector3 position; @@ -261,28 +279,31 @@ struct TrSink int box; }; -struct TrOverlap +struct TrOverlap { int flags; int box; }; -struct TrBox +struct TrBox { Vector2 min; Vector2 max; int floor; + int flags; + int overlapsIndex; + int overlapsCount; vector overlaps; }; -struct TrSample +struct TrSample { int uncompressedSize; int compressedSize; byte* data; }; -struct TrSoundDetails +struct TrSoundDetails { float volume; float range; @@ -295,7 +316,7 @@ struct TrSoundDetails vector samples; }; -struct TrFlybyCamera +struct TrFlybyCamera { string name; int sequence; @@ -311,114 +332,47 @@ struct TrFlybyCamera string script; }; -struct TrSprite +struct TrSprite { int texture; vector textureCoords; }; -struct TrSpriteSequence +struct TrSpriteSequence { int id; + int spritesIndex; + int spritesCount; vector sprites; }; -class TrLevel +struct TrLevel { -private: - ChunkId* m_chunkTextureAtlas = ChunkId::FromString("T5MTex"); - ChunkId* m_chunkTextureColor = ChunkId::FromString("T5MTexColMap"); - ChunkId* m_chunkTextureNormalMap = ChunkId::FromString("T5MTexNrmMap"); - ChunkId* m_chunkRoom = ChunkId::FromString("T5MRoom"); - ChunkId* m_chunkRoomInfo = ChunkId::FromString("T5MRoomInfo"); - ChunkId* m_chunkBucket = ChunkId::FromString("T5MBckt"); - ChunkId* m_chunkRoomLight = ChunkId::FromString("T5MLight"); - ChunkId* m_chunkRoomStatic = ChunkId::FromString("T5MRoomSt"); - ChunkId* m_chunkRoomPortal = ChunkId::FromString("T5MPortal"); - ChunkId* m_chunkRoomSector = ChunkId::FromString("T5MSector"); - ChunkId* m_chunkRoomTriggerVolume = ChunkId::FromString("T5MTrigVol"); - ChunkId* m_chunkRoomClimbVolume = ChunkId::FromString("T5MClimbVol"); - ChunkId* m_chunkMaterial = ChunkId::FromString("T5MMat"); - ChunkId* m_chunkVerticesPositions = ChunkId::FromString("T5MVrtPos"); - ChunkId* m_chunkVerticesNormals = ChunkId::FromString("T5MVrtN"); - ChunkId* m_chunkVerticesTextureCoords = ChunkId::FromString("T5MVrtUV"); - ChunkId* m_chunkVerticesColors = ChunkId::FromString("T5MVrtCol"); - ChunkId* m_chunkVerticesEffects = ChunkId::FromString("T5MVrtFX"); - ChunkId* m_chunkVerticesBones = ChunkId::FromString("T5MVrtB"); - ChunkId* m_chunkPolygon = ChunkId::FromString("T5MPoly"); - ChunkId* m_chunkMesh = ChunkId::FromString("T5MMesh"); - ChunkId* m_chunkBone = ChunkId::FromString("T5MBone"); - ChunkId* m_chunkKeyFrame = ChunkId::FromString("T5MKf"); - ChunkId* m_chunkAnimCommand = ChunkId::FromString("T5MAnCmd"); - ChunkId* m_chunkStateChange = ChunkId::FromString("T5MStCh"); - ChunkId* m_chunkAnimDispatch = ChunkId::FromString("T5MAnDisp"); - ChunkId* m_chunkAnimation = ChunkId::FromString("T5MAnim"); - ChunkId* m_chunkMoveable = ChunkId::FromString("T5MMoveable"); - ChunkId* m_chunkStatic = ChunkId::FromString("T5MStatic"); - ChunkId* m_chunkItem = ChunkId::FromString("T5MItem"); - ChunkId* m_chunkAiItem = ChunkId::FromString("T5MAiItem"); - ChunkId* m_chunkCamera = ChunkId::FromString("T5MCamera"); - ChunkId* m_chunkSink = ChunkId::FromString("T5MSink"); - ChunkId* m_chunkFlybyCamera = ChunkId::FromString("T5MFlyBy"); - ChunkId* m_chunkSoundSource = ChunkId::FromString("T5MSndSrc"); - ChunkId* m_chunkBox = ChunkId::FromString("T5MBox"); - ChunkId* m_chunkOverlap = ChunkId::FromString("T5MOv"); - ChunkId* m_chunkZone = ChunkId::FromString("T5MZone"); - ChunkId* m_chunkSoundMap = ChunkId::FromString("T5MSoundMap"); - ChunkId* m_chunkSoundDetail = ChunkId::FromString("T5MSndDet"); - ChunkId* m_chunkSample = ChunkId::FromString("T5MSam"); - ChunkId* m_chunkLeelScript = ChunkId::FromString("T5MScript"); - ChunkId* m_chunkSprite = ChunkId::FromString("T5MSpr"); - ChunkId* m_chunkSpriteSequence = ChunkId::FromString("T5MSprSeq"); - ChunkId* m_chunkDummy = ChunkId::FromString("T5MDummy"); - ChunkId* m_chunkAnimatedTextureSequence = ChunkId::FromString("T5MAnTxSeq"); - ChunkId* m_chunkAnimatedTextureFrame = ChunkId::FromString("T5MAnTxFr"); - - int m_magicNumber = 0x4D355254; - string m_filename; - ChunkReader* m_reader; - FileStream* m_stream; - - bool readTexture(); - bool readAnimatedTextureSequence(); - bool readRoom(); - bool readBucket(TrBucket* bucket); - bool readMesh(TrMesh* mesh); - bool readAnimation(TrAnimation* animation); - bool readMoveable(); - bool readStatic(); - bool readSpriteSequence(); - bool readItem(); - bool readAiItem(); - bool readSink(); - bool readCamera(); - bool readFlybyCamera(); - bool readSoundSource(); - bool readBox(); - bool readZones(); - bool readSoundMap(); - bool readSoundDetail(); - -public: vector textures; vector rooms; - vector moveables; - vector statics; - vector items; - vector aiItems; - vector cameras; - vector soundSources; - vector sinks; - vector flybyCameras; - vector spriteSequences; + vector floorData; + vector meshes; + vector animations; + vector bones; + vector changes; + vector dispatches; + vector frames; + vector commands; vector animatedTextures; - vector boxes; - vector zones; + vector sprites; + vector spriteSequences; vector soundMap; vector soundDetails; - string script; - - TrLevel(string filename); - ~TrLevel(); - bool Load(); + vector samples; + vector items; + vector aiItems; + vector moveables; + vector statics; + vector boxes; + vector overlaps; + vector zones[5][2]; + vector sinks; + vector cameras; + vector soundSources; + vector flybyCameras; }; \ No newline at end of file diff --git a/TR5Main/TR5Main.vcxproj b/TR5Main/TR5Main.vcxproj index 6344f5cfb..93f55dee4 100644 --- a/TR5Main/TR5Main.vcxproj +++ b/TR5Main/TR5Main.vcxproj @@ -247,7 +247,6 @@ xcopy /Y "$(ProjectDir)Scripting\Scripts\*.lua" "$(TargetDir)\Scripts" - @@ -364,6 +363,8 @@ xcopy /Y "$(ProjectDir)Scripting\Scripts\*.lua" "$(TargetDir)\Scripts" + + @@ -572,7 +573,7 @@ xcopy /Y "$(ProjectDir)Scripting\Scripts\*.lua" "$(TargetDir)\Scripts" - + diff --git a/TR5Main/TR5Main.vcxproj.filters b/TR5Main/TR5Main.vcxproj.filters index e3cedacc0..c4da6d3e2 100644 --- a/TR5Main/TR5Main.vcxproj.filters +++ b/TR5Main/TR5Main.vcxproj.filters @@ -339,9 +339,6 @@ File di intestazione - - File di intestazione - File di intestazione @@ -741,6 +738,12 @@ File di intestazione + + File di intestazione + + + File di intestazione + @@ -1010,9 +1013,6 @@ File di origine - - File di origine - File di origine @@ -1355,6 +1355,9 @@ File di origine + + File di origine +