mirror of
https://github.com/AxioDL/PrimeWorldEditor.git
synced 2025-12-17 08:57:09 +00:00
Mass code cleanup
This commit is contained in:
@@ -32,8 +32,8 @@ void CAreaCooker::DetermineSectionNumbersPrime()
|
||||
break;
|
||||
}
|
||||
|
||||
for (u32 iMesh = 0; iMesh < mpArea->mTerrainModels.size(); iMesh++)
|
||||
GeometrySections += mpArea->mTerrainModels[iMesh]->GetSurfaceCount();
|
||||
for (u32 iMesh = 0; iMesh < mpArea->mWorldModels.size(); iMesh++)
|
||||
GeometrySections += mpArea->mWorldModels[iMesh]->GetSurfaceCount();
|
||||
|
||||
// Set section numbers
|
||||
u32 SecNum = GeometrySections;
|
||||
@@ -349,9 +349,9 @@ void CAreaCooker::WriteCookedArea(CGameArea *pArea, IOutputStream& rOut)
|
||||
Cooker.WriteAreaData(rOut);
|
||||
}
|
||||
|
||||
u32 CAreaCooker::GetMREAVersion(EGame version)
|
||||
u32 CAreaCooker::GetMREAVersion(EGame Version)
|
||||
{
|
||||
switch (version)
|
||||
switch (Version)
|
||||
{
|
||||
case ePrimeDemo: return 0xC;
|
||||
case ePrime: return 0xF;
|
||||
|
||||
@@ -64,7 +64,7 @@ class CAreaCooker
|
||||
|
||||
public:
|
||||
static void WriteCookedArea(CGameArea *pArea, IOutputStream& rOut);
|
||||
static u32 GetMREAVersion(EGame version);
|
||||
static u32 GetMREAVersion(EGame Version);
|
||||
};
|
||||
|
||||
#endif // CAREACOOKER_H
|
||||
|
||||
@@ -2,11 +2,11 @@
|
||||
#include <algorithm>
|
||||
|
||||
CMaterialCooker::CMaterialCooker()
|
||||
: mpMat(nullptr)
|
||||
{
|
||||
mpMat = nullptr;
|
||||
}
|
||||
|
||||
void CMaterialCooker::WriteMatSetPrime(IOutputStream& Out)
|
||||
void CMaterialCooker::WriteMatSetPrime(IOutputStream& rOut)
|
||||
{
|
||||
// Gather texture list from the materials before starting
|
||||
mTextureIDs.clear();
|
||||
@@ -30,47 +30,46 @@ void CMaterialCooker::WriteMatSetPrime(IOutputStream& Out)
|
||||
mTextureIDs.erase(std::unique(mTextureIDs.begin(), mTextureIDs.end()), mTextureIDs.end());
|
||||
|
||||
// Write texture IDs
|
||||
Out.WriteLong(mTextureIDs.size());
|
||||
rOut.WriteLong(mTextureIDs.size());
|
||||
|
||||
for (u32 iTex = 0; iTex < mTextureIDs.size(); iTex++)
|
||||
Out.WriteLong(mTextureIDs[iTex]);
|
||||
rOut.WriteLong(mTextureIDs[iTex]);
|
||||
|
||||
// Write material offset filler
|
||||
Out.WriteLong(NumMats);
|
||||
u32 MatOffsetsStart = Out.Tell();
|
||||
rOut.WriteLong(NumMats);
|
||||
u32 MatOffsetsStart = rOut.Tell();
|
||||
|
||||
for (u32 iMat = 0; iMat < NumMats; iMat++)
|
||||
Out.WriteLong(0);
|
||||
rOut.WriteLong(0);
|
||||
|
||||
// Write materials
|
||||
u32 MatsStart = Out.Tell();
|
||||
u32 MatsStart = rOut.Tell();
|
||||
std::vector<u32> MatEndOffsets(NumMats);
|
||||
|
||||
for (u32 iMat = 0; iMat < NumMats; iMat++)
|
||||
{
|
||||
mpMat = mpSet->mMaterials[iMat];
|
||||
WriteMaterialPrime(Out);
|
||||
MatEndOffsets[iMat] = Out.Tell() - MatsStart;
|
||||
WriteMaterialPrime(rOut);
|
||||
MatEndOffsets[iMat] = rOut.Tell() - MatsStart;
|
||||
}
|
||||
|
||||
// Write material offsets
|
||||
u32 MatsEnd = Out.Tell();
|
||||
Out.Seek(MatOffsetsStart, SEEK_SET);
|
||||
u32 MatsEnd = rOut.Tell();
|
||||
rOut.Seek(MatOffsetsStart, SEEK_SET);
|
||||
|
||||
for (u32 iMat = 0; iMat < NumMats; iMat++)
|
||||
Out.WriteLong(MatEndOffsets[iMat]);
|
||||
rOut.WriteLong(MatEndOffsets[iMat]);
|
||||
|
||||
// Done!
|
||||
Out.Seek(MatsEnd, SEEK_SET);
|
||||
rOut.Seek(MatsEnd, SEEK_SET);
|
||||
}
|
||||
|
||||
void CMaterialCooker::WriteMatSetCorruption(IOutputStream&)
|
||||
void CMaterialCooker::WriteMatSetCorruption(IOutputStream& /*rOut*/)
|
||||
{
|
||||
// Not using parameter 1 (IOutputStream& - Out)
|
||||
// todo
|
||||
}
|
||||
|
||||
void CMaterialCooker::WriteMaterialPrime(IOutputStream& Out)
|
||||
void CMaterialCooker::WriteMaterialPrime(IOutputStream& rOut)
|
||||
{
|
||||
// Gather data from the passes before we start writing
|
||||
u32 TexFlags = 0;
|
||||
@@ -143,12 +142,12 @@ void CMaterialCooker::WriteMaterialPrime(IOutputStream& Out)
|
||||
|
||||
Flags |= (HasKonst ? 0x8 : 0x0) | (mpMat->Options() & ~0x8) | (TexFlags << 16);
|
||||
|
||||
Out.WriteLong(Flags);
|
||||
rOut.WriteLong(Flags);
|
||||
|
||||
// Texture indices
|
||||
Out.WriteLong(TexIndices.size());
|
||||
rOut.WriteLong(TexIndices.size());
|
||||
for (u32 iTex = 0; iTex < TexIndices.size(); iTex++)
|
||||
Out.WriteLong(TexIndices[iTex]);
|
||||
rOut.WriteLong(TexIndices[iTex]);
|
||||
|
||||
// Vertex description
|
||||
FVertexDescription Desc = mpMat->VtxDesc();
|
||||
@@ -156,24 +155,24 @@ void CMaterialCooker::WriteMaterialPrime(IOutputStream& Out)
|
||||
if (mVersion < eEchoes)
|
||||
Desc &= 0x00FFFFFF;
|
||||
|
||||
Out.WriteLong(Desc);
|
||||
rOut.WriteLong(Desc);
|
||||
|
||||
// Echoes unknowns
|
||||
if (mVersion == eEchoes)
|
||||
{
|
||||
Out.WriteLong(mpMat->EchoesUnknownA());
|
||||
Out.WriteLong(mpMat->EchoesUnknownB());
|
||||
rOut.WriteLong(mpMat->EchoesUnknownA());
|
||||
rOut.WriteLong(mpMat->EchoesUnknownB());
|
||||
}
|
||||
|
||||
// Group index
|
||||
Out.WriteLong(GroupIndex);
|
||||
rOut.WriteLong(GroupIndex);
|
||||
|
||||
// Konst
|
||||
if (HasKonst)
|
||||
{
|
||||
Out.WriteLong(NumKonst);
|
||||
rOut.WriteLong(NumKonst);
|
||||
for (u32 iKonst = 0; iKonst < NumKonst; iKonst++)
|
||||
Out.WriteLong( mpMat->Konst(iKonst).ToLongRGBA() );
|
||||
rOut.WriteLong( mpMat->Konst(iKonst).ToLongRGBA() );
|
||||
}
|
||||
|
||||
// Blend Mode
|
||||
@@ -182,16 +181,16 @@ void CMaterialCooker::WriteMaterialPrime(IOutputStream& Out)
|
||||
u16 BlendDstFac = (u16) mpMat->BlendDstFac();
|
||||
if (BlendSrcFac >= 0x300) BlendSrcFac -= 0x2FE;
|
||||
if (BlendDstFac >= 0x300) BlendDstFac -= 0x2FE;
|
||||
Out.WriteShort(BlendDstFac);
|
||||
Out.WriteShort(BlendSrcFac);
|
||||
rOut.WriteShort(BlendDstFac);
|
||||
rOut.WriteShort(BlendSrcFac);
|
||||
|
||||
// Color Channels
|
||||
Out.WriteLong(1);
|
||||
Out.WriteLong(0x3000 | (mpMat->IsLightingEnabled() ? 1 : 0));
|
||||
rOut.WriteLong(1);
|
||||
rOut.WriteLong(0x3000 | (mpMat->IsLightingEnabled() ? 1 : 0));
|
||||
|
||||
// TEV
|
||||
u32 NumPasses = mpMat->PassCount();
|
||||
Out.WriteLong(NumPasses);
|
||||
rOut.WriteLong(NumPasses);
|
||||
|
||||
for (u32 iPass = 0; iPass < NumPasses; iPass++)
|
||||
{
|
||||
@@ -209,14 +208,14 @@ void CMaterialCooker::WriteMaterialPrime(IOutputStream& Out)
|
||||
u32 ColorOpFlags = 0x100 | (pPass->ColorOutput() << 9);
|
||||
u32 AlphaOpFlags = 0x100 | (pPass->AlphaOutput() << 9);
|
||||
|
||||
Out.WriteLong(ColorInputFlags);
|
||||
Out.WriteLong(AlphaInputFlags);
|
||||
Out.WriteLong(ColorOpFlags);
|
||||
Out.WriteLong(AlphaOpFlags);
|
||||
Out.WriteByte(0); // Padding
|
||||
Out.WriteByte(pPass->KAlphaSel());
|
||||
Out.WriteByte(pPass->KColorSel());
|
||||
Out.WriteByte(pPass->RasSel());
|
||||
rOut.WriteLong(ColorInputFlags);
|
||||
rOut.WriteLong(AlphaInputFlags);
|
||||
rOut.WriteLong(ColorOpFlags);
|
||||
rOut.WriteLong(AlphaOpFlags);
|
||||
rOut.WriteByte(0); // Padding
|
||||
rOut.WriteByte(pPass->KAlphaSel());
|
||||
rOut.WriteByte(pPass->KColorSel());
|
||||
rOut.WriteByte(pPass->RasSel());
|
||||
}
|
||||
|
||||
// TEV Tex/UV input selection
|
||||
@@ -224,22 +223,22 @@ void CMaterialCooker::WriteMaterialPrime(IOutputStream& Out)
|
||||
|
||||
for (u32 iPass = 0; iPass < NumPasses; iPass++)
|
||||
{
|
||||
Out.WriteShort(0); // Padding
|
||||
rOut.WriteShort(0); // Padding
|
||||
|
||||
if (mpMat->Pass(iPass)->Texture())
|
||||
{
|
||||
Out.WriteByte((u8) CurTexIdx);
|
||||
Out.WriteByte((u8) CurTexIdx);
|
||||
rOut.WriteByte((u8) CurTexIdx);
|
||||
rOut.WriteByte((u8) CurTexIdx);
|
||||
CurTexIdx++;
|
||||
}
|
||||
|
||||
else
|
||||
Out.WriteShort((u16) 0xFFFF);
|
||||
rOut.WriteShort((u16) 0xFFFF);
|
||||
}
|
||||
|
||||
// TexGen
|
||||
u32 NumTexCoords = CurTexIdx; // TexIdx is currently equal to the tex coord count
|
||||
Out.WriteLong(NumTexCoords);
|
||||
rOut.WriteLong(NumTexCoords);
|
||||
u32 CurTexMtx = 0;
|
||||
|
||||
for (u32 iPass = 0; iPass < NumPasses; iPass++)
|
||||
@@ -280,15 +279,15 @@ void CMaterialCooker::WriteMaterialPrime(IOutputStream& Out)
|
||||
}
|
||||
|
||||
u32 TexGenFlags = (CoordSource << 4) | (TexMtxIdx << 9) | (Normalize << 14) | (PostMtxIdx << 15);
|
||||
Out.WriteLong(TexGenFlags);
|
||||
rOut.WriteLong(TexGenFlags);
|
||||
}
|
||||
|
||||
// Animations
|
||||
u32 AnimSizeOffset = Out.Tell();
|
||||
u32 AnimSizeOffset = rOut.Tell();
|
||||
u32 NumAnims = CurTexMtx; // CurTexMtx is currently equal to the anim count
|
||||
Out.WriteLong(0); // Anim size filler
|
||||
u32 AnimsStart = Out.Tell();
|
||||
Out.WriteLong(NumAnims);
|
||||
rOut.WriteLong(0); // Anim size filler
|
||||
u32 AnimsStart = rOut.Tell();
|
||||
rOut.WriteLong(NumAnims);
|
||||
|
||||
for (u32 iPass = 0; iPass < NumPasses; iPass++)
|
||||
{
|
||||
@@ -296,38 +295,37 @@ void CMaterialCooker::WriteMaterialPrime(IOutputStream& Out)
|
||||
u32 AnimMode = pPass->AnimMode();
|
||||
if (AnimMode == eNoUVAnim) continue;
|
||||
|
||||
Out.WriteLong(AnimMode);
|
||||
rOut.WriteLong(AnimMode);
|
||||
|
||||
if ((AnimMode > 1) && (AnimMode != 6))
|
||||
{
|
||||
Out.WriteFloat(pPass->AnimParam(0));
|
||||
Out.WriteFloat(pPass->AnimParam(1));
|
||||
rOut.WriteFloat(pPass->AnimParam(0));
|
||||
rOut.WriteFloat(pPass->AnimParam(1));
|
||||
|
||||
if ((AnimMode == 2) || (AnimMode == 4) || (AnimMode == 5))
|
||||
{
|
||||
Out.WriteFloat(pPass->AnimParam(2));
|
||||
Out.WriteFloat(pPass->AnimParam(3));
|
||||
rOut.WriteFloat(pPass->AnimParam(2));
|
||||
rOut.WriteFloat(pPass->AnimParam(3));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
u32 AnimsEnd = Out.Tell();
|
||||
u32 AnimsEnd = rOut.Tell();
|
||||
u32 AnimsSize = AnimsEnd - AnimsStart;
|
||||
Out.Seek(AnimSizeOffset, SEEK_SET);
|
||||
Out.WriteLong(AnimsSize);
|
||||
Out.Seek(AnimsEnd, SEEK_SET);
|
||||
rOut.Seek(AnimSizeOffset, SEEK_SET);
|
||||
rOut.WriteLong(AnimsSize);
|
||||
rOut.Seek(AnimsEnd, SEEK_SET);
|
||||
|
||||
// Done!
|
||||
}
|
||||
|
||||
void CMaterialCooker::WriteMaterialCorruption(IOutputStream&)
|
||||
void CMaterialCooker::WriteMaterialCorruption(IOutputStream& /*rOut*/)
|
||||
{
|
||||
// Not using parameter 1 (IOutputStream& - Out)
|
||||
// todo
|
||||
}
|
||||
|
||||
// ************ STATIC ************
|
||||
void CMaterialCooker::WriteCookedMatSet(CMaterialSet *pSet, EGame Version, IOutputStream &Out)
|
||||
void CMaterialCooker::WriteCookedMatSet(CMaterialSet *pSet, EGame Version, IOutputStream& rOut)
|
||||
{
|
||||
CMaterialCooker Cooker;
|
||||
Cooker.mpSet = pSet;
|
||||
@@ -339,12 +337,12 @@ void CMaterialCooker::WriteCookedMatSet(CMaterialSet *pSet, EGame Version, IOutp
|
||||
case ePrime:
|
||||
case eEchoesDemo:
|
||||
case eEchoes:
|
||||
Cooker.WriteMatSetPrime(Out);
|
||||
Cooker.WriteMatSetPrime(rOut);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void CMaterialCooker::WriteCookedMaterial(CMaterial *pMat, EGame Version, IOutputStream &Out)
|
||||
void CMaterialCooker::WriteCookedMaterial(CMaterial *pMat, EGame Version, IOutputStream& rOut)
|
||||
{
|
||||
CMaterialCooker Cooker;
|
||||
Cooker.mpMat = pMat;
|
||||
@@ -356,7 +354,7 @@ void CMaterialCooker::WriteCookedMaterial(CMaterial *pMat, EGame Version, IOutpu
|
||||
case ePrime:
|
||||
case eEchoesDemo:
|
||||
case eEchoes:
|
||||
Cooker.WriteMaterialPrime(Out);
|
||||
Cooker.WriteMaterialPrime(rOut);
|
||||
break;
|
||||
// TODO: Corruption/Uncooked
|
||||
}
|
||||
|
||||
@@ -14,14 +14,14 @@ class CMaterialCooker
|
||||
std::vector<u64> mMaterialHashes;
|
||||
|
||||
CMaterialCooker();
|
||||
void WriteMatSetPrime(IOutputStream& Out);
|
||||
void WriteMatSetCorruption(IOutputStream& Out);
|
||||
void WriteMaterialPrime(IOutputStream& Out);
|
||||
void WriteMaterialCorruption(IOutputStream& Out);
|
||||
void WriteMatSetPrime(IOutputStream& rOut);
|
||||
void WriteMatSetCorruption(IOutputStream& rOut);
|
||||
void WriteMaterialPrime(IOutputStream& rOut);
|
||||
void WriteMaterialCorruption(IOutputStream& rOut);
|
||||
|
||||
public:
|
||||
static void WriteCookedMatSet(CMaterialSet *pSet, EGame Version, IOutputStream& Out);
|
||||
static void WriteCookedMaterial(CMaterial *pMat, EGame Version, IOutputStream& Out);
|
||||
static void WriteCookedMatSet(CMaterialSet *pSet, EGame Version, IOutputStream& rOut);
|
||||
static void WriteCookedMaterial(CMaterial *pMat, EGame Version, IOutputStream& rOut);
|
||||
};
|
||||
|
||||
#endif // CMATERIALCOOKER_H
|
||||
|
||||
@@ -9,14 +9,6 @@ CModelCooker::CModelCooker()
|
||||
{
|
||||
}
|
||||
|
||||
bool SortVertsByArrayPos(const CVertex& A, const CVertex& B) {
|
||||
return (A.ArrayPosition < B.ArrayPosition);
|
||||
}
|
||||
|
||||
bool CheckDuplicateVertsByArrayPos(const CVertex& A, const CVertex& B) {
|
||||
return (A.ArrayPosition == B.ArrayPosition);
|
||||
}
|
||||
|
||||
void CModelCooker::GenerateSurfaceData()
|
||||
{
|
||||
// Need to gather metadata from the model before we can start
|
||||
@@ -60,65 +52,65 @@ void CModelCooker::GenerateSurfaceData()
|
||||
mNumVertices = mVertices.size();
|
||||
}
|
||||
|
||||
void CModelCooker::WriteEditorModel(IOutputStream& /*Out*/)
|
||||
void CModelCooker::WriteEditorModel(IOutputStream& /*rOut*/)
|
||||
{
|
||||
}
|
||||
|
||||
void CModelCooker::WriteModelPrime(IOutputStream& Out)
|
||||
void CModelCooker::WriteModelPrime(IOutputStream& rOut)
|
||||
{
|
||||
GenerateSurfaceData();
|
||||
|
||||
// Header
|
||||
Out.WriteLong(0xDEADBABE);
|
||||
Out.WriteLong(GetCMDLVersion(mVersion));
|
||||
Out.WriteLong(5);
|
||||
mpModel->mAABox.Write(Out);
|
||||
rOut.WriteLong(0xDEADBABE);
|
||||
rOut.WriteLong(GetCMDLVersion(mVersion));
|
||||
rOut.WriteLong(5);
|
||||
mpModel->mAABox.Write(rOut);
|
||||
|
||||
u32 NumSections = mNumMatSets + mNumSurfaces + 6;
|
||||
Out.WriteLong(NumSections);
|
||||
Out.WriteLong(mNumMatSets);
|
||||
rOut.WriteLong(NumSections);
|
||||
rOut.WriteLong(mNumMatSets);
|
||||
|
||||
u32 SectionSizesOffset = Out.Tell();
|
||||
u32 SectionSizesOffset = rOut.Tell();
|
||||
for (u32 iSec = 0; iSec < NumSections; iSec++)
|
||||
Out.WriteLong(0);
|
||||
rOut.WriteLong(0);
|
||||
|
||||
Out.WriteToBoundary(32, 0);
|
||||
rOut.WriteToBoundary(32, 0);
|
||||
|
||||
std::vector<u32> SectionSizes;
|
||||
SectionSizes.reserve(NumSections);
|
||||
|
||||
CSectionMgrOut SectionMgr;
|
||||
SectionMgr.SetSectionCount(NumSections);
|
||||
SectionMgr.Init(Out);
|
||||
SectionMgr.Init(rOut);
|
||||
|
||||
// Materials
|
||||
for (u32 iSet = 0; iSet < mNumMatSets; iSet++)
|
||||
{
|
||||
CMaterialCooker::WriteCookedMatSet(mpModel->mMaterialSets[iSet], mVersion, Out);
|
||||
Out.WriteToBoundary(32, 0);
|
||||
SectionMgr.AddSize(Out);
|
||||
CMaterialCooker::WriteCookedMatSet(mpModel->mMaterialSets[iSet], mVersion, rOut);
|
||||
rOut.WriteToBoundary(32, 0);
|
||||
SectionMgr.AddSize(rOut);
|
||||
}
|
||||
|
||||
// Vertices
|
||||
for (u32 iPos = 0; iPos < mNumVertices; iPos++)
|
||||
mVertices[iPos].Position.Write(Out);
|
||||
mVertices[iPos].Position.Write(rOut);
|
||||
|
||||
Out.WriteToBoundary(32, 0);
|
||||
SectionMgr.AddSize(Out);
|
||||
rOut.WriteToBoundary(32, 0);
|
||||
SectionMgr.AddSize(rOut);
|
||||
|
||||
// Normals
|
||||
for (u32 iNrm = 0; iNrm < mNumVertices; iNrm++)
|
||||
mVertices[iNrm].Normal.Write(Out);
|
||||
mVertices[iNrm].Normal.Write(rOut);
|
||||
|
||||
Out.WriteToBoundary(32, 0);
|
||||
SectionMgr.AddSize(Out);
|
||||
rOut.WriteToBoundary(32, 0);
|
||||
SectionMgr.AddSize(rOut);
|
||||
|
||||
// Colors
|
||||
for (u32 iColor = 0; iColor < mNumVertices; iColor++)
|
||||
mVertices[iColor].Color[0].Write(Out);
|
||||
mVertices[iColor].Color[0].Write(rOut);
|
||||
|
||||
Out.WriteToBoundary(32, 0);
|
||||
SectionMgr.AddSize(Out);
|
||||
rOut.WriteToBoundary(32, 0);
|
||||
SectionMgr.AddSize(rOut);
|
||||
|
||||
// Float UV coordinates
|
||||
for (u32 iTexSlot = 0; iTexSlot < 8; iTexSlot++)
|
||||
@@ -127,50 +119,50 @@ void CModelCooker::WriteModelPrime(IOutputStream& Out)
|
||||
if (HasTexSlot)
|
||||
{
|
||||
for (u32 iTex = 0; iTex < mNumVertices; iTex++)
|
||||
mVertices[iTex].Tex[iTexSlot].Write(Out);
|
||||
mVertices[iTex].Tex[iTexSlot].Write(rOut);
|
||||
}
|
||||
}
|
||||
|
||||
Out.WriteToBoundary(32, 0);
|
||||
SectionMgr.AddSize(Out);
|
||||
SectionMgr.AddSize(Out); // Skipping short UV coordinates
|
||||
rOut.WriteToBoundary(32, 0);
|
||||
SectionMgr.AddSize(rOut);
|
||||
SectionMgr.AddSize(rOut); // Skipping short UV coordinates
|
||||
|
||||
// Surface offsets
|
||||
Out.WriteLong(mNumSurfaces);
|
||||
u32 SurfaceOffsetsStart = Out.Tell();
|
||||
rOut.WriteLong(mNumSurfaces);
|
||||
u32 SurfaceOffsetsStart = rOut.Tell();
|
||||
|
||||
for (u32 iSurf = 0; iSurf < mNumSurfaces; iSurf++)
|
||||
Out.WriteLong(0);
|
||||
rOut.WriteLong(0);
|
||||
|
||||
Out.WriteToBoundary(32, 0);
|
||||
SectionMgr.AddSize(Out);
|
||||
rOut.WriteToBoundary(32, 0);
|
||||
SectionMgr.AddSize(rOut);
|
||||
|
||||
// Surfaces
|
||||
u32 SurfacesStart = Out.Tell();
|
||||
u32 SurfacesStart = rOut.Tell();
|
||||
std::vector<u32> SurfaceEndOffsets(mNumSurfaces);
|
||||
|
||||
for (u32 iSurf = 0; iSurf < mNumSurfaces; iSurf++)
|
||||
{
|
||||
SSurface *pSurface = mpModel->GetSurface(iSurf);
|
||||
|
||||
pSurface->CenterPoint.Write(Out);
|
||||
Out.WriteLong(pSurface->MaterialID);
|
||||
Out.WriteShort((u16) 0x8000);
|
||||
u32 PrimTableSizeOffset = Out.Tell();
|
||||
Out.WriteShort(0);
|
||||
Out.WriteLongLong(0);
|
||||
Out.WriteLong(0);
|
||||
pSurface->ReflectionDirection.Write(Out);
|
||||
Out.WriteToBoundary(32, 0);
|
||||
pSurface->CenterPoint.Write(rOut);
|
||||
rOut.WriteLong(pSurface->MaterialID);
|
||||
rOut.WriteShort((u16) 0x8000);
|
||||
u32 PrimTableSizeOffset = rOut.Tell();
|
||||
rOut.WriteShort(0);
|
||||
rOut.WriteLongLong(0);
|
||||
rOut.WriteLong(0);
|
||||
pSurface->ReflectionDirection.Write(rOut);
|
||||
rOut.WriteToBoundary(32, 0);
|
||||
|
||||
u32 PrimTableStart = Out.Tell();
|
||||
u32 PrimTableStart = rOut.Tell();
|
||||
FVertexDescription MatAttribs = mpModel->GetMaterialBySurface(0, iSurf)->VtxDesc();
|
||||
|
||||
for (u32 iPrim = 0; iPrim < pSurface->Primitives.size(); iPrim++)
|
||||
{
|
||||
SSurface::SPrimitive *pPrimitive = &pSurface->Primitives[iPrim];
|
||||
Out.WriteByte((u8) pPrimitive->Type);
|
||||
Out.WriteShort((u16) pPrimitive->Vertices.size());
|
||||
rOut.WriteByte((u8) pPrimitive->Type);
|
||||
rOut.WriteShort((u16) pPrimitive->Vertices.size());
|
||||
|
||||
for (u32 iVert = 0; iVert < pPrimitive->Vertices.size(); iVert++)
|
||||
{
|
||||
@@ -180,59 +172,59 @@ void CModelCooker::WriteModelPrime(IOutputStream& Out)
|
||||
{
|
||||
for (u32 iMtxAttribs = 0; iMtxAttribs < 8; iMtxAttribs++)
|
||||
if (MatAttribs & (ePosMtx << iMtxAttribs))
|
||||
Out.WriteByte(pVert->MatrixIndices[iMtxAttribs]);
|
||||
rOut.WriteByte(pVert->MatrixIndices[iMtxAttribs]);
|
||||
}
|
||||
|
||||
u16 VertexIndex = (u16) pVert->ArrayPosition;
|
||||
|
||||
if (MatAttribs & ePosition)
|
||||
Out.WriteShort(VertexIndex);
|
||||
rOut.WriteShort(VertexIndex);
|
||||
|
||||
if (MatAttribs & eNormal)
|
||||
Out.WriteShort(VertexIndex);
|
||||
rOut.WriteShort(VertexIndex);
|
||||
|
||||
if (MatAttribs & eColor0)
|
||||
Out.WriteShort(VertexIndex);
|
||||
rOut.WriteShort(VertexIndex);
|
||||
|
||||
if (MatAttribs & eColor1)
|
||||
Out.WriteShort(VertexIndex);
|
||||
rOut.WriteShort(VertexIndex);
|
||||
|
||||
u16 TexOffset = 0;
|
||||
for (u32 iTex = 0; iTex < 8; iTex++)
|
||||
{
|
||||
if (MatAttribs & (eTex0 << (iTex * 2)))
|
||||
{
|
||||
Out.WriteShort(VertexIndex + TexOffset);
|
||||
rOut.WriteShort(VertexIndex + TexOffset);
|
||||
TexOffset += (u16) mNumVertices;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Out.WriteToBoundary(32, 0);
|
||||
u32 PrimTableEnd = Out.Tell();
|
||||
rOut.WriteToBoundary(32, 0);
|
||||
u32 PrimTableEnd = rOut.Tell();
|
||||
u32 PrimTableSize = PrimTableEnd - PrimTableStart;
|
||||
Out.Seek(PrimTableSizeOffset, SEEK_SET);
|
||||
Out.WriteShort((u16) PrimTableSize);
|
||||
Out.Seek(PrimTableEnd, SEEK_SET);
|
||||
rOut.Seek(PrimTableSizeOffset, SEEK_SET);
|
||||
rOut.WriteShort((u16) PrimTableSize);
|
||||
rOut.Seek(PrimTableEnd, SEEK_SET);
|
||||
|
||||
SectionMgr.AddSize(Out);
|
||||
SurfaceEndOffsets[iSurf] = Out.Tell() - SurfacesStart;
|
||||
SectionMgr.AddSize(rOut);
|
||||
SurfaceEndOffsets[iSurf] = rOut.Tell() - SurfacesStart;
|
||||
}
|
||||
|
||||
// Done writing the file - now we go back to fill in surface offsets + section sizes
|
||||
Out.Seek(SurfaceOffsetsStart, SEEK_SET);
|
||||
rOut.Seek(SurfaceOffsetsStart, SEEK_SET);
|
||||
|
||||
for (u32 iSurf = 0; iSurf < mNumSurfaces; iSurf++)
|
||||
Out.WriteLong(SurfaceEndOffsets[iSurf]);
|
||||
rOut.WriteLong(SurfaceEndOffsets[iSurf]);
|
||||
|
||||
Out.Seek(SectionSizesOffset, SEEK_SET);
|
||||
SectionMgr.WriteSizes(Out);
|
||||
rOut.Seek(SectionSizesOffset, SEEK_SET);
|
||||
SectionMgr.WriteSizes(rOut);
|
||||
|
||||
// Done!
|
||||
}
|
||||
|
||||
void CModelCooker::WriteCookedModel(CModel *pModel, EGame Version, IOutputStream& CMDL)
|
||||
void CModelCooker::WriteCookedModel(CModel *pModel, EGame Version, IOutputStream& rOut)
|
||||
{
|
||||
CModelCooker Cooker;
|
||||
Cooker.mpModel = pModel;
|
||||
@@ -244,12 +236,12 @@ void CModelCooker::WriteCookedModel(CModel *pModel, EGame Version, IOutputStream
|
||||
case ePrime:
|
||||
case eEchoesDemo:
|
||||
case eEchoes:
|
||||
Cooker.WriteModelPrime(CMDL);
|
||||
Cooker.WriteModelPrime(rOut);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void CModelCooker::WriteUncookedModel(CModel* /*pModel*/, IOutputStream& /*EMDL*/)
|
||||
void CModelCooker::WriteUncookedModel(CModel* /*pModel*/, IOutputStream& /*rOut*/)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -18,12 +18,12 @@ class CModelCooker
|
||||
|
||||
CModelCooker();
|
||||
void GenerateSurfaceData();
|
||||
void WriteEditorModel(IOutputStream& Out);
|
||||
void WriteModelPrime(IOutputStream& Out);
|
||||
void WriteEditorModel(IOutputStream& rOut);
|
||||
void WriteModelPrime(IOutputStream& rOut);
|
||||
|
||||
public:
|
||||
static void WriteCookedModel(CModel *pModel, EGame Version, IOutputStream& Out);
|
||||
static void WriteUncookedModel(CModel *pModel, IOutputStream& Out);
|
||||
static void WriteCookedModel(CModel *pModel, EGame Version, IOutputStream& rOut);
|
||||
static void WriteUncookedModel(CModel *pModel, IOutputStream& rOut);
|
||||
static u32 GetCMDLVersion(EGame Version);
|
||||
};
|
||||
|
||||
|
||||
@@ -12,13 +12,13 @@ void CPoiToWorldCooker::WriteEGMC(CPoiToWorld *pPoiToWorld, IOutputStream& rOut)
|
||||
|
||||
for (u32 iPoi = 0; iPoi < pPoiToWorld->NumMappedPOIs(); iPoi++)
|
||||
{
|
||||
const CPoiToWorld::SPoiMap *kpMap = pPoiToWorld->MapByIndex(iPoi);
|
||||
const CPoiToWorld::SPoiMap *pkMap = pPoiToWorld->MapByIndex(iPoi);
|
||||
|
||||
for (auto it = kpMap->ModelIDs.begin(); it != kpMap->ModelIDs.end(); it++)
|
||||
for (auto it = pkMap->ModelIDs.begin(); it != pkMap->ModelIDs.end(); it++)
|
||||
{
|
||||
SPoiMapping Mapping;
|
||||
Mapping.MeshID = *it;
|
||||
Mapping.PoiID = kpMap->PoiID;
|
||||
Mapping.PoiID = pkMap->PoiID;
|
||||
Mappings.push_back(Mapping);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,33 +0,0 @@
|
||||
#include "CSectionMgrOut.h"
|
||||
|
||||
CSectionMgrOut::CSectionMgrOut()
|
||||
{
|
||||
mSectionCount = 0;
|
||||
mCurSectionStart = 0;
|
||||
mCurSectionIndex = 0;
|
||||
}
|
||||
|
||||
void CSectionMgrOut::SetSectionCount(u32 Count)
|
||||
{
|
||||
mSectionCount = Count;
|
||||
mSectionSizes.resize(Count);
|
||||
}
|
||||
|
||||
void CSectionMgrOut::Init(const IOutputStream& OutputStream)
|
||||
{
|
||||
mCurSectionStart = OutputStream.Tell();
|
||||
mCurSectionIndex = 0;
|
||||
}
|
||||
|
||||
void CSectionMgrOut::AddSize(IOutputStream& OutputStream)
|
||||
{
|
||||
mSectionSizes[mCurSectionIndex] = OutputStream.Tell() - mCurSectionStart;
|
||||
mCurSectionIndex++;
|
||||
mCurSectionStart = OutputStream.Tell();
|
||||
}
|
||||
|
||||
void CSectionMgrOut::WriteSizes(IOutputStream& OutputStream)
|
||||
{
|
||||
for (u32 iSec = 0; iSec < mSectionCount; iSec++)
|
||||
OutputStream.WriteLong(mSectionSizes[iSec]);
|
||||
}
|
||||
@@ -14,11 +14,36 @@ class CSectionMgrOut
|
||||
std::vector<u32> mSectionSizes;
|
||||
|
||||
public:
|
||||
CSectionMgrOut();
|
||||
void SetSectionCount(u32 Count);
|
||||
void Init(const IOutputStream& OutputStream);
|
||||
void AddSize(IOutputStream& OutputStream);
|
||||
void WriteSizes(IOutputStream& OutputStream);
|
||||
CSectionMgrOut()
|
||||
: mSectionCount(0)
|
||||
, mCurSectionStart(0)
|
||||
, mCurSectionIndex(0)
|
||||
{}
|
||||
|
||||
void SetSectionCount(u32 Count)
|
||||
{
|
||||
mSectionCount = Count;
|
||||
mSectionSizes.resize(Count);
|
||||
}
|
||||
|
||||
void Init(const IOutputStream& rOut)
|
||||
{
|
||||
mCurSectionStart = rOut.Tell();
|
||||
mCurSectionIndex = 0;
|
||||
}
|
||||
|
||||
void AddSize(IOutputStream& rOut)
|
||||
{
|
||||
mSectionSizes[mCurSectionIndex] = rOut.Tell() - mCurSectionStart;
|
||||
mCurSectionIndex++;
|
||||
mCurSectionStart = rOut.Tell();
|
||||
}
|
||||
|
||||
void WriteSizes(IOutputStream& rOut)
|
||||
{
|
||||
for (u32 iSec = 0; iSec < mSectionCount; iSec++)
|
||||
rOut.WriteLong(mSectionSizes[iSec]);
|
||||
}
|
||||
};
|
||||
|
||||
#endif // CBLOCKMGROUT_H
|
||||
|
||||
@@ -41,7 +41,7 @@ void CTemplateWriter::SavePropertyTemplate(IPropertyTemplate *pTemp)
|
||||
void CTemplateWriter::SaveAllTemplates()
|
||||
{
|
||||
// Create directory
|
||||
std::list<CMasterTemplate*> MasterList = CMasterTemplate::GetMasterList();
|
||||
std::list<CMasterTemplate*> MasterList = CMasterTemplate::MasterList();
|
||||
boost::filesystem::create_directory(smTemplatesDir.ToStdString());
|
||||
|
||||
// Resave property list
|
||||
@@ -77,8 +77,8 @@ void CTemplateWriter::SaveAllTemplates()
|
||||
pGame->LinkEndChild(pGameName);
|
||||
|
||||
XMLElement *pAreaVersion = GameList.NewElement("mrea");
|
||||
u32 VersionNumber = CAreaCooker::GetMREAVersion(pMaster->GetGame());
|
||||
pAreaVersion->SetText(*TString::HexString(VersionNumber, true, true, 2));
|
||||
u32 VersionNumber = CAreaCooker::GetMREAVersion(pMaster->Game());
|
||||
pAreaVersion->SetText(*TString::HexString(VersionNumber, 2));
|
||||
pGame->LinkEndChild(pAreaVersion);
|
||||
|
||||
XMLElement *pTempPath = GameList.NewElement("master");
|
||||
@@ -139,7 +139,7 @@ void CTemplateWriter::SaveGameTemplates(CMasterTemplate *pMaster)
|
||||
|
||||
TString StrID;
|
||||
if (ObjID <= 0xFF)
|
||||
StrID = TString::HexString(ObjID, true, true, 2);
|
||||
StrID = TString::HexString(ObjID, 2);
|
||||
else
|
||||
StrID = CFourCC(ObjID).ToString();
|
||||
|
||||
@@ -177,7 +177,7 @@ void CTemplateWriter::SaveGameTemplates(CMasterTemplate *pMaster)
|
||||
}
|
||||
|
||||
TString StrID;
|
||||
if (ID <= 0xFF) StrID = TString::HexString(ID, true, true, 2);
|
||||
if (ID <= 0xFF) StrID = TString::HexString(ID, 2);
|
||||
else StrID = CFourCC(ID).ToString();
|
||||
|
||||
XMLElement *pSubElem = Master.NewElement(*Type);
|
||||
@@ -210,7 +210,7 @@ void CTemplateWriter::SavePropertyList()
|
||||
TString Name = it->second;
|
||||
|
||||
XMLElement *pElem = List.NewElement("property");
|
||||
pElem->SetAttribute("ID", *TString::HexString(ID, true, true, 8));
|
||||
pElem->SetAttribute("ID", *TString::HexString(ID));
|
||||
pElem->SetAttribute("name", *Name);
|
||||
pBase->LinkEndChild(pElem);
|
||||
}
|
||||
@@ -262,7 +262,7 @@ void CTemplateWriter::SaveScriptTemplate(CScriptTemplate *pTemp)
|
||||
XMLElement *pEditorProperties = ScriptXML.NewElement("properties");
|
||||
pEditor->LinkEndChild(pEditorProperties);
|
||||
|
||||
TString propNames[6] = {
|
||||
TString PropNames[6] = {
|
||||
"InstanceName", "Position", "Rotation",
|
||||
"Scale", "Active", "LightParameters"
|
||||
};
|
||||
@@ -277,7 +277,7 @@ void CTemplateWriter::SaveScriptTemplate(CScriptTemplate *pTemp)
|
||||
if (!pPropStrings[iProp]->IsEmpty())
|
||||
{
|
||||
XMLElement *pProperty = ScriptXML.NewElement("property");
|
||||
pProperty->SetAttribute("name", *propNames[iProp]);
|
||||
pProperty->SetAttribute("name", *PropNames[iProp]);
|
||||
pProperty->SetAttribute("ID", **pPropStrings[iProp]);
|
||||
pEditorProperties->LinkEndChild(pProperty);
|
||||
}
|
||||
@@ -373,7 +373,7 @@ void CTemplateWriter::SaveScriptTemplate(CScriptTemplate *pTemp)
|
||||
if (pProp->Type() == eBoolProperty)
|
||||
StrVal = (it->Value == 1 ? "true" : "false");
|
||||
else
|
||||
StrVal = TString::HexString((u32) it->Value, true, true, (it->Value > 0xFF ? 8 : 2));
|
||||
StrVal = TString::HexString((u32) it->Value, (it->Value > 0xFF ? 8 : 2));
|
||||
|
||||
XMLElement *pCondition = ScriptXML.NewElement("condition");
|
||||
pCondition->SetAttribute("value", *StrVal);
|
||||
@@ -469,7 +469,7 @@ void CTemplateWriter::SaveProperties(XMLDocument *pDoc, XMLElement *pParent, CSt
|
||||
// Get ID
|
||||
IPropertyTemplate *pProp = pTemp->PropertyByIndex(iProp);
|
||||
u32 ID = pProp->PropertyID();
|
||||
TString StrID = TString::HexString(ID, true, true, (ID > 0xFF ? 8 : 2));
|
||||
TString StrID = TString::HexString(ID, (ID > 0xFF ? 8 : 2));
|
||||
|
||||
// Create element
|
||||
XMLElement *pElem;
|
||||
@@ -495,7 +495,7 @@ void CTemplateWriter::SaveProperties(XMLDocument *pDoc, XMLElement *pParent, CSt
|
||||
|
||||
if (pProp->Game() >= eEchoesDemo && ID > 0xFF)
|
||||
{
|
||||
TString MasterName = CMasterTemplate::GetPropertyName(ID);
|
||||
TString MasterName = CMasterTemplate::PropertyName(ID);
|
||||
|
||||
if (Name != MasterName)
|
||||
pElem->SetAttribute("name", *Name);
|
||||
@@ -652,7 +652,7 @@ void CTemplateWriter::SaveProperties(XMLDocument *pDoc, XMLElement *pParent, CSt
|
||||
|
||||
else
|
||||
{
|
||||
CStructTemplate *pOriginal = pMaster->GetStructAtSource(pStruct->mSourceFile);
|
||||
CStructTemplate *pOriginal = pMaster->StructAtSource(pStruct->mSourceFile);
|
||||
|
||||
if (pOriginal)
|
||||
SavePropertyOverrides(pDoc, pElem, pStruct, pOriginal);
|
||||
@@ -696,7 +696,7 @@ void CTemplateWriter::SavePropertyOverrides(XMLDocument *pDoc, XMLElement *pPare
|
||||
|
||||
// ID
|
||||
u32 ID = pProp->PropertyID();
|
||||
pElem->SetAttribute("ID", *TString::HexString(pProp->PropertyID(), true, true, (ID > 0xFF ? 8 : 2)));
|
||||
pElem->SetAttribute("ID", *TString::HexString(pProp->PropertyID(), (ID > 0xFF ? 8 : 2)));
|
||||
|
||||
// Name
|
||||
if (pProp->Name() != pSource->Name())
|
||||
@@ -793,7 +793,7 @@ void CTemplateWriter::SaveEnumerators(XMLDocument *pDoc, XMLElement *pParent, CE
|
||||
{
|
||||
XMLElement *pElem = pDoc->NewElement("enumerator");
|
||||
u32 EnumerID = pTemp->EnumeratorID(iEnum);
|
||||
pElem->SetAttribute("ID", *TString::HexString(EnumerID, true, true, (EnumerID > 0xFF ? 8 : 2)));
|
||||
pElem->SetAttribute("ID", *TString::HexString(EnumerID, (EnumerID > 0xFF ? 8 : 2)));
|
||||
pElem->SetAttribute("name", *pTemp->EnumeratorName(iEnum));
|
||||
pEnumerators->LinkEndChild(pElem);
|
||||
}
|
||||
@@ -807,7 +807,7 @@ void CTemplateWriter::SaveBitFlags(XMLDocument *pDoc, XMLElement *pParent, CBitf
|
||||
for (u32 iFlag = 0; iFlag < pTemp->NumFlags(); iFlag++)
|
||||
{
|
||||
XMLElement *pElem = pDoc->NewElement("flag");
|
||||
pElem->SetAttribute("mask", *TString::HexString(pTemp->FlagMask(iFlag), true, true, 8));
|
||||
pElem->SetAttribute("mask", *TString::HexString(pTemp->FlagMask(iFlag)));
|
||||
pElem->SetAttribute("name", *pTemp->FlagName(iFlag));
|
||||
pFlags->LinkEndChild(pElem);
|
||||
}
|
||||
|
||||
@@ -2,34 +2,34 @@
|
||||
#include <Common/Log.h>
|
||||
|
||||
CTextureEncoder::CTextureEncoder()
|
||||
: mpTexture(nullptr)
|
||||
{
|
||||
mpTexture = nullptr;
|
||||
}
|
||||
|
||||
void CTextureEncoder::WriteTXTR(IOutputStream& TXTR)
|
||||
void CTextureEncoder::WriteTXTR(IOutputStream& rTXTR)
|
||||
{
|
||||
// Only DXT1->CMPR supported at the moment
|
||||
TXTR.WriteLong(mOutputFormat);
|
||||
TXTR.WriteShort(mpTexture->mWidth);
|
||||
TXTR.WriteShort(mpTexture->mHeight);
|
||||
TXTR.WriteLong(mpTexture->mNumMipMaps);
|
||||
rTXTR.WriteLong(mOutputFormat);
|
||||
rTXTR.WriteShort(mpTexture->mWidth);
|
||||
rTXTR.WriteShort(mpTexture->mHeight);
|
||||
rTXTR.WriteLong(mpTexture->mNumMipMaps);
|
||||
|
||||
u32 MipW = mpTexture->Width() / 4;
|
||||
u32 MipH = mpTexture->Height() / 4;
|
||||
CMemoryInStream Image(mpTexture->mImgDataBuffer, mpTexture->mImgDataSize, IOUtil::eLittleEndian);
|
||||
CMemoryInStream Image(mpTexture->mpImgDataBuffer, mpTexture->mImgDataSize, IOUtil::eLittleEndian);
|
||||
u32 MipOffset = Image.Tell();
|
||||
|
||||
for (u32 iMip = 0; iMip < mpTexture->mNumMipMaps; iMip++)
|
||||
{
|
||||
for (u32 BlockY = 0; BlockY < MipH; BlockY += 2)
|
||||
for (u32 BlockX = 0; BlockX < MipW; BlockX += 2)
|
||||
for (u32 ImgY = BlockY; ImgY < BlockY + 2; ImgY++)
|
||||
for (u32 ImgX = BlockX; ImgX < BlockX + 2; ImgX++)
|
||||
for (u32 iBlockY = 0; iBlockY < MipH; iBlockY += 2)
|
||||
for (u32 iBlockX = 0; iBlockX < MipW; iBlockX += 2)
|
||||
for (u32 iImgY = iBlockY; iImgY < iBlockY + 2; iImgY++)
|
||||
for (u32 iImgX = iBlockX; iImgX < iBlockX + 2; iImgX++)
|
||||
{
|
||||
u32 SrcPos = ((ImgY * MipW) + ImgX) * 8;
|
||||
u32 SrcPos = ((iImgY * MipW) + iImgX) * 8;
|
||||
Image.Seek(MipOffset + SrcPos, SEEK_SET);
|
||||
|
||||
ReadSubBlockCMPR(Image, TXTR);
|
||||
ReadSubBlockCMPR(Image, rTXTR);
|
||||
}
|
||||
|
||||
MipOffset += MipW * MipH * 8;
|
||||
@@ -45,20 +45,21 @@ void CTextureEncoder::DetermineBestOutputFormat()
|
||||
// todo
|
||||
}
|
||||
|
||||
void CTextureEncoder::ReadSubBlockCMPR(IInputStream& Source, IOutputStream& Dest)
|
||||
void CTextureEncoder::ReadSubBlockCMPR(IInputStream& rSource, IOutputStream& rDest)
|
||||
{
|
||||
Dest.WriteShort(Source.ReadShort());
|
||||
Dest.WriteShort(Source.ReadShort());
|
||||
rDest.WriteShort(rSource.ReadShort());
|
||||
rDest.WriteShort(rSource.ReadShort());
|
||||
|
||||
for (u32 byte = 0; byte < 4; byte++) {
|
||||
u8 b = Source.ReadByte();
|
||||
b = ((b & 0x3) << 6) | ((b & 0xC) << 2) | ((b & 0x30) >> 2) | ((b & 0xC0) >> 6);
|
||||
Dest.WriteByte(b);
|
||||
for (u32 iByte = 0; iByte < 4; iByte++)
|
||||
{
|
||||
u8 Byte = rSource.ReadByte();
|
||||
Byte = ((Byte & 0x3) << 6) | ((Byte & 0xC) << 2) | ((Byte & 0x30) >> 2) | ((Byte & 0xC0) >> 6);
|
||||
rDest.WriteByte(Byte);
|
||||
}
|
||||
}
|
||||
|
||||
// ************ STATIC ************
|
||||
void CTextureEncoder::EncodeTXTR(IOutputStream& TXTR, CTexture *pTex)
|
||||
void CTextureEncoder::EncodeTXTR(IOutputStream& rTXTR, CTexture *pTex)
|
||||
{
|
||||
if (pTex->mTexelFormat != eDXT1)
|
||||
{
|
||||
@@ -70,13 +71,13 @@ void CTextureEncoder::EncodeTXTR(IOutputStream& TXTR, CTexture *pTex)
|
||||
Encoder.mpTexture = pTex;
|
||||
Encoder.mSourceFormat = eDXT1;
|
||||
Encoder.mOutputFormat = eGX_CMPR;
|
||||
Encoder.WriteTXTR(TXTR);
|
||||
Encoder.WriteTXTR(rTXTR);
|
||||
}
|
||||
|
||||
void CTextureEncoder::EncodeTXTR(IOutputStream& TXTR, CTexture *pTex, ETexelFormat /*OutputFormat*/)
|
||||
void CTextureEncoder::EncodeTXTR(IOutputStream& rTXTR, CTexture *pTex, ETexelFormat /*OutputFormat*/)
|
||||
{
|
||||
// todo: support for encoding a specific format
|
||||
EncodeTXTR(TXTR, pTex);
|
||||
EncodeTXTR(rTXTR, pTex);
|
||||
}
|
||||
|
||||
ETexelFormat CTextureEncoder::GetGXFormat(ETexelFormat Format)
|
||||
|
||||
@@ -13,13 +13,13 @@ class CTextureEncoder
|
||||
ETexelFormat mOutputFormat;
|
||||
|
||||
CTextureEncoder();
|
||||
void WriteTXTR(IOutputStream& TXTR);
|
||||
void WriteTXTR(IOutputStream& rTXTR);
|
||||
void DetermineBestOutputFormat();
|
||||
void ReadSubBlockCMPR(IInputStream& Source, IOutputStream& Dest);
|
||||
void ReadSubBlockCMPR(IInputStream& rSource, IOutputStream& rDest);
|
||||
|
||||
public:
|
||||
static void EncodeTXTR(IOutputStream& TXTR, CTexture *pTex);
|
||||
static void EncodeTXTR(IOutputStream& TXTR, CTexture *pTex, ETexelFormat OutputFormat);
|
||||
static void EncodeTXTR(IOutputStream& rTXTR, CTexture *pTex);
|
||||
static void EncodeTXTR(IOutputStream& rTXTR, CTexture *pTex, ETexelFormat OutputFormat);
|
||||
static ETexelFormat GetGXFormat(ETexelFormat Format);
|
||||
static ETexelFormat GetFormat(ETexelFormat Format);
|
||||
};
|
||||
|
||||
@@ -4,9 +4,9 @@ CWorldCooker::CWorldCooker()
|
||||
{
|
||||
}
|
||||
|
||||
u32 CWorldCooker::GetMLVLVersion(EGame version)
|
||||
u32 CWorldCooker::GetMLVLVersion(EGame Version)
|
||||
{
|
||||
switch (version)
|
||||
switch (Version)
|
||||
{
|
||||
case ePrimeDemo: return 0xD;
|
||||
case ePrime: return 0x11;
|
||||
|
||||
@@ -8,7 +8,7 @@ class CWorldCooker
|
||||
{
|
||||
CWorldCooker();
|
||||
public:
|
||||
static u32 GetMLVLVersion(EGame version);
|
||||
static u32 GetMLVLVersion(EGame Version);
|
||||
};
|
||||
|
||||
#endif // CWORLDCOOKER_H
|
||||
|
||||
Reference in New Issue
Block a user