mirror of
https://github.com/AxioDL/PrimeWorldEditor.git
synced 2025-06-18 04:23:29 +00:00
commit
1fb554fa4c
@ -6,23 +6,7 @@
|
|||||||
|
|
||||||
const bool gkForceDisableCompression = false;
|
const bool gkForceDisableCompression = false;
|
||||||
|
|
||||||
CAreaCooker::CAreaCooker()
|
CAreaCooker::CAreaCooker() = default;
|
||||||
: mGeometrySecNum(-1)
|
|
||||||
, mSCLYSecNum(-1)
|
|
||||||
, mSCGNSecNum(-1)
|
|
||||||
, mCollisionSecNum(-1)
|
|
||||||
, mUnknownSecNum(-1)
|
|
||||||
, mLightsSecNum(-1)
|
|
||||||
, mVISISecNum(-1)
|
|
||||||
, mPATHSecNum(-1)
|
|
||||||
, mAROTSecNum(-1)
|
|
||||||
, mFFFFSecNum(-1)
|
|
||||||
, mPTLASecNum(-1)
|
|
||||||
, mEGMCSecNum(-1)
|
|
||||||
, mDepsSecNum(-1)
|
|
||||||
, mModulesSecNum(-1)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void CAreaCooker::DetermineSectionNumbersPrime()
|
void CAreaCooker::DetermineSectionNumbersPrime()
|
||||||
{
|
{
|
||||||
@ -49,8 +33,8 @@ void CAreaCooker::DetermineSectionNumbersPrime()
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (uint32 iMesh = 0; iMesh < mpArea->mWorldModels.size(); iMesh++)
|
for (const auto& worldModel : mpArea->mWorldModels)
|
||||||
GeometrySections += mpArea->mWorldModels[iMesh]->GetSurfaceCount();
|
GeometrySections += worldModel->GetSurfaceCount();
|
||||||
|
|
||||||
// Set section numbers
|
// Set section numbers
|
||||||
uint32 SecNum = GeometrySections;
|
uint32 SecNum = GeometrySections;
|
||||||
@ -83,13 +67,16 @@ void CAreaCooker::DetermineSectionNumbersCorruption()
|
|||||||
{
|
{
|
||||||
// Because we're copying these from the original file (because not all the numbers
|
// Because we're copying these from the original file (because not all the numbers
|
||||||
// are present in every file), we don't care about any of these except SCLY and SCGN.
|
// are present in every file), we don't care about any of these except SCLY and SCGN.
|
||||||
for (uint32 iNum = 0; iNum < mpArea->mSectionNumbers.size(); iNum++)
|
for (const auto& num : mpArea->mSectionNumbers)
|
||||||
{
|
{
|
||||||
CGameArea::SSectionNumber& rNum = mpArea->mSectionNumbers[iNum];
|
if (num.SectionID == "SOBJ")
|
||||||
if (rNum.SectionID == "SOBJ") mSCLYSecNum = rNum.Index;
|
mSCLYSecNum = num.Index;
|
||||||
else if (rNum.SectionID == "SGEN") mSCGNSecNum = rNum.Index;
|
else if (num.SectionID == "SGEN")
|
||||||
else if (rNum.SectionID == "DEPS") mDepsSecNum = rNum.Index;
|
mSCGNSecNum = num.Index;
|
||||||
else if (rNum.SectionID == "RSOS") mModulesSecNum = rNum.Index;
|
else if (num.SectionID == "DEPS")
|
||||||
|
mDepsSecNum = num.Index;
|
||||||
|
else if (num.SectionID == "RSOS")
|
||||||
|
mModulesSecNum = num.Index;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -126,8 +113,8 @@ void CAreaCooker::WritePrimeHeader(IOutputStream& rOut)
|
|||||||
rOut.WriteToBoundary(32, 0);
|
rOut.WriteToBoundary(32, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (uint32 iSec = 0; iSec < mSectionSizes.size(); iSec++)
|
for (const uint32 size : mSectionSizes)
|
||||||
rOut.WriteLong(mSectionSizes[iSec]);
|
rOut.WriteLong(size);
|
||||||
rOut.WriteToBoundary(32, 0);
|
rOut.WriteToBoundary(32, 0);
|
||||||
|
|
||||||
if (mVersion >= EGame::Echoes)
|
if (mVersion >= EGame::Echoes)
|
||||||
@ -146,33 +133,31 @@ void CAreaCooker::WriteCorruptionHeader(IOutputStream& rOut)
|
|||||||
rOut.WriteLong(mpArea->mSectionNumbers.size());
|
rOut.WriteLong(mpArea->mSectionNumbers.size());
|
||||||
rOut.WriteToBoundary(32, 0);
|
rOut.WriteToBoundary(32, 0);
|
||||||
|
|
||||||
for (uint32 iSec = 0; iSec < mSectionSizes.size(); iSec++)
|
for (const uint32 size : mSectionSizes)
|
||||||
rOut.WriteLong(mSectionSizes[iSec]);
|
rOut.WriteLong(size);
|
||||||
|
|
||||||
rOut.WriteToBoundary(32, 0);
|
rOut.WriteToBoundary(32, 0);
|
||||||
|
|
||||||
WriteCompressionHeader(rOut);
|
WriteCompressionHeader(rOut);
|
||||||
|
|
||||||
for (uint32 iNum = 0; iNum < mpArea->mSectionNumbers.size(); iNum++)
|
for (const auto& num : mpArea->mSectionNumbers)
|
||||||
{
|
{
|
||||||
CGameArea::SSectionNumber& rNum = mpArea->mSectionNumbers[iNum];
|
rOut.WriteLong(num.SectionID.ToLong());
|
||||||
rOut.WriteLong(rNum.SectionID.ToLong());
|
rOut.WriteLong(num.Index);
|
||||||
rOut.WriteLong(rNum.Index);
|
|
||||||
}
|
}
|
||||||
rOut.WriteToBoundary(32, 0);
|
rOut.WriteToBoundary(32, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CAreaCooker::WriteCompressionHeader(IOutputStream& rOut)
|
void CAreaCooker::WriteCompressionHeader(IOutputStream& rOut)
|
||||||
{
|
{
|
||||||
for (uint32 iCmp = 0; iCmp < mCompressedBlocks.size(); iCmp++)
|
for (const auto& block : mCompressedBlocks)
|
||||||
{
|
{
|
||||||
SCompressedBlock& rBlock = mCompressedBlocks[iCmp];
|
const bool IsCompressed = block.CompressedSize != 0;
|
||||||
bool IsCompressed = (rBlock.CompressedSize != 0);
|
|
||||||
|
|
||||||
rOut.WriteLong(IsCompressed ? rBlock.DecompressedSize + 0x120 : rBlock.DecompressedSize);
|
rOut.WriteLong(IsCompressed ? block.DecompressedSize + 0x120 : block.DecompressedSize);
|
||||||
rOut.WriteLong(rBlock.DecompressedSize);
|
rOut.WriteLong(block.DecompressedSize);
|
||||||
rOut.WriteLong(rBlock.CompressedSize);
|
rOut.WriteLong(block.CompressedSize);
|
||||||
rOut.WriteLong(rBlock.NumSections);
|
rOut.WriteLong(block.NumSections);
|
||||||
}
|
}
|
||||||
|
|
||||||
rOut.WriteToBoundary(32, 0);
|
rOut.WriteToBoundary(32, 0);
|
||||||
@ -271,18 +256,17 @@ void CAreaCooker::WriteDependencies(IOutputStream& rOut)
|
|||||||
// Write
|
// Write
|
||||||
rOut.WriteLong(Dependencies.size());
|
rOut.WriteLong(Dependencies.size());
|
||||||
|
|
||||||
for (auto Iter = Dependencies.begin(); Iter != Dependencies.end(); Iter++)
|
for (const auto& dependency : Dependencies)
|
||||||
{
|
{
|
||||||
CAssetID ID = *Iter;
|
CResourceEntry *pEntry = gpResourceStore->FindEntry(dependency);
|
||||||
CResourceEntry *pEntry = gpResourceStore->FindEntry(ID);
|
dependency.Write(rOut);
|
||||||
ID.Write(rOut);
|
|
||||||
pEntry->CookedExtension().Write(rOut);
|
pEntry->CookedExtension().Write(rOut);
|
||||||
}
|
}
|
||||||
|
|
||||||
rOut.WriteLong(LayerOffsets.size());
|
rOut.WriteLong(LayerOffsets.size());
|
||||||
|
|
||||||
for (auto Iter = LayerOffsets.begin(); Iter != LayerOffsets.end(); Iter++)
|
for (const uint32 offset : LayerOffsets)
|
||||||
rOut.WriteLong(*Iter);
|
rOut.WriteLong(offset);
|
||||||
|
|
||||||
FinishSection(false);
|
FinishSection(false);
|
||||||
}
|
}
|
||||||
@ -299,13 +283,13 @@ void CAreaCooker::WriteModules(IOutputStream& rOut)
|
|||||||
// Write
|
// Write
|
||||||
rOut.WriteLong(ModuleNames.size());
|
rOut.WriteLong(ModuleNames.size());
|
||||||
|
|
||||||
for (uint32 ModuleIdx = 0; ModuleIdx < ModuleNames.size(); ModuleIdx++)
|
for (const auto& name : ModuleNames)
|
||||||
rOut.WriteString( ModuleNames[ModuleIdx] );
|
rOut.WriteString(name);
|
||||||
|
|
||||||
rOut.WriteLong(LayerOffsets.size());
|
rOut.WriteLong(LayerOffsets.size());
|
||||||
|
|
||||||
for (uint32 OffsetIdx = 0; OffsetIdx < LayerOffsets.size(); OffsetIdx++)
|
for (const uint32 offset : LayerOffsets)
|
||||||
rOut.WriteLong(LayerOffsets[OffsetIdx]);
|
rOut.WriteLong(offset);
|
||||||
|
|
||||||
FinishSection(false);
|
FinishSection(false);
|
||||||
}
|
}
|
||||||
|
@ -9,33 +9,30 @@
|
|||||||
class CAreaCooker
|
class CAreaCooker
|
||||||
{
|
{
|
||||||
TResPtr<CGameArea> mpArea;
|
TResPtr<CGameArea> mpArea;
|
||||||
EGame mVersion;
|
EGame mVersion{};
|
||||||
|
|
||||||
std::vector<uint32> mSectionSizes;
|
std::vector<uint32> mSectionSizes;
|
||||||
|
|
||||||
uint32 mGeometrySecNum;
|
uint32 mGeometrySecNum = UINT32_MAX;
|
||||||
uint32 mSCLYSecNum;
|
uint32 mSCLYSecNum = UINT32_MAX;
|
||||||
uint32 mSCGNSecNum;
|
uint32 mSCGNSecNum = UINT32_MAX;
|
||||||
uint32 mCollisionSecNum;
|
uint32 mCollisionSecNum = UINT32_MAX;
|
||||||
uint32 mUnknownSecNum;
|
uint32 mUnknownSecNum = UINT32_MAX;
|
||||||
uint32 mLightsSecNum;
|
uint32 mLightsSecNum = UINT32_MAX;
|
||||||
uint32 mVISISecNum;
|
uint32 mVISISecNum = UINT32_MAX;
|
||||||
uint32 mPATHSecNum;
|
uint32 mPATHSecNum = UINT32_MAX;
|
||||||
uint32 mAROTSecNum;
|
uint32 mAROTSecNum = UINT32_MAX;
|
||||||
uint32 mFFFFSecNum;
|
uint32 mFFFFSecNum = UINT32_MAX;
|
||||||
uint32 mPTLASecNum;
|
uint32 mPTLASecNum = UINT32_MAX;
|
||||||
uint32 mEGMCSecNum;
|
uint32 mEGMCSecNum = UINT32_MAX;
|
||||||
uint32 mDepsSecNum;
|
uint32 mDepsSecNum = UINT32_MAX;
|
||||||
uint32 mModulesSecNum;
|
uint32 mModulesSecNum = UINT32_MAX;
|
||||||
|
|
||||||
struct SCompressedBlock
|
struct SCompressedBlock
|
||||||
{
|
{
|
||||||
uint32 CompressedSize;
|
uint32 CompressedSize = 0;
|
||||||
uint32 DecompressedSize;
|
uint32 DecompressedSize = 0;
|
||||||
uint32 NumSections;
|
uint32 NumSections = 0;
|
||||||
|
|
||||||
SCompressedBlock()
|
|
||||||
: CompressedSize(0), DecompressedSize(0), NumSections(0) {}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
SCompressedBlock mCurBlock;
|
SCompressedBlock mCurBlock;
|
||||||
|
@ -2,13 +2,8 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <list>
|
#include <list>
|
||||||
|
|
||||||
CBasicModel::CBasicModel(CResourceEntry *pEntry /*= 0*/)
|
CBasicModel::CBasicModel(CResourceEntry *pEntry)
|
||||||
: CResource(pEntry)
|
: CResource(pEntry)
|
||||||
, mVertexCount(0)
|
|
||||||
, mTriangleCount(0)
|
|
||||||
, mBuffered(false)
|
|
||||||
, mHasOwnMaterials(false)
|
|
||||||
, mHasOwnSurfaces(false)
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -19,32 +14,32 @@ CBasicModel::~CBasicModel()
|
|||||||
delete mSurfaces[iSurf];
|
delete mSurfaces[iSurf];
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32 CBasicModel::GetVertexCount()
|
uint32 CBasicModel::GetVertexCount() const
|
||||||
{
|
{
|
||||||
return mVertexCount;
|
return mVertexCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32 CBasicModel::GetTriangleCount()
|
uint32 CBasicModel::GetTriangleCount() const
|
||||||
{
|
{
|
||||||
return mTriangleCount;
|
return mTriangleCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
CAABox CBasicModel::AABox()
|
CAABox CBasicModel::AABox() const
|
||||||
{
|
{
|
||||||
return mAABox;
|
return mAABox;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CBasicModel::IsBuffered()
|
bool CBasicModel::IsBuffered() const
|
||||||
{
|
{
|
||||||
return mBuffered;
|
return mBuffered;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32 CBasicModel::GetSurfaceCount()
|
uint32 CBasicModel::GetSurfaceCount() const
|
||||||
{
|
{
|
||||||
return mSurfaces.size();
|
return mSurfaces.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
CAABox CBasicModel::GetSurfaceAABox(uint32 Surface)
|
CAABox CBasicModel::GetSurfaceAABox(uint32 Surface) const
|
||||||
{
|
{
|
||||||
return mSurfaces[Surface]->AABox;
|
return mSurfaces[Surface]->AABox;
|
||||||
}
|
}
|
||||||
|
@ -11,25 +11,25 @@ class CBasicModel : public CResource
|
|||||||
DECLARE_RESOURCE_TYPE(Model)
|
DECLARE_RESOURCE_TYPE(Model)
|
||||||
protected:
|
protected:
|
||||||
CAABox mAABox;
|
CAABox mAABox;
|
||||||
uint32 mVertexCount;
|
uint32 mVertexCount = 0;
|
||||||
uint32 mTriangleCount;
|
uint32 mTriangleCount = 0;
|
||||||
bool mBuffered;
|
bool mBuffered = false;
|
||||||
bool mHasOwnMaterials;
|
bool mHasOwnMaterials = false;
|
||||||
bool mHasOwnSurfaces;
|
bool mHasOwnSurfaces = false;
|
||||||
|
|
||||||
CVertexBuffer mVBO;
|
CVertexBuffer mVBO;
|
||||||
std::vector<SSurface*> mSurfaces;
|
std::vector<SSurface*> mSurfaces;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CBasicModel(CResourceEntry *pEntry = 0);
|
CBasicModel(CResourceEntry *pEntry = nullptr);
|
||||||
~CBasicModel();
|
~CBasicModel();
|
||||||
|
|
||||||
uint32 GetVertexCount();
|
uint32 GetVertexCount() const;
|
||||||
uint32 GetTriangleCount();
|
uint32 GetTriangleCount() const;
|
||||||
CAABox AABox();
|
CAABox AABox() const;
|
||||||
bool IsBuffered();
|
bool IsBuffered() const;
|
||||||
uint32 GetSurfaceCount();
|
uint32 GetSurfaceCount() const;
|
||||||
CAABox GetSurfaceAABox(uint32 Surface);
|
CAABox GetSurfaceAABox(uint32 Surface) const;
|
||||||
SSurface* GetSurface(uint32 Surface);
|
SSurface* GetSurface(uint32 Surface);
|
||||||
virtual void ClearGLBuffer() = 0;
|
virtual void ClearGLBuffer() = 0;
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user