Cleanup & refactoring
This commit is contained in:
parent
2287b05bc3
commit
c4829f5fda
|
@ -1 +1 @@
|
|||
Subproject commit 42038000181a5fa5b92f2abfb74d91b7bec25040
|
||||
Subproject commit 8847ab12160ef22174e79b64f1620c7a1abdb2a6
|
|
@ -1 +1 @@
|
|||
Subproject commit 4917932573b3e6539113886c537a473550d3bbff
|
||||
Subproject commit 47d83075e0fb20786ad28c2e945a204ed1837856
|
|
@ -17,7 +17,7 @@ void CAudioManager::LoadAssets()
|
|||
mSfxIdMap.clear();
|
||||
|
||||
// Load/sort all audio groups
|
||||
for (TResourceIterator<eAudioGroup> It(mpProject->ResourceStore()); It; ++It)
|
||||
for (TResourceIterator<EResourceType::AudioGroup> It(mpProject->ResourceStore()); It; ++It)
|
||||
{
|
||||
CAudioGroup *pGroup = (CAudioGroup*) It->Load();
|
||||
if (pGroup) mAudioGroups.push_back(pGroup);
|
||||
|
|
|
@ -26,8 +26,8 @@ void ApplyGeneratedName(CResourceEntry *pEntry, const TString& rkDir, const TStr
|
|||
ASSERT(pEntry != nullptr);
|
||||
|
||||
// Don't overwrite hand-picked names and directories with auto-generated ones
|
||||
bool HasCustomDir = !pEntry->HasFlag(eREF_AutoResDir);
|
||||
bool HasCustomName = !pEntry->HasFlag(eREF_AutoResName);
|
||||
bool HasCustomDir = !pEntry->HasFlag(EResEntryFlag::AutoResDir);
|
||||
bool HasCustomName = !pEntry->HasFlag(EResEntryFlag::AutoResName);
|
||||
if (HasCustomDir && HasCustomName) return;
|
||||
|
||||
// Determine final directory to use
|
||||
|
@ -94,8 +94,8 @@ void GenerateAssetNames(CGameProject *pProj)
|
|||
|
||||
for (CResourceIterator It(pStore); It; ++It)
|
||||
{
|
||||
bool HasCustomDir = !It->HasFlag(eREF_AutoResDir);
|
||||
bool HasCustomName = !It->HasFlag(eREF_AutoResName);
|
||||
bool HasCustomDir = !It->HasFlag(EResEntryFlag::AutoResDir);
|
||||
bool HasCustomName = !It->HasFlag(EResEntryFlag::AutoResName);
|
||||
if (HasCustomDir && HasCustomName) continue;
|
||||
|
||||
TString NewDir = (HasCustomDir ? It->DirectoryPath() : pStore->DefaultResourceDirPath());
|
||||
|
@ -131,7 +131,7 @@ void GenerateAssetNames(CGameProject *pProj)
|
|||
debugf("Processing worlds");
|
||||
const TString kWorldsRoot = "Worlds/";
|
||||
|
||||
for (TResourceIterator<eWorld> It(pStore); It; ++It)
|
||||
for (TResourceIterator<EResourceType::World> It(pStore); It; ++It)
|
||||
{
|
||||
// Set world name
|
||||
TResPtr<CWorld> pWorld = It->Load();
|
||||
|
@ -245,7 +245,7 @@ void GenerateAssetNames(CGameProject *pProj)
|
|||
{
|
||||
CMaterialPass *pPass = pMat->Pass(iPass);
|
||||
|
||||
bool IsLightmap = ( (pArea->Game() <= EGame::Echoes && pMat->Options().HasFlag(CMaterial::eLightmap) && iPass == 0) ||
|
||||
bool IsLightmap = ( (pArea->Game() <= EGame::Echoes && pMat->Options().HasFlag(EMaterialOption::Lightmap) && iPass == 0) ||
|
||||
(pArea->Game() >= EGame::CorruptionProto && pPass->Type() == "DIFF") );
|
||||
bool IsBloomLightmap = (pArea->Game() >= EGame::CorruptionProto && pPass->Type() == "BLOL");
|
||||
|
||||
|
@ -398,7 +398,7 @@ void GenerateAssetNames(CGameProject *pProj)
|
|||
// Generate Model Lightmap names
|
||||
debugf("Processing model lightmaps");
|
||||
|
||||
for (TResourceIterator<eModel> It(pStore); It; ++It)
|
||||
for (TResourceIterator<EResourceType::Model> It(pStore); It; ++It)
|
||||
{
|
||||
CModel *pModel = (CModel*) It->Load();
|
||||
uint32 LightmapNum = 0;
|
||||
|
@ -415,7 +415,7 @@ void GenerateAssetNames(CGameProject *pProj)
|
|||
{
|
||||
CMaterialPass *pPass = pMat->Pass(iPass);
|
||||
|
||||
bool IsLightmap = ( (pMat->Version() <= EGame::Echoes && pMat->Options().HasFlag(CMaterial::eLightmap) && iPass == 0) ||
|
||||
bool IsLightmap = ( (pMat->Version() <= EGame::Echoes && pMat->Options().HasFlag(EMaterialOption::Lightmap) && iPass == 0) ||
|
||||
(pMat->Version() >= EGame::CorruptionProto && pPass->Type() == "DIFF") );
|
||||
|
||||
if (IsLightmap)
|
||||
|
@ -442,7 +442,7 @@ void GenerateAssetNames(CGameProject *pProj)
|
|||
debugf("Processing audio groups");
|
||||
const TString kAudioGrpDir = "Audio/";
|
||||
|
||||
for (TResourceIterator<eAudioGroup> It(pStore); It; ++It)
|
||||
for (TResourceIterator<EResourceType::AudioGroup> It(pStore); It; ++It)
|
||||
{
|
||||
CAudioGroup *pGroup = (CAudioGroup*) It->Load();
|
||||
TString GroupName = pGroup->GroupName();
|
||||
|
@ -455,7 +455,7 @@ void GenerateAssetNames(CGameProject *pProj)
|
|||
debugf("Processing audio macros");
|
||||
const TString kSfxDir = "Audio/Uncategorized/";
|
||||
|
||||
for (TResourceIterator<eAudioMacro> It(pStore); It; ++It)
|
||||
for (TResourceIterator<EResourceType::AudioMacro> It(pStore); It; ++It)
|
||||
{
|
||||
CAudioMacro *pMacro = (CAudioMacro*) It->Load();
|
||||
TString MacroName = pMacro->MacroName();
|
||||
|
@ -485,7 +485,9 @@ void GenerateAssetNames(CGameProject *pProj)
|
|||
// Generate animation format names
|
||||
// Hacky syntax because animsets are under eAnimSet in MP1/2 and eCharacter in MP3/DKCR
|
||||
debugf("Processing animation data");
|
||||
CResourceIterator *pIter = (pProj->Game() <= EGame::Echoes ? (CResourceIterator*) new TResourceIterator<eAnimSet> : (CResourceIterator*) new TResourceIterator<eCharacter>);
|
||||
CResourceIterator *pIter = (pProj->Game() <= EGame::Echoes ?
|
||||
(CResourceIterator*) new TResourceIterator<EResourceType::AnimSet> :
|
||||
(CResourceIterator*) new TResourceIterator<EResourceType::Character>);
|
||||
CResourceIterator& It = *pIter;
|
||||
|
||||
for (; It; ++It)
|
||||
|
@ -523,10 +525,10 @@ void GenerateAssetNames(CGameProject *pProj)
|
|||
if (rkOverlay.ModelID.IsValid() || rkOverlay.SkinID.IsValid())
|
||||
{
|
||||
TString TypeName = (
|
||||
rkOverlay.Type == eOT_Frozen ? "frozen" :
|
||||
rkOverlay.Type == eOT_Acid ? "acid" :
|
||||
rkOverlay.Type == eOT_Hypermode ? "hypermode" :
|
||||
rkOverlay.Type == eOT_XRay ? "xray" :
|
||||
rkOverlay.Type == EOverlayType::Frozen ? "frozen" :
|
||||
rkOverlay.Type == EOverlayType::Acid ? "acid" :
|
||||
rkOverlay.Type == EOverlayType::Hypermode ? "hypermode" :
|
||||
rkOverlay.Type == EOverlayType::XRay ? "xray" :
|
||||
""
|
||||
);
|
||||
ASSERT(TypeName != "");
|
||||
|
@ -576,7 +578,7 @@ void GenerateAssetNames(CGameProject *pProj)
|
|||
debugf("Processing strings");
|
||||
const TString kStringsDir = "Strings/Uncategorized/";
|
||||
|
||||
for (TResourceIterator<eStringTable> It(pStore); It; ++It)
|
||||
for (TResourceIterator<EResourceType::StringTable> It(pStore); It; ++It)
|
||||
{
|
||||
if (It->IsNamed()) continue;
|
||||
CStringTable *pString = (CStringTable*) It->Load();
|
||||
|
@ -601,7 +603,7 @@ void GenerateAssetNames(CGameProject *pProj)
|
|||
#if PROCESS_SCANS
|
||||
// Generate scan names
|
||||
debugf("Processing scans");
|
||||
for (TResourceIterator<eScan> It(pStore); It; ++It)
|
||||
for (TResourceIterator<EResourceType::Scan> It(pStore); It; ++It)
|
||||
{
|
||||
if (It->IsNamed()) continue;
|
||||
CScan *pScan = (CScan*) It->Load();
|
||||
|
@ -641,7 +643,7 @@ void GenerateAssetNames(CGameProject *pProj)
|
|||
#if PROCESS_FONTS
|
||||
// Generate font names
|
||||
debugf("Processing fonts");
|
||||
for (TResourceIterator<eFont> It(pStore); It; ++It)
|
||||
for (TResourceIterator<EResourceType::Font> It(pStore); It; ++It)
|
||||
{
|
||||
CFont *pFont = (CFont*) It->Load();
|
||||
|
||||
|
|
|
@ -19,8 +19,8 @@ bool CAssetNameMap::LoadAssetNames(TString Path /*= ""*/)
|
|||
else
|
||||
{
|
||||
debugf("Failed to load asset names; expected %s IDs, got %s",
|
||||
mIDLength == e32Bit ? "32-bit" : "64-bit",
|
||||
FileIDLength == e32Bit ? "32-bit" : "64-bit" );
|
||||
mIDLength == k32Bit ? "32-bit" : "64-bit",
|
||||
FileIDLength == k32Bit ? "32-bit" : "64-bit" );
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -36,7 +36,7 @@ bool CAssetNameMap::SaveAssetNames(TString Path /*= ""*/)
|
|||
if (Path.IsEmpty())
|
||||
Path = DefaultNameMapPath(mIDLength);
|
||||
|
||||
EGame Game = (mIDLength == e32Bit ? EGame::Prime : EGame::Corruption);
|
||||
EGame Game = (mIDLength == k32Bit ? EGame::Prime : EGame::Corruption);
|
||||
CXMLWriter Writer(Path, "AssetNameMap", 0, Game);
|
||||
Serialize(Writer);
|
||||
return Writer.Save();
|
||||
|
@ -58,7 +58,7 @@ bool CAssetNameMap::GetNameInfo(CAssetID ID, TString& rOutDirectory, TString& rO
|
|||
|
||||
else
|
||||
{
|
||||
EGame Game = (ID.Length() == e32Bit ? EGame::Prime : EGame::Corruption);
|
||||
EGame Game = (ID.Length() == k32Bit ? EGame::Prime : EGame::Corruption);
|
||||
rOutDirectory = CResourceStore::StaticDefaultResourceDirPath(Game);
|
||||
rOutName = ID.ToString();
|
||||
rOutAutoGenDir = true;
|
||||
|
@ -99,8 +99,8 @@ void CAssetNameMap::CopyFromStore(CResourceStore *pStore /*= gpResourceStore*/)
|
|||
TString Name = It->Name();
|
||||
TString Directory = It->Directory()->FullPath();
|
||||
CFourCC Type = It->CookedExtension();
|
||||
bool AutoName = It->HasFlag(eREF_AutoResName);
|
||||
bool AutoDir = It->HasFlag(eREF_AutoResDir);
|
||||
bool AutoName = It->HasFlag(EResEntryFlag::AutoResName);
|
||||
bool AutoDir = It->HasFlag(EResEntryFlag::AutoResDir);
|
||||
SAssetNameInfo NameInfo { Name, Directory, Type, AutoName, AutoDir };
|
||||
|
||||
// Check for conflicts with new name
|
||||
|
@ -193,8 +193,8 @@ void CAssetNameMap::PostLoadValidate()
|
|||
|
||||
TString CAssetNameMap::DefaultNameMapPath(EIDLength IDLength)
|
||||
{
|
||||
ASSERT(IDLength != eInvalidIDLength);
|
||||
TString Suffix = (IDLength == e32Bit ? "32" : "64");
|
||||
ASSERT(IDLength != kInvalidIDLength);
|
||||
TString Suffix = (IDLength == k32Bit ? "32" : "64");
|
||||
return gkAssetMapPath + Suffix + "." + gkAssetMapExt;
|
||||
}
|
||||
|
||||
|
|
|
@ -56,8 +56,8 @@ class CAssetNameMap
|
|||
void PostLoadValidate();
|
||||
|
||||
public:
|
||||
CAssetNameMap(EIDLength IDLength) : mIsValid(true), mIDLength(IDLength) { ASSERT(mIDLength != eInvalidIDLength); }
|
||||
CAssetNameMap(EGame Game) : mIsValid(true), mIDLength( CAssetID::GameIDLength(Game) ) { ASSERT(mIDLength != eInvalidIDLength); }
|
||||
CAssetNameMap(EIDLength IDLength) : mIsValid(true), mIDLength(IDLength) { ASSERT(mIDLength != kInvalidIDLength); }
|
||||
CAssetNameMap(EGame Game) : mIsValid(true), mIDLength( CAssetID::GameIDLength(Game) ) { ASSERT(mIDLength != kInvalidIDLength); }
|
||||
bool LoadAssetNames(TString Path = "");
|
||||
bool SaveAssetNames(TString Path = "");
|
||||
bool GetNameInfo(CAssetID ID, TString& rOutDirectory, TString& rOutName, bool& rOutAutoGenDir, bool& rOutAutoGenName);
|
||||
|
|
|
@ -35,15 +35,15 @@ IDependencyNode* IDependencyNode::ArchiveConstructor(EDependencyNodeType Type)
|
|||
{
|
||||
switch (Type)
|
||||
{
|
||||
case eDNT_DependencyTree: return new CDependencyTree;
|
||||
case eDNT_ResourceDependency: return new CResourceDependency;
|
||||
case eDNT_ScriptInstance: return new CScriptInstanceDependency;
|
||||
case eDNT_ScriptProperty: return new CPropertyDependency;
|
||||
case eDNT_CharacterProperty: return new CCharPropertyDependency;
|
||||
case eDNT_SetCharacter: return new CSetCharacterDependency;
|
||||
case eDNT_SetAnimation: return new CSetAnimationDependency;
|
||||
case eDNT_AnimEvent: return new CAnimEventDependency;
|
||||
case eDNT_Area: return new CAreaDependencyTree;
|
||||
case EDependencyNodeType::DependencyTree: return new CDependencyTree;
|
||||
case EDependencyNodeType::Resource: return new CResourceDependency;
|
||||
case EDependencyNodeType::ScriptInstance: return new CScriptInstanceDependency;
|
||||
case EDependencyNodeType::ScriptProperty: return new CPropertyDependency;
|
||||
case EDependencyNodeType::CharacterProperty: return new CCharPropertyDependency;
|
||||
case EDependencyNodeType::SetCharacter: return new CSetCharacterDependency;
|
||||
case EDependencyNodeType::SetAnimation: return new CSetAnimationDependency;
|
||||
case EDependencyNodeType::AnimEvent: return new CAnimEventDependency;
|
||||
case EDependencyNodeType::Area: return new CAreaDependencyTree;
|
||||
default: ASSERT(false); return nullptr;
|
||||
}
|
||||
}
|
||||
|
@ -51,7 +51,7 @@ IDependencyNode* IDependencyNode::ArchiveConstructor(EDependencyNodeType Type)
|
|||
// ************ CDependencyTree ************
|
||||
EDependencyNodeType CDependencyTree::Type() const
|
||||
{
|
||||
return eDNT_DependencyTree;
|
||||
return EDependencyNodeType::DependencyTree;
|
||||
}
|
||||
|
||||
void CDependencyTree::Serialize(IArchive& rArc)
|
||||
|
@ -90,7 +90,7 @@ void CDependencyTree::AddCharacterDependency(const CAnimationParameters& rkAnimP
|
|||
// ************ CResourceDependency ************
|
||||
EDependencyNodeType CResourceDependency::Type() const
|
||||
{
|
||||
return eDNT_ResourceDependency;
|
||||
return EDependencyNodeType::Resource;
|
||||
}
|
||||
|
||||
void CResourceDependency::Serialize(IArchive& rArc)
|
||||
|
@ -111,7 +111,7 @@ bool CResourceDependency::HasDependency(const CAssetID& rkID) const
|
|||
// ************ CPropertyDependency ************
|
||||
EDependencyNodeType CPropertyDependency::Type() const
|
||||
{
|
||||
return eDNT_ScriptProperty;
|
||||
return EDependencyNodeType::ScriptProperty;
|
||||
}
|
||||
|
||||
void CPropertyDependency::Serialize(IArchive& rArc)
|
||||
|
@ -123,7 +123,7 @@ void CPropertyDependency::Serialize(IArchive& rArc)
|
|||
// ************ CCharacterPropertyDependency ************
|
||||
EDependencyNodeType CCharPropertyDependency::Type() const
|
||||
{
|
||||
return eDNT_CharacterProperty;
|
||||
return EDependencyNodeType::CharacterProperty;
|
||||
}
|
||||
|
||||
void CCharPropertyDependency::Serialize(IArchive& rArc)
|
||||
|
@ -135,7 +135,7 @@ void CCharPropertyDependency::Serialize(IArchive& rArc)
|
|||
// ************ CScriptInstanceDependency ************
|
||||
EDependencyNodeType CScriptInstanceDependency::Type() const
|
||||
{
|
||||
return eDNT_ScriptInstance;
|
||||
return EDependencyNodeType::ScriptInstance;
|
||||
}
|
||||
|
||||
void CScriptInstanceDependency::Serialize(IArchive& rArc)
|
||||
|
@ -222,7 +222,7 @@ void CScriptInstanceDependency::ParseStructDependencies(CScriptInstanceDependenc
|
|||
// ************ CSetCharacterDependency ************
|
||||
EDependencyNodeType CSetCharacterDependency::Type() const
|
||||
{
|
||||
return eDNT_SetCharacter;
|
||||
return EDependencyNodeType::SetCharacter;
|
||||
}
|
||||
|
||||
void CSetCharacterDependency::Serialize(IArchive& rArc)
|
||||
|
@ -267,7 +267,7 @@ CSetCharacterDependency* CSetCharacterDependency::BuildTree(const SSetCharacter&
|
|||
// ************ CSetAnimationDependency ************
|
||||
EDependencyNodeType CSetAnimationDependency::Type() const
|
||||
{
|
||||
return eDNT_SetAnimation;
|
||||
return EDependencyNodeType::SetAnimation;
|
||||
}
|
||||
|
||||
void CSetAnimationDependency::Serialize(IArchive& rArc)
|
||||
|
@ -313,7 +313,7 @@ CSetAnimationDependency* CSetAnimationDependency::BuildTree(const CAnimSet *pkOw
|
|||
// ************ CAnimEventDependency ************
|
||||
EDependencyNodeType CAnimEventDependency::Type() const
|
||||
{
|
||||
return eDNT_AnimEvent;
|
||||
return EDependencyNodeType::AnimEvent;
|
||||
}
|
||||
|
||||
void CAnimEventDependency::Serialize(IArchive& rArc)
|
||||
|
@ -325,7 +325,7 @@ void CAnimEventDependency::Serialize(IArchive& rArc)
|
|||
// ************ CAreaDependencyTree ************
|
||||
EDependencyNodeType CAreaDependencyTree::Type() const
|
||||
{
|
||||
return eDNT_Area;
|
||||
return EDependencyNodeType::Area;
|
||||
}
|
||||
|
||||
void CAreaDependencyTree::Serialize(IArchive& rArc)
|
||||
|
@ -379,7 +379,7 @@ void CAreaDependencyTree::GetModuleDependencies(EGame Game, std::vector<TString>
|
|||
for (uint32 iInst = StartIdx; iInst < EndIdx; iInst++)
|
||||
{
|
||||
IDependencyNode *pNode = mChildren[iInst];
|
||||
if (pNode->Type() != eDNT_ScriptInstance) continue;
|
||||
if (pNode->Type() != EDependencyNodeType::ScriptInstance) continue;
|
||||
|
||||
CScriptInstanceDependency *pInst = static_cast<CScriptInstanceDependency*>(pNode);
|
||||
uint32 ObjType = pInst->ObjectType();
|
||||
|
|
|
@ -14,17 +14,17 @@ class CAnimationParameters;
|
|||
struct SSetCharacter;
|
||||
|
||||
// Group of node classes forming a tree of cached resource dependencies.
|
||||
enum EDependencyNodeType
|
||||
enum class EDependencyNodeType
|
||||
{
|
||||
eDNT_DependencyTree = FOURCC('TREE'),
|
||||
eDNT_ResourceDependency = FOURCC('RSDP'),
|
||||
eDNT_ScriptInstance = FOURCC('SCIN'),
|
||||
eDNT_ScriptProperty = FOURCC('SCPR'),
|
||||
eDNT_CharacterProperty = FOURCC('CRPR'),
|
||||
eDNT_SetCharacter = FOURCC('SCHR'),
|
||||
eDNT_SetAnimation = FOURCC('SANM'),
|
||||
eDNT_AnimEvent = FOURCC('EVNT'),
|
||||
eDNT_Area = FOURCC('AREA'),
|
||||
DependencyTree = FOURCC('TREE'),
|
||||
Resource = FOURCC('RSDP'),
|
||||
ScriptInstance = FOURCC('SCIN'),
|
||||
ScriptProperty = FOURCC('SCPR'),
|
||||
CharacterProperty = FOURCC('CRPR'),
|
||||
SetCharacter = FOURCC('SCHR'),
|
||||
SetAnimation = FOURCC('SANM'),
|
||||
AnimEvent = FOURCC('EVNT'),
|
||||
Area = FOURCC('AREA'),
|
||||
};
|
||||
|
||||
// Base class providing an interface for a basic dependency node.
|
||||
|
|
|
@ -100,7 +100,7 @@ void CGameExporter::LoadResource(const CAssetID& rkID, std::vector<uint8>& rBuff
|
|||
|
||||
bool CGameExporter::ShouldExportDiscNode(const nod::Node *pkNode, bool IsInRoot)
|
||||
{
|
||||
if (IsInRoot && mDiscType != eDT_Normal)
|
||||
if (IsInRoot && mDiscType != EDiscType::Normal)
|
||||
{
|
||||
// Directories - exclude the filesystem for other games
|
||||
if (pkNode->getKind() == nod::Node::Kind::Directory)
|
||||
|
@ -115,15 +115,15 @@ bool CGameExporter::ShouldExportDiscNode(const nod::Node *pkNode, bool IsInRoot)
|
|||
switch (mGame)
|
||||
{
|
||||
case EGame::Prime:
|
||||
return ( (mDiscType == eDT_WiiDeAsobu && pkNode->getName() == "MP1JPN") ||
|
||||
(mDiscType == eDT_Trilogy && pkNode->getName() == "MP1") );
|
||||
return ( (mDiscType == EDiscType::WiiDeAsobu && pkNode->getName() == "MP1JPN") ||
|
||||
(mDiscType == EDiscType::Trilogy && pkNode->getName() == "MP1") );
|
||||
|
||||
case EGame::Echoes:
|
||||
return ( (mDiscType == eDT_WiiDeAsobu && pkNode->getName() == "MP2JPN") ||
|
||||
(mDiscType == eDT_Trilogy && pkNode->getName() == "MP2") );
|
||||
return ( (mDiscType == EDiscType::WiiDeAsobu && pkNode->getName() == "MP2JPN") ||
|
||||
(mDiscType == EDiscType::Trilogy && pkNode->getName() == "MP2") );
|
||||
|
||||
case EGame::Corruption:
|
||||
return (mDiscType == eDT_Trilogy && pkNode->getName() == "MP3");
|
||||
return (mDiscType == EDiscType::Trilogy && pkNode->getName() == "MP3");
|
||||
|
||||
default:
|
||||
return false;
|
||||
|
@ -143,15 +143,15 @@ bool CGameExporter::ShouldExportDiscNode(const nod::Node *pkNode, bool IsInRoot)
|
|||
switch (mGame)
|
||||
{
|
||||
case EGame::Prime:
|
||||
return ( (mDiscType == eDT_WiiDeAsobu && pkNode->getName() == "rs5mp1jpn_p.dol") ||
|
||||
(mDiscType == eDT_Trilogy && pkNode->getName() == "rs5mp1_p.dol") );
|
||||
return ( (mDiscType == EDiscType::WiiDeAsobu && pkNode->getName() == "rs5mp1jpn_p.dol") ||
|
||||
(mDiscType == EDiscType::Trilogy && pkNode->getName() == "rs5mp1_p.dol") );
|
||||
|
||||
case EGame::Echoes:
|
||||
return ( (mDiscType == eDT_WiiDeAsobu && pkNode->getName() == "rs5mp2jpn_p.dol") ||
|
||||
(mDiscType == eDT_Trilogy && pkNode->getName() == "rs5mp2_p.dol") );
|
||||
return ( (mDiscType == EDiscType::WiiDeAsobu && pkNode->getName() == "rs5mp2jpn_p.dol") ||
|
||||
(mDiscType == EDiscType::Trilogy && pkNode->getName() == "rs5mp2_p.dol") );
|
||||
|
||||
case EGame::Corruption:
|
||||
return (mDiscType == eDT_Trilogy && pkNode->getName() == "rs5mp3_p.dol");
|
||||
return (mDiscType == EDiscType::Trilogy && pkNode->getName() == "rs5mp3_p.dol");
|
||||
|
||||
default:
|
||||
return false;
|
||||
|
@ -232,7 +232,7 @@ bool CGameExporter::ExtractDiscNodeRecursive(const nod::Node *pkNode, const TStr
|
|||
if (FilePath.GetFileExtension().CaseInsensitiveCompare("pak"))
|
||||
{
|
||||
// For multi-game Wii discs, don't track packages for frontend unless we're exporting frontend
|
||||
if (mDiscType == eDT_Normal || mFrontEnd || pkNode->getName() != "fe")
|
||||
if (mDiscType == EDiscType::Normal || mFrontEnd || pkNode->getName() != "fe")
|
||||
mPaks.push_back(FilePath);
|
||||
}
|
||||
}
|
||||
|
@ -264,7 +264,7 @@ void CGameExporter::LoadPaks()
|
|||
for (auto It = mPaks.begin(); It != mPaks.end(); It++)
|
||||
{
|
||||
TString PakPath = *It;
|
||||
CFileInStream Pak(PakPath, IOUtil::eBigEndian);
|
||||
CFileInStream Pak(PakPath, EEndian::BigEndian);
|
||||
|
||||
if (!Pak.IsValid())
|
||||
{
|
||||
|
@ -427,7 +427,7 @@ void CGameExporter::LoadPaks()
|
|||
|
||||
void CGameExporter::LoadResource(const SResourceInstance& rkResource, std::vector<uint8>& rBuffer)
|
||||
{
|
||||
CFileInStream Pak(rkResource.PakFile, IOUtil::eBigEndian);
|
||||
CFileInStream Pak(rkResource.PakFile, EEndian::BigEndian);
|
||||
|
||||
if (Pak.IsValid())
|
||||
{
|
||||
|
@ -559,13 +559,13 @@ void CGameExporter::ExportResourceEditorData()
|
|||
for (CResourceIterator It(mpStore); It && !mpProgress->ShouldCancel(); ++It, ++ResIndex)
|
||||
{
|
||||
// Update progress
|
||||
if ((ResIndex & 0x3) == 0 || It->ResourceType() == eArea)
|
||||
if ((ResIndex & 0x3) == 0 || It->ResourceType() == EResourceType::Area)
|
||||
mpProgress->Report(ResIndex, mpStore->NumTotalResources(), TString::Format("Processing asset %d/%d: %s",
|
||||
ResIndex, mpStore->NumTotalResources(), *It->CookedAssetPath(true).GetFileName()) );
|
||||
|
||||
// Worlds need some info we can only get from the pak at export time; namely, which areas can
|
||||
// have duplicates, as well as the world's internal name.
|
||||
if (It->ResourceType() == eWorld)
|
||||
if (It->ResourceType() == EResourceType::World)
|
||||
{
|
||||
CWorld *pWorld = (CWorld*) It->Load();
|
||||
|
||||
|
@ -629,15 +629,15 @@ void CGameExporter::ExportResource(SResourceInstance& rRes)
|
|||
CResourceEntry *pEntry = mpStore->RegisterResource(rRes.ResourceID, CResTypeInfo::TypeForCookedExtension(mGame, rRes.ResourceType)->Type(), Directory, Name);
|
||||
|
||||
// Set flags
|
||||
pEntry->SetFlag(eREF_IsBaseGameResource);
|
||||
pEntry->SetFlagEnabled(eREF_AutoResDir, AutoDir);
|
||||
pEntry->SetFlagEnabled(eREF_AutoResName, AutoName);
|
||||
pEntry->SetFlag(EResEntryFlag::IsBaseGameResource);
|
||||
pEntry->SetFlagEnabled(EResEntryFlag::AutoResDir, AutoDir);
|
||||
pEntry->SetFlagEnabled(EResEntryFlag::AutoResName, AutoName);
|
||||
|
||||
#if EXPORT_COOKED
|
||||
// Save cooked asset
|
||||
TString OutCookedPath = pEntry->CookedAssetPath();
|
||||
FileUtil::MakeDirectory(OutCookedPath.GetFileDirectory());
|
||||
CFileOutStream Out(OutCookedPath, IOUtil::eBigEndian);
|
||||
CFileOutStream Out(OutCookedPath, EEndian::BigEndian);
|
||||
|
||||
if (Out.IsValid())
|
||||
Out.WriteBytes(ResourceData.data(), ResourceData.size());
|
||||
|
@ -652,7 +652,7 @@ void CGameExporter::ExportResource(SResourceInstance& rRes)
|
|||
TString CGameExporter::MakeWorldName(CAssetID WorldID)
|
||||
{
|
||||
CResourceEntry *pWorldEntry = mpStore->FindEntry(WorldID);
|
||||
ASSERT(pWorldEntry && pWorldEntry->ResourceType() == eWorld);
|
||||
ASSERT(pWorldEntry && pWorldEntry->ResourceType() == EResourceType::World);
|
||||
|
||||
// Find the original world name in the package resource names
|
||||
TString WorldName;
|
||||
|
|
|
@ -11,11 +11,11 @@
|
|||
#include <map>
|
||||
#include <nod/nod.hpp>
|
||||
|
||||
enum EDiscType
|
||||
enum class EDiscType
|
||||
{
|
||||
eDT_Normal,
|
||||
eDT_WiiDeAsobu,
|
||||
eDT_Trilogy
|
||||
Normal,
|
||||
WiiDeAsobu,
|
||||
Trilogy
|
||||
};
|
||||
|
||||
class CGameExporter
|
||||
|
|
|
@ -26,7 +26,7 @@ bool CGameProject::Save()
|
|||
{
|
||||
mProjFileLock.Release();
|
||||
TString ProjPath = ProjectPath();
|
||||
CXMLWriter Writer(ProjPath, "GameProject", eVer_Current, mGame);
|
||||
CXMLWriter Writer(ProjPath, "GameProject", (int) EProjectVersion::Current, mGame);
|
||||
Serialize(Writer);
|
||||
bool SaveSuccess = Writer.Save();
|
||||
mProjFileLock.Lock(*ProjPath);
|
||||
|
|
|
@ -15,6 +15,15 @@
|
|||
|
||||
namespace nod { class DiscWii; }
|
||||
|
||||
enum class EProjectVersion
|
||||
{
|
||||
Initial,
|
||||
// Add new versions before this line
|
||||
|
||||
Max,
|
||||
Current = EProjectVersion::Max - 1
|
||||
};
|
||||
|
||||
class CGameProject
|
||||
{
|
||||
TString mProjectName;
|
||||
|
@ -33,14 +42,6 @@ class CGameProject
|
|||
// in multiple instances of PWE
|
||||
CFileLock mProjFileLock;
|
||||
|
||||
enum EProjectVersion
|
||||
{
|
||||
eVer_Initial,
|
||||
|
||||
eVer_Max,
|
||||
eVer_Current = eVer_Max - 1
|
||||
};
|
||||
|
||||
// Private Constructor
|
||||
CGameProject()
|
||||
: mProjectName("Unnamed Project")
|
||||
|
|
|
@ -7,7 +7,7 @@ COpeningBanner::COpeningBanner(CGameProject *pProj)
|
|||
mWii = mpProj->IsWiiBuild();
|
||||
|
||||
TString BannerPath = mpProj->DiscFilesystemRoot(false) + "opening.bnr";
|
||||
CFileInStream Banner(BannerPath, IOUtil::eBigEndian);
|
||||
CFileInStream Banner(BannerPath, EEndian::BigEndian);
|
||||
|
||||
if (Banner.IsValid())
|
||||
{
|
||||
|
@ -20,7 +20,7 @@ TString COpeningBanner::EnglishGameName() const
|
|||
{
|
||||
// opening.bnr stores the game name in a fixed-length buffer. Need to account for
|
||||
// this and prevent the string-reading function from overrunning the buffer
|
||||
CMemoryInStream Banner(mBannerData.data(), mBannerData.size(), IOUtil::eBigEndian);
|
||||
CMemoryInStream Banner(mBannerData.data(), mBannerData.size(), EEndian::BigEndian);
|
||||
|
||||
uint32 CharSize = mWii ? 2 : 1;
|
||||
uint32 MaxLen = MaxGameNameLength();
|
||||
|
@ -29,13 +29,13 @@ TString COpeningBanner::EnglishGameName() const
|
|||
Banner.GoTo( mWii ? 0xB0 : 0x1860 );
|
||||
Banner.ReadBytes(NameBuffer.data(), MaxLen * CharSize);
|
||||
|
||||
Banner.SetData(NameBuffer.data(), NameBuffer.size(), IOUtil::eBigEndian);
|
||||
Banner.SetData(NameBuffer.data(), NameBuffer.size(), EEndian::BigEndian);
|
||||
return mWii ? Banner.ReadWString().ToUTF8() : Banner.ReadString();
|
||||
}
|
||||
|
||||
void COpeningBanner::SetEnglishGameName(const TString& rkName)
|
||||
{
|
||||
CMemoryOutStream Banner(mBannerData.data(), mBannerData.size(), IOUtil::eBigEndian);
|
||||
CMemoryOutStream Banner(mBannerData.data(), mBannerData.size(), EEndian::BigEndian);
|
||||
uint32 PadCount = 0;
|
||||
|
||||
uint32 MaxLen = MaxGameNameLength();
|
||||
|
@ -61,7 +61,7 @@ void COpeningBanner::SetEnglishGameName(const TString& rkName)
|
|||
void COpeningBanner::Save()
|
||||
{
|
||||
TString BannerPath = mpProj->DiscFilesystemRoot(false) + "opening.bnr";
|
||||
CFileOutStream Banner(BannerPath, IOUtil::eBigEndian);
|
||||
CFileOutStream Banner(BannerPath, EEndian::BigEndian);
|
||||
Banner.WriteBytes(mBannerData.data(), mBannerData.size());
|
||||
}
|
||||
|
||||
|
|
|
@ -73,7 +73,7 @@ void CPackage::Cook(IProgressNotifier *pProgress)
|
|||
|
||||
// Write new pak
|
||||
TString PakPath = CookedPackagePath(false);
|
||||
CFileOutStream Pak(PakPath, IOUtil::eBigEndian);
|
||||
CFileOutStream Pak(PakPath, EEndian::BigEndian);
|
||||
|
||||
if (!Pak.IsValid())
|
||||
{
|
||||
|
@ -191,7 +191,7 @@ void CPackage::Cook(IProgressNotifier *pProgress)
|
|||
rTableInfo.Offset = (Game <= EGame::Echoes ? AssetOffset : AssetOffset - ResDataOffset);
|
||||
|
||||
// Load resource data
|
||||
CFileInStream CookedAsset(pEntry->CookedAssetPath(), IOUtil::eBigEndian);
|
||||
CFileInStream CookedAsset(pEntry->CookedAssetPath(), EEndian::BigEndian);
|
||||
ASSERT(CookedAsset.IsValid());
|
||||
uint32 ResourceSize = CookedAsset.Size();
|
||||
|
||||
|
@ -200,24 +200,28 @@ void CPackage::Cook(IProgressNotifier *pProgress)
|
|||
|
||||
// Check if this asset should be compressed; there are a few resource types that are
|
||||
// always compressed, and some types that are compressed if they're over a certain size
|
||||
EResType Type = pEntry->ResourceType();
|
||||
EResourceType Type = pEntry->ResourceType();
|
||||
uint32 CompressThreshold = (Game <= EGame::CorruptionProto ? 0x400 : 0x80);
|
||||
|
||||
bool ShouldAlwaysCompress = (Type == eTexture || Type == eModel || Type == eSkin ||
|
||||
Type == eAnimSet || Type == eAnimation || Type == eFont);
|
||||
bool ShouldAlwaysCompress = (Type == EResourceType::Texture || Type == EResourceType::Model ||
|
||||
Type == EResourceType::Skin || Type == EResourceType::AnimSet ||
|
||||
Type == EResourceType::Animation || Type == EResourceType::Font);
|
||||
|
||||
if (Game >= EGame::Corruption)
|
||||
{
|
||||
ShouldAlwaysCompress = ShouldAlwaysCompress ||
|
||||
(Type == eCharacter || Type == eSourceAnimData || Type == eScan ||
|
||||
Type == eAudioSample || Type == eStringTable || Type == eAudioAmplitudeData ||
|
||||
Type == eDynamicCollision);
|
||||
(Type == EResourceType::Character || Type == EResourceType::SourceAnimData ||
|
||||
Type == EResourceType::Scan || Type == EResourceType::AudioSample ||
|
||||
Type == EResourceType::StringTable || Type == EResourceType::AudioAmplitudeData ||
|
||||
Type == EResourceType::DynamicCollision);
|
||||
}
|
||||
|
||||
bool ShouldCompressConditional = !ShouldAlwaysCompress &&
|
||||
(Type == eParticle || Type == eParticleElectric || Type == eParticleSwoosh ||
|
||||
Type == eParticleWeapon || Type == eParticleDecal || Type == eParticleCollisionResponse ||
|
||||
Type == eParticleSpawn || Type == eParticleSorted || Type == eBurstFireData);
|
||||
(Type == EResourceType::Particle || Type == EResourceType::ParticleElectric ||
|
||||
Type == EResourceType::ParticleSwoosh || Type == EResourceType::ParticleWeapon ||
|
||||
Type == EResourceType::ParticleDecal || Type == EResourceType::ParticleCollisionResponse ||
|
||||
Type == EResourceType::ParticleSpawn || Type == EResourceType::ParticleSorted ||
|
||||
Type == EResourceType::BurstFireData);
|
||||
|
||||
bool ShouldCompress = ShouldAlwaysCompress || (ShouldCompressConditional && ResourceSize >= CompressThreshold);
|
||||
|
||||
|
@ -342,7 +346,7 @@ void CPackage::CompareOriginalAssetList(const std::list<CAssetID>& rkNewList)
|
|||
|
||||
// Read the original pak
|
||||
TString CookedPath = CookedPackagePath(false);
|
||||
CFileInStream Pak(CookedPath, IOUtil::eBigEndian);
|
||||
CFileInStream Pak(CookedPath, EEndian::BigEndian);
|
||||
|
||||
if (!Pak.IsValid() || Pak.Size() == 0)
|
||||
{
|
||||
|
@ -373,7 +377,7 @@ void CPackage::CompareOriginalAssetList(const std::list<CAssetID>& rkNewList)
|
|||
for (uint32 iRes = 0; iRes < NumResources; iRes++)
|
||||
{
|
||||
Pak.Seek(0x8, SEEK_CUR);
|
||||
OldListSet.insert( CAssetID(Pak, e32Bit) );
|
||||
OldListSet.insert( CAssetID(Pak, k32Bit) );
|
||||
Pak.Seek(0x8, SEEK_CUR);
|
||||
}
|
||||
}
|
||||
|
@ -397,7 +401,7 @@ void CPackage::CompareOriginalAssetList(const std::list<CAssetID>& rkNewList)
|
|||
for (uint32 iRes = 0; iRes < NumResources; iRes++)
|
||||
{
|
||||
Pak.Seek(0x8, SEEK_CUR);
|
||||
OldListSet.insert( CAssetID(Pak, e64Bit) );
|
||||
OldListSet.insert( CAssetID(Pak, k64Bit) );
|
||||
Pak.Seek(0x8, SEEK_CUR);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,6 +9,15 @@
|
|||
|
||||
class CGameProject;
|
||||
|
||||
enum class EPackageDefinitionVersion
|
||||
{
|
||||
Initial,
|
||||
// Add new versions before this line
|
||||
|
||||
Max,
|
||||
Current = EPackageDefinitionVersion::Max - 1
|
||||
};
|
||||
|
||||
struct SNamedResource
|
||||
{
|
||||
TString Name;
|
||||
|
@ -35,14 +44,6 @@ class CPackage
|
|||
mutable bool mCacheDirty;
|
||||
mutable std::set<CAssetID> mCachedDependencies;
|
||||
|
||||
enum EPackageDefinitionVersion
|
||||
{
|
||||
eVer_Initial,
|
||||
|
||||
eVer_Max,
|
||||
eVer_Current = eVer_Max - 1
|
||||
};
|
||||
|
||||
public:
|
||||
CPackage() {}
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@ CResourceEntry::CResourceEntry(CResourceStore *pStore)
|
|||
// Static constructors
|
||||
CResourceEntry* CResourceEntry::CreateNewResource(CResourceStore *pStore, const CAssetID& rkID,
|
||||
const TString& rkDir, const TString& rkName,
|
||||
EResType Type)
|
||||
EResourceType Type)
|
||||
{
|
||||
// Initialize all entry info with the input data.
|
||||
CResourceEntry *pEntry = new CResourceEntry(pStore);
|
||||
|
@ -257,7 +257,7 @@ bool CResourceEntry::NeedsRecook() const
|
|||
// toggled to arbitrarily flag any asset for recook.
|
||||
if (!HasRawVersion()) return false;
|
||||
if (!HasCookedVersion()) return true;
|
||||
if (HasFlag(eREF_NeedsRecook)) return true;
|
||||
if (HasFlag(EResEntryFlag::NeedsRecook)) return true;
|
||||
return (FileUtil::LastModifiedTime(CookedAssetPath()) < FileUtil::LastModifiedTime(RawAssetPath()));
|
||||
}
|
||||
|
||||
|
@ -298,7 +298,7 @@ bool CResourceEntry::Save(bool SkipCacheSave /*= false*/)
|
|||
return false;
|
||||
}
|
||||
|
||||
SetFlag(eREF_NeedsRecook);
|
||||
SetFlag(EResEntryFlag::NeedsRecook);
|
||||
}
|
||||
|
||||
// This resource type doesn't have a raw format; save cooked instead
|
||||
|
@ -314,7 +314,7 @@ bool CResourceEntry::Save(bool SkipCacheSave /*= false*/)
|
|||
}
|
||||
|
||||
// Resource has been saved; now make sure metadata, dependencies, and packages are all up to date
|
||||
SetFlag(eREF_HasBeenModified);
|
||||
SetFlag(EResEntryFlag::HasBeenModified);
|
||||
SaveMetadata();
|
||||
UpdateDependencies();
|
||||
|
||||
|
@ -348,7 +348,7 @@ bool CResourceEntry::Cook()
|
|||
FileUtil::MakeDirectory(Dir);
|
||||
|
||||
// Attempt to open output cooked file
|
||||
CFileOutStream File(Path, IOUtil::eBigEndian);
|
||||
CFileOutStream File(Path, EEndian::BigEndian);
|
||||
if (!File.IsValid())
|
||||
{
|
||||
errorf("Failed to open cooked file for writing: %s", *Path);
|
||||
|
@ -359,8 +359,8 @@ bool CResourceEntry::Cook()
|
|||
|
||||
if (Success)
|
||||
{
|
||||
ClearFlag(eREF_NeedsRecook);
|
||||
SetFlag(eREF_HasBeenModified);
|
||||
ClearFlag(EResEntryFlag::NeedsRecook);
|
||||
SetFlag(EResEntryFlag::HasBeenModified);
|
||||
SaveMetadata();
|
||||
}
|
||||
|
||||
|
@ -409,7 +409,7 @@ CResource* CResourceEntry::Load()
|
|||
ASSERT(!mpResource);
|
||||
if (HasCookedVersion())
|
||||
{
|
||||
CFileInStream File(CookedAssetPath(), IOUtil::eBigEndian);
|
||||
CFileInStream File(CookedAssetPath(), EEndian::BigEndian);
|
||||
|
||||
if (!File.IsValid())
|
||||
{
|
||||
|
@ -571,12 +571,12 @@ bool CResourceEntry::MoveAndRename(const TString& rkDir, const TString& rkName,
|
|||
FSMoveSuccess = pOldDir->RemoveChildResource(this);
|
||||
ASSERT(FSMoveSuccess == true); // this shouldn't be able to fail
|
||||
mpDirectory->AddChild("", this);
|
||||
SetFlagEnabled(eREF_AutoResDir, IsAutoGenDir);
|
||||
SetFlagEnabled(EResEntryFlag::AutoResDir, IsAutoGenDir);
|
||||
}
|
||||
|
||||
if (mName != OldName)
|
||||
{
|
||||
SetFlagEnabled(eREF_AutoResName, IsAutoGenName);
|
||||
SetFlagEnabled(EResEntryFlag::AutoResName, IsAutoGenName);
|
||||
}
|
||||
|
||||
mpStore->SetCacheDirty();
|
||||
|
|
|
@ -13,14 +13,14 @@ class CResource;
|
|||
class CGameProject;
|
||||
class CDependencyTree;
|
||||
|
||||
enum EResEntryFlag
|
||||
enum class EResEntryFlag
|
||||
{
|
||||
eREF_NeedsRecook = 0x00000001, // Resource has been updated but not recooked
|
||||
eREF_IsBaseGameResource = 0x00000002, // Resource is from the original game, not user-created
|
||||
eREF_Hidden = 0x00000004, // Resource is hidden, doesn't show up in resource browser
|
||||
eREF_HasBeenModified = 0x00000008, // Resource has been modified and resaved by the user
|
||||
eREF_AutoResName = 0x00000010, // Resource name is auto-generated
|
||||
eREF_AutoResDir = 0x00000020, // Resource directory name is auto-generated
|
||||
NeedsRecook = 0x00000001, // Resource has been updated but not recooked
|
||||
IsBaseGameResource = 0x00000002, // Resource is from the original game, not user-created
|
||||
Hidden = 0x00000004, // Resource is hidden, doesn't show up in resource browser
|
||||
HasBeenModified = 0x00000008, // Resource has been modified and resaved by the user
|
||||
AutoResName = 0x00000010, // Resource name is auto-generated
|
||||
AutoResDir = 0x00000020, // Resource directory name is auto-generated
|
||||
};
|
||||
DECLARE_FLAGS(EResEntryFlag, FResEntryFlags)
|
||||
|
||||
|
@ -45,7 +45,7 @@ class CResourceEntry
|
|||
public:
|
||||
static CResourceEntry* CreateNewResource(CResourceStore *pStore, const CAssetID& rkID,
|
||||
const TString& rkDir, const TString& rkName,
|
||||
EResType Type);
|
||||
EResourceType Type);
|
||||
static CResourceEntry* BuildFromArchive(CResourceStore *pStore, IArchive& rArc);
|
||||
static CResourceEntry* BuildFromDirectory(CResourceStore *pStore, CResTypeInfo *pTypeInfo,
|
||||
const TString& rkDirPath, const TString& rkName);
|
||||
|
@ -86,10 +86,10 @@ public:
|
|||
// Accessors
|
||||
inline void SetFlagEnabled(EResEntryFlag Flag, bool Enabled) { Enabled ? SetFlag(Flag) : ClearFlag(Flag); }
|
||||
|
||||
inline void SetDirty() { SetFlag(eREF_NeedsRecook); }
|
||||
inline void SetHidden(bool Hidden) { Hidden ? SetFlag(eREF_Hidden) : ClearFlag(eREF_Hidden); }
|
||||
inline void SetDirty() { SetFlag(EResEntryFlag::NeedsRecook); }
|
||||
inline void SetHidden(bool Hidden) { Hidden ? SetFlag(EResEntryFlag::Hidden) : ClearFlag(EResEntryFlag::Hidden); }
|
||||
inline bool HasFlag(EResEntryFlag Flag) const { return mFlags.HasFlag(Flag); }
|
||||
inline bool IsHidden() const { return HasFlag(eREF_Hidden); }
|
||||
inline bool IsHidden() const { return HasFlag(EResEntryFlag::Hidden); }
|
||||
|
||||
inline bool IsLoaded() const { return mpResource != nullptr; }
|
||||
inline bool IsCategorized() const { return mpDirectory && !mpDirectory->FullPath().CaseInsensitiveCompare( mpStore->DefaultResourceDirPath() ); }
|
||||
|
@ -103,7 +103,7 @@ public:
|
|||
inline TString DirectoryPath() const { return mpDirectory->FullPath(); }
|
||||
inline TString Name() const { return mName; }
|
||||
inline const TString& UppercaseName() const { return mCachedUppercaseName; }
|
||||
inline EResType ResourceType() const { return mpTypeInfo->Type(); }
|
||||
inline EResourceType ResourceType() const { return mpTypeInfo->Type(); }
|
||||
|
||||
protected:
|
||||
CResource* InternalLoad(IInputStream& rInput);
|
||||
|
|
|
@ -66,7 +66,7 @@ public:
|
|||
}
|
||||
};
|
||||
|
||||
template<EResType ResType>
|
||||
template<EResourceType ResType>
|
||||
class TResourceIterator : public CResourceIterator
|
||||
{
|
||||
public:
|
||||
|
|
|
@ -384,7 +384,7 @@ bool CResourceStore::IsResourceRegistered(const CAssetID& rkID) const
|
|||
return FindEntry(rkID) != nullptr;
|
||||
}
|
||||
|
||||
CResourceEntry* CResourceStore::RegisterResource(const CAssetID& rkID, EResType Type, const TString& rkDir, const TString& rkName)
|
||||
CResourceEntry* CResourceStore::RegisterResource(const CAssetID& rkID, EResourceType Type, const TString& rkDir, const TString& rkName)
|
||||
{
|
||||
CResourceEntry *pEntry = FindEntry(rkID);
|
||||
|
||||
|
@ -424,7 +424,7 @@ CResource* CResourceStore::LoadResource(const CAssetID& rkID)
|
|||
}
|
||||
}
|
||||
|
||||
CResource* CResourceStore::LoadResource(const CAssetID& rkID, EResType Type)
|
||||
CResource* CResourceStore::LoadResource(const CAssetID& rkID, EResourceType Type)
|
||||
{
|
||||
CResource *pRes = LoadResource(rkID);
|
||||
|
||||
|
|
|
@ -14,6 +14,15 @@ class CGameExporter;
|
|||
class CGameProject;
|
||||
class CResource;
|
||||
|
||||
enum class EDatabaseVersion
|
||||
{
|
||||
Initial,
|
||||
// Add new versions before this line
|
||||
|
||||
Max,
|
||||
Current = EDatabaseVersion::Max - 1
|
||||
};
|
||||
|
||||
class CResourceStore
|
||||
{
|
||||
friend class CResourceIterator;
|
||||
|
@ -28,14 +37,6 @@ class CResourceStore
|
|||
// Directory paths
|
||||
TString mDatabasePath;
|
||||
|
||||
enum EDatabaseVersion
|
||||
{
|
||||
eVer_Initial,
|
||||
|
||||
eVer_Max,
|
||||
eVer_Current = eVer_Max - 1
|
||||
};
|
||||
|
||||
public:
|
||||
CResourceStore(const TString& rkDatabasePath);
|
||||
CResourceStore(CGameProject *pProject);
|
||||
|
@ -53,7 +54,7 @@ public:
|
|||
TString DefaultResourceDirPath() const;
|
||||
|
||||
bool IsResourceRegistered(const CAssetID& rkID) const;
|
||||
CResourceEntry* RegisterResource(const CAssetID& rkID, EResType Type, const TString& rkDir, const TString& rkName);
|
||||
CResourceEntry* RegisterResource(const CAssetID& rkID, EResourceType Type, const TString& rkDir, const TString& rkName);
|
||||
CResourceEntry* FindEntry(const CAssetID& rkID) const;
|
||||
CResourceEntry* FindEntry(const TString& rkPath) const;
|
||||
bool AreAllEntriesValid() const;
|
||||
|
@ -63,7 +64,7 @@ public:
|
|||
|
||||
template<typename ResType> ResType* LoadResource(const CAssetID& rkID) { return static_cast<ResType*>(LoadResource(rkID, ResType::StaticType())); }
|
||||
CResource* LoadResource(const CAssetID& rkID);
|
||||
CResource* LoadResource(const CAssetID& rkID, EResType Type);
|
||||
CResource* LoadResource(const CAssetID& rkID, EResourceType Type);
|
||||
CResource* LoadResource(const TString& rkPath);
|
||||
void TrackLoadedResource(CResourceEntry *pEntry);
|
||||
void DestroyUnreferencedResources();
|
||||
|
|
|
@ -117,14 +117,14 @@ CResourceEntry* CVirtualDirectory::FindChildResource(const TString& rkPath)
|
|||
else if (!Name.IsEmpty())
|
||||
{
|
||||
TString Ext = Name.GetFileExtension();
|
||||
EResType Type = CResTypeInfo::TypeForCookedExtension(mpStore->Game(), Ext)->Type();
|
||||
EResourceType Type = CResTypeInfo::TypeForCookedExtension(mpStore->Game(), Ext)->Type();
|
||||
return FindChildResource(Name.GetFileName(false), Type);
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
CResourceEntry* CVirtualDirectory::FindChildResource(const TString& rkName, EResType Type)
|
||||
CResourceEntry* CVirtualDirectory::FindChildResource(const TString& rkName, EResourceType Type)
|
||||
{
|
||||
for (uint32 iRes = 0; iRes < mResources.size(); iRes++)
|
||||
{
|
||||
|
|
|
@ -31,7 +31,7 @@ public:
|
|||
CVirtualDirectory* GetRoot();
|
||||
CVirtualDirectory* FindChildDirectory(const TString& rkName, bool AllowCreate);
|
||||
CResourceEntry* FindChildResource(const TString& rkPath);
|
||||
CResourceEntry* FindChildResource(const TString& rkName, EResType Type);
|
||||
CResourceEntry* FindChildResource(const TString& rkName, EResourceType Type);
|
||||
bool AddChild(const TString& rkPath, CResourceEntry *pEntry);
|
||||
bool AddChild(CVirtualDirectory *pDir);
|
||||
bool RemoveChildDirectory(CVirtualDirectory *pSubdir);
|
||||
|
|
|
@ -35,7 +35,7 @@ void CCharacterUsageMap::FindUsagesForAsset(CResourceEntry *pEntry)
|
|||
|
||||
void CCharacterUsageMap::FindUsagesForArea(CWorld *pWorld, CResourceEntry *pEntry)
|
||||
{
|
||||
ASSERT(pEntry->ResourceType() == eArea);
|
||||
ASSERT(pEntry->ResourceType() == EResourceType::Area);
|
||||
|
||||
for (uint32 iArea = 0; iArea < pWorld->NumAreas(); iArea++)
|
||||
{
|
||||
|
@ -59,7 +59,7 @@ void CCharacterUsageMap::FindUsagesForArea(CWorld *pWorld, uint32 AreaIndex)
|
|||
|
||||
CAssetID AreaID = pWorld->AreaResourceID(iArea);
|
||||
CResourceEntry *pEntry = mpStore->FindEntry(AreaID);
|
||||
ASSERT(pEntry && pEntry->ResourceType() == eArea);
|
||||
ASSERT(pEntry && pEntry->ResourceType() == EResourceType::Area);
|
||||
|
||||
ParseDependencyNode(pEntry->Dependencies());
|
||||
mIsInitialArea = false;
|
||||
|
@ -72,7 +72,7 @@ void CCharacterUsageMap::FindUsagesForLayer(CResourceEntry *pAreaEntry, uint32 L
|
|||
mLayerIndex = LayerIndex;
|
||||
|
||||
CAreaDependencyTree *pTree = static_cast<CAreaDependencyTree*>(pAreaEntry->Dependencies());
|
||||
ASSERT(pTree->Type() == eDNT_Area);
|
||||
ASSERT(pTree->Type() == EDependencyNodeType::Area);
|
||||
|
||||
// Only examine dependencies of the particular layer specified by the caller
|
||||
bool IsLastLayer = (mLayerIndex == pTree->NumScriptLayers() - 1);
|
||||
|
@ -115,7 +115,7 @@ void CCharacterUsageMap::ParseDependencyNode(IDependencyNode *pNode)
|
|||
{
|
||||
EDependencyNodeType Type = pNode->Type();
|
||||
|
||||
if (Type == eDNT_CharacterProperty)
|
||||
if (Type == EDependencyNodeType::CharacterProperty)
|
||||
{
|
||||
CCharPropertyDependency *pDep = static_cast<CCharPropertyDependency*>(pNode);
|
||||
CAssetID ResID = pDep->ID();
|
||||
|
@ -150,12 +150,12 @@ void CCharacterUsageMap::ParseDependencyNode(IDependencyNode *pNode)
|
|||
}
|
||||
|
||||
// Parse dependencies of the referenced resource if it's a type that can reference animsets
|
||||
else if (Type == eDNT_ResourceDependency || Type == eDNT_ScriptProperty)
|
||||
else if (Type == EDependencyNodeType::Resource || Type == EDependencyNodeType::ScriptProperty)
|
||||
{
|
||||
CResourceDependency *pDep = static_cast<CResourceDependency*>(pNode);
|
||||
CResourceEntry *pEntry = mpStore->FindEntry(pDep->ID());
|
||||
|
||||
if (pEntry && pEntry->ResourceType() == eScan)
|
||||
if (pEntry && pEntry->ResourceType() == EResourceType::Scan)
|
||||
{
|
||||
ParseDependencyNode(pEntry->Dependencies());
|
||||
}
|
||||
|
@ -206,17 +206,17 @@ void CPackageDependencyListBuilder::BuildDependencyList(bool AllowDuplicates, st
|
|||
|
||||
void CPackageDependencyListBuilder::AddDependency(CResourceEntry *pCurEntry, const CAssetID& rkID, std::list<CAssetID>& rOut)
|
||||
{
|
||||
if (pCurEntry && pCurEntry->ResourceType() == eDependencyGroup) return;
|
||||
if (pCurEntry && pCurEntry->ResourceType() == EResourceType::DependencyGroup) return;
|
||||
CResourceEntry *pEntry = mpStore->FindEntry(rkID);
|
||||
if (!pEntry) return;
|
||||
|
||||
EResType ResType = pEntry->ResourceType();
|
||||
EResourceType ResType = pEntry->ResourceType();
|
||||
|
||||
// Is this entry valid?
|
||||
bool IsValid = ResType != eMidi &&
|
||||
(ResType != eAudioGroup || mGame >= EGame::EchoesDemo) &&
|
||||
(ResType != eWorld || !pCurEntry) &&
|
||||
(ResType != eArea || !pCurEntry || pCurEntry->ResourceType() == eWorld);
|
||||
bool IsValid = ResType != EResourceType::Midi &&
|
||||
(ResType != EResourceType::AudioGroup || mGame >= EGame::EchoesDemo) &&
|
||||
(ResType != EResourceType::World || !pCurEntry) &&
|
||||
(ResType != EResourceType::Area || !pCurEntry || pCurEntry->ResourceType() == EResourceType::World);
|
||||
|
||||
if (!IsValid) return;
|
||||
|
||||
|
@ -230,7 +230,7 @@ void CPackageDependencyListBuilder::AddDependency(CResourceEntry *pCurEntry, con
|
|||
mAreaUsedAssets.insert(rkID);
|
||||
|
||||
// New area - toggle duplicates and find character usages
|
||||
if (ResType == eArea)
|
||||
if (ResType == EResourceType::Area)
|
||||
{
|
||||
if (mGame <= EGame::Echoes)
|
||||
mCharacterUsageMap.FindUsagesForArea(mpWorld, pEntry);
|
||||
|
@ -252,7 +252,7 @@ void CPackageDependencyListBuilder::AddDependency(CResourceEntry *pCurEntry, con
|
|||
}
|
||||
|
||||
// Animset - keep track of the current animset ID
|
||||
else if (ResType == eAnimSet)
|
||||
else if (ResType == EResourceType::AnimSet)
|
||||
mCurrentAnimSetID = rkID;
|
||||
|
||||
// Evaluate dependencies of this entry
|
||||
|
@ -261,11 +261,11 @@ void CPackageDependencyListBuilder::AddDependency(CResourceEntry *pCurEntry, con
|
|||
rOut.push_back(rkID);
|
||||
|
||||
// Revert current animset ID
|
||||
if (ResType == eAnimSet)
|
||||
if (ResType == EResourceType::AnimSet)
|
||||
mCurrentAnimSetID = CAssetID::InvalidID(mGame);
|
||||
|
||||
// Revert duplicate flag
|
||||
else if (ResType == eArea)
|
||||
else if (ResType == EResourceType::Area)
|
||||
mCurrentAreaHasDuplicates = false;
|
||||
}
|
||||
|
||||
|
@ -275,14 +275,14 @@ void CPackageDependencyListBuilder::EvaluateDependencyNode(CResourceEntry *pCurE
|
|||
bool ParseChildren = false;
|
||||
|
||||
// Straight resource dependencies should just be added to the tree directly
|
||||
if (Type == eDNT_ResourceDependency || Type == eDNT_ScriptProperty || Type == eDNT_CharacterProperty)
|
||||
if (Type == EDependencyNodeType::Resource || Type == EDependencyNodeType::ScriptProperty || Type == EDependencyNodeType::CharacterProperty)
|
||||
{
|
||||
CResourceDependency *pDep = static_cast<CResourceDependency*>(pNode);
|
||||
AddDependency(pCurEntry, pDep->ID(), rOut);
|
||||
}
|
||||
|
||||
// Anim events should be added if either they apply to characters, or their character index is used
|
||||
else if (Type == eDNT_AnimEvent)
|
||||
else if (Type == EDependencyNodeType::AnimEvent)
|
||||
{
|
||||
CAnimEventDependency *pDep = static_cast<CAnimEventDependency*>(pNode);
|
||||
uint32 CharIndex = pDep->CharIndex();
|
||||
|
@ -292,14 +292,14 @@ void CPackageDependencyListBuilder::EvaluateDependencyNode(CResourceEntry *pCurE
|
|||
}
|
||||
|
||||
// Set characters should only be added if their character index is used
|
||||
else if (Type == eDNT_SetCharacter)
|
||||
else if (Type == EDependencyNodeType::SetCharacter)
|
||||
{
|
||||
CSetCharacterDependency *pChar = static_cast<CSetCharacterDependency*>(pNode);
|
||||
ParseChildren = mCharacterUsageMap.IsCharacterUsed(mCurrentAnimSetID, pChar->CharSetIndex()) || mIsPlayerActor;
|
||||
}
|
||||
|
||||
// Set animations should only be added if they're being used by at least one used character
|
||||
else if (Type == eDNT_SetAnimation)
|
||||
else if (Type == EDependencyNodeType::SetAnimation)
|
||||
{
|
||||
CSetAnimationDependency *pAnim = static_cast<CSetAnimationDependency*>(pNode);
|
||||
ParseChildren = mCharacterUsageMap.IsAnimationUsed(mCurrentAnimSetID, pAnim) || (mIsPlayerActor && pAnim->IsUsedByAnyCharacter());
|
||||
|
@ -311,7 +311,7 @@ void CPackageDependencyListBuilder::EvaluateDependencyNode(CResourceEntry *pCurE
|
|||
// Analyze this node's children
|
||||
if (ParseChildren)
|
||||
{
|
||||
if (Type == eDNT_ScriptInstance)
|
||||
if (Type == EDependencyNodeType::ScriptInstance)
|
||||
{
|
||||
uint32 ObjType = static_cast<CScriptInstanceDependency*>(pNode)->ObjectType();
|
||||
mIsPlayerActor = (ObjType == 0x4C || ObjType == FOURCC('PLAC'));
|
||||
|
@ -320,7 +320,7 @@ void CPackageDependencyListBuilder::EvaluateDependencyNode(CResourceEntry *pCurE
|
|||
for (uint32 iChild = 0; iChild < pNode->NumChildren(); iChild++)
|
||||
EvaluateDependencyNode(pCurEntry, pNode->ChildByIndex(iChild), rOut);
|
||||
|
||||
if (Type == eDNT_ScriptInstance)
|
||||
if (Type == EDependencyNodeType::ScriptInstance)
|
||||
mIsPlayerActor = false;
|
||||
}
|
||||
}
|
||||
|
@ -388,7 +388,7 @@ void CAreaDependencyListBuilder::BuildDependencyList(std::list<CAssetID>& rAsset
|
|||
for (uint32 iDep = 0; iDep < BaseEndIndex; iDep++)
|
||||
{
|
||||
CResourceDependency *pRes = static_cast<CResourceDependency*>(pTree->ChildByIndex(iDep));
|
||||
ASSERT(pRes->Type() == eDNT_ResourceDependency);
|
||||
ASSERT(pRes->Type() == EDependencyNodeType::Resource);
|
||||
mBaseUsedAssets.insert(pRes->ID());
|
||||
}
|
||||
|
||||
|
@ -407,7 +407,7 @@ void CAreaDependencyListBuilder::BuildDependencyList(std::list<CAssetID>& rAsset
|
|||
{
|
||||
IDependencyNode *pNode = pTree->ChildByIndex(iChild);
|
||||
|
||||
if (pNode->Type() == eDNT_ScriptInstance)
|
||||
if (pNode->Type() == EDependencyNodeType::ScriptInstance)
|
||||
{
|
||||
CScriptInstanceDependency *pInst = static_cast<CScriptInstanceDependency*>(pNode);
|
||||
mIsPlayerActor = (pInst->ObjectType() == 0x4C || pInst->ObjectType() == FOURCC('PLAC'));
|
||||
|
@ -435,7 +435,7 @@ void CAreaDependencyListBuilder::BuildDependencyList(std::list<CAssetID>& rAsset
|
|||
AddDependency(pDep->ID(), rAssetsOut, pAudioGroupsOut);
|
||||
}
|
||||
}
|
||||
else if (pNode->Type() == eDNT_ResourceDependency)
|
||||
else if (pNode->Type() == EDependencyNodeType::Resource)
|
||||
{
|
||||
CResourceDependency *pResDep = static_cast<CResourceDependency*>(pNode);
|
||||
AddDependency(pResDep->ID(), rAssetsOut, pAudioGroupsOut);
|
||||
|
@ -464,10 +464,10 @@ void CAreaDependencyListBuilder::AddDependency(const CAssetID& rkID, std::list<C
|
|||
CResourceEntry *pEntry = mpStore->FindEntry(rkID);
|
||||
if (!pEntry) return;
|
||||
|
||||
EResType ResType = pEntry->ResourceType();
|
||||
EResourceType ResType = pEntry->ResourceType();
|
||||
|
||||
// If this is an audio group, for MP1, save it in the output set. For MP2, treat audio groups as a normal dependency.
|
||||
if (mGame <= EGame::Prime && ResType == eAudioGroup)
|
||||
if (mGame <= EGame::Prime && ResType == EResourceType::AudioGroup)
|
||||
{
|
||||
if (pAudioGroupsOut)
|
||||
pAudioGroupsOut->insert(rkID);
|
||||
|
@ -475,20 +475,20 @@ void CAreaDependencyListBuilder::AddDependency(const CAssetID& rkID, std::list<C
|
|||
}
|
||||
|
||||
// If this is an audio stream, skip
|
||||
if (ResType == eStreamedAudio)
|
||||
if (ResType == EResourceType::StreamedAudio)
|
||||
return;
|
||||
|
||||
// Check to ensure this is a valid/new dependency
|
||||
if (ResType == eWorld || ResType == eArea)
|
||||
if (ResType == EResourceType::World || ResType == EResourceType::Area)
|
||||
return;
|
||||
|
||||
if (mBaseUsedAssets.find(rkID) != mBaseUsedAssets.end() || mLayerUsedAssets.find(rkID) != mLayerUsedAssets.end())
|
||||
return;
|
||||
|
||||
// Dependency is valid! Evaluate the node tree (except for SCAN and DGRP)
|
||||
if (ResType != eScan && ResType != eDependencyGroup)
|
||||
if (ResType != EResourceType::Scan && ResType != EResourceType::DependencyGroup)
|
||||
{
|
||||
if (ResType == eAnimSet)
|
||||
if (ResType == EResourceType::AnimSet)
|
||||
{
|
||||
ASSERT(!mCurrentAnimSetID.IsValid());
|
||||
mCurrentAnimSetID = pEntry->ID();
|
||||
|
@ -496,7 +496,7 @@ void CAreaDependencyListBuilder::AddDependency(const CAssetID& rkID, std::list<C
|
|||
|
||||
EvaluateDependencyNode(pEntry, pEntry->Dependencies(), rOut, pAudioGroupsOut);
|
||||
|
||||
if (ResType == eAnimSet)
|
||||
if (ResType == EResourceType::AnimSet)
|
||||
{
|
||||
ASSERT(mCurrentAnimSetID.IsValid());
|
||||
mCurrentAnimSetID = CAssetID::InvalidID(mGame);
|
||||
|
@ -504,7 +504,7 @@ void CAreaDependencyListBuilder::AddDependency(const CAssetID& rkID, std::list<C
|
|||
}
|
||||
|
||||
// Don't add CSNGs to the output dependency list (we parse them because we need their AGSC dependencies in the output AudioGroup set)
|
||||
if (ResType != eMidi)
|
||||
if (ResType != EResourceType::Midi)
|
||||
{
|
||||
rOut.push_back(rkID);
|
||||
mLayerUsedAssets.insert(rkID);
|
||||
|
@ -516,13 +516,13 @@ void CAreaDependencyListBuilder::EvaluateDependencyNode(CResourceEntry *pCurEntr
|
|||
EDependencyNodeType Type = pNode->Type();
|
||||
bool ParseChildren = false;
|
||||
|
||||
if (Type == eDNT_ResourceDependency || Type == eDNT_ScriptProperty || Type == eDNT_CharacterProperty)
|
||||
if (Type == EDependencyNodeType::Resource || Type == EDependencyNodeType::ScriptProperty || Type == EDependencyNodeType::CharacterProperty)
|
||||
{
|
||||
CResourceDependency *pDep = static_cast<CResourceDependency*>(pNode);
|
||||
AddDependency(pDep->ID(), rOut, pAudioGroupsOut);
|
||||
}
|
||||
|
||||
else if (Type == eDNT_AnimEvent)
|
||||
else if (Type == EDependencyNodeType::AnimEvent)
|
||||
{
|
||||
CAnimEventDependency *pDep = static_cast<CAnimEventDependency*>(pNode);
|
||||
uint32 CharIndex = pDep->CharIndex();
|
||||
|
@ -531,7 +531,7 @@ void CAreaDependencyListBuilder::EvaluateDependencyNode(CResourceEntry *pCurEntr
|
|||
AddDependency(pDep->ID(), rOut, pAudioGroupsOut);
|
||||
}
|
||||
|
||||
else if (Type == eDNT_SetCharacter)
|
||||
else if (Type == EDependencyNodeType::SetCharacter)
|
||||
{
|
||||
// Note: For MP1/2 PlayerActor, always treat as if Empty Suit is the only used one
|
||||
const uint32 kEmptySuitIndex = (mGame >= EGame::EchoesDemo ? 3 : 5);
|
||||
|
@ -541,7 +541,7 @@ void CAreaDependencyListBuilder::EvaluateDependencyNode(CResourceEntry *pCurEntr
|
|||
ParseChildren = mCharacterUsageMap.IsCharacterUsed(mCurrentAnimSetID, pChar->CharSetIndex()) || (mIsPlayerActor && SetIndex == kEmptySuitIndex);
|
||||
}
|
||||
|
||||
else if (Type == eDNT_SetAnimation)
|
||||
else if (Type == EDependencyNodeType::SetAnimation)
|
||||
{
|
||||
CSetAnimationDependency *pAnim = static_cast<CSetAnimationDependency*>(pNode);
|
||||
ParseChildren = mCharacterUsageMap.IsAnimationUsed(mCurrentAnimSetID, pAnim) || (mIsPlayerActor && pAnim->IsUsedByAnyCharacter());
|
||||
|
|
|
@ -88,7 +88,7 @@ public:
|
|||
, mGame(pAreaEntry->Game())
|
||||
, mCharacterUsageMap(pAreaEntry->ResourceStore())
|
||||
{
|
||||
ASSERT(mpAreaEntry->ResourceType() == eArea);
|
||||
ASSERT(mpAreaEntry->ResourceType() == EResourceType::Area);
|
||||
}
|
||||
|
||||
void BuildDependencyList(std::list<CAssetID>& rAssetsOut, std::list<uint32>& rLayerOffsetsOut, std::set<CAssetID> *pAudioGroupsOut = nullptr);
|
||||
|
|
|
@ -6,8 +6,8 @@ static const uint32 gskAttribSize[] = {
|
|||
};
|
||||
|
||||
CDynamicVertexBuffer::CDynamicVertexBuffer()
|
||||
: mAttribFlags(eNoAttributes)
|
||||
, mBufferedFlags(eNoAttributes)
|
||||
: mAttribFlags(EVertexAttribute::None)
|
||||
, mBufferedFlags(EVertexAttribute::None)
|
||||
, mNumVertices(0)
|
||||
{
|
||||
}
|
||||
|
@ -48,18 +48,18 @@ void CDynamicVertexBuffer::BufferAttrib(EVertexAttribute Attrib, const void *pkD
|
|||
|
||||
switch (Attrib)
|
||||
{
|
||||
case ePosition: Index = 0; break;
|
||||
case eNormal: Index = 1; break;
|
||||
case eColor0: Index = 2; break;
|
||||
case eColor1: Index = 3; break;
|
||||
case eTex0: Index = 4; break;
|
||||
case eTex1: Index = 5; break;
|
||||
case eTex2: Index = 6; break;
|
||||
case eTex3: Index = 7; break;
|
||||
case eTex4: Index = 8; break;
|
||||
case eTex5: Index = 9; break;
|
||||
case eTex6: Index = 10; break;
|
||||
case eTex7: Index = 11; break;
|
||||
case EVertexAttribute::Position: Index = 0; break;
|
||||
case EVertexAttribute::Normal: Index = 1; break;
|
||||
case EVertexAttribute::Color0: Index = 2; break;
|
||||
case EVertexAttribute::Color1: Index = 3; break;
|
||||
case EVertexAttribute::Tex0: Index = 4; break;
|
||||
case EVertexAttribute::Tex1: Index = 5; break;
|
||||
case EVertexAttribute::Tex2: Index = 6; break;
|
||||
case EVertexAttribute::Tex3: Index = 7; break;
|
||||
case EVertexAttribute::Tex4: Index = 8; break;
|
||||
case EVertexAttribute::Tex5: Index = 9; break;
|
||||
case EVertexAttribute::Tex6: Index = 10; break;
|
||||
case EVertexAttribute::Tex7: Index = 11; break;
|
||||
default: return;
|
||||
}
|
||||
|
||||
|
@ -77,7 +77,7 @@ void CDynamicVertexBuffer::ClearBuffers()
|
|||
glDeleteBuffers(1, &mAttribBuffers[iAttrib]);
|
||||
}
|
||||
|
||||
mBufferedFlags = eNoAttributes;
|
||||
mBufferedFlags = EVertexAttribute::None;
|
||||
}
|
||||
|
||||
GLuint CDynamicVertexBuffer::CreateVAO()
|
||||
|
|
|
@ -155,29 +155,29 @@ bool CShaderGenerator::CreateVertexShader(const CMaterial& rkMat)
|
|||
// Input
|
||||
ShaderCode << "// Input\n";
|
||||
FVertexDescription VtxDesc = rkMat.VtxDesc();
|
||||
ASSERT(VtxDesc & ePosition);
|
||||
ASSERT(VtxDesc & EVertexAttribute::Position);
|
||||
|
||||
ShaderCode << "layout(location = 0) in vec3 RawPosition;\n";
|
||||
if (VtxDesc & eNormal) ShaderCode << "layout(location = 1) in vec3 RawNormal;\n";
|
||||
if (VtxDesc & eColor0) ShaderCode << "layout(location = 2) in vec4 RawColor0;\n";
|
||||
if (VtxDesc & eColor1) ShaderCode << "layout(location = 3) in vec4 RawColor1;\n";
|
||||
if (VtxDesc & eTex0) ShaderCode << "layout(location = 4) in vec2 RawTex0;\n";
|
||||
if (VtxDesc & eTex1) ShaderCode << "layout(location = 5) in vec2 RawTex1;\n";
|
||||
if (VtxDesc & eTex2) ShaderCode << "layout(location = 6) in vec2 RawTex2;\n";
|
||||
if (VtxDesc & eTex3) ShaderCode << "layout(location = 7) in vec2 RawTex3;\n";
|
||||
if (VtxDesc & eTex4) ShaderCode << "layout(location = 8) in vec2 RawTex4;\n";
|
||||
if (VtxDesc & eTex5) ShaderCode << "layout(location = 9) in vec2 RawTex5;\n";
|
||||
if (VtxDesc & eTex6) ShaderCode << "layout(location = 10) in vec2 RawTex6;\n";
|
||||
if (VtxDesc & eTex7) ShaderCode << "layout(location = 11) in vec2 RawTex7;\n";
|
||||
if (VtxDesc & eBoneIndices) ShaderCode << "layout(location = 12) in int BoneIndices;\n";
|
||||
if (VtxDesc & eBoneWeights) ShaderCode << "layout(location = 13) in vec4 BoneWeights;\n";
|
||||
if (VtxDesc & EVertexAttribute::Normal) ShaderCode << "layout(location = 1) in vec3 RawNormal;\n";
|
||||
if (VtxDesc & EVertexAttribute::Color0) ShaderCode << "layout(location = 2) in vec4 RawColor0;\n";
|
||||
if (VtxDesc & EVertexAttribute::Color1) ShaderCode << "layout(location = 3) in vec4 RawColor1;\n";
|
||||
if (VtxDesc & EVertexAttribute::Tex0) ShaderCode << "layout(location = 4) in vec2 RawTex0;\n";
|
||||
if (VtxDesc & EVertexAttribute::Tex1) ShaderCode << "layout(location = 5) in vec2 RawTex1;\n";
|
||||
if (VtxDesc & EVertexAttribute::Tex2) ShaderCode << "layout(location = 6) in vec2 RawTex2;\n";
|
||||
if (VtxDesc & EVertexAttribute::Tex3) ShaderCode << "layout(location = 7) in vec2 RawTex3;\n";
|
||||
if (VtxDesc & EVertexAttribute::Tex4) ShaderCode << "layout(location = 8) in vec2 RawTex4;\n";
|
||||
if (VtxDesc & EVertexAttribute::Tex5) ShaderCode << "layout(location = 9) in vec2 RawTex5;\n";
|
||||
if (VtxDesc & EVertexAttribute::Tex6) ShaderCode << "layout(location = 10) in vec2 RawTex6;\n";
|
||||
if (VtxDesc & EVertexAttribute::Tex7) ShaderCode << "layout(location = 11) in vec2 RawTex7;\n";
|
||||
if (VtxDesc & EVertexAttribute::BoneIndices) ShaderCode << "layout(location = 12) in int BoneIndices;\n";
|
||||
if (VtxDesc & EVertexAttribute::BoneWeights) ShaderCode << "layout(location = 13) in vec4 BoneWeights;\n";
|
||||
ShaderCode << "\n";
|
||||
|
||||
// Output
|
||||
ShaderCode << "// Output\n";
|
||||
if (VtxDesc & eNormal) ShaderCode << "out vec3 Normal;\n";
|
||||
if (VtxDesc & eColor0) ShaderCode << "out vec4 Color0;\n";
|
||||
if (VtxDesc & eColor1) ShaderCode << "out vec4 Color1;\n";
|
||||
if (VtxDesc & EVertexAttribute::Normal) ShaderCode << "out vec3 Normal;\n";
|
||||
if (VtxDesc & EVertexAttribute::Color0) ShaderCode << "out vec4 Color0;\n";
|
||||
if (VtxDesc & EVertexAttribute::Color1) ShaderCode << "out vec4 Color1;\n";
|
||||
|
||||
for (uint32 iPass = 0; iPass < rkMat.PassCount(); iPass++)
|
||||
if (rkMat.Pass(iPass)->TexCoordSource() != 0xFF)
|
||||
|
@ -222,7 +222,7 @@ bool CShaderGenerator::CreateVertexShader(const CMaterial& rkMat)
|
|||
<< "uniform int NumLights;\n"
|
||||
<< "\n";
|
||||
|
||||
bool HasSkinning = (rkMat.VtxDesc().HasAnyFlags(eBoneIndices | eBoneWeights));
|
||||
bool HasSkinning = (rkMat.VtxDesc().HasAnyFlags(EVertexAttribute::BoneIndices | EVertexAttribute::BoneWeights));
|
||||
|
||||
if (HasSkinning)
|
||||
{
|
||||
|
@ -240,8 +240,8 @@ bool CShaderGenerator::CreateVertexShader(const CMaterial& rkMat)
|
|||
<< " mat4 MV = ModelMtx * ViewMtx;\n"
|
||||
<< " mat4 MVP = MV * ProjMtx;\n";
|
||||
|
||||
if (VtxDesc & eColor0) ShaderCode << " Color0 = RawColor0;\n";
|
||||
if (VtxDesc & eColor1) ShaderCode << " Color1 = RawColor1;\n";
|
||||
if (VtxDesc & EVertexAttribute::Color0) ShaderCode << " Color0 = RawColor0;\n";
|
||||
if (VtxDesc & EVertexAttribute::Color1) ShaderCode << " Color1 = RawColor1;\n";
|
||||
ShaderCode << "\n";
|
||||
|
||||
// Skinning
|
||||
|
@ -250,7 +250,7 @@ bool CShaderGenerator::CreateVertexShader(const CMaterial& rkMat)
|
|||
ShaderCode << " // Skinning\n"
|
||||
<< " vec3 ModelSpacePos = vec3(0,0,0);\n";
|
||||
|
||||
if (VtxDesc & eNormal)
|
||||
if (VtxDesc & EVertexAttribute::Normal)
|
||||
ShaderCode << " vec3 ModelSpaceNormal = vec3(0,0,0);\n";
|
||||
|
||||
ShaderCode << " \n"
|
||||
|
@ -264,14 +264,14 @@ bool CShaderGenerator::CreateVertexShader(const CMaterial& rkMat)
|
|||
<< " {\n"
|
||||
<< " ModelSpacePos += vec3(vec4(RawPosition, 1) * BoneTransforms[BoneIdx] * Weight);\n";
|
||||
|
||||
if (VtxDesc & eNormal)
|
||||
if (VtxDesc & EVertexAttribute::Normal)
|
||||
ShaderCode << " ModelSpaceNormal += RawNormal.xyz * inverse(transpose(mat3(BoneTransforms[BoneIdx]))) * Weight;\n";
|
||||
|
||||
ShaderCode << " }\n"
|
||||
<< " }\n"
|
||||
<< " \n";
|
||||
|
||||
if (VtxDesc & eNormal)
|
||||
if (VtxDesc & EVertexAttribute::Normal)
|
||||
ShaderCode << " ModelSpaceNormal = normalize(ModelSpaceNormal);\n"
|
||||
<< " \n";
|
||||
}
|
||||
|
@ -279,7 +279,7 @@ bool CShaderGenerator::CreateVertexShader(const CMaterial& rkMat)
|
|||
{
|
||||
ShaderCode << " vec3 ModelSpacePos = RawPosition;\n";
|
||||
|
||||
if (VtxDesc & eNormal)
|
||||
if (VtxDesc & EVertexAttribute::Normal)
|
||||
ShaderCode << " vec3 ModelSpaceNormal = RawNormal.xyz;\n";
|
||||
|
||||
ShaderCode << "\n";
|
||||
|
@ -287,7 +287,7 @@ bool CShaderGenerator::CreateVertexShader(const CMaterial& rkMat)
|
|||
|
||||
ShaderCode << " gl_Position = vec4(ModelSpacePos, 1) * MVP;\n";
|
||||
|
||||
if (VtxDesc & eNormal)
|
||||
if (VtxDesc & EVertexAttribute::Normal)
|
||||
ShaderCode << " Normal = normalize(ModelSpaceNormal * inverse(transpose(mat3(MV))));\n";
|
||||
|
||||
// Per-vertex lighting
|
||||
|
@ -341,7 +341,7 @@ bool CShaderGenerator::CreateVertexShader(const CMaterial& rkMat)
|
|||
|
||||
EUVAnimMode AnimMode = pPass->AnimMode();
|
||||
|
||||
if (AnimMode == eNoUVAnim) // No animation
|
||||
if (AnimMode == EUVAnimMode::NoUVAnim) // No animation
|
||||
ShaderCode << " Tex" << iPass << " = vec3(" << gkCoordSrc[pPass->TexCoordSource()] << ");\n";
|
||||
|
||||
else // Animation used - texture matrix at least, possibly normalize/post-transform
|
||||
|
@ -349,7 +349,7 @@ bool CShaderGenerator::CreateVertexShader(const CMaterial& rkMat)
|
|||
// Texture Matrix
|
||||
ShaderCode << " Tex" << iPass << " = vec3(vec4(" << gkCoordSrc[pPass->TexCoordSource()] << ", 1.0) * TexMtx[" << iPass << "]).xyz;\n";
|
||||
|
||||
if ((AnimMode < 2) || (AnimMode > 5))
|
||||
if ((AnimMode < EUVAnimMode::UVScroll) || (AnimMode > EUVAnimMode::VFilmstrip))
|
||||
{
|
||||
// Normalization + Post-Transform
|
||||
ShaderCode << " Tex" << iPass << " = normalize(Tex" << iPass << ");\n"
|
||||
|
@ -373,10 +373,10 @@ bool CShaderGenerator::CreatePixelShader(const CMaterial& rkMat)
|
|||
<< "\n";
|
||||
|
||||
FVertexDescription VtxDesc = rkMat.VtxDesc();
|
||||
if (VtxDesc & ePosition) ShaderCode << "in vec3 Position;\n";
|
||||
if (VtxDesc & eNormal) ShaderCode << "in vec3 Normal;\n";
|
||||
if (VtxDesc & eColor0) ShaderCode << "in vec4 Color0;\n";
|
||||
if (VtxDesc & eColor1) ShaderCode << "in vec4 Color1;\n";
|
||||
if (VtxDesc & EVertexAttribute::Position) ShaderCode << "in vec3 Position;\n";
|
||||
if (VtxDesc & EVertexAttribute::Normal) ShaderCode << "in vec3 Normal;\n";
|
||||
if (VtxDesc & EVertexAttribute::Color0) ShaderCode << "in vec4 Color0;\n";
|
||||
if (VtxDesc & EVertexAttribute::Color1) ShaderCode << "in vec4 Color1;\n";
|
||||
|
||||
uint32 PassCount = rkMat.PassCount();
|
||||
|
||||
|
@ -441,14 +441,14 @@ bool CShaderGenerator::CreatePixelShader(const CMaterial& rkMat)
|
|||
|
||||
// Apply lightmap multiplier
|
||||
if ( (PassType == "DIFF") ||
|
||||
(PassType == "CUST" && (rkMat.Options() & CMaterial::eLightmap) && iPass == 0) )
|
||||
(PassType == "CUST" && (rkMat.Options() & EMaterialOption::Lightmap) && iPass == 0) )
|
||||
ShaderCode << " * LightmapMultiplier";
|
||||
|
||||
ShaderCode << ";\n";
|
||||
|
||||
ShaderCode << " Konst = vec4(" << gkKonstColor[pPass->KColorSel()] << ", " << gkKonstAlpha[pPass->KAlphaSel()] << ");\n";
|
||||
|
||||
if (pPass->RasSel() != eRasColorNull)
|
||||
if (pPass->RasSel() != kRasColorNull)
|
||||
ShaderCode << " Ras = " << gkRasSel[pPass->RasSel()] << ";\n";
|
||||
|
||||
for (uint8 iInput = 0; iInput < 4; iInput++)
|
||||
|
@ -479,7 +479,7 @@ bool CShaderGenerator::CreatePixelShader(const CMaterial& rkMat)
|
|||
ShaderCode << "clamp(TevInD.a + ((1.0 - TevInC.a) * TevInA.a + TevInC.a * TevInB.a), 0.0, 1.0);\n\n";
|
||||
}
|
||||
|
||||
if (rkMat.Options() & CMaterial::ePunchthrough)
|
||||
if (rkMat.Options() & EMaterialOption::Masked)
|
||||
{
|
||||
if (rkMat.Version() < EGame::CorruptionProto)
|
||||
{
|
||||
|
|
|
@ -5,6 +5,21 @@
|
|||
#include "Core/Resource/CMaterial.h"
|
||||
#include <GL/glew.h>
|
||||
|
||||
/**
|
||||
* @todo Would be great to have a more complex shader system that would allow
|
||||
* more advanced things to be done with shaders and materials in particular.
|
||||
* Currently every material only has one shader, which means any extra rendering
|
||||
* effects that need to be rendered on a mesh that has a material has to be
|
||||
* integrated directly into that material's shader and has to be toggled via a
|
||||
* shader uniform, which is pretty messy. If you look at Unreal for instance,
|
||||
* there is a much nicer system where the output of a material (color, emissive,
|
||||
* opacity, etc) is provided via a function call in the shader code, and then
|
||||
* you can write another shader on top that calls that function and then integrates
|
||||
* the material output into the shader's output pixel color however you want, which
|
||||
* allows for vastly more customization in how materials render for any given situation.
|
||||
* As the current system stands, it's kind of a pain to extend with any new features,
|
||||
* or to add any new graphical effects to game assets.
|
||||
*/
|
||||
class CShaderGenerator
|
||||
{
|
||||
CShader *mpShader;
|
||||
|
|
|
@ -4,7 +4,11 @@
|
|||
CVertexBuffer::CVertexBuffer()
|
||||
{
|
||||
mBuffered = false;
|
||||
SetVertexDesc(ePosition | eNormal | eTex0 | eTex1 | eTex2 | eTex3 | eTex4 | eTex5 | eTex6 | eTex7);
|
||||
SetVertexDesc(EVertexAttribute::Position | EVertexAttribute::Normal |
|
||||
EVertexAttribute::Tex0 | EVertexAttribute::Tex1 |
|
||||
EVertexAttribute::Tex2 | EVertexAttribute::Tex3 |
|
||||
EVertexAttribute::Tex4 | EVertexAttribute::Tex5 |
|
||||
EVertexAttribute::Tex6 | EVertexAttribute::Tex7);
|
||||
}
|
||||
|
||||
CVertexBuffer::CVertexBuffer(FVertexDescription Desc)
|
||||
|
@ -25,22 +29,22 @@ uint16 CVertexBuffer::AddVertex(const CVertex& rkVtx)
|
|||
{
|
||||
if (mPositions.size() == 0xFFFF) throw std::overflow_error("VBO contains too many vertices");
|
||||
|
||||
if (mVtxDesc & ePosition) mPositions.push_back(rkVtx.Position);
|
||||
if (mVtxDesc & eNormal) mNormals.push_back(rkVtx.Normal);
|
||||
if (mVtxDesc & eColor0) mColors[0].push_back(rkVtx.Color[0]);
|
||||
if (mVtxDesc & eColor1) mColors[1].push_back(rkVtx.Color[1]);
|
||||
if (mVtxDesc & EVertexAttribute::Position) mPositions.push_back(rkVtx.Position);
|
||||
if (mVtxDesc & EVertexAttribute::Normal) mNormals.push_back(rkVtx.Normal);
|
||||
if (mVtxDesc & EVertexAttribute::Color0) mColors[0].push_back(rkVtx.Color[0]);
|
||||
if (mVtxDesc & EVertexAttribute::Color1) mColors[1].push_back(rkVtx.Color[1]);
|
||||
|
||||
for (uint32 iTex = 0; iTex < 8; iTex++)
|
||||
if (mVtxDesc & (eTex0 << iTex)) mTexCoords[iTex].push_back(rkVtx.Tex[iTex]);
|
||||
if (mVtxDesc & (EVertexAttribute::Tex0 << iTex)) mTexCoords[iTex].push_back(rkVtx.Tex[iTex]);
|
||||
|
||||
for (uint32 iMtx = 0; iMtx < 8; iMtx++)
|
||||
if (mVtxDesc & (ePosMtx << iMtx)) mTexCoords[iMtx].push_back(rkVtx.MatrixIndices[iMtx]);
|
||||
if (mVtxDesc & (EVertexAttribute::PosMtx << iMtx)) mTexCoords[iMtx].push_back(rkVtx.MatrixIndices[iMtx]);
|
||||
|
||||
if (mVtxDesc.HasAnyFlags(eBoneIndices | eBoneWeights) && mpSkin)
|
||||
if (mVtxDesc.HasAnyFlags(EVertexAttribute::BoneIndices | EVertexAttribute::BoneWeights) && mpSkin)
|
||||
{
|
||||
const SVertexWeights& rkWeights = mpSkin->WeightsForVertex(rkVtx.ArrayPosition);
|
||||
if (mVtxDesc & eBoneIndices) mBoneIndices.push_back(rkWeights.Indices);
|
||||
if (mVtxDesc & eBoneWeights) mBoneWeights.push_back(rkWeights.Weights);
|
||||
if (mVtxDesc & EVertexAttribute::BoneIndices) mBoneIndices.push_back(rkWeights.Indices);
|
||||
if (mVtxDesc & EVertexAttribute::BoneWeights) mBoneWeights.push_back(rkWeights.Weights);
|
||||
}
|
||||
|
||||
return (mPositions.size() - 1);
|
||||
|
@ -55,35 +59,35 @@ uint16 CVertexBuffer::AddIfUnique(const CVertex& rkVtx, uint16 Start)
|
|||
// I use a bool because "continue" doesn't work properly within the iTex loop
|
||||
bool Unique = false;
|
||||
|
||||
if (mVtxDesc & ePosition)
|
||||
if (mVtxDesc & EVertexAttribute::Position)
|
||||
if (rkVtx.Position != mPositions[iVert]) Unique = true;
|
||||
|
||||
if (!Unique && (mVtxDesc & eNormal))
|
||||
if (!Unique && (mVtxDesc & EVertexAttribute::Normal))
|
||||
if (rkVtx.Normal != mNormals[iVert]) Unique = true;
|
||||
|
||||
if (!Unique && (mVtxDesc & eColor0))
|
||||
if (!Unique && (mVtxDesc & EVertexAttribute::Color0))
|
||||
if (rkVtx.Color[0] != mColors[0][iVert]) Unique = true;
|
||||
|
||||
if (!Unique && (mVtxDesc & eColor1))
|
||||
if (!Unique && (mVtxDesc & EVertexAttribute::Color1))
|
||||
if (rkVtx.Color[1] != mColors[1][iVert]) Unique = true;
|
||||
|
||||
if (!Unique)
|
||||
for (uint32 iTex = 0; iTex < 8; iTex++)
|
||||
if ((mVtxDesc & (eTex0 << iTex)))
|
||||
if ((mVtxDesc & (EVertexAttribute::Tex0 << iTex)))
|
||||
if (rkVtx.Tex[iTex] != mTexCoords[iTex][iVert])
|
||||
{
|
||||
Unique = true;
|
||||
break;
|
||||
}
|
||||
|
||||
if (!Unique && mpSkin && (mVtxDesc.HasAnyFlags(eBoneIndices | eBoneWeights)))
|
||||
if (!Unique && mpSkin && (mVtxDesc.HasAnyFlags(EVertexAttribute::BoneIndices | EVertexAttribute::BoneWeights)))
|
||||
{
|
||||
const SVertexWeights& rkWeights = mpSkin->WeightsForVertex(rkVtx.ArrayPosition);
|
||||
|
||||
for (uint32 iWgt = 0; iWgt < 4; iWgt++)
|
||||
{
|
||||
if ( ((mVtxDesc & eBoneIndices) && (rkWeights.Indices[iWgt] != mBoneIndices[iVert][iWgt])) ||
|
||||
((mVtxDesc & eBoneWeights) && (rkWeights.Weights[iWgt] != mBoneWeights[iVert][iWgt])) )
|
||||
if ( ((mVtxDesc & EVertexAttribute::BoneIndices) && (rkWeights.Indices[iWgt] != mBoneIndices[iVert][iWgt])) ||
|
||||
((mVtxDesc & EVertexAttribute::BoneWeights) && (rkWeights.Weights[iWgt] != mBoneWeights[iVert][iWgt])) )
|
||||
{
|
||||
Unique = true;
|
||||
break;
|
||||
|
@ -102,26 +106,26 @@ void CVertexBuffer::Reserve(uint16 Size)
|
|||
{
|
||||
uint32 ReserveSize = mPositions.size() + Size;
|
||||
|
||||
if (mVtxDesc & ePosition)
|
||||
if (mVtxDesc & EVertexAttribute::Position)
|
||||
mPositions.reserve(ReserveSize);
|
||||
|
||||
if (mVtxDesc & eNormal)
|
||||
if (mVtxDesc & EVertexAttribute::Normal)
|
||||
mNormals.reserve(ReserveSize);
|
||||
|
||||
if (mVtxDesc & eColor0)
|
||||
if (mVtxDesc & EVertexAttribute::Color0)
|
||||
mColors[0].reserve(ReserveSize);
|
||||
|
||||
if (mVtxDesc & eColor1)
|
||||
if (mVtxDesc & EVertexAttribute::Color1)
|
||||
mColors[1].reserve(ReserveSize);
|
||||
|
||||
for (uint32 iTex = 0; iTex < 8; iTex++)
|
||||
if (mVtxDesc & (eTex0 << iTex))
|
||||
if (mVtxDesc & (EVertexAttribute::Tex0 << iTex))
|
||||
mTexCoords[iTex].reserve(ReserveSize);
|
||||
|
||||
if (mVtxDesc & eBoneIndices)
|
||||
if (mVtxDesc & EVertexAttribute::BoneIndices)
|
||||
mBoneIndices.reserve(ReserveSize);
|
||||
|
||||
if (mVtxDesc & eBoneWeights)
|
||||
if (mVtxDesc & EVertexAttribute::BoneWeights)
|
||||
mBoneWeights.reserve(ReserveSize);
|
||||
}
|
||||
|
||||
|
@ -157,7 +161,7 @@ void CVertexBuffer::Buffer()
|
|||
|
||||
for (uint32 iAttrib = 0; iAttrib < 14; iAttrib++)
|
||||
{
|
||||
int Attrib = (ePosition << iAttrib);
|
||||
int Attrib = (EVertexAttribute::Position << iAttrib);
|
||||
bool HasAttrib = ((mVtxDesc & Attrib) != 0);
|
||||
if (!HasAttrib) continue;
|
||||
|
||||
|
@ -247,7 +251,7 @@ GLuint CVertexBuffer::CreateVAO()
|
|||
|
||||
for (uint32 iAttrib = 0; iAttrib < 14; iAttrib++)
|
||||
{
|
||||
int Attrib = (ePosition << iAttrib);
|
||||
int Attrib = (EVertexAttribute::Position << iAttrib);
|
||||
bool HasAttrib = ((mVtxDesc & Attrib) != 0);
|
||||
if (!HasAttrib) continue;
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#include "GLCommon.h"
|
||||
#include <stdexcept>
|
||||
#include <Common/Macros.h>
|
||||
|
||||
GLenum gBlendFactor[] =
|
||||
{
|
||||
|
@ -25,16 +25,16 @@ GLenum gZMode[] =
|
|||
GL_ALWAYS // GX_ALWAYS
|
||||
};
|
||||
|
||||
GLenum GXPrimToGLPrim(EGXPrimitiveType Type)
|
||||
GLenum GXPrimToGLPrim(EPrimitiveType Type)
|
||||
{
|
||||
switch (Type) {
|
||||
case eGX_Quads: return GL_TRIANGLE_STRIP; // Quads are converted to strips
|
||||
case eGX_Triangles: return GL_TRIANGLE_STRIP; // Triangles are converted to strips
|
||||
case eGX_TriangleStrip: return GL_TRIANGLE_STRIP;
|
||||
case eGX_TriangleFan: return GL_TRIANGLE_STRIP; // Fans are converted to strips
|
||||
case eGX_Lines: return GL_LINES;
|
||||
case eGX_LineStrip: return GL_LINE_STRIP;
|
||||
case eGX_Points: return GL_POINTS;
|
||||
default: throw std::invalid_argument("Invalid GX primitive type");
|
||||
case EPrimitiveType::Quads: return GL_TRIANGLE_STRIP; // Quads are converted to strips
|
||||
case EPrimitiveType::Triangles: return GL_TRIANGLE_STRIP; // Triangles are converted to strips
|
||||
case EPrimitiveType::TriangleStrip: return GL_TRIANGLE_STRIP;
|
||||
case EPrimitiveType::TriangleFan: return GL_TRIANGLE_STRIP; // Fans are converted to strips
|
||||
case EPrimitiveType::Lines: return GL_LINES;
|
||||
case EPrimitiveType::LineStrip: return GL_LINE_STRIP;
|
||||
case EPrimitiveType::Points: return GL_POINTS;
|
||||
default: ASSERT(false); return GL_INVALID_ENUM;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,31 +4,33 @@
|
|||
#include <Common/BasicTypes.h>
|
||||
#include <GL/glew.h>
|
||||
|
||||
enum EBlendFactor
|
||||
enum class EBlendFactor
|
||||
{
|
||||
eBlendZero = GL_ZERO,
|
||||
eBlendOne = GL_ONE,
|
||||
eBlendSrcColor = GL_SRC_COLOR,
|
||||
eBlendInvSrcColor = GL_ONE_MINUS_SRC_COLOR,
|
||||
eBlendSrcAlpha = GL_SRC_ALPHA,
|
||||
eBlendInvSrcAlpha = GL_ONE_MINUS_SRC_ALPHA,
|
||||
eBlendDstAlpha = GL_DST_ALPHA,
|
||||
eBlendInvDstAlpha = GL_ONE_MINUS_DST_ALPHA
|
||||
Zero = GL_ZERO,
|
||||
One = GL_ONE,
|
||||
SrcColor = GL_SRC_COLOR,
|
||||
InvSrcColor = GL_ONE_MINUS_SRC_COLOR,
|
||||
SrcAlpha = GL_SRC_ALPHA,
|
||||
InvSrcAlpha = GL_ONE_MINUS_SRC_ALPHA,
|
||||
DstAlpha = GL_DST_ALPHA,
|
||||
InvDstAlpha = GL_ONE_MINUS_DST_ALPHA
|
||||
};
|
||||
|
||||
enum EGXPrimitiveType
|
||||
enum class EPrimitiveType
|
||||
{
|
||||
eGX_Quads = 0x80,
|
||||
eGX_Triangles = 0x90,
|
||||
eGX_TriangleStrip = 0x98,
|
||||
eGX_TriangleFan = 0xA0,
|
||||
eGX_Lines = 0xA8,
|
||||
eGX_LineStrip = 0xB0,
|
||||
eGX_Points = 0xB8
|
||||
// The values assigned here match the defines for primitive types in GX
|
||||
// and appear in geometry data in game file formats
|
||||
Quads = 0x80,
|
||||
Triangles = 0x90,
|
||||
TriangleStrip = 0x98,
|
||||
TriangleFan = 0xA0,
|
||||
Lines = 0xA8,
|
||||
LineStrip = 0xB0,
|
||||
Points = 0xB8
|
||||
};
|
||||
|
||||
extern GLenum gBlendFactor[];
|
||||
extern GLenum gZMode[];
|
||||
GLenum GXPrimToGLPrim(EGXPrimitiveType Type);
|
||||
GLenum GXPrimToGLPrim(EPrimitiveType Type);
|
||||
|
||||
#endif // GLCOMMON_H
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
#include <Common/Math/MathUtil.h>
|
||||
|
||||
CCamera::CCamera()
|
||||
: mMode(eFreeCamera)
|
||||
: mMode(ECameraMoveMode::Free)
|
||||
, mPosition(0)
|
||||
, mAspectRatio(1.7777777f)
|
||||
, mYaw(-Math::skHalfPi)
|
||||
|
@ -22,7 +22,7 @@ CCamera::CCamera()
|
|||
// todo: make it actually look at the target!
|
||||
// don't actually use this constructor, it's unfinished and won't work properly
|
||||
CCamera::CCamera(CVector3f Position, CVector3f /*Target*/)
|
||||
: mMode(eFreeCamera)
|
||||
: mMode(ECameraMoveMode::Free)
|
||||
, mMoveSpeed(1.f)
|
||||
, mLookSpeed(1.f)
|
||||
, mPosition(Position)
|
||||
|
@ -33,7 +33,7 @@ CCamera::CCamera(CVector3f Position, CVector3f /*Target*/)
|
|||
|
||||
void CCamera::Pan(float XAmount, float YAmount)
|
||||
{
|
||||
if (mMode == eFreeCamera)
|
||||
if (mMode == ECameraMoveMode::Free)
|
||||
{
|
||||
mPosition += mRightVector * (XAmount * mMoveSpeed);
|
||||
mPosition += mUpVector * (YAmount * mMoveSpeed);
|
||||
|
@ -59,7 +59,7 @@ void CCamera::Rotate(float XAmount, float YAmount)
|
|||
|
||||
void CCamera::Zoom(float Amount)
|
||||
{
|
||||
if (mMode == eFreeCamera)
|
||||
if (mMode == ECameraMoveMode::Free)
|
||||
mPosition += mDirection * (Amount * mMoveSpeed);
|
||||
|
||||
else
|
||||
|
@ -86,32 +86,32 @@ void CCamera::ProcessKeyInput(FKeyInputs KeyFlags, double DeltaTime)
|
|||
{
|
||||
float FDeltaTime = (float) DeltaTime;
|
||||
|
||||
if (KeyFlags & eWKey) Zoom(FDeltaTime * 25.f);
|
||||
if (KeyFlags & eSKey) Zoom(-FDeltaTime * 25.f);
|
||||
if (KeyFlags & eQKey) Pan(0, -FDeltaTime * 25.f);
|
||||
if (KeyFlags & eEKey) Pan(0, FDeltaTime * 25.f);
|
||||
if (KeyFlags & eAKey) Pan(-FDeltaTime * 25.f, 0);
|
||||
if (KeyFlags & eDKey) Pan(FDeltaTime * 25.f, 0);
|
||||
if (KeyFlags & EKeyInput::W) Zoom(FDeltaTime * 25.f);
|
||||
if (KeyFlags & EKeyInput::S) Zoom(-FDeltaTime * 25.f);
|
||||
if (KeyFlags & EKeyInput::Q) Pan(0, -FDeltaTime * 25.f);
|
||||
if (KeyFlags & EKeyInput::E) Pan(0, FDeltaTime * 25.f);
|
||||
if (KeyFlags & EKeyInput::A) Pan(-FDeltaTime * 25.f, 0);
|
||||
if (KeyFlags & EKeyInput::D) Pan(FDeltaTime * 25.f, 0);
|
||||
}
|
||||
|
||||
void CCamera::ProcessMouseInput(FKeyInputs KeyFlags, FMouseInputs MouseFlags, float XMovement, float YMovement)
|
||||
{
|
||||
// Free Camera
|
||||
if (mMode == eFreeCamera)
|
||||
if (mMode == ECameraMoveMode::Free)
|
||||
{
|
||||
if (MouseFlags & eMiddleButton)
|
||||
if (MouseFlags & EMouseInput::MiddleButton)
|
||||
{
|
||||
if (KeyFlags & eCtrlKey) Zoom(-YMovement * 0.2f);
|
||||
if (KeyFlags & EKeyInput::Ctrl) Zoom(-YMovement * 0.2f);
|
||||
else Pan(-XMovement, YMovement);
|
||||
}
|
||||
|
||||
else if (MouseFlags & eRightButton) Rotate(XMovement, YMovement);
|
||||
else if (MouseFlags & EMouseInput::RightButton) Rotate(XMovement, YMovement);
|
||||
}
|
||||
|
||||
// Orbit Camera
|
||||
else if (mMode == eOrbitCamera)
|
||||
else if (mMode == ECameraMoveMode::Orbit)
|
||||
{
|
||||
if ((MouseFlags & eMiddleButton) || (MouseFlags & eRightButton))
|
||||
if ((MouseFlags & EMouseInput::MiddleButton) || (MouseFlags & EMouseInput::RightButton))
|
||||
Pan(-XMovement, YMovement);
|
||||
}
|
||||
}
|
||||
|
@ -136,7 +136,7 @@ void CCamera::SetMoveMode(ECameraMoveMode Mode)
|
|||
mViewDirty = true;
|
||||
mFrustumPlanesDirty = true;
|
||||
|
||||
if (mMode == eOrbitCamera)
|
||||
if (mMode == ECameraMoveMode::Orbit)
|
||||
mTransformDirty = true;
|
||||
}
|
||||
|
||||
|
@ -145,7 +145,7 @@ void CCamera::SetOrbit(const CVector3f& OrbitTarget, float Distance)
|
|||
mOrbitTarget = OrbitTarget;
|
||||
mOrbitDistance = Distance;
|
||||
|
||||
if (mMode == eOrbitCamera)
|
||||
if (mMode == ECameraMoveMode::Orbit)
|
||||
{
|
||||
mTransformDirty = true;
|
||||
mViewDirty = true;
|
||||
|
@ -161,7 +161,7 @@ void CCamera::SetOrbit(const CAABox& OrbitTarget, float DistScale /*= 1.75f*/)
|
|||
float Dist = OrbitTarget.Center().Distance(OrbitTarget.Max());
|
||||
mOrbitDistance = Dist * DistScale;
|
||||
|
||||
if (mMode == eOrbitCamera)
|
||||
if (mMode == ECameraMoveMode::Orbit)
|
||||
{
|
||||
mTransformDirty = true;
|
||||
mViewDirty = true;
|
||||
|
@ -173,7 +173,7 @@ void CCamera::SetOrbitTarget(const CVector3f& rkOrbitTarget)
|
|||
{
|
||||
mOrbitTarget = rkOrbitTarget;
|
||||
|
||||
if (mMode == eOrbitCamera)
|
||||
if (mMode == ECameraMoveMode::Orbit)
|
||||
{
|
||||
mTransformDirty = true;
|
||||
mViewDirty = true;
|
||||
|
@ -185,7 +185,7 @@ void CCamera::SetOrbitDistance(float Distance)
|
|||
{
|
||||
mOrbitDistance = Distance;
|
||||
|
||||
if (mMode == eOrbitCamera)
|
||||
if (mMode == ECameraMoveMode::Orbit)
|
||||
{
|
||||
mTransformDirty = true;
|
||||
mViewDirty = true;
|
||||
|
@ -228,7 +228,7 @@ void CCamera::UpdateTransform() const
|
|||
mUpVector = mRightVector.Cross(mDirection);
|
||||
|
||||
// Update position
|
||||
if (mMode == eOrbitCamera)
|
||||
if (mMode == ECameraMoveMode::Orbit)
|
||||
{
|
||||
if (mOrbitDistance < 1.f) mOrbitDistance = 1.f;
|
||||
mPosition = mOrbitTarget + (mDirection * -mOrbitDistance);
|
||||
|
|
|
@ -11,9 +11,9 @@
|
|||
#include <Common/Math/CVector2i.h>
|
||||
#include <Common/Math/CVector3f.h>
|
||||
|
||||
enum ECameraMoveMode
|
||||
enum class ECameraMoveMode
|
||||
{
|
||||
eFreeCamera, eOrbitCamera
|
||||
Free, Orbit
|
||||
};
|
||||
|
||||
/* This class uses a lot of mutable members as an optimization so that they can
|
||||
|
|
|
@ -87,7 +87,7 @@ void CDrawUtil::DrawSquare(const float *pTexCoords)
|
|||
// Set tex coords
|
||||
for (uint32 iTex = 0; iTex < 8; iTex++)
|
||||
{
|
||||
EVertexAttribute TexAttrib = (EVertexAttribute) (eTex0 << (iTex *2));
|
||||
EVertexAttribute TexAttrib = (EVertexAttribute) ((uint) (EVertexAttribute::Tex0) << iTex);
|
||||
mSquareVertices.BufferAttrib(TexAttrib, pTexCoords);
|
||||
}
|
||||
|
||||
|
@ -114,7 +114,7 @@ void CDrawUtil::DrawLine(const CVector3f& PointA, const CVector3f& PointB, const
|
|||
|
||||
// Copy vec3s into an array to ensure they are adjacent in memory
|
||||
CVector3f Points[2] = { PointA, PointB };
|
||||
mLineVertices.BufferAttrib(ePosition, Points);
|
||||
mLineVertices.BufferAttrib(EVertexAttribute::Position, Points);
|
||||
|
||||
// Draw
|
||||
UseColorShader(LineColor);
|
||||
|
@ -132,7 +132,7 @@ void CDrawUtil::DrawLine(const CVector2f& PointA, const CVector2f& PointB, const
|
|||
void CDrawUtil::DrawCube()
|
||||
{
|
||||
Init();
|
||||
mpCubeModel->Draw(eNoMaterialSetup, 0);
|
||||
mpCubeModel->Draw(ERenderOption::NoMaterialSetup, 0);
|
||||
}
|
||||
|
||||
void CDrawUtil::DrawCube(const CColor& Color)
|
||||
|
@ -186,9 +186,9 @@ void CDrawUtil::DrawSphere(bool DoubleSided)
|
|||
Init();
|
||||
|
||||
if (!DoubleSided)
|
||||
mpSphereModel->Draw(eNoMaterialSetup, 0);
|
||||
mpSphereModel->Draw(ERenderOption::NoMaterialSetup, 0);
|
||||
else
|
||||
mpDoubleSidedSphereModel->Draw(eNoMaterialSetup, 0);
|
||||
mpDoubleSidedSphereModel->Draw(ERenderOption::NoMaterialSetup, 0);
|
||||
}
|
||||
|
||||
void CDrawUtil::DrawSphere(const CColor &kColor)
|
||||
|
@ -217,7 +217,7 @@ void CDrawUtil::DrawWireSphere(const CVector3f& Position, float Radius, const CC
|
|||
glDepthMask(GL_TRUE);
|
||||
|
||||
// Draw
|
||||
mpWireSphereModel->Draw(eNoMaterialSetup, 0);
|
||||
mpWireSphereModel->Draw(ERenderOption::NoMaterialSetup, 0);
|
||||
}
|
||||
|
||||
void CDrawUtil::DrawBillboard(CTexture* pTexture, const CVector3f& Position, const CVector2f& Scale /*= CVector2f::skOne*/, const CColor& Tint /*= CColor::skWhite*/)
|
||||
|
@ -366,13 +366,13 @@ void CDrawUtil::LoadCheckerboardTexture(uint32 GLTextureUnit)
|
|||
CTexture* CDrawUtil::GetLightTexture(ELightType Type)
|
||||
{
|
||||
Init();
|
||||
return mpLightTextures[Type];
|
||||
return mpLightTextures[(int) Type];
|
||||
}
|
||||
|
||||
CTexture* CDrawUtil::GetLightMask(ELightType Type)
|
||||
{
|
||||
Init();
|
||||
return mpLightMasks[Type];
|
||||
return mpLightMasks[(int) Type];
|
||||
}
|
||||
|
||||
CModel* CDrawUtil::GetCubeModel()
|
||||
|
@ -413,7 +413,7 @@ void CDrawUtil::InitGrid()
|
|||
int MinIdx = (kGridSize - 1) / -2;
|
||||
int MaxIdx = (kGridSize - 1) / 2;
|
||||
|
||||
mGridVertices.SetVertexDesc(ePosition);
|
||||
mGridVertices.SetVertexDesc(EVertexAttribute::Position);
|
||||
mGridVertices.Reserve(kGridSize * 4);
|
||||
|
||||
for (int32 i = MinIdx; i <= MaxIdx; i++)
|
||||
|
@ -439,9 +439,16 @@ void CDrawUtil::InitGrid()
|
|||
void CDrawUtil::InitSquare()
|
||||
{
|
||||
debugf("Creating square");
|
||||
mSquareVertices.SetActiveAttribs(ePosition | eNormal |
|
||||
eTex0 | eTex1 | eTex2 | eTex3 |
|
||||
eTex4 | eTex5 | eTex6 | eTex7);
|
||||
mSquareVertices.SetActiveAttribs(EVertexAttribute::Position |
|
||||
EVertexAttribute::Normal |
|
||||
EVertexAttribute::Tex0 |
|
||||
EVertexAttribute::Tex1 |
|
||||
EVertexAttribute::Tex2 |
|
||||
EVertexAttribute::Tex3 |
|
||||
EVertexAttribute::Tex4 |
|
||||
EVertexAttribute::Tex5 |
|
||||
EVertexAttribute::Tex6 |
|
||||
EVertexAttribute::Tex7 );
|
||||
mSquareVertices.SetVertexCount(4);
|
||||
|
||||
CVector3f SquareVertices[] = {
|
||||
|
@ -465,12 +472,12 @@ void CDrawUtil::InitSquare()
|
|||
CVector2f(0.f, 0.f)
|
||||
};
|
||||
|
||||
mSquareVertices.BufferAttrib(ePosition, SquareVertices);
|
||||
mSquareVertices.BufferAttrib(eNormal, SquareNormals);
|
||||
mSquareVertices.BufferAttrib(EVertexAttribute::Position, SquareVertices);
|
||||
mSquareVertices.BufferAttrib(EVertexAttribute::Normal, SquareNormals);
|
||||
|
||||
for (uint32 iTex = 0; iTex < 8; iTex++)
|
||||
{
|
||||
EVertexAttribute Attrib = (EVertexAttribute) (eTex0 << (iTex *2));
|
||||
EVertexAttribute Attrib = (EVertexAttribute) (EVertexAttribute::Tex0 << iTex);
|
||||
mSquareVertices.BufferAttrib(Attrib, SquareTexCoords);
|
||||
}
|
||||
|
||||
|
@ -485,7 +492,7 @@ void CDrawUtil::InitSquare()
|
|||
void CDrawUtil::InitLine()
|
||||
{
|
||||
debugf("Creating line");
|
||||
mLineVertices.SetActiveAttribs(ePosition);
|
||||
mLineVertices.SetActiveAttribs(EVertexAttribute::Position);
|
||||
mLineVertices.SetVertexCount(2);
|
||||
|
||||
mLineIndices.Reserve(2);
|
||||
|
@ -503,7 +510,7 @@ void CDrawUtil::InitCube()
|
|||
void CDrawUtil::InitWireCube()
|
||||
{
|
||||
debugf("Creating wire cube");
|
||||
mWireCubeVertices.SetVertexDesc(ePosition);
|
||||
mWireCubeVertices.SetVertexDesc(EVertexAttribute::Position);
|
||||
mWireCubeVertices.Reserve(8);
|
||||
mWireCubeVertices.AddVertex(CVector3f(-0.5f, -0.5f, -0.5f));
|
||||
mWireCubeVertices.AddVertex(CVector3f(-0.5f, 0.5f, -0.5f));
|
||||
|
|
|
@ -7,9 +7,13 @@
|
|||
#include "Core/Resource/model/CModel.h"
|
||||
#include "Core/Resource/CLight.h"
|
||||
|
||||
/* todo: CDrawUtil should work with CRenderer to queue primitives for rendering
|
||||
* rather than trying to draw them straight away, so that CDrawUtil functions can
|
||||
* be called from anywhere in the codebase and still function correctly */
|
||||
/**
|
||||
* @todo there are a LOT of problems with how this is implemented; trying to
|
||||
* use CDrawUtil in a lot of places in the codebase just plain doesn't work
|
||||
* because it goes outside CRenderer to draw stuff, and also it's slow as heck
|
||||
* because it issues tons of draw calls instead of batching items together
|
||||
* which is a cause of significant performance problems
|
||||
*/
|
||||
class CDrawUtil
|
||||
{
|
||||
// 7x7 Grid
|
||||
|
|
|
@ -48,7 +48,7 @@ void CGraphics::Initialize()
|
|||
mpLightBlockBuffer = new CUniformBuffer(sizeof(sLightBlock));
|
||||
mpBoneTransformBuffer = new CUniformBuffer(sizeof(CTransform4f) * 100);
|
||||
|
||||
sLightMode = eWorldLighting;
|
||||
sLightMode = ELightingMode::World;
|
||||
sNumLights = 0;
|
||||
sWorldLightMultiplier = 1.f;
|
||||
|
||||
|
@ -175,9 +175,9 @@ void CGraphics::SetDefaultLighting()
|
|||
|
||||
void CGraphics::SetupAmbientColor()
|
||||
{
|
||||
if (sLightMode == eWorldLighting)
|
||||
if (sLightMode == ELightingMode::World)
|
||||
sVertexBlock.COLOR0_Amb = sAreaAmbientColor * sWorldLightMultiplier;
|
||||
else if (sLightMode == eBasicLighting)
|
||||
else if (sLightMode == ELightingMode::Basic)
|
||||
sVertexBlock.COLOR0_Amb = skDefaultAmbientColor;
|
||||
else
|
||||
sVertexBlock.COLOR0_Amb = CColor::skWhite;
|
||||
|
|
|
@ -12,11 +12,11 @@
|
|||
#include <GL/glew.h>
|
||||
|
||||
/**
|
||||
* todo: should probably be replaced with a CGraphicsState class which
|
||||
* can be instantiated and is probably more safe/functional than global access.
|
||||
* also, should probably have inline set/get functions rather than having all
|
||||
* members public so that we can track when a value is modified and maybe
|
||||
* execute extra functionality when certain values are changed
|
||||
* todo: this entire thing needs to be further abstracted, other classes shouldn't
|
||||
* need to get this close to the metal - makes it harder to extend and harder to
|
||||
* theoretically add support for other kinds of graphics backends. additionally,
|
||||
* all this stuff really shouldn't be global, and shouldn't all use public members
|
||||
* either... basically, there's a lot wrong with this system
|
||||
*/
|
||||
class CGraphics
|
||||
{
|
||||
|
@ -79,7 +79,7 @@ public:
|
|||
static SLightBlock sLightBlock;
|
||||
|
||||
// Lighting-related
|
||||
enum ELightingMode { eNoLighting, eBasicLighting, eWorldLighting };
|
||||
enum class ELightingMode { None, Basic, World };
|
||||
static ELightingMode sLightMode;
|
||||
static uint32 sNumLights;
|
||||
static const CColor skDefaultAmbientColor;
|
||||
|
|
|
@ -68,7 +68,7 @@ void CRenderBucket::CSubBucket::Draw(const SViewInfo& rkViewInfo)
|
|||
const SRenderablePtr& rkPtr = mRenderables[iPtr];
|
||||
|
||||
// todo: DrawSelection probably shouldn't be a separate function anymore.
|
||||
if (rkPtr.Command == eDrawSelection)
|
||||
if (rkPtr.Command == ERenderCommand::DrawSelection)
|
||||
rkPtr.pRenderable->DrawSelection();
|
||||
else
|
||||
rkPtr.pRenderable->Draw(Options, rkPtr.ComponentIndex, rkPtr.Command, rkViewInfo);
|
||||
|
|
|
@ -17,8 +17,8 @@ uint32 CRenderer::sNumRenderers = 0;
|
|||
|
||||
// ************ INITIALIZATION ************
|
||||
CRenderer::CRenderer()
|
||||
: mOptions(eEnableUVScroll | eEnableBackfaceCull)
|
||||
, mBloomMode(eNoBloom)
|
||||
: mOptions(ERenderOption::EnableUVScroll | ERenderOption::EnableBackfaceCull)
|
||||
, mBloomMode(EBloomMode::NoBloom)
|
||||
, mDrawGrid(true)
|
||||
, mInitialized(false)
|
||||
, mContextIndex(-1)
|
||||
|
@ -55,14 +55,14 @@ FRenderOptions CRenderer::RenderOptions() const
|
|||
|
||||
void CRenderer::ToggleBackfaceCull(bool Enable)
|
||||
{
|
||||
if (Enable) mOptions |= eEnableBackfaceCull;
|
||||
else mOptions &= ~eEnableBackfaceCull;
|
||||
if (Enable) mOptions |= ERenderOption::EnableBackfaceCull;
|
||||
else mOptions &= ~ERenderOption::EnableBackfaceCull;
|
||||
}
|
||||
|
||||
void CRenderer::ToggleUVAnimation(bool Enable)
|
||||
{
|
||||
if (Enable) mOptions |= eEnableUVScroll;
|
||||
else mOptions &= ~eEnableUVScroll;
|
||||
if (Enable) mOptions |= ERenderOption::EnableUVScroll;
|
||||
else mOptions &= ~ERenderOption::EnableUVScroll;
|
||||
}
|
||||
|
||||
void CRenderer::ToggleGrid(bool Enable)
|
||||
|
@ -72,24 +72,24 @@ void CRenderer::ToggleGrid(bool Enable)
|
|||
|
||||
void CRenderer::ToggleOccluders(bool Enable)
|
||||
{
|
||||
if (Enable) mOptions |= eEnableOccluders;
|
||||
else mOptions &= ~eEnableOccluders;
|
||||
if (Enable) mOptions |= ERenderOption::EnableOccluders;
|
||||
else mOptions &= ~ERenderOption::EnableOccluders;
|
||||
}
|
||||
|
||||
void CRenderer::ToggleAlphaDisabled(bool Enable)
|
||||
{
|
||||
if (Enable) mOptions |= eNoAlpha;
|
||||
else mOptions &= ~eNoAlpha;
|
||||
if (Enable) mOptions |= ERenderOption::NoAlpha;
|
||||
else mOptions &= ~ERenderOption::NoAlpha;
|
||||
}
|
||||
|
||||
void CRenderer::SetBloom(EBloomMode BloomMode)
|
||||
{
|
||||
mBloomMode = BloomMode;
|
||||
|
||||
if (BloomMode != eNoBloom)
|
||||
mOptions |= eEnableBloom;
|
||||
if (BloomMode != EBloomMode::NoBloom)
|
||||
mOptions |= ERenderOption::EnableBloom;
|
||||
else
|
||||
mOptions &= ~eEnableBloom;
|
||||
mOptions &= ~ERenderOption::EnableBloom;
|
||||
}
|
||||
|
||||
void CRenderer::SetClearColor(const CColor& rkClear)
|
||||
|
@ -118,7 +118,7 @@ void CRenderer::RenderBuckets(const SViewInfo& rkViewInfo)
|
|||
mSceneFramebuffer.Bind();
|
||||
|
||||
// Set backface culling
|
||||
if (mOptions & eEnableBackfaceCull) glEnable(GL_CULL_FACE);
|
||||
if (mOptions & ERenderOption::EnableBackfaceCull) glEnable(GL_CULL_FACE);
|
||||
else glDisable(GL_CULL_FACE);
|
||||
|
||||
// Render scene to texture
|
||||
|
@ -145,7 +145,7 @@ void CRenderer::RenderBuckets(const SViewInfo& rkViewInfo)
|
|||
void CRenderer::RenderBloom()
|
||||
{
|
||||
// Check to ensure bloom is enabled. Also don't render bloom in unlit mode.
|
||||
if (mBloomMode == eNoBloom || CGraphics::sLightMode != CGraphics::eWorldLighting) return;
|
||||
if (mBloomMode == EBloomMode::NoBloom || CGraphics::sLightMode != CGraphics::ELightingMode::World) return;
|
||||
|
||||
// Setup
|
||||
static const float skHOffset[6] = { -0.008595f, -0.005470f, -0.002345f,
|
||||
|
@ -161,10 +161,10 @@ void CRenderer::RenderBloom()
|
|||
CColor::Integral(53, 53, 53),
|
||||
CColor::Integral(17, 17, 17) };
|
||||
|
||||
uint32 BloomWidth = (mBloomMode == eBloom ? mBloomWidth : mViewportWidth);
|
||||
uint32 BloomHeight = (mBloomMode == eBloom ? mBloomHeight : mViewportHeight);
|
||||
float BloomHScale = (mBloomMode == eBloom ? mBloomHScale : 0);
|
||||
float BloomVScale = (mBloomMode == eBloom ? mBloomVScale : 0);
|
||||
uint32 BloomWidth = (mBloomMode == EBloomMode::Bloom ? mBloomWidth : mViewportWidth);
|
||||
uint32 BloomHeight = (mBloomMode == EBloomMode::Bloom ? mBloomHeight : mViewportHeight);
|
||||
float BloomHScale = (mBloomMode == EBloomMode::Bloom ? mBloomHScale : 0);
|
||||
float BloomVScale = (mBloomMode == EBloomMode::Bloom ? mBloomVScale : 0);
|
||||
|
||||
glDisable(GL_DEPTH_TEST);
|
||||
glViewport(0, 0, BloomWidth, BloomHeight);
|
||||
|
@ -242,7 +242,7 @@ void CRenderer::RenderBloom()
|
|||
mBloomFramebuffers[2].Texture()->Bind(0);
|
||||
CDrawUtil::DrawSquare();
|
||||
|
||||
if (mBloomMode == eBloomMaps)
|
||||
if (mBloomMode == EBloomMode::BloomMaps)
|
||||
{
|
||||
// Bloom maps are in the framebuffer alpha channel.
|
||||
// White * dst alpha = bloom map colors
|
||||
|
@ -294,19 +294,19 @@ void CRenderer::AddMesh(IRenderable *pRenderable, int ComponentIndex, const CAAB
|
|||
|
||||
switch (DepthGroup)
|
||||
{
|
||||
case eBackground:
|
||||
case EDepthGroup::Background:
|
||||
mBackgroundBucket.Add(Ptr, Transparent);
|
||||
break;
|
||||
|
||||
case eMidground:
|
||||
case EDepthGroup::Midground:
|
||||
mMidgroundBucket.Add(Ptr, Transparent);
|
||||
break;
|
||||
|
||||
case eForeground:
|
||||
case EDepthGroup::Foreground:
|
||||
mForegroundBucket.Add(Ptr, Transparent);
|
||||
break;
|
||||
|
||||
case eUI:
|
||||
case EDepthGroup::UI:
|
||||
mUIBucket.Add(Ptr, Transparent);
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -21,14 +21,35 @@
|
|||
|
||||
#include <GL/glew.h>
|
||||
|
||||
class CRenderer
|
||||
enum class EBloomMode
|
||||
{
|
||||
public:
|
||||
enum EBloomMode {
|
||||
eNoBloom, eBloom, eBloomMaps, eFakeBloom
|
||||
NoBloom,
|
||||
Bloom,
|
||||
BloomMaps,
|
||||
FakeBloom
|
||||
};
|
||||
|
||||
private:
|
||||
/**
|
||||
* @todo this rendering subsystem is bad and needs a rewrite
|
||||
* there's quite a lot of problems overall, but generally speaking, one of the
|
||||
* biggest problems with it is that scene nodes have too much control over how
|
||||
* they render, and the renderer doesn't have enough. for example, if a certain
|
||||
* render option is set, it should not be up to the node classes to respect that
|
||||
* option, the renderer should be able to enforce it. there's a lot of other issues
|
||||
* that make the renderer suboptimal and harder to maintain/extend than it should be.
|
||||
* this is also a more general issue but graphics stuff needs to be further abstracted
|
||||
* so that rendering code isn't directly calling OpenGL functions, ideally it should
|
||||
* just have more abstracted code that gets redirected to OpenGL at a lower level so
|
||||
* that other graphics backends could be supported in the future without needing to
|
||||
* majorly rewrite everything (but I guess that's the point we're at right now anyway).
|
||||
* I'm also pretty sure there's been no attempt made whatsoever to reduce the number of
|
||||
* shader/texture state changes needed per frame, outside batching world geometry (via
|
||||
* CStaticModel), which might be a performance drain.
|
||||
*
|
||||
* for more complaints about the rendering system implementation, see CSceneNode
|
||||
*/
|
||||
class CRenderer
|
||||
{
|
||||
FRenderOptions mOptions;
|
||||
EBloomMode mBloomMode;
|
||||
bool mDrawGrid;
|
||||
|
@ -73,7 +94,7 @@ public:
|
|||
void RenderBuckets(const SViewInfo& rkViewInfo);
|
||||
void RenderBloom();
|
||||
void RenderSky(CModel *pSkyboxModel, const SViewInfo& rkViewInfo);
|
||||
void AddMesh(IRenderable *pRenderable, int ComponentIndex, const CAABox& rkAABox, bool Transparent, ERenderCommand Command, EDepthGroup DepthGroup = eMidground);
|
||||
void AddMesh(IRenderable *pRenderable, int ComponentIndex, const CAABox& rkAABox, bool Transparent, ERenderCommand Command, EDepthGroup DepthGroup = EDepthGroup::Midground);
|
||||
void BeginFrame();
|
||||
void EndFrame();
|
||||
void ClearDepthBuffer();
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
#ifndef EDEPTHGROUP
|
||||
#define EDEPTHGROUP
|
||||
|
||||
enum EDepthGroup
|
||||
enum class EDepthGroup
|
||||
{
|
||||
eBackground,
|
||||
eMidground,
|
||||
eForeground,
|
||||
eUI
|
||||
Background,
|
||||
Midground,
|
||||
Foreground,
|
||||
UI
|
||||
};
|
||||
|
||||
#endif // EDEPTHGROUP
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
#ifndef ERENDERCOMMAND
|
||||
#define ERENDERCOMMAND
|
||||
|
||||
enum ERenderCommand
|
||||
enum class ERenderCommand
|
||||
{
|
||||
eDrawMesh,
|
||||
eDrawOpaqueParts,
|
||||
eDrawTransparentParts,
|
||||
eDrawSelection
|
||||
DrawMesh,
|
||||
DrawOpaqueParts,
|
||||
DrawTransparentParts,
|
||||
DrawSelection
|
||||
};
|
||||
|
||||
#endif // ERENDERCOMMAND
|
||||
|
|
|
@ -3,17 +3,17 @@
|
|||
|
||||
#include <Common/Flags.h>
|
||||
|
||||
enum ERenderOption
|
||||
enum class ERenderOption
|
||||
{
|
||||
eNoRenderOptions = 0x0,
|
||||
eEnableUVScroll = 0x1,
|
||||
eEnableBackfaceCull = 0x2,
|
||||
eEnableOccluders = 0x4,
|
||||
eNoMaterialSetup = 0x8,
|
||||
eEnableBloom = 0x10,
|
||||
eNoAlpha = 0x20
|
||||
None = 0x0,
|
||||
EnableUVScroll = 0x1,
|
||||
EnableBackfaceCull = 0x2,
|
||||
EnableOccluders = 0x4,
|
||||
NoMaterialSetup = 0x8,
|
||||
EnableBloom = 0x10,
|
||||
NoAlpha = 0x20
|
||||
};
|
||||
DECLARE_FLAGS(ERenderOption, FRenderOptions)
|
||||
DECLARE_FLAGS_ENUMCLASS(ERenderOption, FRenderOptions)
|
||||
|
||||
#endif // FRENDEROPTIONS_H
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
class CAnimEventData : public CResource
|
||||
{
|
||||
DECLARE_RESOURCE_TYPE(eAnimEventData)
|
||||
DECLARE_RESOURCE_TYPE(AnimEventData)
|
||||
|
||||
struct SEvent
|
||||
{
|
||||
|
|
|
@ -45,12 +45,12 @@ struct SHalfTransition
|
|||
};
|
||||
|
||||
// Character structures
|
||||
enum EOverlayType
|
||||
enum class EOverlayType
|
||||
{
|
||||
eOT_Frozen = FOURCC('FRZN'),
|
||||
eOT_Hypermode = FOURCC('HYPR'),
|
||||
eOT_Acid = FOURCC('ACID'),
|
||||
eOT_XRay = FOURCC('XRAY')
|
||||
Frozen = FOURCC('FRZN'),
|
||||
Hypermode = FOURCC('HYPR'),
|
||||
Acid = FOURCC('ACID'),
|
||||
XRay = FOURCC('XRAY')
|
||||
};
|
||||
|
||||
struct SOverlayModel
|
||||
|
@ -84,7 +84,7 @@ struct SSetCharacter
|
|||
|
||||
class CAnimSet : public CResource
|
||||
{
|
||||
DECLARE_RESOURCE_TYPE(eAnimSet)
|
||||
DECLARE_RESOURCE_TYPE(AnimSet)
|
||||
friend class CAnimSetLoader;
|
||||
|
||||
// Character Set
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
|
||||
class CAnimation : public CResource
|
||||
{
|
||||
DECLARE_RESOURCE_TYPE(eAnimation)
|
||||
DECLARE_RESOURCE_TYPE(Animation)
|
||||
friend class CAnimationLoader;
|
||||
|
||||
typedef std::vector<CVector3f> TScaleChannel;
|
||||
|
|
|
@ -160,7 +160,7 @@ const SSetCharacter* CAnimationParameters::GetCurrentSetCharacter(int32 NodeInde
|
|||
{
|
||||
CAnimSet *pSet = AnimSet();
|
||||
|
||||
if (pSet && (pSet->Type() == eAnimSet || pSet->Type() == eCharacter))
|
||||
if (pSet && (pSet->Type() == EResourceType::AnimSet || pSet->Type() == EResourceType::Character))
|
||||
{
|
||||
if (NodeIndex == -1)
|
||||
NodeIndex = mCharIndex;
|
||||
|
@ -215,7 +215,7 @@ void CAnimationParameters::SetResource(const CAssetID& rkID)
|
|||
|
||||
if (!pEntry)
|
||||
errorf("Invalid resource ID passed to CAnimationParameters: %s", *rkID.ToString());
|
||||
else if (pEntry->ResourceType() != eAnimSet && pEntry->ResourceType() != eCharacter)
|
||||
else if (pEntry->ResourceType() != EResourceType::AnimSet && pEntry->ResourceType() != EResourceType::Character)
|
||||
errorf("Resource with invalid type passed to CAnimationParameters: %s", *pEntry->CookedAssetPath().GetFileName());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@ struct SBoneTransformInfo
|
|||
|
||||
class CSkeleton : public CResource
|
||||
{
|
||||
DECLARE_RESOURCE_TYPE(eSkeleton)
|
||||
DECLARE_RESOURCE_TYPE(Skeleton)
|
||||
friend class CSkeletonLoader;
|
||||
|
||||
CBone *mpRootBone;
|
||||
|
|
|
@ -12,7 +12,7 @@ struct SVertexWeights
|
|||
|
||||
class CSkin : public CResource
|
||||
{
|
||||
DECLARE_RESOURCE_TYPE(eSkin)
|
||||
DECLARE_RESOURCE_TYPE(Skin)
|
||||
friend class CSkinLoader;
|
||||
|
||||
struct SVertGroup
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
class CSourceAnimData : public CResource
|
||||
{
|
||||
DECLARE_RESOURCE_TYPE(eSourceAnimData)
|
||||
DECLARE_RESOURCE_TYPE(SourceAnimData)
|
||||
friend class CAnimSetLoader;
|
||||
|
||||
struct STransition
|
||||
|
|
|
@ -5,21 +5,21 @@ CMetaAnimFactory gMetaAnimFactory;
|
|||
|
||||
IMetaAnimation* CMetaAnimFactory::LoadFromStream(IInputStream& rInput, EGame Game)
|
||||
{
|
||||
EMetaAnimationType Type = (EMetaAnimationType) rInput.ReadLong();
|
||||
EMetaAnimType Type = (EMetaAnimType) rInput.ReadLong();
|
||||
|
||||
switch (Type)
|
||||
{
|
||||
case eMAT_Play:
|
||||
case EMetaAnimType::Play:
|
||||
return new CMetaAnimPlay(rInput, Game);
|
||||
|
||||
case eMAT_Blend:
|
||||
case eMAT_PhaseBlend:
|
||||
case EMetaAnimType::Blend:
|
||||
case EMetaAnimType::PhaseBlend:
|
||||
return new CMetaAnimBlend(Type, rInput, Game);
|
||||
|
||||
case eMAT_Random:
|
||||
case EMetaAnimType::Random:
|
||||
return new CMetaAnimRandom(rInput, Game);
|
||||
|
||||
case eMAT_Sequence:
|
||||
case EMetaAnimType::Sequence:
|
||||
return new CMetaAnimSequence(rInput, Game);
|
||||
|
||||
default:
|
||||
|
@ -43,9 +43,9 @@ CMetaAnimPlay::CMetaAnimPlay(IInputStream& rInput, EGame Game)
|
|||
mUnknownB = rInput.ReadLong();
|
||||
}
|
||||
|
||||
EMetaAnimationType CMetaAnimPlay::Type() const
|
||||
EMetaAnimType CMetaAnimPlay::Type() const
|
||||
{
|
||||
return eMAT_Play;
|
||||
return EMetaAnimType::Play;
|
||||
}
|
||||
|
||||
void CMetaAnimPlay::GetUniquePrimitives(std::set<CAnimPrimitive>& rPrimSet) const
|
||||
|
@ -54,9 +54,9 @@ void CMetaAnimPlay::GetUniquePrimitives(std::set<CAnimPrimitive>& rPrimSet) cons
|
|||
}
|
||||
|
||||
// ************ CMetaAnimBlend ************
|
||||
CMetaAnimBlend::CMetaAnimBlend(EMetaAnimationType Type, IInputStream& rInput, EGame Game)
|
||||
CMetaAnimBlend::CMetaAnimBlend(EMetaAnimType Type, IInputStream& rInput, EGame Game)
|
||||
{
|
||||
ASSERT(Type == eMAT_Blend || Type == eMAT_PhaseBlend);
|
||||
ASSERT(Type == EMetaAnimType::Blend || Type == EMetaAnimType::PhaseBlend);
|
||||
mType = Type;
|
||||
mpMetaAnimA = gMetaAnimFactory.LoadFromStream(rInput, Game);
|
||||
mpMetaAnimB = gMetaAnimFactory.LoadFromStream(rInput, Game);
|
||||
|
@ -70,7 +70,7 @@ CMetaAnimBlend::~CMetaAnimBlend()
|
|||
delete mpMetaAnimB;
|
||||
}
|
||||
|
||||
EMetaAnimationType CMetaAnimBlend::Type() const
|
||||
EMetaAnimType CMetaAnimBlend::Type() const
|
||||
{
|
||||
return mType;
|
||||
}
|
||||
|
@ -102,9 +102,9 @@ CMetaAnimRandom::~CMetaAnimRandom()
|
|||
delete mProbabilityPairs[iPair].pAnim;
|
||||
}
|
||||
|
||||
EMetaAnimationType CMetaAnimRandom::Type() const
|
||||
EMetaAnimType CMetaAnimRandom::Type() const
|
||||
{
|
||||
return eMAT_Random;
|
||||
return EMetaAnimType::Random;
|
||||
}
|
||||
|
||||
void CMetaAnimRandom::GetUniquePrimitives(std::set<CAnimPrimitive>& rPrimSet) const
|
||||
|
@ -132,9 +132,9 @@ CMetaAnimSequence::~CMetaAnimSequence()
|
|||
delete mAnimations[iAnim];
|
||||
}
|
||||
|
||||
EMetaAnimationType CMetaAnimSequence::Type() const
|
||||
EMetaAnimType CMetaAnimSequence::Type() const
|
||||
{
|
||||
return eMAT_Sequence;
|
||||
return EMetaAnimType::Sequence;
|
||||
}
|
||||
|
||||
void CMetaAnimSequence::GetUniquePrimitives(std::set<CAnimPrimitive>& rPrimSet) const
|
||||
|
|
|
@ -5,13 +5,13 @@
|
|||
#include "Core/Resource/TResPtr.h"
|
||||
#include <Common/TString.h>
|
||||
|
||||
enum EMetaAnimationType
|
||||
enum class EMetaAnimType
|
||||
{
|
||||
eMAT_Play = 0,
|
||||
eMAT_Blend = 1,
|
||||
eMAT_PhaseBlend = 2, // note: structure shared with eMAT_Blend
|
||||
eMAT_Random = 3,
|
||||
eMAT_Sequence = 4
|
||||
Play = 0,
|
||||
Blend = 1,
|
||||
PhaseBlend = 2, // note: structure shared with eMAT_Blend
|
||||
Random = 3,
|
||||
Sequence = 4
|
||||
};
|
||||
|
||||
// Factory class
|
||||
|
@ -60,7 +60,7 @@ class IMetaAnimation
|
|||
public:
|
||||
IMetaAnimation() {}
|
||||
virtual ~IMetaAnimation() {}
|
||||
virtual EMetaAnimationType Type() const = 0;
|
||||
virtual EMetaAnimType Type() const = 0;
|
||||
virtual void GetUniquePrimitives(std::set<CAnimPrimitive>& rPrimSet) const = 0;
|
||||
|
||||
// Static
|
||||
|
@ -78,7 +78,7 @@ protected:
|
|||
public:
|
||||
CMetaAnimPlay(const CAnimPrimitive& rkPrimitive, float UnkA, uint32 UnkB);
|
||||
CMetaAnimPlay(IInputStream& rInput, EGame Game);
|
||||
virtual EMetaAnimationType Type() const;
|
||||
virtual EMetaAnimType Type() const;
|
||||
virtual void GetUniquePrimitives(std::set<CAnimPrimitive>& rPrimSet) const;
|
||||
|
||||
// Accessors
|
||||
|
@ -91,16 +91,16 @@ public:
|
|||
class CMetaAnimBlend : public IMetaAnimation
|
||||
{
|
||||
protected:
|
||||
EMetaAnimationType mType;
|
||||
EMetaAnimType mType;
|
||||
IMetaAnimation *mpMetaAnimA;
|
||||
IMetaAnimation *mpMetaAnimB;
|
||||
float mUnknownA;
|
||||
bool mUnknownB;
|
||||
|
||||
public:
|
||||
CMetaAnimBlend(EMetaAnimationType Type, IInputStream& rInput, EGame Game);
|
||||
CMetaAnimBlend(EMetaAnimType Type, IInputStream& rInput, EGame Game);
|
||||
~CMetaAnimBlend();
|
||||
virtual EMetaAnimationType Type() const;
|
||||
virtual EMetaAnimType Type() const;
|
||||
virtual void GetUniquePrimitives(std::set<CAnimPrimitive>& rPrimSet) const;
|
||||
|
||||
// Accessors
|
||||
|
@ -126,7 +126,7 @@ protected:
|
|||
public:
|
||||
CMetaAnimRandom(IInputStream& rInput, EGame Game);
|
||||
~CMetaAnimRandom();
|
||||
virtual EMetaAnimationType Type() const;
|
||||
virtual EMetaAnimType Type() const;
|
||||
virtual void GetUniquePrimitives(std::set<CAnimPrimitive>& rPrimSet) const;
|
||||
};
|
||||
|
||||
|
@ -139,7 +139,7 @@ protected:
|
|||
public:
|
||||
CMetaAnimSequence(IInputStream& rInput, EGame Game);
|
||||
~CMetaAnimSequence();
|
||||
virtual EMetaAnimationType Type() const;
|
||||
virtual EMetaAnimType Type() const;
|
||||
virtual void GetUniquePrimitives(std::set<CAnimPrimitive>& rPrimSet) const;
|
||||
};
|
||||
|
||||
|
|
|
@ -6,21 +6,21 @@ CMetaTransFactory gMetaTransFactory;
|
|||
|
||||
IMetaTransition* CMetaTransFactory::LoadFromStream(IInputStream& rInput, EGame Game)
|
||||
{
|
||||
EMetaTransitionType Type = (EMetaTransitionType) rInput.ReadLong();
|
||||
EMetaTransType Type = (EMetaTransType) rInput.ReadLong();
|
||||
|
||||
switch (Type)
|
||||
{
|
||||
case eMTT_MetaAnim:
|
||||
case EMetaTransType::MetaAnim:
|
||||
return new CMetaTransMetaAnim(rInput, Game);
|
||||
|
||||
case eMTT_Trans:
|
||||
case eMTT_PhaseTrans:
|
||||
case EMetaTransType::Trans:
|
||||
case EMetaTransType::PhaseTrans:
|
||||
return new CMetaTransTrans(Type, rInput, Game);
|
||||
|
||||
case eMTT_Snap:
|
||||
case EMetaTransType::Snap:
|
||||
return new CMetaTransSnap(rInput, Game);
|
||||
|
||||
case eMTT_Type4:
|
||||
case EMetaTransType::Type4:
|
||||
return new CMetaTransType4(rInput, Game);
|
||||
|
||||
default:
|
||||
|
@ -40,9 +40,9 @@ CMetaTransMetaAnim::~CMetaTransMetaAnim()
|
|||
delete mpAnim;
|
||||
}
|
||||
|
||||
EMetaTransitionType CMetaTransMetaAnim::Type() const
|
||||
EMetaTransType CMetaTransMetaAnim::Type() const
|
||||
{
|
||||
return eMTT_MetaAnim;
|
||||
return EMetaTransType::MetaAnim;
|
||||
}
|
||||
|
||||
void CMetaTransMetaAnim::GetUniquePrimitives(std::set<CAnimPrimitive>& rPrimSet) const
|
||||
|
@ -51,9 +51,9 @@ void CMetaTransMetaAnim::GetUniquePrimitives(std::set<CAnimPrimitive>& rPrimSet)
|
|||
}
|
||||
|
||||
// ************ CMetaTransTrans ************
|
||||
CMetaTransTrans::CMetaTransTrans(EMetaTransitionType Type, IInputStream& rInput, EGame Game)
|
||||
CMetaTransTrans::CMetaTransTrans(EMetaTransType Type, IInputStream& rInput, EGame Game)
|
||||
{
|
||||
ASSERT(Type == eMTT_Trans || Type == eMTT_PhaseTrans);
|
||||
ASSERT(Type == EMetaTransType::Trans || Type == EMetaTransType::PhaseTrans);
|
||||
mType = Type;
|
||||
|
||||
if (Game <= EGame::Echoes)
|
||||
|
@ -70,7 +70,7 @@ CMetaTransTrans::CMetaTransTrans(EMetaTransitionType Type, IInputStream& rInput,
|
|||
}
|
||||
}
|
||||
|
||||
EMetaTransitionType CMetaTransTrans::Type() const
|
||||
EMetaTransType CMetaTransTrans::Type() const
|
||||
{
|
||||
return mType;
|
||||
}
|
||||
|
@ -84,9 +84,9 @@ CMetaTransSnap::CMetaTransSnap(IInputStream&, EGame)
|
|||
{
|
||||
}
|
||||
|
||||
EMetaTransitionType CMetaTransSnap::Type() const
|
||||
EMetaTransType CMetaTransSnap::Type() const
|
||||
{
|
||||
return eMTT_Snap;
|
||||
return EMetaTransType::Snap;
|
||||
}
|
||||
|
||||
void CMetaTransSnap::GetUniquePrimitives(std::set<CAnimPrimitive>&) const
|
||||
|
@ -99,9 +99,9 @@ CMetaTransType4::CMetaTransType4(IInputStream& rInput, EGame)
|
|||
rInput.Skip(0x14);
|
||||
}
|
||||
|
||||
EMetaTransitionType CMetaTransType4::Type() const
|
||||
EMetaTransType CMetaTransType4::Type() const
|
||||
{
|
||||
return eMTT_Type4;
|
||||
return EMetaTransType::Type4;
|
||||
}
|
||||
|
||||
void CMetaTransType4::GetUniquePrimitives(std::set<CAnimPrimitive>&) const
|
||||
|
|
|
@ -6,13 +6,13 @@
|
|||
class IMetaAnimation;
|
||||
class IMetaTransition;
|
||||
|
||||
enum EMetaTransitionType
|
||||
enum class EMetaTransType
|
||||
{
|
||||
eMTT_MetaAnim = 0,
|
||||
eMTT_Trans = 1,
|
||||
eMTT_PhaseTrans = 2, // note: structure shared with eMTT_Trans
|
||||
eMTT_Snap = 3,
|
||||
eMTT_Type4 = 4 // MP3 only
|
||||
MetaAnim = 0,
|
||||
Trans = 1,
|
||||
PhaseTrans = 2, // note: structure shared with eMTT_Trans
|
||||
Snap = 3,
|
||||
Type4 = 4 // MP3 only
|
||||
};
|
||||
|
||||
// Factory class
|
||||
|
@ -29,7 +29,7 @@ class IMetaTransition
|
|||
public:
|
||||
IMetaTransition() {}
|
||||
virtual ~IMetaTransition() {}
|
||||
virtual EMetaTransitionType Type() const = 0;
|
||||
virtual EMetaTransType Type() const = 0;
|
||||
virtual void GetUniquePrimitives(std::set<CAnimPrimitive>& rPrimSet) const = 0;
|
||||
};
|
||||
|
||||
|
@ -41,14 +41,14 @@ class CMetaTransMetaAnim : public IMetaTransition
|
|||
public:
|
||||
CMetaTransMetaAnim(IInputStream& rInput, EGame Game);
|
||||
~CMetaTransMetaAnim();
|
||||
virtual EMetaTransitionType Type() const;
|
||||
virtual EMetaTransType Type() const;
|
||||
virtual void GetUniquePrimitives(std::set<CAnimPrimitive>& rPrimSet) const;
|
||||
};
|
||||
|
||||
// CMetaTransTrans
|
||||
class CMetaTransTrans : public IMetaTransition
|
||||
{
|
||||
EMetaTransitionType mType;
|
||||
EMetaTransType mType;
|
||||
float mUnknownA;
|
||||
uint32 mUnknownB;
|
||||
bool mUnknownC;
|
||||
|
@ -56,8 +56,8 @@ class CMetaTransTrans : public IMetaTransition
|
|||
uint32 mUnknownE;
|
||||
|
||||
public:
|
||||
CMetaTransTrans(EMetaTransitionType Type, IInputStream& rInput, EGame Game);
|
||||
virtual EMetaTransitionType Type() const;
|
||||
CMetaTransTrans(EMetaTransType Type, IInputStream& rInput, EGame Game);
|
||||
virtual EMetaTransType Type() const;
|
||||
virtual void GetUniquePrimitives(std::set<CAnimPrimitive>& rPrimSet) const;
|
||||
};
|
||||
|
||||
|
@ -66,7 +66,7 @@ class CMetaTransSnap : public IMetaTransition
|
|||
{
|
||||
public:
|
||||
CMetaTransSnap(IInputStream& rInput, EGame Game);
|
||||
virtual EMetaTransitionType Type() const;
|
||||
virtual EMetaTransType Type() const;
|
||||
virtual void GetUniquePrimitives(std::set<CAnimPrimitive>& rPrimSet) const;
|
||||
};
|
||||
|
||||
|
@ -75,7 +75,7 @@ class CMetaTransType4 : public IMetaTransition
|
|||
{
|
||||
public:
|
||||
CMetaTransType4(IInputStream& rInput, EGame Game);
|
||||
virtual EMetaTransitionType Type() const;
|
||||
virtual EMetaTransType Type() const;
|
||||
virtual void GetUniquePrimitives(std::set<CAnimPrimitive>& rPrimSet) const;
|
||||
};
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ class CScriptTemplate;
|
|||
|
||||
class CGameArea : public CResource
|
||||
{
|
||||
DECLARE_RESOURCE_TYPE(eArea)
|
||||
DECLARE_RESOURCE_TYPE(Area)
|
||||
friend class CAreaLoader;
|
||||
friend class CAreaCooker;
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
// Very limited functionality - mostly just intended to find the AGSC that a sound ID belongs to
|
||||
class CAudioGroup : public CResource
|
||||
{
|
||||
DECLARE_RESOURCE_TYPE(eAudioGroup)
|
||||
DECLARE_RESOURCE_TYPE(AudioGroup)
|
||||
friend class CAudioGroupLoader;
|
||||
|
||||
TString mGroupName;
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
class CAudioLookupTable : public CResource
|
||||
{
|
||||
DECLARE_RESOURCE_TYPE(eAudioLookupTable)
|
||||
DECLARE_RESOURCE_TYPE(AudioLookupTable)
|
||||
friend class CAudioGroupLoader;
|
||||
std::vector<uint16> mDefineIDs;
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
class CAudioMacro : public CResource
|
||||
{
|
||||
DECLARE_RESOURCE_TYPE(eAudioMacro)
|
||||
DECLARE_RESOURCE_TYPE(AudioMacro)
|
||||
friend class CUnsupportedFormatLoader;
|
||||
|
||||
TString mMacroName;
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
CCollisionMesh::CCollisionMesh()
|
||||
{
|
||||
mVBO.SetVertexDesc(ePosition | eNormal);
|
||||
mVBO.SetVertexDesc(EVertexAttribute::Position | EVertexAttribute::Normal);
|
||||
mVertexCount = 0;
|
||||
mLineCount = 0;
|
||||
mFaceCount = 0;
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
|
||||
class CCollisionMeshGroup : public CResource
|
||||
{
|
||||
DECLARE_RESOURCE_TYPE(eDynamicCollision)
|
||||
DECLARE_RESOURCE_TYPE(DynamicCollision)
|
||||
std::vector<CCollisionMesh*> mMeshes;
|
||||
|
||||
public:
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
class CDependencyGroup : public CResource
|
||||
{
|
||||
DECLARE_RESOURCE_TYPE(eDependencyGroup)
|
||||
DECLARE_RESOURCE_TYPE(DependencyGroup)
|
||||
std::vector<CAssetID> mDependencies;
|
||||
|
||||
public:
|
||||
|
|
|
@ -116,7 +116,7 @@ CVector2f CFont::RenderString(const TString& rkString, CRenderer* /*pRenderer*/,
|
|||
|
||||
// Load shader uniforms, buffer texture
|
||||
glUniformMatrix4fv(ModelMtxLoc, 1, GL_FALSE, (GLfloat*) &GlyphTransform);
|
||||
smGlyphVertices.BufferAttrib(eTex0, &pGlyph->TexCoords);
|
||||
smGlyphVertices.BufferAttrib(EVertexAttribute::Tex0, &pGlyph->TexCoords);
|
||||
|
||||
// Draw fill
|
||||
glUniform1i(LayerLoc, GlyphLayer);
|
||||
|
@ -148,7 +148,7 @@ CVector2f CFont::RenderString(const TString& rkString, CRenderer* /*pRenderer*/,
|
|||
|
||||
void CFont::InitBuffers()
|
||||
{
|
||||
smGlyphVertices.SetActiveAttribs(ePosition | eTex0);
|
||||
smGlyphVertices.SetActiveAttribs(EVertexAttribute::Position | EVertexAttribute::Tex0);
|
||||
smGlyphVertices.SetVertexCount(4);
|
||||
|
||||
CVector3f Vertices[4] = {
|
||||
|
@ -157,7 +157,7 @@ void CFont::InitBuffers()
|
|||
CVector3f( 0.f, -2.f, 0.f),
|
||||
CVector3f( 2.f, -2.f, 0.f)
|
||||
};
|
||||
smGlyphVertices.BufferAttrib(ePosition, Vertices);
|
||||
smGlyphVertices.BufferAttrib(EVertexAttribute::Position, Vertices);
|
||||
|
||||
CVector2f TexCoords[4] = {
|
||||
CVector2f(0.f, 0.f),
|
||||
|
@ -165,7 +165,7 @@ void CFont::InitBuffers()
|
|||
CVector2f(0.f, 1.f),
|
||||
CVector2f(1.f, 1.f)
|
||||
};
|
||||
smGlyphVertices.BufferAttrib(eTex0, TexCoords);
|
||||
smGlyphVertices.BufferAttrib(EVertexAttribute::Tex0, TexCoords);
|
||||
|
||||
smGlyphIndices.Reserve(4);
|
||||
smGlyphIndices.AddIndex(0);
|
||||
|
|
|
@ -18,7 +18,7 @@ class CRenderer;
|
|||
|
||||
class CFont : public CResource
|
||||
{
|
||||
DECLARE_RESOURCE_TYPE(eFont)
|
||||
DECLARE_RESOURCE_TYPE(Font)
|
||||
friend class CFontLoader;
|
||||
static CDynamicVertexBuffer smGlyphVertices; // This is the vertex buffer used to draw glyphs. It has two attributes - Pos and Tex0. Tex0 should be updated for each glyph.
|
||||
static CIndexBuffer smGlyphIndices; // This is the index buffer used to draw glyphs. It uses a triangle strip.
|
||||
|
|
|
@ -60,14 +60,14 @@ float CLight::CalculateIntensity() const
|
|||
float Greatest = (mColor.G >= mColor.B) ? mColor.G : mColor.B;
|
||||
Greatest = (mColor.R >= Greatest) ? mColor.R : Greatest;
|
||||
|
||||
float Multiplier = (mType == eCustom) ? mAngleAttenCoefficients.X : 1.0f;
|
||||
float Multiplier = (mType == ELightType::Custom) ? mAngleAttenCoefficients.X : 1.0f;
|
||||
return Greatest * Multiplier;
|
||||
}
|
||||
|
||||
// As is this one... partly
|
||||
CVector3f CLight::CalculateSpotAngleAtten()
|
||||
{
|
||||
if (mType != eSpot) return CVector3f(1.f, 0.f, 0.f);
|
||||
if (mType != ELightType::Spot) return CVector3f(1.f, 0.f, 0.f);
|
||||
|
||||
if ((mSpotCutoff < 0.f) || (mSpotCutoff > 90.f))
|
||||
return CVector3f(1.f, 0.f, 0.f);
|
||||
|
@ -141,14 +141,15 @@ CStructProperty* CLight::GetProperties() const
|
|||
0,
|
||||
"Light");
|
||||
|
||||
//@todo it would be really cool if the property could detect all possible values automatically from TEnumReflection
|
||||
CChoiceProperty* pLightType = (CChoiceProperty*) IProperty::CreateIntrinsic(EPropertyType::Choice,
|
||||
pProperties,
|
||||
MEMBER_OFFSET(CLight, mType),
|
||||
"LightType");
|
||||
pLightType->AddValue("LocalAmbient", eLocalAmbient);
|
||||
pLightType->AddValue("Directional", eDirectional);
|
||||
pLightType->AddValue("Spot", eSpot);
|
||||
pLightType->AddValue("Custom", eCustom);
|
||||
pLightType->AddValue("LocalAmbient", (uint32) ELightType::LocalAmbient);
|
||||
pLightType->AddValue("Directional", (uint32) ELightType::Directional);
|
||||
pLightType->AddValue("Spot", (uint32) ELightType::Spot);
|
||||
pLightType->AddValue("Custom", (uint32) ELightType::Custom);
|
||||
|
||||
IProperty::CreateIntrinsic(EPropertyType::Color,
|
||||
pProperties,
|
||||
|
@ -184,24 +185,24 @@ void CLight::Load() const
|
|||
|
||||
switch (mType)
|
||||
{
|
||||
case eLocalAmbient:
|
||||
case ELightType::LocalAmbient:
|
||||
// LocalAmbient is already accounted for in CGraphics::sAreaAmbientColor
|
||||
return;
|
||||
case eDirectional:
|
||||
case ELightType::Directional:
|
||||
pLight->Position = CVector4f(-mDirection * 1048576.f, 1.f);
|
||||
pLight->Direction = CVector4f(mDirection, 0.f);
|
||||
pLight->Color = mColor * CGraphics::sWorldLightMultiplier;
|
||||
pLight->DistAtten = CVector4f(1.f, 0.f, 0.f, 0.f);
|
||||
pLight->AngleAtten = CVector4f(1.f, 0.f, 0.f, 0.f);
|
||||
break;
|
||||
case eSpot:
|
||||
case ELightType::Spot:
|
||||
pLight->Position = CVector4f(mPosition, 1.f);
|
||||
pLight->Direction = CVector4f(mDirection, 0.f);
|
||||
pLight->Color = mColor * CGraphics::sWorldLightMultiplier;
|
||||
pLight->DistAtten = mDistAttenCoefficients;
|
||||
pLight->AngleAtten = mAngleAttenCoefficients;
|
||||
break;
|
||||
case eCustom:
|
||||
case ELightType::Custom:
|
||||
pLight->Position = CVector4f(mPosition, 1.f);
|
||||
pLight->Direction = CVector4f(mDirection, 0.f);
|
||||
pLight->Color = mColor * CGraphics::sWorldLightMultiplier;
|
||||
|
@ -218,7 +219,7 @@ void CLight::Load() const
|
|||
CLight* CLight::BuildLocalAmbient(const CVector3f& rkPosition, const CColor& rkColor)
|
||||
{
|
||||
CLight *pLight = new CLight;
|
||||
pLight->mType = eLocalAmbient;
|
||||
pLight->mType = ELightType::LocalAmbient;
|
||||
pLight->mPosition = rkPosition;
|
||||
pLight->mDirection = skDefaultLightDir;
|
||||
pLight->mColor = rkColor;
|
||||
|
@ -229,7 +230,7 @@ CLight* CLight::BuildLocalAmbient(const CVector3f& rkPosition, const CColor& rkC
|
|||
CLight* CLight::BuildDirectional(const CVector3f& rkPosition, const CVector3f& rkDirection, const CColor& rkColor)
|
||||
{
|
||||
CLight *pLight = new CLight;
|
||||
pLight->mType = eDirectional;
|
||||
pLight->mType = ELightType::Directional;
|
||||
pLight->mPosition = rkPosition;
|
||||
pLight->mDirection = rkDirection;
|
||||
pLight->mColor = rkColor;
|
||||
|
@ -240,7 +241,7 @@ CLight* CLight::BuildDirectional(const CVector3f& rkPosition, const CVector3f& r
|
|||
CLight* CLight::BuildSpot(const CVector3f& rkPosition, const CVector3f& rkDirection, const CColor& rkColor, float Cutoff)
|
||||
{
|
||||
CLight *pLight = new CLight;
|
||||
pLight->mType = eSpot;
|
||||
pLight->mType = ELightType::Spot;
|
||||
pLight->mPosition = rkPosition;
|
||||
pLight->mDirection = -rkDirection.Normalized();
|
||||
pLight->mColor = rkColor;
|
||||
|
@ -254,7 +255,7 @@ CLight* CLight::BuildCustom(const CVector3f& rkPosition, const CVector3f& rkDire
|
|||
float AngleAttenA, float AngleAttenB, float AngleAttenC)
|
||||
{
|
||||
CLight *pLight = new CLight;
|
||||
pLight->mType = eCustom;
|
||||
pLight->mType = ELightType::Custom;
|
||||
pLight->mPosition = rkPosition;
|
||||
pLight->mDirection = rkDirection;
|
||||
pLight->mColor = rkColor;
|
||||
|
|
|
@ -9,12 +9,12 @@
|
|||
/* CLight is currently heavily based on the lights system from Metroid Prime,
|
||||
* including code reverse engineered from the game's executable. Not yet sure
|
||||
* how much needs to be modified to properly support DKCR. */
|
||||
enum ELightType
|
||||
enum class ELightType
|
||||
{
|
||||
eLocalAmbient = 0,
|
||||
eDirectional = 1,
|
||||
eSpot = 3,
|
||||
eCustom = 2
|
||||
LocalAmbient = 0,
|
||||
Directional = 1,
|
||||
Spot = 3,
|
||||
Custom = 2
|
||||
};
|
||||
|
||||
class CLight
|
||||
|
|
|
@ -15,12 +15,12 @@ std::map<uint64, CMaterial::SMaterialShader> CMaterial::smShaderMap;
|
|||
|
||||
CMaterial::CMaterial()
|
||||
: mpShader(nullptr)
|
||||
, mShaderStatus(eNoShader)
|
||||
, mShaderStatus(EShaderStatus::NoShader)
|
||||
, mRecalcHash(true)
|
||||
, mEnableBloom(false)
|
||||
, mVersion(EGame::Invalid)
|
||||
, mOptions(eNoSettings)
|
||||
, mVtxDesc(eNoAttributes)
|
||||
, mOptions(EMaterialOption::None)
|
||||
, mVtxDesc(EVertexAttribute::None)
|
||||
, mBlendSrcFac(GL_ONE)
|
||||
, mBlendDstFac(GL_ZERO)
|
||||
, mLightingEnabled(true)
|
||||
|
@ -32,11 +32,11 @@ CMaterial::CMaterial()
|
|||
|
||||
CMaterial::CMaterial(EGame Version, FVertexDescription VtxDesc)
|
||||
: mpShader(nullptr)
|
||||
, mShaderStatus(eNoShader)
|
||||
, mShaderStatus(EShaderStatus::NoShader)
|
||||
, mRecalcHash(true)
|
||||
, mEnableBloom(Version == EGame::Corruption)
|
||||
, mVersion(Version)
|
||||
, mOptions(eDepthWrite)
|
||||
, mOptions(EMaterialOption::DepthWrite)
|
||||
, mVtxDesc(VtxDesc)
|
||||
, mBlendSrcFac(GL_ONE)
|
||||
, mBlendDstFac(GL_ZERO)
|
||||
|
@ -46,11 +46,11 @@ CMaterial::CMaterial(EGame Version, FVertexDescription VtxDesc)
|
|||
, mpIndirectTexture(nullptr)
|
||||
{
|
||||
mpShader = nullptr;
|
||||
mShaderStatus = eNoShader;
|
||||
mShaderStatus = EShaderStatus::NoShader;
|
||||
mRecalcHash = true;
|
||||
mEnableBloom = (Version == EGame::Corruption);
|
||||
mVersion = Version;
|
||||
mOptions = eDepthWrite;
|
||||
mOptions = EMaterialOption::DepthWrite;
|
||||
mVtxDesc = VtxDesc;
|
||||
mBlendSrcFac = GL_ONE;
|
||||
mBlendDstFac = GL_ZERO;
|
||||
|
@ -96,7 +96,7 @@ void CMaterial::GenerateShader(bool AllowRegen /*= true*/)
|
|||
{
|
||||
HashParameters(); // Calling HashParameters() may change mShaderStatus so call it before checking
|
||||
|
||||
if (mShaderStatus != eShaderExists || AllowRegen)
|
||||
if (mShaderStatus != EShaderStatus::ShaderExists || AllowRegen)
|
||||
{
|
||||
auto Find = smShaderMap.find(mParametersHash);
|
||||
|
||||
|
@ -119,14 +119,14 @@ void CMaterial::GenerateShader(bool AllowRegen /*= true*/)
|
|||
|
||||
if (!mpShader->IsValidProgram())
|
||||
{
|
||||
mShaderStatus = eShaderFailed;
|
||||
mShaderStatus = EShaderStatus::ShaderFailed;
|
||||
delete mpShader;
|
||||
mpShader = nullptr;
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
mShaderStatus = eShaderExists;
|
||||
mShaderStatus = EShaderStatus::ShaderExists;
|
||||
smShaderMap[mParametersHash] = SMaterialShader { 1, mpShader };
|
||||
}
|
||||
}
|
||||
|
@ -152,7 +152,7 @@ void CMaterial::ClearShader()
|
|||
}
|
||||
|
||||
mpShader = nullptr;
|
||||
mShaderStatus = eNoShader;
|
||||
mShaderStatus = EShaderStatus::NoShader;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -162,16 +162,16 @@ bool CMaterial::SetCurrent(FRenderOptions Options)
|
|||
if (sCurrentMaterial != HashParameters())
|
||||
{
|
||||
// Shader setup
|
||||
if (mShaderStatus == eNoShader) GenerateShader();
|
||||
if (mShaderStatus == EShaderStatus::NoShader) GenerateShader();
|
||||
mpShader->SetCurrent();
|
||||
|
||||
if (mShaderStatus == eShaderFailed)
|
||||
if (mShaderStatus == EShaderStatus::ShaderFailed)
|
||||
return false;
|
||||
|
||||
// Set RGB blend equation - force to ZERO/ONE if alpha is disabled
|
||||
GLenum srcRGB, dstRGB, srcAlpha, dstAlpha;
|
||||
|
||||
if (Options & eNoAlpha) {
|
||||
if (Options & ERenderOption::NoAlpha) {
|
||||
srcRGB = GL_ONE;
|
||||
dstRGB = GL_ZERO;
|
||||
} else {
|
||||
|
@ -182,7 +182,7 @@ bool CMaterial::SetCurrent(FRenderOptions Options)
|
|||
// Set alpha blend equation
|
||||
bool AlphaBlended = ((mBlendSrcFac == GL_SRC_ALPHA) && (mBlendDstFac == GL_ONE_MINUS_SRC_ALPHA));
|
||||
|
||||
if ((mEnableBloom) && (Options & eEnableBloom) && (!AlphaBlended)) {
|
||||
if ((mEnableBloom) && (Options & ERenderOption::EnableBloom) && (!AlphaBlended)) {
|
||||
srcAlpha = mBlendSrcFac;
|
||||
dstAlpha = mBlendDstFac;
|
||||
} else {
|
||||
|
@ -201,7 +201,7 @@ bool CMaterial::SetCurrent(FRenderOptions Options)
|
|||
CGraphics::sVertexBlock.COLOR0_Mat = CColor::skWhite;
|
||||
|
||||
// Set depth write - force on if alpha is disabled (lots of weird depth issues otherwise)
|
||||
if ((mOptions & eDepthWrite) || (Options & eNoAlpha)) glDepthMask(GL_TRUE);
|
||||
if ((mOptions & EMaterialOption::DepthWrite) || (Options & ERenderOption::NoAlpha)) glDepthMask(GL_TRUE);
|
||||
else glDepthMask(GL_FALSE);
|
||||
|
||||
// Load uniforms
|
||||
|
@ -218,8 +218,8 @@ bool CMaterial::SetCurrent(FRenderOptions Options)
|
|||
{
|
||||
EUVAnimMode mode = mPasses[iPass]->AnimMode();
|
||||
|
||||
if ((mode == eInverseMV) || (mode == eInverseMVTranslated) ||
|
||||
(mode == eModelMatrix) || (mode == eSimpleMode))
|
||||
if ((mode == EUVAnimMode::InverseMV) || (mode == EUVAnimMode::InverseMVTranslated) ||
|
||||
(mode == EUVAnimMode::ModelMatrix) || (mode == EUVAnimMode::SimpleMode))
|
||||
mPasses[iPass]->SetAnimCurrent(Options, iPass);
|
||||
}
|
||||
}
|
||||
|
@ -243,7 +243,7 @@ uint64 CMaterial::HashParameters()
|
|||
{
|
||||
if (mRecalcHash)
|
||||
{
|
||||
CFNV1A Hash(CFNV1A::e64Bit);
|
||||
CFNV1A Hash(CFNV1A::k64Bit);
|
||||
|
||||
Hash.HashLong((int) mVersion);
|
||||
Hash.HashLong(mOptions);
|
||||
|
@ -273,7 +273,7 @@ uint64 CMaterial::HashParameters()
|
|||
void CMaterial::Update()
|
||||
{
|
||||
mRecalcHash = true;
|
||||
mShaderStatus = eNoShader;
|
||||
mShaderStatus = EShaderStatus::NoShader;
|
||||
}
|
||||
|
||||
void CMaterial::SetNumPasses(uint32 NumPasses)
|
||||
|
|
|
@ -16,35 +16,33 @@
|
|||
|
||||
class CMaterialSet;
|
||||
|
||||
// Enums
|
||||
enum class EMaterialOption
|
||||
{
|
||||
None = 0,
|
||||
Konst = 0x8,
|
||||
Transparent = 0x10,
|
||||
Masked = 0x20,
|
||||
Reflection = 0x40,
|
||||
DepthWrite = 0x80,
|
||||
SurfaceReflection = 0x100,
|
||||
Occluder = 0x200,
|
||||
IndStage = 0x400,
|
||||
Lightmap = 0x800,
|
||||
ShortTexCoord = 0x2000,
|
||||
AllMP1Settings = 0x2FF8,
|
||||
DrawWhiteAmbientDKCR = 0x80000
|
||||
};
|
||||
DECLARE_FLAGS_ENUMCLASS(EMaterialOption, FMaterialOptions)
|
||||
|
||||
class CMaterial
|
||||
{
|
||||
public:
|
||||
friend class CMaterialLoader;
|
||||
friend class CMaterialCooker;
|
||||
|
||||
// Enums
|
||||
enum EMaterialOption
|
||||
enum class EShaderStatus
|
||||
{
|
||||
eNoSettings = 0,
|
||||
eKonst = 0x8,
|
||||
eTransparent = 0x10,
|
||||
ePunchthrough = 0x20,
|
||||
eReflection = 0x40,
|
||||
eDepthWrite = 0x80,
|
||||
eSurfaceReflection = 0x100,
|
||||
eOccluder = 0x200,
|
||||
eIndStage = 0x400,
|
||||
eLightmap = 0x800,
|
||||
eShortTexCoord = 0x2000,
|
||||
eAllMP1Settings = 0x2FF8,
|
||||
eDrawWhiteAmbientDKCR = 0x80000
|
||||
};
|
||||
DECLARE_FLAGS(EMaterialOption, FMaterialOptions)
|
||||
|
||||
private:
|
||||
enum EShaderStatus
|
||||
{
|
||||
eNoShader, eShaderExists, eShaderFailed
|
||||
NoShader, ShaderExists, ShaderFailed
|
||||
};
|
||||
|
||||
// Statics
|
||||
|
|
|
@ -5,22 +5,22 @@
|
|||
|
||||
CMaterialPass::CMaterialPass(CMaterial *pParent)
|
||||
: mPassType("CUST")
|
||||
, mSettings(eNoPassSettings)
|
||||
, mSettings(EPassSettings::None)
|
||||
, mpTexture(nullptr)
|
||||
, mEnabled(true)
|
||||
, mpParentMat(pParent)
|
||||
, mColorOutput(ePrevReg)
|
||||
, mAlphaOutput(ePrevReg)
|
||||
, mKColorSel(eKonstOne)
|
||||
, mKAlphaSel(eKonstOne)
|
||||
, mRasSel(eRasColorNull)
|
||||
, mColorOutput(kPrevReg)
|
||||
, mAlphaOutput(kPrevReg)
|
||||
, mKColorSel(kKonstOne)
|
||||
, mKAlphaSel(kKonstOne)
|
||||
, mRasSel(kRasColorNull)
|
||||
, mTexCoordSource(0xFF)
|
||||
, mAnimMode(eNoUVAnim)
|
||||
, mAnimMode(EUVAnimMode::NoUVAnim)
|
||||
{
|
||||
for (uint32 iParam = 0; iParam < 4; iParam++)
|
||||
{
|
||||
mColorInputs[iParam] = eZeroRGB;
|
||||
mAlphaInputs[iParam] = eZeroAlpha;
|
||||
mColorInputs[iParam] = kZeroRGB;
|
||||
mAlphaInputs[iParam] = kZeroAlpha;
|
||||
mAnimParams[iParam] = 0.f;
|
||||
}
|
||||
}
|
||||
|
@ -72,7 +72,7 @@ void CMaterialPass::HashParameters(CFNV1A& rHash)
|
|||
rHash.HashLong(mKAlphaSel);
|
||||
rHash.HashLong(mRasSel);
|
||||
rHash.HashLong(mTexCoordSource);
|
||||
rHash.HashLong(mAnimMode);
|
||||
rHash.HashLong((uint) mAnimMode);
|
||||
rHash.HashData(mAnimParams, sizeof(float) * 4);
|
||||
rHash.HashByte(mEnabled);
|
||||
}
|
||||
|
@ -86,7 +86,7 @@ void CMaterialPass::LoadTexture(uint32 PassIndex)
|
|||
|
||||
void CMaterialPass::SetAnimCurrent(FRenderOptions Options, uint32 PassIndex)
|
||||
{
|
||||
if (mAnimMode == eNoUVAnim) return;
|
||||
if (mAnimMode == EUVAnimMode::NoUVAnim) return;
|
||||
|
||||
float Seconds = CTimer::SecondsMod900();
|
||||
const CMatrix4f& ModelMtx = CGraphics::sMVPBlock.ModelMatrix;
|
||||
|
@ -98,8 +98,8 @@ void CMaterialPass::SetAnimCurrent(FRenderOptions Options, uint32 PassIndex)
|
|||
switch (mAnimMode)
|
||||
{
|
||||
|
||||
case eInverseMV: // Mode 0
|
||||
case eSimpleMode: // Mode 10 - maybe not correct?
|
||||
case EUVAnimMode::InverseMV: // Mode 0
|
||||
case EUVAnimMode::SimpleMode: // Mode 10 - maybe not correct?
|
||||
{
|
||||
TexMtx = (ViewMtx.Inverse().Transpose() * ModelMtx);
|
||||
TexMtx[0][3] = TexMtx[1][3] = TexMtx[2][3] = 0.f;
|
||||
|
@ -110,7 +110,7 @@ void CMaterialPass::SetAnimCurrent(FRenderOptions Options, uint32 PassIndex)
|
|||
break;
|
||||
}
|
||||
|
||||
case eInverseMVTranslated: // Mode 1
|
||||
case EUVAnimMode::InverseMVTranslated: // Mode 1
|
||||
{
|
||||
TexMtx = (ViewMtx.Inverse().Transpose() * ModelMtx);
|
||||
PostMtx = CMatrix4f(0.5f, 0.0f, 0.0f, 0.5f,
|
||||
|
@ -119,9 +119,9 @@ void CMaterialPass::SetAnimCurrent(FRenderOptions Options, uint32 PassIndex)
|
|||
0.0f, 0.0f, 0.0f, 1.0f);
|
||||
}
|
||||
|
||||
case eUVScroll: // Mode 2
|
||||
case EUVAnimMode::UVScroll: // Mode 2
|
||||
{
|
||||
if (Options & eEnableUVScroll)
|
||||
if (Options & ERenderOption::EnableUVScroll)
|
||||
{
|
||||
TexMtx[0][3] = (Seconds * mAnimParams[2]) + mAnimParams[0];
|
||||
TexMtx[1][3] = (Seconds * mAnimParams[3]) + mAnimParams[1];
|
||||
|
@ -129,9 +129,9 @@ void CMaterialPass::SetAnimCurrent(FRenderOptions Options, uint32 PassIndex)
|
|||
break;
|
||||
}
|
||||
|
||||
case eUVRotation: // Mode 3
|
||||
case EUVAnimMode::UVRotation: // Mode 3
|
||||
{
|
||||
if (Options & eEnableUVScroll)
|
||||
if (Options & ERenderOption::EnableUVScroll)
|
||||
{
|
||||
float Angle = (Seconds * mAnimParams[1]) + mAnimParams[0];
|
||||
|
||||
|
@ -148,20 +148,20 @@ void CMaterialPass::SetAnimCurrent(FRenderOptions Options, uint32 PassIndex)
|
|||
break;
|
||||
}
|
||||
|
||||
case eHFilmstrip: // Mode 4
|
||||
case eVFilmstrip: // Mode 5
|
||||
case EUVAnimMode::HFilmstrip: // Mode 4
|
||||
case EUVAnimMode::VFilmstrip: // Mode 5
|
||||
{
|
||||
if (Options & eEnableUVScroll)
|
||||
if (Options & ERenderOption::EnableUVScroll)
|
||||
{
|
||||
float Offset = mAnimParams[2] * mAnimParams[0] * (mAnimParams[3] + Seconds);
|
||||
Offset = (float)(short)(float)(mAnimParams[1] * fmod(Offset, 1.0f)) * mAnimParams[2];
|
||||
if (mAnimMode == eHFilmstrip) TexMtx[0][3] = Offset;
|
||||
if (mAnimMode == eVFilmstrip) TexMtx[1][3] = Offset;
|
||||
if (mAnimMode == EUVAnimMode::HFilmstrip) TexMtx[0][3] = Offset;
|
||||
if (mAnimMode == EUVAnimMode::VFilmstrip) TexMtx[1][3] = Offset;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case eModelMatrix: // Mode 6
|
||||
case EUVAnimMode::ModelMatrix: // Mode 6
|
||||
{
|
||||
// It looks ok, but I can't tell whether it's correct...
|
||||
TexMtx = ModelMtx;
|
||||
|
@ -174,7 +174,7 @@ void CMaterialPass::SetAnimCurrent(FRenderOptions Options, uint32 PassIndex)
|
|||
TexMtx[2][3] = 0.f;
|
||||
}
|
||||
|
||||
case eConvolutedModeA: // Mode 7
|
||||
case EUVAnimMode::ConvolutedModeA: // Mode 7
|
||||
{
|
||||
CMatrix4f View = CGraphics::sMVPBlock.ViewMatrix;
|
||||
|
||||
|
@ -196,7 +196,7 @@ void CMaterialPass::SetAnimCurrent(FRenderOptions Options, uint32 PassIndex)
|
|||
break;
|
||||
}
|
||||
|
||||
case eConvolutedModeB: // Mode 8 (MP3/DKCR only)
|
||||
case EUVAnimMode::ConvolutedModeB: // Mode 8 (MP3/DKCR only)
|
||||
{
|
||||
// todo
|
||||
break;
|
||||
|
@ -256,8 +256,8 @@ void CMaterialPass::SetKColorSel(ETevKSel Sel)
|
|||
void CMaterialPass::SetKAlphaSel(ETevKSel Sel)
|
||||
{
|
||||
// Konst RGB is invalid for alpha, so reset to One if that's the selection
|
||||
if ((Sel >= eKonst0_RGB) && (Sel <= eKonst3_RGB))
|
||||
Sel = eKonstOne;
|
||||
if ((Sel >= kKonst0_RGB) && (Sel <= kKonst3_RGB))
|
||||
Sel = kKonstOne;
|
||||
|
||||
mKAlphaSel = Sel;
|
||||
mpParentMat->Update();
|
||||
|
|
|
@ -10,23 +10,22 @@
|
|||
|
||||
class CMaterial;
|
||||
|
||||
enum class EPassSettings
|
||||
{
|
||||
None = 0x0,
|
||||
EmissiveBloom = 0x4,
|
||||
InvertOpacityMap = 0x10
|
||||
};
|
||||
DECLARE_FLAGS_ENUMCLASS(EPassSettings, FPassSettings)
|
||||
|
||||
class CMaterialPass
|
||||
{
|
||||
friend class CMaterialLoader;
|
||||
friend class CMaterialCooker;
|
||||
|
||||
public:
|
||||
enum EPassSettings
|
||||
{
|
||||
eNoPassSettings = 0x0,
|
||||
eEmissiveBloom = 0x4,
|
||||
eInvertOpacityMap = 0x10
|
||||
};
|
||||
|
||||
private:
|
||||
CMaterial *mpParentMat;
|
||||
CFourCC mPassType;
|
||||
EPassSettings mSettings;
|
||||
FPassSettings mSettings;
|
||||
|
||||
ETevColorInput mColorInputs[4];
|
||||
ETevAlphaInput mAlphaInputs[4];
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
|
||||
class CPoiToWorld : public CResource
|
||||
{
|
||||
DECLARE_RESOURCE_TYPE(eStaticGeometryMap)
|
||||
DECLARE_RESOURCE_TYPE(StaticGeometryMap)
|
||||
|
||||
public:
|
||||
struct SPoiMap
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
class CResTypeFilter
|
||||
{
|
||||
EGame mGame;
|
||||
std::set<EResType> mAcceptedTypes;
|
||||
std::set<EResourceType> mAcceptedTypes;
|
||||
|
||||
public:
|
||||
CResTypeFilter() : mGame(EGame::Invalid) { }
|
||||
|
@ -53,7 +53,7 @@ public:
|
|||
rArc << SerialParameter("AcceptedTypes", mAcceptedTypes, SH_Proxy);
|
||||
}
|
||||
|
||||
inline bool Accepts(EResType Type) const
|
||||
inline bool Accepts(EResourceType Type) const
|
||||
{
|
||||
return mAcceptedTypes.find(Type) != mAcceptedTypes.end();
|
||||
}
|
||||
|
|
|
@ -2,9 +2,9 @@
|
|||
#include <Common/Macros.h>
|
||||
#include <algorithm>
|
||||
|
||||
std::unordered_map<EResType, CResTypeInfo*> CResTypeInfo::smTypeMap;
|
||||
std::unordered_map<EResourceType, CResTypeInfo*> CResTypeInfo::smTypeMap;
|
||||
|
||||
CResTypeInfo::CResTypeInfo(EResType Type, const TString& rkTypeName, const TString& rkRetroExtension)
|
||||
CResTypeInfo::CResTypeInfo(EResourceType Type, const TString& rkTypeName, const TString& rkRetroExtension)
|
||||
: mType(Type)
|
||||
, mTypeName(rkTypeName)
|
||||
, mRetroExtension(rkRetroExtension)
|
||||
|
@ -117,7 +117,7 @@ void Serialize(IArchive& rArc, CResTypeInfo*& rpType)
|
|||
}
|
||||
}
|
||||
|
||||
void Serialize(IArchive& rArc, EResType& rType)
|
||||
void Serialize(IArchive& rArc, EResourceType& rType)
|
||||
{
|
||||
CFourCC Extension;
|
||||
|
||||
|
@ -169,235 +169,235 @@ void CResTypeInfo::CResTypeInfoFactory::AddExtension(CResTypeInfo *pType, CFourC
|
|||
void CResTypeInfo::CResTypeInfoFactory::InitTypes()
|
||||
{
|
||||
{
|
||||
CResTypeInfo *pType = new CResTypeInfo(eAnimation, "Animation", "ani");
|
||||
CResTypeInfo *pType = new CResTypeInfo(EResourceType::Animation, "Animation", "ani");
|
||||
AddExtension(pType, "ANIM", EGame::PrimeDemo, EGame::DKCReturns);
|
||||
}
|
||||
{
|
||||
CResTypeInfo *pType = new CResTypeInfo(eAnimCollisionPrimData, "Animation Collision Primitive Data", "?");
|
||||
CResTypeInfo *pType = new CResTypeInfo(EResourceType::AnimCollisionPrimData, "Animation Collision Primitive Data", "?");
|
||||
AddExtension(pType, "CPRM", EGame::DKCReturns, EGame::DKCReturns);
|
||||
pType->mCanHaveDependencies = false;
|
||||
}
|
||||
{
|
||||
CResTypeInfo *pType = new CResTypeInfo(eAnimEventData, "Animation Event Data", "evnt");
|
||||
CResTypeInfo *pType = new CResTypeInfo(EResourceType::AnimEventData, "Animation Event Data", "evnt");
|
||||
AddExtension(pType, "EVNT", EGame::PrimeDemo, EGame::Prime);
|
||||
}
|
||||
{
|
||||
CResTypeInfo *pType = new CResTypeInfo(eAnimSet, "Animation Character Set", "acs");
|
||||
CResTypeInfo *pType = new CResTypeInfo(EResourceType::AnimSet, "Animation Character Set", "acs");
|
||||
AddExtension(pType, "ANCS", EGame::PrimeDemo, EGame::Echoes);
|
||||
}
|
||||
{
|
||||
CResTypeInfo *pType = new CResTypeInfo(eArea, "Area", "mrea");
|
||||
CResTypeInfo *pType = new CResTypeInfo(EResourceType::Area, "Area", "mrea");
|
||||
AddExtension(pType, "MREA", EGame::PrimeDemo, EGame::DKCReturns);
|
||||
}
|
||||
{
|
||||
CResTypeInfo *pType = new CResTypeInfo(eAudioAmplitudeData, "Audio Amplitude Data", "?");
|
||||
CResTypeInfo *pType = new CResTypeInfo(EResourceType::AudioAmplitudeData, "Audio Amplitude Data", "?");
|
||||
AddExtension(pType, "CAAD", EGame::Corruption, EGame::Corruption);
|
||||
}
|
||||
{
|
||||
CResTypeInfo *pType = new CResTypeInfo(eAudioGroup, "Audio Group", "agsc");
|
||||
CResTypeInfo *pType = new CResTypeInfo(EResourceType::AudioGroup, "Audio Group", "agsc");
|
||||
AddExtension(pType, "AGSC", EGame::PrimeDemo, EGame::Echoes);
|
||||
pType->mCanHaveDependencies = false;
|
||||
}
|
||||
{
|
||||
CResTypeInfo *pType = new CResTypeInfo(eAudioMacro, "Audio Macro", "caud");
|
||||
CResTypeInfo *pType = new CResTypeInfo(EResourceType::AudioMacro, "Audio Macro", "caud");
|
||||
AddExtension(pType, "CAUD", EGame::CorruptionProto, EGame::DKCReturns);
|
||||
}
|
||||
{
|
||||
CResTypeInfo *pType = new CResTypeInfo(eAudioSample, "Audio Sample", "csmp");
|
||||
CResTypeInfo *pType = new CResTypeInfo(EResourceType::AudioSample, "Audio Sample", "csmp");
|
||||
AddExtension(pType, "CSMP", EGame::CorruptionProto, EGame::DKCReturns);
|
||||
pType->mCanHaveDependencies = false;
|
||||
}
|
||||
{
|
||||
CResTypeInfo *pType = new CResTypeInfo(eAudioLookupTable, "Audio Lookup Table", "atbl");
|
||||
CResTypeInfo *pType = new CResTypeInfo(EResourceType::AudioLookupTable, "Audio Lookup Table", "atbl");
|
||||
AddExtension(pType, "ATBL", EGame::PrimeDemo, EGame::Corruption);
|
||||
pType->mCanHaveDependencies = false;
|
||||
}
|
||||
{
|
||||
CResTypeInfo *pType = new CResTypeInfo(eBinaryData, "Generic Data", "dat");
|
||||
CResTypeInfo *pType = new CResTypeInfo(EResourceType::BinaryData, "Generic Data", "dat");
|
||||
AddExtension(pType, "DUMB", EGame::PrimeDemo, EGame::Corruption);
|
||||
}
|
||||
{
|
||||
CResTypeInfo *pType = new CResTypeInfo(eBurstFireData, "Burst Fire Data", "bfre.bfrc");
|
||||
CResTypeInfo *pType = new CResTypeInfo(EResourceType::BurstFireData, "Burst Fire Data", "bfre.bfrc");
|
||||
AddExtension(pType, "BFRC", EGame::CorruptionProto, EGame::Corruption);
|
||||
}
|
||||
{
|
||||
CResTypeInfo *pType = new CResTypeInfo(eCharacter, "Character", "char");
|
||||
CResTypeInfo *pType = new CResTypeInfo(EResourceType::Character, "Character", "char");
|
||||
AddExtension(pType, "CHAR", EGame::CorruptionProto, EGame::DKCReturns);
|
||||
}
|
||||
{
|
||||
CResTypeInfo *pType = new CResTypeInfo(eDependencyGroup, "Dependency Group", "?");
|
||||
CResTypeInfo *pType = new CResTypeInfo(EResourceType::DependencyGroup, "Dependency Group", "?");
|
||||
AddExtension(pType, "DGRP", EGame::PrimeDemo, EGame::DKCReturns);
|
||||
}
|
||||
{
|
||||
CResTypeInfo *pType = new CResTypeInfo(eDynamicCollision, "Dynamic Collision", "dcln");
|
||||
CResTypeInfo *pType = new CResTypeInfo(EResourceType::DynamicCollision, "Dynamic Collision", "dcln");
|
||||
AddExtension(pType, "DCLN", EGame::PrimeDemo, EGame::DKCReturns);
|
||||
pType->mCanHaveDependencies = false;
|
||||
}
|
||||
{
|
||||
CResTypeInfo *pType = new CResTypeInfo(eFont, "Font", "rpff");
|
||||
CResTypeInfo *pType = new CResTypeInfo(EResourceType::Font, "Font", "rpff");
|
||||
AddExtension(pType, "FONT", EGame::PrimeDemo, EGame::DKCReturns);
|
||||
}
|
||||
{
|
||||
CResTypeInfo *pType = new CResTypeInfo(eGuiFrame, "Gui Frame", "frme");
|
||||
CResTypeInfo *pType = new CResTypeInfo(EResourceType::GuiFrame, "Gui Frame", "frme");
|
||||
AddExtension(pType, "FRME", EGame::PrimeDemo, EGame::DKCReturns);
|
||||
}
|
||||
{
|
||||
CResTypeInfo *pType = new CResTypeInfo(eGuiKeyFrame, "Gui Keyframe", "?");
|
||||
CResTypeInfo *pType = new CResTypeInfo(EResourceType::GuiKeyFrame, "Gui Keyframe", "?");
|
||||
AddExtension(pType, "KFAM", EGame::PrimeDemo, EGame::PrimeDemo);
|
||||
}
|
||||
{
|
||||
CResTypeInfo *pType = new CResTypeInfo(eHintSystem, "Hint System Data", "hint");
|
||||
CResTypeInfo *pType = new CResTypeInfo(EResourceType::HintSystem, "Hint System Data", "hint");
|
||||
AddExtension(pType, "HINT", EGame::Prime, EGame::Corruption);
|
||||
}
|
||||
{
|
||||
CResTypeInfo *pType = new CResTypeInfo(eMapArea, "Area Map", "mapa");
|
||||
CResTypeInfo *pType = new CResTypeInfo(EResourceType::MapArea, "Area Map", "mapa");
|
||||
AddExtension(pType, "MAPA", EGame::PrimeDemo, EGame::Corruption);
|
||||
}
|
||||
{
|
||||
CResTypeInfo *pType = new CResTypeInfo(eMapWorld, "World Map", "mapw");
|
||||
CResTypeInfo *pType = new CResTypeInfo(EResourceType::MapWorld, "World Map", "mapw");
|
||||
AddExtension(pType, "MAPW", EGame::PrimeDemo, EGame::Corruption);
|
||||
}
|
||||
{
|
||||
CResTypeInfo *pType = new CResTypeInfo(eMapUniverse, "Universe Map", "mapu");
|
||||
CResTypeInfo *pType = new CResTypeInfo(EResourceType::MapUniverse, "Universe Map", "mapu");
|
||||
AddExtension(pType, "MAPU", EGame::PrimeDemo, EGame::Echoes);
|
||||
}
|
||||
{
|
||||
CResTypeInfo *pType = new CResTypeInfo(eMidi, "MIDI", "?");
|
||||
CResTypeInfo *pType = new CResTypeInfo(EResourceType::Midi, "MIDI", "?");
|
||||
AddExtension(pType, "CSNG", EGame::PrimeDemo, EGame::Echoes);
|
||||
}
|
||||
{
|
||||
CResTypeInfo *pType = new CResTypeInfo(eModel, "Model", "cmdl");
|
||||
CResTypeInfo *pType = new CResTypeInfo(EResourceType::Model, "Model", "cmdl");
|
||||
AddExtension(pType, "CMDL", EGame::PrimeDemo, EGame::DKCReturns);
|
||||
}
|
||||
{
|
||||
CResTypeInfo *pType = new CResTypeInfo(eParticle, "Particle System", "gpsm.part");
|
||||
CResTypeInfo *pType = new CResTypeInfo(EResourceType::Particle, "Particle System", "gpsm.part");
|
||||
AddExtension(pType, "PART", EGame::PrimeDemo, EGame::DKCReturns);
|
||||
}
|
||||
{
|
||||
CResTypeInfo *pType = new CResTypeInfo(eParticleCollisionResponse, "Collision Response Particle System", "crsm.crsc");
|
||||
CResTypeInfo *pType = new CResTypeInfo(EResourceType::ParticleCollisionResponse, "Collision Response Particle System", "crsm.crsc");
|
||||
AddExtension(pType, "CRSC", EGame::PrimeDemo, EGame::Corruption);
|
||||
}
|
||||
{
|
||||
CResTypeInfo *pType = new CResTypeInfo(eParticleDecal, "Decal Particle System", "dpsm.dpsc");
|
||||
CResTypeInfo *pType = new CResTypeInfo(EResourceType::ParticleDecal, "Decal Particle System", "dpsm.dpsc");
|
||||
AddExtension(pType, "DPSC", EGame::PrimeDemo, EGame::Corruption);
|
||||
}
|
||||
{
|
||||
CResTypeInfo *pType = new CResTypeInfo(eParticleElectric, "Electric Particle System", "elsm.elsc");
|
||||
CResTypeInfo *pType = new CResTypeInfo(EResourceType::ParticleElectric, "Electric Particle System", "elsm.elsc");
|
||||
AddExtension(pType, "ELSC", EGame::PrimeDemo, EGame::Corruption);
|
||||
}
|
||||
{
|
||||
CResTypeInfo *pType = new CResTypeInfo(eParticleSorted, "Sorted Particle System", "srsm.srsc");
|
||||
CResTypeInfo *pType = new CResTypeInfo(EResourceType::ParticleSorted, "Sorted Particle System", "srsm.srsc");
|
||||
AddExtension(pType, "SRSC", EGame::EchoesDemo, EGame::Echoes);
|
||||
}
|
||||
{
|
||||
CResTypeInfo *pType = new CResTypeInfo(eParticleSpawn, "Spawn Particle System", "spsm.spsc");
|
||||
CResTypeInfo *pType = new CResTypeInfo(EResourceType::ParticleSpawn, "Spawn Particle System", "spsm.spsc");
|
||||
AddExtension(pType, "SPSC", EGame::EchoesDemo, EGame::DKCReturns);
|
||||
}
|
||||
{
|
||||
CResTypeInfo *pType = new CResTypeInfo(eParticleSwoosh, "Swoosh Particle System", "swsh.swhc");
|
||||
CResTypeInfo *pType = new CResTypeInfo(EResourceType::ParticleSwoosh, "Swoosh Particle System", "swsh.swhc");
|
||||
AddExtension(pType, "SWHC", EGame::PrimeDemo, EGame::DKCReturns);
|
||||
}
|
||||
{
|
||||
CResTypeInfo *pType = new CResTypeInfo(eParticleTransform, "Transform Particle System", "xfsm.xfsc");
|
||||
CResTypeInfo *pType = new CResTypeInfo(EResourceType::ParticleTransform, "Transform Particle System", "xfsm.xfsc");
|
||||
AddExtension(pType, "XFSC", EGame::DKCReturns, EGame::DKCReturns);
|
||||
}
|
||||
{
|
||||
CResTypeInfo *pType = new CResTypeInfo(eParticleWeapon, "Weapon Particle System", "wpsm.wpsc");
|
||||
CResTypeInfo *pType = new CResTypeInfo(EResourceType::ParticleWeapon, "Weapon Particle System", "wpsm.wpsc");
|
||||
AddExtension(pType, "WPSC", EGame::PrimeDemo, EGame::Corruption);
|
||||
}
|
||||
{
|
||||
CResTypeInfo *pType = new CResTypeInfo(ePathfinding, "Pathfinding Mesh", "path");
|
||||
CResTypeInfo *pType = new CResTypeInfo(EResourceType::Pathfinding, "Pathfinding Mesh", "path");
|
||||
AddExtension(pType, "PATH", EGame::PrimeDemo, EGame::Corruption);
|
||||
pType->mCanHaveDependencies = false;
|
||||
}
|
||||
{
|
||||
CResTypeInfo *pType = new CResTypeInfo(ePortalArea, "Portal Area", "?");
|
||||
CResTypeInfo *pType = new CResTypeInfo(EResourceType::PortalArea, "Portal Area", "?");
|
||||
AddExtension(pType, "PTLA", EGame::EchoesDemo, EGame::Corruption);
|
||||
pType->mCanHaveDependencies = false;
|
||||
}
|
||||
{
|
||||
CResTypeInfo *pType = new CResTypeInfo(eRuleSet, "Rule Set", "rule");
|
||||
CResTypeInfo *pType = new CResTypeInfo(EResourceType::RuleSet, "Rule Set", "rule");
|
||||
AddExtension(pType, "RULE", EGame::EchoesDemo, EGame::DKCReturns);
|
||||
}
|
||||
{
|
||||
CResTypeInfo *pType = new CResTypeInfo(eSaveArea, "Area Save Info", "sava");
|
||||
CResTypeInfo *pType = new CResTypeInfo(EResourceType::SaveArea, "Area Save Info", "sava");
|
||||
AddExtension(pType, "SAVA", EGame::CorruptionProto, EGame::Corruption);
|
||||
pType->mCanHaveDependencies = false;
|
||||
}
|
||||
{
|
||||
CResTypeInfo *pType = new CResTypeInfo(eSaveWorld, "World Save Info", "savw");
|
||||
CResTypeInfo *pType = new CResTypeInfo(EResourceType::SaveWorld, "World Save Info", "savw");
|
||||
AddExtension(pType, "SAVW", EGame::Prime, EGame::DKCReturns);
|
||||
pType->mCanHaveDependencies = false;
|
||||
}
|
||||
{
|
||||
CResTypeInfo *pType = new CResTypeInfo(eScan, "Scan", "scan");
|
||||
CResTypeInfo *pType = new CResTypeInfo(EResourceType::Scan, "Scan", "scan");
|
||||
AddExtension(pType, "SCAN", EGame::PrimeDemo, EGame::Corruption);
|
||||
}
|
||||
{
|
||||
CResTypeInfo *pType = new CResTypeInfo(eSkeleton, "Skeleton", "cin");
|
||||
CResTypeInfo *pType = new CResTypeInfo(EResourceType::Skeleton, "Skeleton", "cin");
|
||||
AddExtension(pType, "CINF", EGame::PrimeDemo, EGame::DKCReturns);
|
||||
pType->mCanHaveDependencies = false;
|
||||
}
|
||||
{
|
||||
CResTypeInfo *pType = new CResTypeInfo(eSkin, "Skin", "cskr");
|
||||
CResTypeInfo *pType = new CResTypeInfo(EResourceType::Skin, "Skin", "cskr");
|
||||
AddExtension(pType, "CSKR", EGame::PrimeDemo, EGame::DKCReturns);
|
||||
pType->mCanHaveDependencies = false;
|
||||
}
|
||||
{
|
||||
CResTypeInfo *pType = new CResTypeInfo(eSourceAnimData, "Source Animation Data", "sand");
|
||||
CResTypeInfo *pType = new CResTypeInfo(EResourceType::SourceAnimData, "Source Animation Data", "sand");
|
||||
AddExtension(pType, "SAND", EGame::CorruptionProto, EGame::Corruption);
|
||||
pType->mCanHaveDependencies = false; // all dependencies are added to the CHAR dependency tree
|
||||
}
|
||||
{
|
||||
CResTypeInfo *pType = new CResTypeInfo(eSpatialPrimitive, "Spatial Primitive", "?");
|
||||
CResTypeInfo *pType = new CResTypeInfo(EResourceType::SpatialPrimitive, "Spatial Primitive", "?");
|
||||
AddExtension(pType, "CSPP", EGame::EchoesDemo, EGame::Echoes);
|
||||
pType->mCanHaveDependencies = false;
|
||||
}
|
||||
{
|
||||
CResTypeInfo *pType = new CResTypeInfo(eStateMachine, "State Machine", "afsm");
|
||||
CResTypeInfo *pType = new CResTypeInfo(EResourceType::StateMachine, "State Machine", "afsm");
|
||||
AddExtension(pType, "AFSM", EGame::PrimeDemo, EGame::Echoes);
|
||||
AddExtension(pType, "FSM2", EGame::CorruptionProto, EGame::Corruption);
|
||||
AddExtension(pType, "FSMC", EGame::DKCReturns, EGame::DKCReturns);
|
||||
}
|
||||
{
|
||||
CResTypeInfo *pType = new CResTypeInfo(eStateMachine2, "State Machine 2", "fsm2");
|
||||
CResTypeInfo *pType = new CResTypeInfo(EResourceType::StateMachine2, "State Machine 2", "fsm2");
|
||||
AddExtension(pType, "FSM2", EGame::EchoesDemo, EGame::Corruption);
|
||||
}
|
||||
{
|
||||
CResTypeInfo *pType = new CResTypeInfo(eStaticGeometryMap, "Static Scan Map", "egmc");
|
||||
CResTypeInfo *pType = new CResTypeInfo(EResourceType::StaticGeometryMap, "Static Scan Map", "egmc");
|
||||
AddExtension(pType, "EGMC", EGame::EchoesDemo, EGame::Corruption);
|
||||
pType->mCanHaveDependencies = false;
|
||||
}
|
||||
{
|
||||
CResTypeInfo *pType = new CResTypeInfo(eStreamedAudio, "Streamed Audio", "?");
|
||||
CResTypeInfo *pType = new CResTypeInfo(EResourceType::StreamedAudio, "Streamed Audio", "?");
|
||||
AddExtension(pType, "STRM", EGame::CorruptionProto, EGame::DKCReturns);
|
||||
pType->mCanHaveDependencies = false;
|
||||
}
|
||||
{
|
||||
CResTypeInfo *pType = new CResTypeInfo(eStringList, "String List", "stlc");
|
||||
CResTypeInfo *pType = new CResTypeInfo(EResourceType::StringList, "String List", "stlc");
|
||||
AddExtension(pType, "STLC", EGame::EchoesDemo, EGame::CorruptionProto);
|
||||
pType->mCanHaveDependencies = false;
|
||||
}
|
||||
{
|
||||
CResTypeInfo *pType = new CResTypeInfo(eStringTable, "String Table", "strg");
|
||||
CResTypeInfo *pType = new CResTypeInfo(EResourceType::StringTable, "String Table", "strg");
|
||||
AddExtension(pType, "STRG", EGame::PrimeDemo, EGame::DKCReturns);
|
||||
}
|
||||
{
|
||||
CResTypeInfo *pType = new CResTypeInfo(eTexture, "Texture", "txtr");
|
||||
CResTypeInfo *pType = new CResTypeInfo(EResourceType::Texture, "Texture", "txtr");
|
||||
AddExtension(pType, "TXTR", EGame::PrimeDemo, EGame::DKCReturns);
|
||||
pType->mCanHaveDependencies = false;
|
||||
}
|
||||
{
|
||||
CResTypeInfo *pType = new CResTypeInfo(eTweak, "Tweak Data", "ctwk");
|
||||
CResTypeInfo *pType = new CResTypeInfo(EResourceType::Tweak, "Tweak Data", "ctwk");
|
||||
AddExtension(pType, "CTWK", EGame::PrimeDemo, EGame::Prime);
|
||||
pType->mCanHaveDependencies = false;
|
||||
}
|
||||
{
|
||||
CResTypeInfo *pType = new CResTypeInfo(eUserEvaluatorData, "User Evaluator Data", "user.usrc");
|
||||
CResTypeInfo *pType = new CResTypeInfo(EResourceType::UserEvaluatorData, "User Evaluator Data", "user.usrc");
|
||||
AddExtension(pType, "USRC", EGame::CorruptionProto, EGame::Corruption);
|
||||
}
|
||||
{
|
||||
CResTypeInfo *pType = new CResTypeInfo(eWorld, "World", "mwld");
|
||||
CResTypeInfo *pType = new CResTypeInfo(EResourceType::World, "World", "mwld");
|
||||
AddExtension(pType, "MLVL", EGame::PrimeDemo, EGame::DKCReturns);
|
||||
pType->mCanBeSerialized = true;
|
||||
}
|
||||
|
|
|
@ -17,17 +17,17 @@ class CResTypeInfo
|
|||
CFourCC CookedExt;
|
||||
};
|
||||
|
||||
EResType mType;
|
||||
EResourceType mType;
|
||||
TString mTypeName;
|
||||
std::vector<SGameExtension> mCookedExtensions;
|
||||
TString mRetroExtension; // File extension in Retro's directory tree. We don't use it directly but it is needed for generating asset ID hashes
|
||||
bool mCanBeSerialized;
|
||||
bool mCanHaveDependencies;
|
||||
|
||||
static std::unordered_map<EResType, CResTypeInfo*> smTypeMap;
|
||||
static std::unordered_map<EResourceType, CResTypeInfo*> smTypeMap;
|
||||
|
||||
// Private Methods
|
||||
CResTypeInfo(EResType Type, const TString& rkTypeName, const TString& rkRetroExtension);
|
||||
CResTypeInfo(EResourceType Type, const TString& rkTypeName, const TString& rkRetroExtension);
|
||||
~CResTypeInfo() {}
|
||||
|
||||
// Public Methods
|
||||
|
@ -36,7 +36,7 @@ public:
|
|||
CFourCC CookedExtension(EGame Game) const;
|
||||
|
||||
// Accessors
|
||||
inline EResType Type() const { return mType; }
|
||||
inline EResourceType Type() const { return mType; }
|
||||
inline TString TypeName() const { return mTypeName; }
|
||||
inline bool CanBeSerialized() const { return mCanBeSerialized; }
|
||||
inline bool CanHaveDependencies() const { return mCanHaveDependencies; }
|
||||
|
@ -45,7 +45,7 @@ public:
|
|||
static void GetAllTypesInGame(EGame Game, std::list<CResTypeInfo*>& rOut);
|
||||
static CResTypeInfo* TypeForCookedExtension(EGame, CFourCC Ext);
|
||||
|
||||
inline static CResTypeInfo* FindTypeInfo(EResType Type)
|
||||
inline static CResTypeInfo* FindTypeInfo(EResourceType Type)
|
||||
{
|
||||
auto Iter = smTypeMap.find(Type);
|
||||
return (Iter == smTypeMap.end() ? nullptr : Iter->second);
|
||||
|
|
|
@ -13,11 +13,11 @@
|
|||
|
||||
// This macro creates functions that allow us to easily identify this resource type.
|
||||
// Must be included on every CResource subclass.
|
||||
#define DECLARE_RESOURCE_TYPE(ResTypeEnum) \
|
||||
#define DECLARE_RESOURCE_TYPE(ResourceTypeEnum) \
|
||||
public: \
|
||||
static EResType StaticType() \
|
||||
static EResourceType StaticType() \
|
||||
{ \
|
||||
return ResTypeEnum; \
|
||||
return EResourceType::ResourceTypeEnum; \
|
||||
} \
|
||||
\
|
||||
static CResTypeInfo* StaticTypeInfo() \
|
||||
|
@ -29,7 +29,7 @@ private: \
|
|||
|
||||
class CResource
|
||||
{
|
||||
DECLARE_RESOURCE_TYPE(eResource)
|
||||
DECLARE_RESOURCE_TYPE(Resource)
|
||||
|
||||
CResourceEntry *mpEntry;
|
||||
int mRefCount;
|
||||
|
@ -46,7 +46,7 @@ public:
|
|||
|
||||
inline CResourceEntry* Entry() const { return mpEntry; }
|
||||
inline CResTypeInfo* TypeInfo() const { return mpEntry->TypeInfo(); }
|
||||
inline EResType Type() const { return mpEntry->TypeInfo()->Type(); }
|
||||
inline EResourceType Type() const { return mpEntry->TypeInfo()->Type(); }
|
||||
inline TString Source() const { return mpEntry ? mpEntry->CookedAssetPath(true).GetFileName() : ""; }
|
||||
inline TString FullSource() const { return mpEntry ? mpEntry->CookedAssetPath(true) : ""; }
|
||||
inline CAssetID ID() const { return mpEntry ? mpEntry->ID() : CAssetID::skInvalidID64; }
|
||||
|
|
|
@ -9,18 +9,18 @@
|
|||
|
||||
class CScan : public CResource
|
||||
{
|
||||
DECLARE_RESOURCE_TYPE(eScan)
|
||||
DECLARE_RESOURCE_TYPE(Scan)
|
||||
friend class CScanLoader;
|
||||
|
||||
public:
|
||||
// This likely needs revising when MP2/MP3 support is added
|
||||
enum ELogbookCategory
|
||||
enum class ELogbookCategory
|
||||
{
|
||||
eNone,
|
||||
ePirateData,
|
||||
eChozoLore,
|
||||
eCreatures,
|
||||
eResearch
|
||||
None,
|
||||
PirateData,
|
||||
ChozoLore,
|
||||
Creatures,
|
||||
Research
|
||||
};
|
||||
|
||||
struct SScanInfoSecondaryModel
|
||||
|
@ -61,7 +61,7 @@ public:
|
|||
, mpStringTable(nullptr)
|
||||
, mIsSlow(false)
|
||||
, mIsImportant(false)
|
||||
, mCategory(eNone)
|
||||
, mCategory(ELogbookCategory::None)
|
||||
{}
|
||||
|
||||
CDependencyTree* BuildDependencyTree() const
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
class CStringList : public CResource
|
||||
{
|
||||
DECLARE_RESOURCE_TYPE(eStringList)
|
||||
DECLARE_RESOURCE_TYPE(StringList)
|
||||
friend class CAudioGroupLoader;
|
||||
std::vector<TString> mStringList;
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
|
||||
class CStringTable : public CResource
|
||||
{
|
||||
DECLARE_RESOURCE_TYPE(eStringTable)
|
||||
DECLARE_RESOURCE_TYPE(StringTable)
|
||||
friend class CStringLoader;
|
||||
|
||||
std::vector<TString> mStringNames;
|
||||
|
@ -46,7 +46,7 @@ public:
|
|||
{
|
||||
// STRGs can reference FONTs with the &font=; formatting tag and TXTRs with the &image=; tag
|
||||
CDependencyTree *pTree = new CDependencyTree();
|
||||
EIDLength IDLength = (Game() <= EGame::Echoes ? e32Bit : e64Bit);
|
||||
EIDLength IDLength = (Game() <= EGame::Echoes ? k32Bit : k64Bit);
|
||||
|
||||
for (uint32 iLang = 0; iLang < mLangTables.size(); iLang++)
|
||||
{
|
||||
|
|
|
@ -2,8 +2,8 @@
|
|||
|
||||
CTexture::CTexture(CResourceEntry *pEntry /*= 0*/)
|
||||
: CResource(pEntry)
|
||||
, mTexelFormat(eRGBA8)
|
||||
, mSourceTexelFormat(eRGBA8)
|
||||
, mTexelFormat(ETexelFormat::RGBA8)
|
||||
, mSourceTexelFormat(ETexelFormat::RGBA8)
|
||||
, mWidth(0)
|
||||
, mHeight(0)
|
||||
, mNumMipMaps(0)
|
||||
|
@ -17,8 +17,8 @@ CTexture::CTexture(CResourceEntry *pEntry /*= 0*/)
|
|||
}
|
||||
|
||||
CTexture::CTexture(uint32 Width, uint32 Height)
|
||||
: mTexelFormat(eRGBA8)
|
||||
, mSourceTexelFormat(eRGBA8)
|
||||
: mTexelFormat(ETexelFormat::RGBA8)
|
||||
, mSourceTexelFormat(ETexelFormat::RGBA8)
|
||||
, mWidth((uint16) Width)
|
||||
, mHeight((uint16) Height)
|
||||
, mNumMipMaps(1)
|
||||
|
@ -47,27 +47,27 @@ bool CTexture::BufferGL()
|
|||
|
||||
switch (mTexelFormat)
|
||||
{
|
||||
case eLuminance:
|
||||
case ETexelFormat::Luminance:
|
||||
GLFormat = GL_LUMINANCE;
|
||||
GLType = GL_UNSIGNED_BYTE;
|
||||
break;
|
||||
case eLuminanceAlpha:
|
||||
case ETexelFormat::LuminanceAlpha:
|
||||
GLFormat = GL_LUMINANCE_ALPHA;
|
||||
GLType = GL_UNSIGNED_BYTE;
|
||||
break;
|
||||
case eRGB565:
|
||||
case ETexelFormat::RGB565:
|
||||
GLFormat = GL_RGB;
|
||||
GLType = GL_UNSIGNED_SHORT_5_6_5;
|
||||
break;
|
||||
case eRGBA4:
|
||||
case ETexelFormat::RGBA4:
|
||||
GLFormat = GL_RGBA;
|
||||
GLType = GL_UNSIGNED_SHORT_4_4_4_4;
|
||||
break;
|
||||
case eRGBA8:
|
||||
case ETexelFormat::RGBA8:
|
||||
GLFormat = GL_RGBA;
|
||||
GLType = GL_UNSIGNED_BYTE;
|
||||
break;
|
||||
case eDXT1:
|
||||
case ETexelFormat::DXT1:
|
||||
GLFormat = GL_COMPRESSED_RGBA_S3TC_DXT1_EXT;
|
||||
IsCompressed = true;
|
||||
break;
|
||||
|
@ -145,9 +145,9 @@ float CTexture::ReadTexelAlpha(const CVector2f& rkTexCoord)
|
|||
uint32 TexelX = (uint32) ((mWidth - 1) * rkTexCoord.X);
|
||||
uint32 TexelY = (uint32) ((mHeight - 1) * (1.f - fmodf(rkTexCoord.Y, 1.f)));
|
||||
|
||||
if (mTexelFormat == eDXT1 && mBufferExists)
|
||||
if (mTexelFormat == ETexelFormat::DXT1 && mBufferExists)
|
||||
{
|
||||
CMemoryInStream Buffer(mpImgDataBuffer, mImgDataSize, IOUtil::kSystemEndianness);
|
||||
CMemoryInStream Buffer(mpImgDataBuffer, mImgDataSize, EEndian::SystemEndian);
|
||||
|
||||
// 8 bytes per 4x4 16-pixel block, left-to-right top-to-bottom
|
||||
uint32 BlockIdxX = TexelX / 4;
|
||||
|
@ -205,18 +205,18 @@ bool CTexture::WriteDDS(IOutputStream& rOut)
|
|||
|
||||
switch (mTexelFormat)
|
||||
{
|
||||
case eLuminance:
|
||||
case ETexelFormat::Luminance:
|
||||
PFFlags = 0x20000;
|
||||
PFBpp = 0x8;
|
||||
PFRBitMask = 0xFF;
|
||||
break;
|
||||
case eLuminanceAlpha:
|
||||
case ETexelFormat::LuminanceAlpha:
|
||||
PFFlags = 0x20001;
|
||||
PFBpp = 0x10;
|
||||
PFRBitMask = 0x00FF;
|
||||
PFABitMask = 0xFF00;
|
||||
break;
|
||||
case eRGBA4:
|
||||
case ETexelFormat::RGBA4:
|
||||
PFFlags = 0x41;
|
||||
PFBpp = 0x10;
|
||||
PFRBitMask = 0x0F00;
|
||||
|
@ -224,14 +224,14 @@ bool CTexture::WriteDDS(IOutputStream& rOut)
|
|||
PFBBitMask = 0x000F;
|
||||
PFABitMask = 0xF000;
|
||||
break;
|
||||
case eRGB565:
|
||||
case ETexelFormat::RGB565:
|
||||
PFFlags = 0x40;
|
||||
PFBpp = 0x10;
|
||||
PFRBitMask = 0xF800;
|
||||
PFGBitMask = 0x7E0;
|
||||
PFBBitMask = 0x1F;
|
||||
break;
|
||||
case eRGBA8:
|
||||
case ETexelFormat::RGBA8:
|
||||
PFFlags = 0x41;
|
||||
PFBpp = 0x20;
|
||||
PFRBitMask = 0x00FF0000;
|
||||
|
@ -239,13 +239,13 @@ bool CTexture::WriteDDS(IOutputStream& rOut)
|
|||
PFBBitMask = 0x000000FF;
|
||||
PFABitMask = 0xFF000000;
|
||||
break;
|
||||
case eDXT1:
|
||||
case ETexelFormat::DXT1:
|
||||
PFFlags = 0x4;
|
||||
break;
|
||||
}
|
||||
|
||||
rOut.WriteLong(PFFlags); // DDS_PIXELFORMAT.dwFlags
|
||||
(mTexelFormat == eDXT1) ? rOut.WriteFourCC(FOURCC('DXT1')) : rOut.WriteLong(0); // DDS_PIXELFORMAT.dwFourCC
|
||||
(mTexelFormat == ETexelFormat::DXT1) ? rOut.WriteFourCC(FOURCC('DXT1')) : rOut.WriteLong(0); // DDS_PIXELFORMAT.dwFourCC
|
||||
rOut.WriteLong(PFBpp); // DDS_PIXELFORMAT.dwRGBBitCount
|
||||
rOut.WriteLong(PFRBitMask); // DDS_PIXELFORMAT.dwRBitMask
|
||||
rOut.WriteLong(PFGBitMask); // DDS_PIXELFORMAT.dwGBitMask
|
||||
|
@ -267,22 +267,22 @@ uint32 CTexture::FormatBPP(ETexelFormat Format)
|
|||
{
|
||||
switch (Format)
|
||||
{
|
||||
case eGX_I4: return 4;
|
||||
case eGX_I8: return 8;
|
||||
case eGX_IA4: return 8;
|
||||
case eGX_IA8: return 16;
|
||||
case eGX_C4: return 4;
|
||||
case eGX_C8: return 8;
|
||||
case eGX_RGB565: return 16;
|
||||
case eGX_RGB5A3: return 16;
|
||||
case eGX_RGBA8: return 32;
|
||||
case eGX_CMPR: return 4;
|
||||
case eLuminance: return 8;
|
||||
case eLuminanceAlpha: return 16;
|
||||
case eRGBA4: return 16;
|
||||
case eRGB565: return 16;
|
||||
case eRGBA8: return 32;
|
||||
case eDXT1: return 4;
|
||||
case ETexelFormat::GX_I4: return 4;
|
||||
case ETexelFormat::GX_I8: return 8;
|
||||
case ETexelFormat::GX_IA4: return 8;
|
||||
case ETexelFormat::GX_IA8: return 16;
|
||||
case ETexelFormat::GX_C4: return 4;
|
||||
case ETexelFormat::GX_C8: return 8;
|
||||
case ETexelFormat::GX_RGB565: return 16;
|
||||
case ETexelFormat::GX_RGB5A3: return 16;
|
||||
case ETexelFormat::GX_RGBA8: return 32;
|
||||
case ETexelFormat::GX_CMPR: return 4;
|
||||
case ETexelFormat::Luminance: return 8;
|
||||
case ETexelFormat::LuminanceAlpha: return 16;
|
||||
case ETexelFormat::RGBA4: return 16;
|
||||
case ETexelFormat::RGB565: return 16;
|
||||
case ETexelFormat::RGBA8: return 32;
|
||||
case ETexelFormat::DXT1: return 4;
|
||||
default: return 0;
|
||||
}
|
||||
}
|
||||
|
@ -346,7 +346,7 @@ void CTexture::CopyGLBuffer()
|
|||
MipH /= 2;
|
||||
}
|
||||
|
||||
mTexelFormat = eRGBA8;
|
||||
mTexelFormat = ETexelFormat::RGBA8;
|
||||
mLinearSize = mWidth * mHeight * 4;
|
||||
}
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
|
||||
class CTexture : public CResource
|
||||
{
|
||||
DECLARE_RESOURCE_TYPE(eTexture)
|
||||
DECLARE_RESOURCE_TYPE(Texture)
|
||||
friend class CTextureDecoder;
|
||||
friend class CTextureEncoder;
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
|
||||
class CWorld : public CResource
|
||||
{
|
||||
DECLARE_RESOURCE_TYPE(eWorld)
|
||||
DECLARE_RESOURCE_TYPE(World)
|
||||
friend class CWorldLoader;
|
||||
friend class CWorldCooker;
|
||||
|
||||
|
|
|
@ -9,26 +9,26 @@ CMaterialCooker::CMaterialCooker()
|
|||
uint32 CMaterialCooker::ConvertFromVertexDescription(FVertexDescription VtxDesc)
|
||||
{
|
||||
uint32 Flags = 0;
|
||||
if (VtxDesc & ePosition) Flags |= 0x00000003;
|
||||
if (VtxDesc & eNormal) Flags |= 0x0000000C;
|
||||
if (VtxDesc & eColor0) Flags |= 0x00000030;
|
||||
if (VtxDesc & eColor1) Flags |= 0x000000C0;
|
||||
if (VtxDesc & eTex0) Flags |= 0x00000300;
|
||||
if (VtxDesc & eTex1) Flags |= 0x00000C00;
|
||||
if (VtxDesc & eTex2) Flags |= 0x00003000;
|
||||
if (VtxDesc & eTex3) Flags |= 0x0000C000;
|
||||
if (VtxDesc & eTex4) Flags |= 0x00030000;
|
||||
if (VtxDesc & eTex5) Flags |= 0x000C0000;
|
||||
if (VtxDesc & eTex6) Flags |= 0x00300000;
|
||||
if (VtxDesc & eTex7) Flags |= 0x00C00000;
|
||||
if (VtxDesc & ePosMtx) Flags |= 0x01000000;
|
||||
if (VtxDesc & eTex0Mtx) Flags |= 0x02000000;
|
||||
if (VtxDesc & eTex1Mtx) Flags |= 0x04000000;
|
||||
if (VtxDesc & eTex2Mtx) Flags |= 0x08000000;
|
||||
if (VtxDesc & eTex3Mtx) Flags |= 0x10000000;
|
||||
if (VtxDesc & eTex4Mtx) Flags |= 0x20000000;
|
||||
if (VtxDesc & eTex5Mtx) Flags |= 0x40000000;
|
||||
if (VtxDesc & eTex6Mtx) Flags |= 0x80000000;
|
||||
if (VtxDesc & EVertexAttribute::Position) Flags |= 0x00000003;
|
||||
if (VtxDesc & EVertexAttribute::Normal) Flags |= 0x0000000C;
|
||||
if (VtxDesc & EVertexAttribute::Color0) Flags |= 0x00000030;
|
||||
if (VtxDesc & EVertexAttribute::Color1) Flags |= 0x000000C0;
|
||||
if (VtxDesc & EVertexAttribute::Tex0) Flags |= 0x00000300;
|
||||
if (VtxDesc & EVertexAttribute::Tex1) Flags |= 0x00000C00;
|
||||
if (VtxDesc & EVertexAttribute::Tex2) Flags |= 0x00003000;
|
||||
if (VtxDesc & EVertexAttribute::Tex3) Flags |= 0x0000C000;
|
||||
if (VtxDesc & EVertexAttribute::Tex4) Flags |= 0x00030000;
|
||||
if (VtxDesc & EVertexAttribute::Tex5) Flags |= 0x000C0000;
|
||||
if (VtxDesc & EVertexAttribute::Tex6) Flags |= 0x00300000;
|
||||
if (VtxDesc & EVertexAttribute::Tex7) Flags |= 0x00C00000;
|
||||
if (VtxDesc & EVertexAttribute::PosMtx) Flags |= 0x01000000;
|
||||
if (VtxDesc & EVertexAttribute::Tex0Mtx) Flags |= 0x02000000;
|
||||
if (VtxDesc & EVertexAttribute::Tex1Mtx) Flags |= 0x04000000;
|
||||
if (VtxDesc & EVertexAttribute::Tex2Mtx) Flags |= 0x08000000;
|
||||
if (VtxDesc & EVertexAttribute::Tex3Mtx) Flags |= 0x10000000;
|
||||
if (VtxDesc & EVertexAttribute::Tex4Mtx) Flags |= 0x20000000;
|
||||
if (VtxDesc & EVertexAttribute::Tex5Mtx) Flags |= 0x40000000;
|
||||
if (VtxDesc & EVertexAttribute::Tex6Mtx) Flags |= 0x80000000;
|
||||
return Flags;
|
||||
}
|
||||
|
||||
|
@ -98,19 +98,20 @@ void CMaterialCooker::WriteMatSetCorruption(IOutputStream& /*rOut*/)
|
|||
void CMaterialCooker::WriteMaterialPrime(IOutputStream& rOut)
|
||||
{
|
||||
// Gather data from the passes before we start writing
|
||||
uint32 TexFlags = 0;
|
||||
uint32 NumKonst = 0;
|
||||
std::vector<uint32> TexIndices;
|
||||
uint TexFlags = 0;
|
||||
uint NumKonst = 0;
|
||||
std::vector<uint> TexIndices;
|
||||
|
||||
for (uint32 iPass = 0; iPass < mpMat->mPasses.size(); iPass++)
|
||||
for (uint iPass = 0; iPass < mpMat->mPasses.size(); iPass++)
|
||||
{
|
||||
CMaterialPass *pPass = mpMat->Pass(iPass);
|
||||
|
||||
if ((pPass->KColorSel() >= 0xC) || (pPass->KAlphaSel() >= 0x10))
|
||||
if ((pPass->KColorSel() >= kKonst0_RGB) ||
|
||||
(pPass->KAlphaSel() >= kKonst0_R))
|
||||
{
|
||||
// Determine the highest Konst index being used
|
||||
uint32 KColorIndex = pPass->KColorSel() % 4;
|
||||
uint32 KAlphaIndex = pPass->KAlphaSel() % 4;
|
||||
uint KColorIndex = ((uint) pPass->KColorSel()) % 4;
|
||||
uint KAlphaIndex = ((uint) pPass->KAlphaSel()) % 4;
|
||||
|
||||
if (KColorIndex >= NumKonst)
|
||||
NumKonst = KColorIndex + 1;
|
||||
|
@ -272,14 +273,14 @@ void CMaterialCooker::WriteMaterialPrime(IOutputStream& rOut)
|
|||
CMaterialPass *pPass = mpMat->Pass(iPass);
|
||||
if (pPass->Texture() == nullptr) continue;
|
||||
|
||||
uint32 AnimType = pPass->AnimMode();
|
||||
EUVAnimMode AnimType = pPass->AnimMode();
|
||||
uint32 CoordSource = pPass->TexCoordSource();
|
||||
|
||||
uint32 TexMtxIdx, PostMtxIdx;
|
||||
bool Normalize;
|
||||
|
||||
// No animation - set TexMtx and PostMtx to identity, disable normalization
|
||||
if (AnimType == eNoUVAnim)
|
||||
if (AnimType == EUVAnimMode::NoUVAnim)
|
||||
{
|
||||
TexMtxIdx = 30;
|
||||
PostMtxIdx = 61;
|
||||
|
@ -291,7 +292,7 @@ void CMaterialCooker::WriteMaterialPrime(IOutputStream& rOut)
|
|||
{
|
||||
TexMtxIdx = CurTexMtx;
|
||||
|
||||
if ((AnimType < 2) || (AnimType > 5))
|
||||
if ((AnimType <= EUVAnimMode::InverseMVTranslated) || (AnimType >= EUVAnimMode::ModelMatrix))
|
||||
{
|
||||
PostMtxIdx = CurTexMtx;
|
||||
Normalize = true;
|
||||
|
@ -318,17 +319,17 @@ void CMaterialCooker::WriteMaterialPrime(IOutputStream& rOut)
|
|||
for (uint32 iPass = 0; iPass < NumPasses; iPass++)
|
||||
{
|
||||
CMaterialPass *pPass = mpMat->Pass(iPass);
|
||||
uint32 AnimMode = pPass->AnimMode();
|
||||
if (AnimMode == eNoUVAnim) continue;
|
||||
EUVAnimMode AnimMode = pPass->AnimMode();
|
||||
if (AnimMode == EUVAnimMode::NoUVAnim) continue;
|
||||
|
||||
rOut.WriteLong(AnimMode);
|
||||
rOut.WriteLong((int) AnimMode);
|
||||
|
||||
if ((AnimMode > 1) && (AnimMode != 6))
|
||||
if ((AnimMode >= EUVAnimMode::UVScroll) && (AnimMode != EUVAnimMode::ModelMatrix))
|
||||
{
|
||||
rOut.WriteFloat(pPass->AnimParam(0));
|
||||
rOut.WriteFloat(pPass->AnimParam(1));
|
||||
|
||||
if ((AnimMode == 2) || (AnimMode == 4) || (AnimMode == 5))
|
||||
if ((AnimMode == EUVAnimMode::UVScroll) || (AnimMode == EUVAnimMode::HFilmstrip) || (AnimMode == EUVAnimMode::VFilmstrip))
|
||||
{
|
||||
rOut.WriteFloat(pPass->AnimParam(2));
|
||||
rOut.WriteFloat(pPass->AnimParam(3));
|
||||
|
|
|
@ -18,7 +18,7 @@ void CModelCooker::GenerateSurfaceData()
|
|||
mVertices.resize(mNumVertices);
|
||||
|
||||
// Get vertex attributes
|
||||
mVtxAttribs = eNoAttributes;
|
||||
mVtxAttribs = EVertexAttribute::None;
|
||||
|
||||
for (uint32 iMat = 0; iMat < mpModel->GetMatCount(); iMat++)
|
||||
{
|
||||
|
@ -115,7 +115,8 @@ void CModelCooker::WriteModelPrime(IOutputStream& rOut)
|
|||
// Float UV coordinates
|
||||
for (uint32 iTexSlot = 0; iTexSlot < 8; iTexSlot++)
|
||||
{
|
||||
bool HasTexSlot = (mVtxAttribs & (eTex0 << iTexSlot)) != 0;
|
||||
uint TexSlotBit = ((uint) (EVertexAttribute::Tex0)) << iTexSlot;
|
||||
bool HasTexSlot = (mVtxAttribs & TexSlotBit) != 0;
|
||||
if (HasTexSlot)
|
||||
{
|
||||
for (uint32 iTex = 0; iTex < mNumVertices; iTex++)
|
||||
|
@ -171,28 +172,35 @@ void CModelCooker::WriteModelPrime(IOutputStream& rOut)
|
|||
if (mVersion == EGame::Echoes)
|
||||
{
|
||||
for (uint32 iMtxAttribs = 0; iMtxAttribs < 8; iMtxAttribs++)
|
||||
if (VtxAttribs & (ePosMtx << iMtxAttribs))
|
||||
{
|
||||
uint MatrixBit = ((uint) (EVertexAttribute::PosMtx) << iMtxAttribs);
|
||||
if (VtxAttribs & MatrixBit)
|
||||
{
|
||||
rOut.WriteByte(pVert->MatrixIndices[iMtxAttribs]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
uint16 VertexIndex = (uint16) pVert->ArrayPosition;
|
||||
|
||||
if (VtxAttribs & ePosition)
|
||||
if (VtxAttribs & EVertexAttribute::Position)
|
||||
rOut.WriteShort(VertexIndex);
|
||||
|
||||
if (VtxAttribs & eNormal)
|
||||
if (VtxAttribs & EVertexAttribute::Normal)
|
||||
rOut.WriteShort(VertexIndex);
|
||||
|
||||
if (VtxAttribs & eColor0)
|
||||
if (VtxAttribs & EVertexAttribute::Color0)
|
||||
rOut.WriteShort(VertexIndex);
|
||||
|
||||
if (VtxAttribs & eColor1)
|
||||
if (VtxAttribs & EVertexAttribute::Color1)
|
||||
rOut.WriteShort(VertexIndex);
|
||||
|
||||
uint16 TexOffset = 0;
|
||||
for (uint32 iTex = 0; iTex < 8; iTex++)
|
||||
{
|
||||
if (VtxAttribs & (eTex0 << iTex))
|
||||
uint TexBit = ((uint) EVertexAttribute::Tex0) << iTex;
|
||||
|
||||
if (VtxAttribs & TexBit)
|
||||
{
|
||||
rOut.WriteShort(VertexIndex + TexOffset);
|
||||
TexOffset += (uint16) mNumVertices;
|
||||
|
|
|
@ -20,10 +20,10 @@ public:
|
|||
|
||||
switch (pEntry->ResourceType())
|
||||
{
|
||||
case eArea: return CAreaCooker::CookMREA((CGameArea*) pRes, rOutput);
|
||||
case eModel: return CModelCooker::CookCMDL((CModel*) pRes, rOutput);
|
||||
case eStaticGeometryMap: return CPoiToWorldCooker::CookEGMC((CPoiToWorld*) pRes, rOutput);
|
||||
case eWorld: return CWorldCooker::CookMLVL((CWorld*) pRes, rOutput);
|
||||
case EResourceType::Area: return CAreaCooker::CookMREA((CGameArea*) pRes, rOutput);
|
||||
case EResourceType::Model: return CModelCooker::CookCMDL((CModel*) pRes, rOutput);
|
||||
case EResourceType::StaticGeometryMap: return CPoiToWorldCooker::CookEGMC((CPoiToWorld*) pRes, rOutput);
|
||||
case EResourceType::World: return CWorldCooker::CookMLVL((CWorld*) pRes, rOutput);
|
||||
|
||||
default:
|
||||
warnf("Failed to cook %s asset; this resource type is not supported for cooking", *pEntry->CookedExtension().ToString());
|
||||
|
|
|
@ -250,12 +250,12 @@ void CScriptCooker::WriteInstance(IOutputStream& rOut, CScriptObject *pInstance)
|
|||
uint32 InstanceID = (pInstance->Layer()->AreaIndex() << 26) | pInstance->InstanceID();
|
||||
rOut.WriteLong(InstanceID);
|
||||
|
||||
uint32 NumLinks = pInstance->NumLinks(eOutgoing);
|
||||
uint32 NumLinks = pInstance->NumLinks(ELinkType::Outgoing);
|
||||
IsPrime1 ? rOut.WriteLong(NumLinks) : rOut.WriteShort((uint16) NumLinks);
|
||||
|
||||
for (uint32 LinkIdx = 0; LinkIdx < NumLinks; LinkIdx++)
|
||||
{
|
||||
CLink *pLink = pInstance->Link(eOutgoing, LinkIdx);
|
||||
CLink *pLink = pInstance->Link(ELinkType::Outgoing, LinkIdx);
|
||||
rOut.WriteLong(pLink->State());
|
||||
rOut.WriteLong(pLink->Message());
|
||||
rOut.WriteLong(pLink->ReceiverID());
|
||||
|
@ -298,9 +298,9 @@ void CScriptCooker::WriteLayer(IOutputStream& rOut, CScriptLayer *pLayer)
|
|||
// Generate/Attach message (MP3+) should be written to SCGN, not SCLY
|
||||
else
|
||||
{
|
||||
for (uint32 LinkIdx = 0; LinkIdx < pInstance->NumLinks(eIncoming); LinkIdx++)
|
||||
for (uint32 LinkIdx = 0; LinkIdx < pInstance->NumLinks(ELinkType::Incoming); LinkIdx++)
|
||||
{
|
||||
CLink *pLink = pInstance->Link(eIncoming, LinkIdx);
|
||||
CLink *pLink = pInstance->Link(ELinkType::Incoming, LinkIdx);
|
||||
|
||||
if (mGame <= EGame::Echoes)
|
||||
{
|
||||
|
|
|
@ -9,14 +9,14 @@ CTextureEncoder::CTextureEncoder()
|
|||
void CTextureEncoder::WriteTXTR(IOutputStream& rTXTR)
|
||||
{
|
||||
// Only DXT1->CMPR supported at the moment
|
||||
rTXTR.WriteLong(mOutputFormat);
|
||||
rTXTR.WriteLong((uint) mOutputFormat);
|
||||
rTXTR.WriteShort(mpTexture->mWidth);
|
||||
rTXTR.WriteShort(mpTexture->mHeight);
|
||||
rTXTR.WriteLong(mpTexture->mNumMipMaps);
|
||||
|
||||
uint32 MipW = mpTexture->Width() / 4;
|
||||
uint32 MipH = mpTexture->Height() / 4;
|
||||
CMemoryInStream Image(mpTexture->mpImgDataBuffer, mpTexture->mImgDataSize, IOUtil::eLittleEndian);
|
||||
CMemoryInStream Image(mpTexture->mpImgDataBuffer, mpTexture->mImgDataSize, EEndian::LittleEndian);
|
||||
uint32 MipOffset = Image.Tell();
|
||||
|
||||
for (uint32 iMip = 0; iMip < mpTexture->mNumMipMaps; iMip++)
|
||||
|
@ -61,7 +61,7 @@ void CTextureEncoder::ReadSubBlockCMPR(IInputStream& rSource, IOutputStream& rDe
|
|||
// ************ STATIC ************
|
||||
void CTextureEncoder::EncodeTXTR(IOutputStream& rTXTR, CTexture *pTex)
|
||||
{
|
||||
if (pTex->mTexelFormat != eDXT1)
|
||||
if (pTex->mTexelFormat != ETexelFormat::DXT1)
|
||||
{
|
||||
errorf("Unsupported texel format for decoding");
|
||||
return;
|
||||
|
@ -69,8 +69,8 @@ void CTextureEncoder::EncodeTXTR(IOutputStream& rTXTR, CTexture *pTex)
|
|||
|
||||
CTextureEncoder Encoder;
|
||||
Encoder.mpTexture = pTex;
|
||||
Encoder.mSourceFormat = eDXT1;
|
||||
Encoder.mOutputFormat = eGX_CMPR;
|
||||
Encoder.mSourceFormat = ETexelFormat::DXT1;
|
||||
Encoder.mOutputFormat = ETexelFormat::GX_CMPR;
|
||||
Encoder.WriteTXTR(rTXTR);
|
||||
}
|
||||
|
||||
|
@ -84,13 +84,13 @@ ETexelFormat CTextureEncoder::GetGXFormat(ETexelFormat Format)
|
|||
{
|
||||
switch (Format)
|
||||
{
|
||||
case eLuminance: return eGX_I8;
|
||||
case eLuminanceAlpha: return eGX_IA8;
|
||||
case eRGBA4: return eGX_RGB5A3;
|
||||
case eRGB565: return eGX_RGB565;
|
||||
case eRGBA8: return eGX_RGBA8;
|
||||
case eDXT1: return eGX_CMPR;
|
||||
default: return eInvalidTexelFormat;
|
||||
case ETexelFormat::Luminance: return ETexelFormat::GX_I8;
|
||||
case ETexelFormat::LuminanceAlpha: return ETexelFormat::GX_IA8;
|
||||
case ETexelFormat::RGBA4: return ETexelFormat::GX_RGB5A3;
|
||||
case ETexelFormat::RGB565: return ETexelFormat::GX_RGB565;
|
||||
case ETexelFormat::RGBA8: return ETexelFormat::GX_RGBA8;
|
||||
case ETexelFormat::DXT1: return ETexelFormat::GX_CMPR;
|
||||
default: return ETexelFormat::Invalid;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -98,12 +98,12 @@ ETexelFormat CTextureEncoder::GetFormat(ETexelFormat Format)
|
|||
{
|
||||
switch (Format)
|
||||
{
|
||||
case eGX_I4: return eLuminance;
|
||||
case eGX_I8: return eLuminance;
|
||||
case eGX_IA4: return eLuminanceAlpha;
|
||||
case eGX_IA8: return eLuminanceAlpha;
|
||||
case ETexelFormat::GX_I4: return ETexelFormat::Luminance;
|
||||
case ETexelFormat::GX_I8: return ETexelFormat::Luminance;
|
||||
case ETexelFormat::GX_IA4: return ETexelFormat::LuminanceAlpha;
|
||||
case ETexelFormat::GX_IA8: return ETexelFormat::LuminanceAlpha;
|
||||
// todo rest of these
|
||||
case eGX_CMPR: return eDXT1;
|
||||
default: return eInvalidTexelFormat;
|
||||
case ETexelFormat::GX_CMPR: return ETexelFormat::DXT1;
|
||||
default: return ETexelFormat::Invalid;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -73,7 +73,7 @@ bool CWorldCooker::CookMLVL(CWorld *pWorld, IOutputStream& rMLVL)
|
|||
// Area Header
|
||||
CWorld::SArea& rArea = pWorld->mAreas[iArea];
|
||||
CResourceEntry *pAreaEntry = gpResourceStore->FindEntry(rArea.AreaResID);
|
||||
ASSERT(pAreaEntry && pAreaEntry->ResourceType() == eArea);
|
||||
ASSERT(pAreaEntry && pAreaEntry->ResourceType() == EResourceType::Area);
|
||||
|
||||
CAssetID AreaNameID = rArea.pAreaName ? rArea.pAreaName->ID() : CAssetID::InvalidID(Game);
|
||||
AreaNameID.Write(rMLVL);
|
||||
|
|
|
@ -1,81 +1,81 @@
|
|||
#ifndef ERESTYPE
|
||||
#define ERESTYPE
|
||||
#ifndef ERESOURCETYPE
|
||||
#define ERESOURCETYPE
|
||||
|
||||
#include <Common/EGame.h>
|
||||
#include <Common/TString.h>
|
||||
|
||||
enum EResType
|
||||
enum class EResourceType
|
||||
{
|
||||
eAnimation,
|
||||
eAnimCollisionPrimData,
|
||||
eAnimEventData,
|
||||
eAnimSet,
|
||||
eArea,
|
||||
eAreaCollision,
|
||||
eAreaGeometry,
|
||||
eAreaLights,
|
||||
eAreaMaterials,
|
||||
eAreaSurfaceBounds,
|
||||
eAreaOctree,
|
||||
eAreaVisibilityTree,
|
||||
eAudioAmplitudeData,
|
||||
eAudioGroup,
|
||||
eAudioMacro,
|
||||
eAudioSample,
|
||||
eAudioLookupTable,
|
||||
eBinaryData,
|
||||
eBurstFireData,
|
||||
eCharacter,
|
||||
eDependencyGroup,
|
||||
eDynamicCollision,
|
||||
eFont,
|
||||
eGuiFrame,
|
||||
eGuiKeyFrame,
|
||||
eHintSystem,
|
||||
eMapArea,
|
||||
eMapWorld,
|
||||
eMapUniverse,
|
||||
eMidi,
|
||||
eModel,
|
||||
eMusicTrack,
|
||||
ePackage,
|
||||
eParticle,
|
||||
eParticleCollisionResponse,
|
||||
eParticleDecal,
|
||||
eParticleElectric,
|
||||
eParticleSorted,
|
||||
eParticleSpawn,
|
||||
eParticleSwoosh,
|
||||
eParticleTransform,
|
||||
eParticleWeapon,
|
||||
ePathfinding,
|
||||
ePortalArea,
|
||||
eResource,
|
||||
eRuleSet,
|
||||
eSaveArea,
|
||||
eSaveWorld,
|
||||
eScan,
|
||||
eSkeleton,
|
||||
eSkin,
|
||||
eSourceAnimData,
|
||||
eSpatialPrimitive,
|
||||
eStateMachine,
|
||||
eStateMachine2, // For distinguishing AFSM/FSM2
|
||||
eStaticGeometryMap,
|
||||
eStreamedAudio,
|
||||
eStringList,
|
||||
eStringTable,
|
||||
eTexture,
|
||||
eTweak,
|
||||
eUserEvaluatorData,
|
||||
eVideo,
|
||||
eWorld,
|
||||
Animation,
|
||||
AnimCollisionPrimData,
|
||||
AnimEventData,
|
||||
AnimSet,
|
||||
Area,
|
||||
AreaCollision,
|
||||
AreaGeometry,
|
||||
AreaLights,
|
||||
AreaMaterials,
|
||||
AreaSurfaceBounds,
|
||||
AreaOctree,
|
||||
AreaVisibilityTree,
|
||||
AudioAmplitudeData,
|
||||
AudioGroup,
|
||||
AudioMacro,
|
||||
AudioSample,
|
||||
AudioLookupTable,
|
||||
BinaryData,
|
||||
BurstFireData,
|
||||
Character,
|
||||
DependencyGroup,
|
||||
DynamicCollision,
|
||||
Font,
|
||||
GuiFrame,
|
||||
GuiKeyFrame,
|
||||
HintSystem,
|
||||
MapArea,
|
||||
MapWorld,
|
||||
MapUniverse,
|
||||
Midi,
|
||||
Model,
|
||||
MusicTrack,
|
||||
Package,
|
||||
Particle,
|
||||
ParticleCollisionResponse,
|
||||
ParticleDecal,
|
||||
ParticleElectric,
|
||||
ParticleSorted,
|
||||
ParticleSpawn,
|
||||
ParticleSwoosh,
|
||||
ParticleTransform,
|
||||
ParticleWeapon,
|
||||
Pathfinding,
|
||||
PortalArea,
|
||||
Resource,
|
||||
RuleSet,
|
||||
SaveArea,
|
||||
SaveWorld,
|
||||
Scan,
|
||||
Skeleton,
|
||||
Skin,
|
||||
SourceAnimData,
|
||||
SpatialPrimitive,
|
||||
StateMachine,
|
||||
StateMachine2, // For distinguishing AFSM/FSM2
|
||||
StaticGeometryMap,
|
||||
StreamedAudio,
|
||||
StringList,
|
||||
StringTable,
|
||||
Texture,
|
||||
Tweak,
|
||||
UserEvaluatorData,
|
||||
Video,
|
||||
World,
|
||||
|
||||
eInvalidResType = -1
|
||||
Invalid = -1
|
||||
};
|
||||
|
||||
// Defined in CResTypeInfo.cpp
|
||||
void Serialize(IArchive& rArc, EResType& rType);
|
||||
void Serialize(IArchive& rArc, EResourceType& rType);
|
||||
|
||||
#endif // ERESTYPE
|
||||
#endif // ERESOURCETYPE
|
||||
|
||||
|
|
|
@ -3,103 +3,103 @@
|
|||
|
||||
enum ETevColorInput
|
||||
{
|
||||
ePrevRGB = 0x0,
|
||||
ePrevAAA = 0x1,
|
||||
eColor0RGB = 0x2,
|
||||
eColor0AAA = 0x3,
|
||||
eColor1RGB = 0x4,
|
||||
eColor1AAA = 0x5,
|
||||
eColor2RGB = 0x6,
|
||||
eColor2AAA = 0x7,
|
||||
eTextureRGB = 0x8,
|
||||
eTextureAAA = 0x9,
|
||||
eRasRGB = 0xA,
|
||||
eRasAAA = 0xB,
|
||||
eOneRGB = 0xC,
|
||||
eHalfRGB = 0xD,
|
||||
eKonstRGB = 0xE,
|
||||
eZeroRGB = 0xF
|
||||
kPrevRGB = 0x0,
|
||||
kPrevAAA = 0x1,
|
||||
kColor0RGB = 0x2,
|
||||
kColor0AAA = 0x3,
|
||||
kColor1RGB = 0x4,
|
||||
kColor1AAA = 0x5,
|
||||
kColor2RGB = 0x6,
|
||||
kColor2AAA = 0x7,
|
||||
kTextureRGB = 0x8,
|
||||
kTextureAAA = 0x9,
|
||||
kRasRGB = 0xA,
|
||||
kRasAAA = 0xB,
|
||||
kOneRGB = 0xC,
|
||||
kHalfRGB = 0xD,
|
||||
kKonstRGB = 0xE,
|
||||
kZeroRGB = 0xF
|
||||
};
|
||||
|
||||
enum ETevAlphaInput
|
||||
{
|
||||
ePrevAlpha = 0x0,
|
||||
eColor0Alpha = 0x1,
|
||||
eColor1Alpha = 0x2,
|
||||
eColor2Alpha = 0x3,
|
||||
eTextureAlpha = 0x4,
|
||||
eRasAlpha = 0x5,
|
||||
eKonstAlpha = 0x6,
|
||||
eZeroAlpha = 0x7
|
||||
kPrevAlpha = 0x0,
|
||||
kColor0Alpha = 0x1,
|
||||
kColor1Alpha = 0x2,
|
||||
kColor2Alpha = 0x3,
|
||||
kTextureAlpha = 0x4,
|
||||
kRasAlpha = 0x5,
|
||||
kKonstAlpha = 0x6,
|
||||
kZeroAlpha = 0x7
|
||||
};
|
||||
|
||||
enum ETevOutput
|
||||
{
|
||||
ePrevReg = 0x0,
|
||||
eColor0Reg = 0x1,
|
||||
eColor1Reg = 0x2,
|
||||
eColor2Reg = 0x3
|
||||
kPrevReg = 0x0,
|
||||
kColor0Reg = 0x1,
|
||||
kColor1Reg = 0x2,
|
||||
kColor2Reg = 0x3
|
||||
};
|
||||
|
||||
enum ETevKSel
|
||||
{
|
||||
eKonstOne = 0x0,
|
||||
eKonstSevenEighths = 0x1,
|
||||
eKonstThreeFourths = 0x2,
|
||||
eKonstFiveEighths = 0x3,
|
||||
eKonstOneHalf = 0x4,
|
||||
eKonstThreeEighths = 0x5,
|
||||
eKonstOneFourth = 0x6,
|
||||
eKonstOneEighth = 0x7,
|
||||
eKonst0_RGB = 0xC,
|
||||
eKonst1_RGB = 0xD,
|
||||
eKonst2_RGB = 0xE,
|
||||
eKonst3_RGB = 0xF,
|
||||
eKonst0_R = 0x10,
|
||||
eKonst1_R = 0x11,
|
||||
eKonst2_R = 0x12,
|
||||
eKonst3_R = 0x13,
|
||||
eKonst0_G = 0x14,
|
||||
eKonst1_G = 0x15,
|
||||
eKonst2_G = 0x16,
|
||||
eKonst3_G = 0x17,
|
||||
eKonst0_B = 0x18,
|
||||
eKonst1_B = 0x19,
|
||||
eKonst2_B = 0x1A,
|
||||
eKonst3_B = 0x1B,
|
||||
eKonst0_A = 0x1C,
|
||||
eKonst1_A = 0x1D,
|
||||
eKonst2_A = 0x1E,
|
||||
eKonst3_A = 0x1F
|
||||
kKonstOne = 0x0,
|
||||
kKonstSevenEighths = 0x1,
|
||||
kKonstThreeFourths = 0x2,
|
||||
kKonstFiveEighths = 0x3,
|
||||
kKonstOneHalf = 0x4,
|
||||
kKonstThreeEighths = 0x5,
|
||||
kKonstOneFourth = 0x6,
|
||||
kKonstOneEighth = 0x7,
|
||||
kKonst0_RGB = 0xC,
|
||||
kKonst1_RGB = 0xD,
|
||||
kKonst2_RGB = 0xE,
|
||||
kKonst3_RGB = 0xF,
|
||||
kKonst0_R = 0x10,
|
||||
kKonst1_R = 0x11,
|
||||
kKonst2_R = 0x12,
|
||||
kKonst3_R = 0x13,
|
||||
kKonst0_G = 0x14,
|
||||
kKonst1_G = 0x15,
|
||||
kKonst2_G = 0x16,
|
||||
kKonst3_G = 0x17,
|
||||
kKonst0_B = 0x18,
|
||||
kKonst1_B = 0x19,
|
||||
kKonst2_B = 0x1A,
|
||||
kKonst3_B = 0x1B,
|
||||
kKonst0_A = 0x1C,
|
||||
kKonst1_A = 0x1D,
|
||||
kKonst2_A = 0x1E,
|
||||
kKonst3_A = 0x1F
|
||||
};
|
||||
|
||||
enum ETevRasSel
|
||||
{
|
||||
eRasColor0 = 0x0,
|
||||
eRasColor1 = 0x1,
|
||||
eRasAlpha0 = 0x2,
|
||||
eRasAlpha1 = 0x3,
|
||||
eRasColor0A0 = 0x4,
|
||||
eRasColor1A1 = 0x5,
|
||||
eRasColorZero = 0x6,
|
||||
eRasAlphaBump = 0x7,
|
||||
eRasAlphaBumpN = 0x8,
|
||||
eRasColorNull = 0xFF
|
||||
kRasColor0 = 0x0,
|
||||
kRasColor1 = 0x1,
|
||||
kRasAlpha0 = 0x2,
|
||||
kRasAlpha1 = 0x3,
|
||||
kRasColor0A0 = 0x4,
|
||||
kRasColor1A1 = 0x5,
|
||||
kRasColorZero = 0x6,
|
||||
kRasAlphaBump = 0x7,
|
||||
kRasAlphaBumpN = 0x8,
|
||||
kRasColorNull = 0xFF
|
||||
};
|
||||
|
||||
enum EUVAnimMode
|
||||
enum class EUVAnimMode
|
||||
{
|
||||
eInverseMV = 0x0,
|
||||
eInverseMVTranslated = 0x1,
|
||||
eUVScroll = 0x2,
|
||||
eUVRotation = 0x3,
|
||||
eHFilmstrip = 0x4,
|
||||
eVFilmstrip = 0x5,
|
||||
eModelMatrix = 0x6,
|
||||
eConvolutedModeA = 0x7,
|
||||
eConvolutedModeB = 0x8,
|
||||
eSimpleMode = 0xA,
|
||||
eNoUVAnim = 0xFFFFFFFF
|
||||
InverseMV = 0x0,
|
||||
InverseMVTranslated = 0x1,
|
||||
UVScroll = 0x2,
|
||||
UVRotation = 0x3,
|
||||
HFilmstrip = 0x4,
|
||||
VFilmstrip = 0x5,
|
||||
ModelMatrix = 0x6,
|
||||
ConvolutedModeA = 0x7,
|
||||
ConvolutedModeB = 0x8,
|
||||
SimpleMode = 0xA,
|
||||
NoUVAnim = -1
|
||||
};
|
||||
|
||||
#endif // ETEVENUMS
|
||||
|
|
|
@ -2,36 +2,36 @@
|
|||
#define ETEXELFORMAT
|
||||
|
||||
// ETexelFormat - supported internal formats for decoded textures
|
||||
enum ETexelFormat
|
||||
enum class ETexelFormat
|
||||
{
|
||||
// Supported texel formats in GX using Retro's numbering
|
||||
eGX_I4 = 0x0,
|
||||
eGX_I8 = 0x1,
|
||||
eGX_IA4 = 0x2,
|
||||
eGX_IA8 = 0x3,
|
||||
eGX_C4 = 0x4,
|
||||
eGX_C8 = 0x5,
|
||||
eGX_C14x2 = 0x6,
|
||||
eGX_RGB565 = 0x7,
|
||||
eGX_RGB5A3 = 0x8,
|
||||
eGX_RGBA8 = 0x9,
|
||||
eGX_CMPR = 0xA,
|
||||
GX_I4 = 0x0,
|
||||
GX_I8 = 0x1,
|
||||
GX_IA4 = 0x2,
|
||||
GX_IA8 = 0x3,
|
||||
GX_C4 = 0x4,
|
||||
GX_C8 = 0x5,
|
||||
GX_C14x2 = 0x6,
|
||||
GX_RGB565 = 0x7,
|
||||
GX_RGB5A3 = 0x8,
|
||||
GX_RGBA8 = 0x9,
|
||||
GX_CMPR = 0xA,
|
||||
// Supported internal texel formats for decoded textures
|
||||
eLuminance,
|
||||
eLuminanceAlpha,
|
||||
eRGBA4,
|
||||
eRGB565,
|
||||
eRGBA8,
|
||||
eDXT1,
|
||||
eInvalidTexelFormat
|
||||
Luminance,
|
||||
LuminanceAlpha,
|
||||
RGBA4,
|
||||
RGB565,
|
||||
RGBA8,
|
||||
DXT1,
|
||||
Invalid = -1
|
||||
};
|
||||
|
||||
// EGXPaletteFormat - GX's supported palette texel formats for C4/C8
|
||||
enum EGXPaletteFormat
|
||||
enum class EGXPaletteFormat
|
||||
{
|
||||
ePalette_IA8 = 0,
|
||||
ePalette_RGB565 = 1,
|
||||
ePalette_RGB5A3 = 2
|
||||
IA8 = 0,
|
||||
RGB565 = 1,
|
||||
RGB5A3 = 2
|
||||
};
|
||||
|
||||
#endif // ETEXELFORMAT
|
||||
|
|
|
@ -24,13 +24,13 @@ CAnimSet* CAnimSetLoader::LoadCorruptionCHAR(IInputStream& rCHAR)
|
|||
{
|
||||
SOverlayModel Overlay;
|
||||
Overlay.Type = (EOverlayType) rCHAR.ReadLong();
|
||||
Overlay.ModelID = CAssetID(rCHAR, e64Bit);
|
||||
Overlay.SkinID = CAssetID(rCHAR, e64Bit);
|
||||
Overlay.ModelID = CAssetID(rCHAR, k64Bit);
|
||||
Overlay.SkinID = CAssetID(rCHAR, k64Bit);
|
||||
rChar.OverlayModels.push_back(Overlay);
|
||||
}
|
||||
|
||||
rChar.pSkeleton = gpResourceStore->LoadResource<CSkeleton>(rCHAR.ReadLongLong());
|
||||
rChar.AnimDataID = CAssetID(rCHAR, e64Bit);
|
||||
rChar.AnimDataID = CAssetID(rCHAR, k64Bit);
|
||||
|
||||
// PAS Database
|
||||
LoadPASDatabase(rCHAR);
|
||||
|
@ -88,7 +88,7 @@ CAnimSet* CAnimSetLoader::LoadCorruptionCHAR(IInputStream& rCHAR)
|
|||
|
||||
for (uint32 SoundIdx = 0; SoundIdx < NumSounds; SoundIdx++)
|
||||
{
|
||||
CAssetID SoundID(rCHAR, e64Bit);
|
||||
CAssetID SoundID(rCHAR, k64Bit);
|
||||
rChar.SoundEffects.push_back(SoundID);
|
||||
}
|
||||
|
||||
|
@ -581,7 +581,7 @@ CAnimSet* CAnimSetLoader::LoadANCS(IInputStream& rANCS, CResourceEntry *pEntry)
|
|||
{
|
||||
rANCS.ReadString();
|
||||
rANCS.Seek(0x4, SEEK_CUR);
|
||||
CAssetID ParticleID(rANCS, e32Bit);
|
||||
CAssetID ParticleID(rANCS, k32Bit);
|
||||
if (ParticleID.IsValid()) pChar->EffectParticles.push_back(ParticleID);
|
||||
|
||||
if (Loader.mGame == EGame::Prime) rANCS.ReadString();
|
||||
|
@ -591,9 +591,9 @@ CAnimSet* CAnimSetLoader::LoadANCS(IInputStream& rANCS, CResourceEntry *pEntry)
|
|||
}
|
||||
|
||||
SOverlayModel Overlay;
|
||||
Overlay.Type = eOT_Frozen;
|
||||
Overlay.ModelID = CAssetID(rANCS, e32Bit);
|
||||
Overlay.SkinID = CAssetID(rANCS, e32Bit);
|
||||
Overlay.Type = EOverlayType::Frozen;
|
||||
Overlay.ModelID = CAssetID(rANCS, k32Bit);
|
||||
Overlay.SkinID = CAssetID(rANCS, k32Bit);
|
||||
pChar->OverlayModels.push_back(Overlay);
|
||||
|
||||
uint32 AnimIndexCount = rANCS.ReadLong();
|
||||
|
@ -664,8 +664,8 @@ CSourceAnimData* CAnimSetLoader::LoadSAND(IInputStream& rSAND, CResourceEntry *p
|
|||
ASSERT(UnkByte == 0);
|
||||
|
||||
CSourceAnimData::STransition Transition;
|
||||
Transition.AnimA = CAssetID(rSAND, e64Bit);
|
||||
Transition.AnimB = CAssetID(rSAND, e64Bit);
|
||||
Transition.AnimA = CAssetID(rSAND, k64Bit);
|
||||
Transition.AnimB = CAssetID(rSAND, k64Bit);
|
||||
Transition.pTransition = gMetaTransFactory.LoadFromStream(rSAND, pEntry->Game());
|
||||
pData->mTransitions.push_back(Transition);
|
||||
}
|
||||
|
@ -679,7 +679,7 @@ CSourceAnimData* CAnimSetLoader::LoadSAND(IInputStream& rSAND, CResourceEntry *p
|
|||
ASSERT(UnkByte == 0);
|
||||
|
||||
CSourceAnimData::SHalfTransition HalfTrans;
|
||||
HalfTrans.Anim = CAssetID(rSAND, e64Bit);
|
||||
HalfTrans.Anim = CAssetID(rSAND, k64Bit);
|
||||
HalfTrans.pTransition = gMetaTransFactory.LoadFromStream(rSAND, pEntry->Game());
|
||||
pData->mHalfTransitions.push_back(HalfTrans);
|
||||
}
|
||||
|
|
|
@ -198,7 +198,7 @@ void CAreaLoader::ReadLightsPrime()
|
|||
Multiplier = FLT_EPSILON;
|
||||
|
||||
// Local Ambient
|
||||
if (Type == eLocalAmbient)
|
||||
if (Type == ELightType::LocalAmbient)
|
||||
{
|
||||
Color *= Multiplier;
|
||||
|
||||
|
@ -212,13 +212,13 @@ void CAreaLoader::ReadLightsPrime()
|
|||
}
|
||||
|
||||
// Directional
|
||||
else if (Type == eDirectional)
|
||||
else if (Type == ELightType::Directional)
|
||||
{
|
||||
pLight = CLight::BuildDirectional(Position, Direction, LightColor);
|
||||
}
|
||||
|
||||
// Spot
|
||||
else if (Type == eSpot)
|
||||
else if (Type == ELightType::Spot)
|
||||
{
|
||||
pLight = CLight::BuildSpot(Position, Direction.Normalized(), LightColor, SpotCutoff);
|
||||
|
||||
|
@ -499,19 +499,19 @@ void CAreaLoader::ReadLightsCorruption()
|
|||
Multiplier = FLT_EPSILON;
|
||||
|
||||
// Local Ambient
|
||||
if (Type == eLocalAmbient)
|
||||
if (Type == ELightType::LocalAmbient)
|
||||
{
|
||||
pLight = CLight::BuildLocalAmbient(Position, LightColor * Multiplier);
|
||||
}
|
||||
|
||||
// Directional
|
||||
else if (Type == eDirectional)
|
||||
else if (Type == ELightType::Directional)
|
||||
{
|
||||
pLight = CLight::BuildDirectional(Position, Direction, LightColor);
|
||||
}
|
||||
|
||||
// Spot
|
||||
else if (Type == eSpot)
|
||||
else if (Type == ELightType::Spot)
|
||||
{
|
||||
pLight = CLight::BuildSpot(Position, Direction.Normalized(), LightColor, SpotCutoff);
|
||||
|
||||
|
@ -597,7 +597,7 @@ void CAreaLoader::Decompress()
|
|||
}
|
||||
|
||||
TString Source = mpMREA->GetSourceString();
|
||||
mpMREA = new CMemoryInStream(mpDecmpBuffer, mTotalDecmpSize, IOUtil::eBigEndian);
|
||||
mpMREA = new CMemoryInStream(mpDecmpBuffer, mTotalDecmpSize, EEndian::BigEndian);
|
||||
mpMREA->SetSourceString(Source);
|
||||
mpSectionMgr->SetInputStream(mpMREA);
|
||||
mHasDecompressedBuffer = true;
|
||||
|
@ -639,7 +639,7 @@ void CAreaLoader::ReadEGMC()
|
|||
{
|
||||
mpSectionMgr->ToSection(mEGMCBlockNum);
|
||||
CAssetID EGMC(*mpMREA, mVersion);
|
||||
mpArea->mpPoiToWorldMap = gpResourceStore->LoadResource(EGMC, eStaticGeometryMap);
|
||||
mpArea->mpPoiToWorldMap = gpResourceStore->LoadResource(EGMC, EResourceType::StaticGeometryMap);
|
||||
}
|
||||
|
||||
void CAreaLoader::SetUpObjects(CScriptLayer *pGenLayer)
|
||||
|
@ -692,9 +692,9 @@ void CAreaLoader::SetUpObjects(CScriptLayer *pGenLayer)
|
|||
CScriptObject *pInst = Iter->second;
|
||||
|
||||
// Store outgoing connections
|
||||
for (uint32 iCon = 0; iCon < pInst->NumLinks(eOutgoing); iCon++)
|
||||
for (uint32 iCon = 0; iCon < pInst->NumLinks(ELinkType::Outgoing); iCon++)
|
||||
{
|
||||
CLink *pLink = pInst->Link(eOutgoing, iCon);
|
||||
CLink *pLink = pInst->Link(ELinkType::Outgoing, iCon);
|
||||
mConnectionMap[pLink->ReceiverID()].push_back(pLink);
|
||||
}
|
||||
|
||||
|
|
|
@ -17,10 +17,7 @@ CFont* CFontLoader::LoadFont(IInputStream& rFONT)
|
|||
rFONT.Seek(0x2, SEEK_CUR);
|
||||
mpFont->mDefaultSize = rFONT.ReadLong();
|
||||
mpFont->mFontName = rFONT.ReadString();
|
||||
|
||||
if (mVersion <= EGame::Echoes) mpFont->mpFontTexture = gpResourceStore->LoadResource(rFONT.ReadLong(), eTexture);
|
||||
else mpFont->mpFontTexture = gpResourceStore->LoadResource(rFONT.ReadLongLong(), eTexture);
|
||||
|
||||
mpFont->mpFontTexture = gpResourceStore->LoadResource(CAssetID(rFONT, mVersion), EResourceType::Texture);
|
||||
mpFont->mTextureFormat = rFONT.ReadLong();
|
||||
uint32 NumGlyphs = rFONT.ReadLong();
|
||||
mpFont->mGlyphs.reserve(NumGlyphs);
|
||||
|
|
|
@ -18,26 +18,26 @@ CMaterialLoader::~CMaterialLoader()
|
|||
FVertexDescription CMaterialLoader::ConvertToVertexDescription(uint32 VertexFlags)
|
||||
{
|
||||
FVertexDescription Desc;
|
||||
if (VertexFlags & 0x00000003) Desc |= ePosition;
|
||||
if (VertexFlags & 0x0000000C) Desc |= eNormal;
|
||||
if (VertexFlags & 0x00000030) Desc |= eColor0;
|
||||
if (VertexFlags & 0x000000C0) Desc |= eColor1;
|
||||
if (VertexFlags & 0x00000300) Desc |= eTex0;
|
||||
if (VertexFlags & 0x00000C00) Desc |= eTex1;
|
||||
if (VertexFlags & 0x00003000) Desc |= eTex2;
|
||||
if (VertexFlags & 0x0000C000) Desc |= eTex3;
|
||||
if (VertexFlags & 0x00030000) Desc |= eTex4;
|
||||
if (VertexFlags & 0x000C0000) Desc |= eTex5;
|
||||
if (VertexFlags & 0x00300000) Desc |= eTex6;
|
||||
if (VertexFlags & 0x00C00000) Desc |= eTex7;
|
||||
if (VertexFlags & 0x01000000) Desc |= ePosMtx;
|
||||
if (VertexFlags & 0x02000000) Desc |= eTex0Mtx;
|
||||
if (VertexFlags & 0x04000000) Desc |= eTex1Mtx;
|
||||
if (VertexFlags & 0x08000000) Desc |= eTex2Mtx;
|
||||
if (VertexFlags & 0x10000000) Desc |= eTex3Mtx;
|
||||
if (VertexFlags & 0x20000000) Desc |= eTex4Mtx;
|
||||
if (VertexFlags & 0x40000000) Desc |= eTex5Mtx;
|
||||
if (VertexFlags & 0x80000000) Desc |= eTex6Mtx;
|
||||
if (VertexFlags & 0x00000003) Desc |= EVertexAttribute::Position;
|
||||
if (VertexFlags & 0x0000000C) Desc |= EVertexAttribute::Normal;
|
||||
if (VertexFlags & 0x00000030) Desc |= EVertexAttribute::Color0;
|
||||
if (VertexFlags & 0x000000C0) Desc |= EVertexAttribute::Color1;
|
||||
if (VertexFlags & 0x00000300) Desc |= EVertexAttribute::Tex0;
|
||||
if (VertexFlags & 0x00000C00) Desc |= EVertexAttribute::Tex1;
|
||||
if (VertexFlags & 0x00003000) Desc |= EVertexAttribute::Tex2;
|
||||
if (VertexFlags & 0x0000C000) Desc |= EVertexAttribute::Tex3;
|
||||
if (VertexFlags & 0x00030000) Desc |= EVertexAttribute::Tex4;
|
||||
if (VertexFlags & 0x000C0000) Desc |= EVertexAttribute::Tex5;
|
||||
if (VertexFlags & 0x00300000) Desc |= EVertexAttribute::Tex6;
|
||||
if (VertexFlags & 0x00C00000) Desc |= EVertexAttribute::Tex7;
|
||||
if (VertexFlags & 0x01000000) Desc |= EVertexAttribute::PosMtx;
|
||||
if (VertexFlags & 0x02000000) Desc |= EVertexAttribute::Tex0Mtx;
|
||||
if (VertexFlags & 0x04000000) Desc |= EVertexAttribute::Tex1Mtx;
|
||||
if (VertexFlags & 0x08000000) Desc |= EVertexAttribute::Tex2Mtx;
|
||||
if (VertexFlags & 0x10000000) Desc |= EVertexAttribute::Tex3Mtx;
|
||||
if (VertexFlags & 0x20000000) Desc |= EVertexAttribute::Tex4Mtx;
|
||||
if (VertexFlags & 0x40000000) Desc |= EVertexAttribute::Tex5Mtx;
|
||||
if (VertexFlags & 0x80000000) Desc |= EVertexAttribute::Tex6Mtx;
|
||||
return Desc;
|
||||
}
|
||||
|
||||
|
@ -76,7 +76,7 @@ CMaterial* CMaterialLoader::ReadPrimeMaterial()
|
|||
pMat->mEnableBloom = false;
|
||||
|
||||
// Flags
|
||||
pMat->mOptions = (mpFile->ReadLong() & CMaterial::eAllMP1Settings);
|
||||
pMat->mOptions = (mpFile->ReadLong() & (uint) EMaterialOption::AllMP1Settings);
|
||||
|
||||
// Textures
|
||||
uint32 NumTextures = mpFile->ReadLong();
|
||||
|
@ -100,7 +100,7 @@ CMaterial* CMaterialLoader::ReadPrimeMaterial()
|
|||
mpFile->Seek(0x4, SEEK_CUR); // Skipping group index
|
||||
|
||||
// Konst
|
||||
if (pMat->mOptions & CMaterial::eKonst)
|
||||
if (pMat->mOptions & EMaterialOption::Konst)
|
||||
{
|
||||
uint32 KonstCount = mpFile->ReadLong();
|
||||
|
||||
|
@ -117,7 +117,7 @@ CMaterial* CMaterialLoader::ReadPrimeMaterial()
|
|||
pMat->mBlendSrcFac = gBlendFactor[mpFile->ReadShort()];
|
||||
|
||||
// Indirect texture
|
||||
if (pMat->mOptions & CMaterial::eIndStage)
|
||||
if (pMat->mOptions & EMaterialOption::IndStage)
|
||||
{
|
||||
uint32 IndTexIndex = mpFile->ReadLong();
|
||||
pMat->mpIndirectTexture = mTextures[TextureIndices[IndTexIndex]];
|
||||
|
@ -224,7 +224,7 @@ CMaterial* CMaterialLoader::ReadPrimeMaterial()
|
|||
if ((TexGens.size() == 0) || (TexCoordIdx == 0xFF))
|
||||
{
|
||||
pPass->mTexCoordSource = 0xFF;
|
||||
pPass->mAnimMode = eNoUVAnim;
|
||||
pPass->mAnimMode = EUVAnimMode::NoUVAnim;
|
||||
}
|
||||
|
||||
else
|
||||
|
@ -235,7 +235,7 @@ CMaterial* CMaterialLoader::ReadPrimeMaterial()
|
|||
// Texture matrix is a reliable way to tell, because every UV anim mode generates a texture matrix
|
||||
uint32 TexMtxIdx = ((TexGens[TexCoordIdx] & 0x3E00) >> 9) / 3;
|
||||
|
||||
if (TexMtxIdx == 10) pPass->mAnimMode = eNoUVAnim; // 10 is identity matrix; indicates no UV anim for this pass
|
||||
if (TexMtxIdx == 10) pPass->mAnimMode = EUVAnimMode::NoUVAnim; // 10 is identity matrix; indicates no UV anim for this pass
|
||||
|
||||
else
|
||||
{
|
||||
|
@ -269,7 +269,7 @@ void CMaterialLoader::ReadCorruptionMatSet()
|
|||
CMaterial* CMaterialLoader::ReadCorruptionMaterial()
|
||||
{
|
||||
CMaterial *pMat = new CMaterial();
|
||||
pMat->mOptions = CMaterial::eDepthWrite;
|
||||
pMat->mOptions = EMaterialOption::DepthWrite;
|
||||
pMat->mEnableBloom = true;
|
||||
|
||||
// Flags
|
||||
|
@ -278,18 +278,18 @@ CMaterial* CMaterialLoader::ReadCorruptionMaterial()
|
|||
{
|
||||
pMat->mBlendSrcFac = GL_SRC_ALPHA;
|
||||
pMat->mBlendDstFac = GL_ONE_MINUS_SRC_ALPHA;
|
||||
pMat->mOptions |= CMaterial::eTransparent;
|
||||
pMat->mOptions |= EMaterialOption::Transparent;
|
||||
}
|
||||
else if (Flags & 0x20)
|
||||
{
|
||||
pMat->mBlendSrcFac = GL_ONE;
|
||||
pMat->mBlendDstFac = GL_ONE;
|
||||
pMat->mOptions |= CMaterial::eTransparent;
|
||||
pMat->mOptions |= EMaterialOption::Transparent;
|
||||
}
|
||||
|
||||
if (Flags & 0x10) pMat->mOptions |= CMaterial::ePunchthrough;
|
||||
if (Flags & 0x100) pMat->mOptions |= CMaterial::eOccluder;
|
||||
if (Flags & 0x80000) pMat->mOptions |= CMaterial::eDrawWhiteAmbientDKCR;
|
||||
if (Flags & 0x10) pMat->mOptions |= EMaterialOption::Masked;
|
||||
if (Flags & 0x100) pMat->mOptions |= EMaterialOption::Occluder;
|
||||
if (Flags & 0x80000) pMat->mOptions |= EMaterialOption::DrawWhiteAmbientDKCR;
|
||||
mHas0x400 = ((Flags & 0x400) != 0);
|
||||
|
||||
mpFile->Seek(0x8, SEEK_CUR); // Don't know what any of this is
|
||||
|
@ -356,7 +356,7 @@ CMaterial* CMaterialLoader::ReadCorruptionMaterial()
|
|||
uint32 Next = Size + mpFile->Tell();
|
||||
|
||||
pPass->mPassType = mpFile->ReadLong();
|
||||
pPass->mSettings = (CMaterialPass::EPassSettings) mpFile->ReadLong();
|
||||
pPass->mSettings = (EPassSettings) mpFile->ReadLong();
|
||||
|
||||
// Skip passes that don't have a texture. Honestly don't really know what to do with these right now
|
||||
uint64 TextureID = mpFile->ReadLongLong();
|
||||
|
@ -408,11 +408,16 @@ CMaterial* CMaterialLoader::ReadCorruptionMaterial()
|
|||
}
|
||||
|
||||
// Hack until the correct way to determine tex coord source is figured out
|
||||
if ((pPass->mAnimMode < 2) || (pPass->mAnimMode == 6) || (pPass->mAnimMode == 7) || (pPass->mAnimMode == 10))
|
||||
if ((pPass->mAnimMode < EUVAnimMode::UVScroll) ||
|
||||
(pPass->mAnimMode == EUVAnimMode::ModelMatrix) ||
|
||||
(pPass->mAnimMode == EUVAnimMode::ConvolutedModeA) ||
|
||||
(pPass->mAnimMode == EUVAnimMode::SimpleMode))
|
||||
{
|
||||
pPass->mTexCoordSource = 1;
|
||||
}
|
||||
}
|
||||
|
||||
else pPass->mAnimMode = eNoUVAnim;
|
||||
else pPass->mAnimMode = EUVAnimMode::NoUVAnim;
|
||||
|
||||
pMat->mPasses.push_back(pPass);
|
||||
mpFile->Seek(Next, SEEK_SET);
|
||||
|
@ -438,48 +443,48 @@ void CMaterialLoader::CreateCorruptionPasses(CMaterial *pMat)
|
|||
// Color Map (Diffuse)
|
||||
if (Type == "CLR ")
|
||||
{
|
||||
pPass->SetRasSel(eRasColor0A0);
|
||||
pPass->SetRasSel(kRasColor0A0);
|
||||
|
||||
if (Lightmap)
|
||||
{
|
||||
pPass->SetColorInputs(eZeroRGB, eColor0RGB, eTextureRGB, eZeroRGB);
|
||||
pPass->SetColorInputs(kZeroRGB, kColor0RGB, kTextureRGB, kZeroRGB);
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
pPass->SetColorInputs(eZeroRGB, eRasRGB, eTextureRGB, eZeroRGB);
|
||||
pPass->SetColorInputs(kZeroRGB, kRasRGB, kTextureRGB, kZeroRGB);
|
||||
}
|
||||
|
||||
|
||||
if (pMat->mOptions & CMaterial::ePunchthrough)
|
||||
if (pMat->mOptions & EMaterialOption::Masked)
|
||||
{
|
||||
pPass->SetAlphaInputs(eZeroAlpha, eZeroAlpha, eZeroAlpha, eTextureAlpha);
|
||||
pPass->SetAlphaInputs(kZeroAlpha, kZeroAlpha, kZeroAlpha, kTextureAlpha);
|
||||
}
|
||||
else if (mHasOPAC)
|
||||
{
|
||||
pPass->SetAlphaInputs(eZeroAlpha, eZeroAlpha, eZeroAlpha, eKonstAlpha);
|
||||
pPass->SetKColorSel(eKonst0_RGB);
|
||||
pPass->SetKAlphaSel(eKonst0_A);
|
||||
pPass->SetAlphaInputs(kZeroAlpha, kZeroAlpha, kZeroAlpha, kKonstAlpha);
|
||||
pPass->SetKColorSel(kKonst0_RGB);
|
||||
pPass->SetKAlphaSel(kKonst0_A);
|
||||
}
|
||||
else
|
||||
{
|
||||
pPass->SetAlphaInputs(eZeroAlpha, eZeroAlpha, eZeroAlpha, ePrevAlpha);
|
||||
pPass->SetAlphaInputs(kZeroAlpha, kZeroAlpha, kZeroAlpha, kPrevAlpha);
|
||||
}
|
||||
|
||||
pPass->SetColorOutput(ePrevReg);
|
||||
pPass->SetAlphaOutput(ePrevReg);
|
||||
pPass->SetColorOutput(kPrevReg);
|
||||
pPass->SetAlphaOutput(kPrevReg);
|
||||
}
|
||||
|
||||
// Lightmap
|
||||
else if (Type == "DIFF")
|
||||
{
|
||||
pPass->SetColorInputs(eZeroRGB, eKonstRGB, eTextureRGB, eRasRGB);
|
||||
pPass->SetAlphaInputs(eZeroAlpha, eZeroAlpha, eZeroAlpha, eKonstAlpha);
|
||||
pPass->SetColorOutput(eColor0Reg);
|
||||
pPass->SetAlphaOutput(eColor0Reg);
|
||||
pPass->SetKColorSel(eKonst1_RGB);
|
||||
pPass->SetKAlphaSel(eKonst1_A);
|
||||
pPass->SetRasSel(eRasColor0A0);
|
||||
pPass->SetColorInputs(kZeroRGB, kKonstRGB, kTextureRGB, kRasRGB);
|
||||
pPass->SetAlphaInputs(kZeroAlpha, kZeroAlpha, kZeroAlpha, kKonstAlpha);
|
||||
pPass->SetColorOutput(kColor0Reg);
|
||||
pPass->SetAlphaOutput(kColor0Reg);
|
||||
pPass->SetKColorSel(kKonst1_RGB);
|
||||
pPass->SetKAlphaSel(kKonst1_A);
|
||||
pPass->SetRasSel(kRasColor0A0);
|
||||
Lightmap = true;
|
||||
}
|
||||
|
||||
|
@ -487,91 +492,91 @@ void CMaterialLoader::CreateCorruptionPasses(CMaterial *pMat)
|
|||
else if (Type == "BLOL")
|
||||
{
|
||||
// Bloom maps work by writing to framebuffer alpha. Can't do this on alpha-blended mats.
|
||||
pPass->SetColorInputs(eZeroRGB, eZeroRGB, eZeroRGB, ePrevRGB);
|
||||
pPass->SetColorInputs(kZeroRGB, kZeroRGB, kZeroRGB, kPrevRGB);
|
||||
|
||||
if ((AlphaBlended) || (pMat->mOptions & CMaterial::ePunchthrough))
|
||||
pPass->SetAlphaInputs(eZeroAlpha, eZeroAlpha, eZeroAlpha, ePrevAlpha);
|
||||
if ((AlphaBlended) || (pMat->mOptions & EMaterialOption::Masked))
|
||||
pPass->SetAlphaInputs(kZeroAlpha, kZeroAlpha, kZeroAlpha, kPrevAlpha);
|
||||
else
|
||||
pPass->SetAlphaInputs(eZeroAlpha, eZeroAlpha, eZeroAlpha, eTextureAlpha);
|
||||
pPass->SetAlphaInputs(kZeroAlpha, kZeroAlpha, kZeroAlpha, kTextureAlpha);
|
||||
|
||||
pPass->SetColorOutput(ePrevReg);
|
||||
pPass->SetAlphaOutput(ePrevReg);
|
||||
pPass->SetColorOutput(kPrevReg);
|
||||
pPass->SetAlphaOutput(kPrevReg);
|
||||
}
|
||||
|
||||
// Rim Light Map
|
||||
else if (Type == "RIML")
|
||||
{
|
||||
pPass->SetColorInputs(eZeroRGB, eOneRGB, ePrevRGB, eTextureRGB);
|
||||
pPass->SetAlphaInputs(eZeroAlpha, eZeroAlpha, eZeroAlpha, ePrevAlpha);
|
||||
pPass->SetColorOutput(ePrevReg);
|
||||
pPass->SetAlphaOutput(ePrevReg);
|
||||
pPass->SetColorInputs(kZeroRGB, kOneRGB, kPrevRGB, kTextureRGB);
|
||||
pPass->SetAlphaInputs(kZeroAlpha, kZeroAlpha, kZeroAlpha, kPrevAlpha);
|
||||
pPass->SetColorOutput(kPrevReg);
|
||||
pPass->SetAlphaOutput(kPrevReg);
|
||||
}
|
||||
|
||||
// Emissive Map
|
||||
else if (Type == "INCA")
|
||||
{
|
||||
pPass->SetColorInputs(eZeroRGB, eTextureRGB, eOneRGB, ePrevRGB);
|
||||
pPass->SetColorInputs(kZeroRGB, kTextureRGB, kOneRGB, kPrevRGB);
|
||||
|
||||
if ((pPass->mSettings & CMaterialPass::eEmissiveBloom) && (!AlphaBlended))
|
||||
if ((pPass->mSettings & EPassSettings::EmissiveBloom) && (!AlphaBlended))
|
||||
{
|
||||
pPass->SetAlphaInputs(eZeroAlpha, eTextureAlpha, eKonstAlpha, ePrevAlpha);
|
||||
pPass->SetKAlphaSel(eKonstOneFourth);
|
||||
pPass->SetAlphaInputs(kZeroAlpha, kTextureAlpha, kKonstAlpha, kPrevAlpha);
|
||||
pPass->SetKAlphaSel(kKonstOneFourth);
|
||||
}
|
||||
else
|
||||
{
|
||||
pPass->SetAlphaInputs(eZeroAlpha, eZeroAlpha, eZeroAlpha, ePrevAlpha);
|
||||
pPass->SetAlphaInputs(kZeroAlpha, kZeroAlpha, kZeroAlpha, kPrevAlpha);
|
||||
}
|
||||
|
||||
pPass->SetColorOutput(ePrevReg);
|
||||
pPass->SetAlphaOutput(ePrevReg);
|
||||
pPass->SetColorOutput(kPrevReg);
|
||||
pPass->SetAlphaOutput(kPrevReg);
|
||||
}
|
||||
|
||||
// Opacity Map
|
||||
else if (Type == "TRAN")
|
||||
{
|
||||
pPass->SetColorInputs(eZeroRGB, eZeroRGB, eZeroRGB, ePrevRGB);
|
||||
pPass->SetColorInputs(kZeroRGB, kZeroRGB, kZeroRGB, kPrevRGB);
|
||||
|
||||
if (pPass->mSettings & CMaterialPass::eInvertOpacityMap)
|
||||
pPass->SetAlphaInputs(eKonstAlpha, eZeroAlpha, eTextureAlpha, eZeroAlpha);
|
||||
if (pPass->mSettings & EPassSettings::InvertOpacityMap)
|
||||
pPass->SetAlphaInputs(kKonstAlpha, kZeroAlpha, kTextureAlpha, kZeroAlpha);
|
||||
else
|
||||
pPass->SetAlphaInputs(eZeroAlpha, eKonstAlpha, eTextureAlpha, eZeroAlpha);
|
||||
pPass->SetAlphaInputs(kZeroAlpha, kKonstAlpha, kTextureAlpha, kZeroAlpha);
|
||||
|
||||
pPass->SetColorOutput(ePrevReg);
|
||||
pPass->SetAlphaOutput(ePrevReg);
|
||||
pPass->SetColorOutput(kPrevReg);
|
||||
pPass->SetAlphaOutput(kPrevReg);
|
||||
}
|
||||
|
||||
// Specular Map
|
||||
else if (Type == "RFLV")
|
||||
{
|
||||
pPass->SetColorInputs(eZeroRGB, eZeroRGB, eZeroRGB, eTextureRGB);
|
||||
pPass->SetAlphaInputs(eZeroAlpha, eZeroAlpha, eZeroAlpha, ePrevAlpha);
|
||||
pPass->SetColorOutput(eColor2Reg);
|
||||
pPass->SetAlphaOutput(eColor2Reg);
|
||||
pPass->SetColorInputs(kZeroRGB, kZeroRGB, kZeroRGB, kTextureRGB);
|
||||
pPass->SetAlphaInputs(kZeroAlpha, kZeroAlpha, kZeroAlpha, kPrevAlpha);
|
||||
pPass->SetColorOutput(kColor2Reg);
|
||||
pPass->SetAlphaOutput(kColor2Reg);
|
||||
}
|
||||
|
||||
// Reflection Map
|
||||
else if (Type == "RFLD")
|
||||
{
|
||||
pPass->SetColorInputs(eZeroRGB, eColor2RGB, eTextureRGB, ePrevRGB);
|
||||
pPass->SetAlphaInputs(eZeroAlpha, eZeroAlpha, eZeroAlpha, ePrevAlpha);
|
||||
pPass->SetColorOutput(ePrevReg);
|
||||
pPass->SetAlphaOutput(ePrevReg);
|
||||
pPass->SetColorInputs(kZeroRGB, kColor2RGB, kTextureRGB, kPrevRGB);
|
||||
pPass->SetAlphaInputs(kZeroAlpha, kZeroAlpha, kZeroAlpha, kPrevAlpha);
|
||||
pPass->SetColorOutput(kPrevReg);
|
||||
pPass->SetAlphaOutput(kPrevReg);
|
||||
if (mHas0x400) pPass->SetEnabled(false);
|
||||
}
|
||||
|
||||
// Bloom Incandescence
|
||||
else if (Type == "BLOI")
|
||||
{
|
||||
pPass->SetColorInputs(eZeroRGB, eZeroRGB, eZeroRGB, ePrevRGB);
|
||||
pPass->SetColorInputs(kZeroRGB, kZeroRGB, kZeroRGB, kPrevRGB);
|
||||
|
||||
// Comes out wrong every time even though this is exactly how the Dolphin shaders say this is done.
|
||||
if (AlphaBlended)
|
||||
pPass->SetAlphaInputs(eZeroAlpha, eZeroAlpha, eZeroAlpha, ePrevAlpha);
|
||||
pPass->SetAlphaInputs(kZeroAlpha, kZeroAlpha, kZeroAlpha, kPrevAlpha);
|
||||
else
|
||||
pPass->SetAlphaInputs(eTextureAlpha, eZeroAlpha, eZeroAlpha, ePrevAlpha);
|
||||
pPass->SetAlphaInputs(kTextureAlpha, kZeroAlpha, kZeroAlpha, kPrevAlpha);
|
||||
|
||||
pPass->SetColorOutput(ePrevReg);
|
||||
pPass->SetAlphaOutput(ePrevReg);
|
||||
pPass->SetColorOutput(kPrevReg);
|
||||
pPass->SetAlphaOutput(kPrevReg);
|
||||
}
|
||||
|
||||
// Bloom Diffuse
|
||||
|
@ -583,28 +588,28 @@ void CMaterialLoader::CreateCorruptionPasses(CMaterial *pMat)
|
|||
// X-Ray - since we don't support X-Ray previews, no effect
|
||||
else if (Type == "XRAY")
|
||||
{
|
||||
pPass->SetColorInputs(eZeroRGB, eZeroRGB, eZeroRGB, ePrevRGB);
|
||||
pPass->SetAlphaInputs(eZeroAlpha, eZeroAlpha, eZeroAlpha, ePrevAlpha);
|
||||
pPass->SetColorOutput(ePrevReg);
|
||||
pPass->SetAlphaOutput(ePrevReg);
|
||||
pPass->SetColorInputs(kZeroRGB, kZeroRGB, kZeroRGB, kPrevRGB);
|
||||
pPass->SetAlphaInputs(kZeroAlpha, kZeroAlpha, kZeroAlpha, kPrevAlpha);
|
||||
pPass->SetColorOutput(kPrevReg);
|
||||
pPass->SetAlphaOutput(kPrevReg);
|
||||
}
|
||||
|
||||
// Toon? Don't know what it's for but got TEV setup from shader dumps
|
||||
else if (Type == "TOON")
|
||||
{
|
||||
pPass->SetColorInputs(eZeroRGB, ePrevRGB, eTextureRGB, eZeroRGB);
|
||||
pPass->SetAlphaInputs(eZeroAlpha, eZeroAlpha, eZeroAlpha, eTextureAlpha);
|
||||
pPass->SetColorOutput(ePrevReg);
|
||||
pPass->SetAlphaOutput(ePrevReg);
|
||||
pPass->SetColorInputs(kZeroRGB, kPrevRGB, kTextureRGB, kZeroRGB);
|
||||
pPass->SetAlphaInputs(kZeroAlpha, kZeroAlpha, kZeroAlpha, kTextureAlpha);
|
||||
pPass->SetColorOutput(kPrevReg);
|
||||
pPass->SetAlphaOutput(kPrevReg);
|
||||
}
|
||||
|
||||
// LURD and LRLD are unknown and don't seem to do anything
|
||||
else if ((Type == "LURD") || (Type == "LRLD"))
|
||||
{
|
||||
pPass->SetColorInputs(eZeroRGB, eZeroRGB, eZeroRGB, ePrevRGB);
|
||||
pPass->SetAlphaInputs(eZeroAlpha, eZeroAlpha, eZeroAlpha, ePrevAlpha);
|
||||
pPass->SetColorOutput(ePrevReg);
|
||||
pPass->SetAlphaOutput(ePrevReg);
|
||||
pPass->SetColorInputs(kZeroRGB, kZeroRGB, kZeroRGB, kPrevRGB);
|
||||
pPass->SetAlphaInputs(kZeroAlpha, kZeroAlpha, kZeroAlpha, kPrevAlpha);
|
||||
pPass->SetColorOutput(kPrevReg);
|
||||
pPass->SetAlphaOutput(kPrevReg);
|
||||
}
|
||||
|
||||
else if (Type == "CUST") {}
|
||||
|
@ -620,7 +625,7 @@ void CMaterialLoader::CreateCorruptionPasses(CMaterial *pMat)
|
|||
CMaterial* CMaterialLoader::LoadAssimpMaterial(const aiMaterial *pAiMat)
|
||||
{
|
||||
// todo: generate new material using import values.
|
||||
CMaterial *pMat = new CMaterial(mVersion, eNoAttributes);
|
||||
CMaterial *pMat = new CMaterial(mVersion, EVertexAttribute::None);
|
||||
|
||||
aiString Name;
|
||||
pAiMat->Get(AI_MATKEY_NAME, Name);
|
||||
|
@ -628,11 +633,11 @@ CMaterial* CMaterialLoader::LoadAssimpMaterial(const aiMaterial *pAiMat)
|
|||
|
||||
// Create generic custom pass that uses Konst color
|
||||
CMaterialPass *pPass = new CMaterialPass(pMat);
|
||||
pPass->SetColorInputs(eZeroRGB, eRasRGB, eKonstRGB, eZeroRGB);
|
||||
pPass->SetAlphaInputs(eZeroAlpha, eZeroAlpha, eZeroAlpha, eKonstAlpha);
|
||||
pPass->SetKColorSel(eKonst0_RGB);
|
||||
pPass->SetKAlphaSel(eKonstOne);
|
||||
pPass->SetRasSel(eRasColor0A0);
|
||||
pPass->SetColorInputs(kZeroRGB, kRasRGB, kKonstRGB, kZeroRGB);
|
||||
pPass->SetAlphaInputs(kZeroAlpha, kZeroAlpha, kZeroAlpha, kKonstAlpha);
|
||||
pPass->SetKColorSel(kKonst0_RGB);
|
||||
pPass->SetKAlphaSel(kKonstOne);
|
||||
pPass->SetRasSel(kRasColor0A0);
|
||||
pMat->mKonstColors[0] = CColor::RandomLightColor(false);
|
||||
pMat->mPasses.push_back(pPass);
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
#include <map>
|
||||
|
||||
CModelLoader::CModelLoader()
|
||||
: mFlags(eNoFlags)
|
||||
: mFlags(EModelLoaderFlag::None)
|
||||
, mNumVertices(0)
|
||||
{
|
||||
}
|
||||
|
@ -24,7 +24,7 @@ void CModelLoader::LoadWorldMeshHeader(IInputStream& rModel)
|
|||
void CModelLoader::LoadAttribArrays(IInputStream& rModel)
|
||||
{
|
||||
// Positions
|
||||
if (mFlags & eShortPositions) // Shorts (DKCR only)
|
||||
if (mFlags & EModelLoaderFlag::HalfPrecisionPositions) // 16-bit (DKCR only)
|
||||
{
|
||||
mPositions.resize(mpSectionMgr->CurrentSectionSize() / 0x6);
|
||||
float Divisor = 8192.f; // Might be incorrect! Needs verification via size comparison.
|
||||
|
@ -38,7 +38,7 @@ void CModelLoader::LoadAttribArrays(IInputStream& rModel)
|
|||
}
|
||||
}
|
||||
|
||||
else // Floats
|
||||
else // 32-bit
|
||||
{
|
||||
mPositions.resize(mpSectionMgr->CurrentSectionSize() / 0xC);
|
||||
|
||||
|
@ -49,7 +49,7 @@ void CModelLoader::LoadAttribArrays(IInputStream& rModel)
|
|||
mpSectionMgr->ToNextSection();
|
||||
|
||||
// Normals
|
||||
if (mFlags & eShortNormals) // Shorts
|
||||
if (mFlags & EModelLoaderFlag::HalfPrecisionNormals) // 16-bit
|
||||
{
|
||||
mNormals.resize(mpSectionMgr->CurrentSectionSize() / 0x6);
|
||||
float Divisor = (mVersion < EGame::DKCReturns) ? 32768.f : 16384.f;
|
||||
|
@ -62,7 +62,7 @@ void CModelLoader::LoadAttribArrays(IInputStream& rModel)
|
|||
mNormals[iVtx] = CVector3f(X, Y, Z);
|
||||
}
|
||||
}
|
||||
else // Floats
|
||||
else // 32-bit
|
||||
{
|
||||
mNormals.resize(mpSectionMgr->CurrentSectionSize() / 0xC);
|
||||
|
||||
|
@ -81,7 +81,7 @@ void CModelLoader::LoadAttribArrays(IInputStream& rModel)
|
|||
mpSectionMgr->ToNextSection();
|
||||
|
||||
|
||||
// Float UVs
|
||||
// UVs
|
||||
mTex0.resize(mpSectionMgr->CurrentSectionSize() / 0x8);
|
||||
|
||||
for (uint32 iVtx = 0; iVtx < mTex0.size(); iVtx++)
|
||||
|
@ -89,8 +89,8 @@ void CModelLoader::LoadAttribArrays(IInputStream& rModel)
|
|||
|
||||
mpSectionMgr->ToNextSection();
|
||||
|
||||
// Short UVs
|
||||
if (mFlags & eHasTex1)
|
||||
// Lightmap UVs
|
||||
if (mFlags & EModelLoaderFlag::LightmapUVs)
|
||||
{
|
||||
mTex1.resize(mpSectionMgr->CurrentSectionSize() / 0x4);
|
||||
float Divisor = (mVersion < EGame::DKCReturns) ? 32768.f : 8192.f;
|
||||
|
@ -137,7 +137,7 @@ SSurface* CModelLoader::LoadSurface(IInputStream& rModel)
|
|||
while ((Flag != 0) && ((uint32) rModel.Tell() < NextSurface))
|
||||
{
|
||||
SSurface::SPrimitive Prim;
|
||||
Prim.Type = EGXPrimitiveType(Flag & 0xF8);
|
||||
Prim.Type = EPrimitiveType(Flag & 0xF8);
|
||||
uint16 VertexCount = rModel.ReadShort();
|
||||
|
||||
for (uint16 iVtx = 0; iVtx < VertexCount; iVtx++)
|
||||
|
@ -146,14 +146,14 @@ SSurface* CModelLoader::LoadSurface(IInputStream& rModel)
|
|||
FVertexDescription VtxDesc = pMat->VtxDesc();
|
||||
|
||||
for (uint32 iMtxAttr = 0; iMtxAttr < 8; iMtxAttr++)
|
||||
if (VtxDesc & (ePosMtx << iMtxAttr)) rModel.Seek(0x1, SEEK_CUR);
|
||||
if (VtxDesc & ((uint) EVertexAttribute::PosMtx << iMtxAttr)) rModel.Seek(0x1, SEEK_CUR);
|
||||
|
||||
// Only thing to do here is check whether each attribute is present, and if so, read it.
|
||||
// A couple attributes have special considerations; normals can be floats or shorts, as can tex0, depending on vtxfmt.
|
||||
// tex0 can also be read from either UV buffer; depends what the material says.
|
||||
|
||||
// Position
|
||||
if (VtxDesc & ePosition)
|
||||
if (VtxDesc & EVertexAttribute::Position)
|
||||
{
|
||||
uint16 PosIndex = rModel.ReadShort() & 0xFFFF;
|
||||
Vtx.Position = mPositions[PosIndex];
|
||||
|
@ -163,21 +163,21 @@ SSurface* CModelLoader::LoadSurface(IInputStream& rModel)
|
|||
}
|
||||
|
||||
// Normal
|
||||
if (VtxDesc & eNormal)
|
||||
if (VtxDesc & EVertexAttribute::Normal)
|
||||
Vtx.Normal = mNormals[rModel.ReadShort() & 0xFFFF];
|
||||
|
||||
// Color
|
||||
for (uint32 iClr = 0; iClr < 2; iClr++)
|
||||
if (VtxDesc & (eColor0 << iClr))
|
||||
if (VtxDesc & ((uint) EVertexAttribute::Color0 << iClr))
|
||||
Vtx.Color[iClr] = mColors[rModel.ReadShort() & 0xFFFF];
|
||||
|
||||
// Tex Coords - these are done a bit differently in DKCR than in the Prime series
|
||||
if (mVersion < EGame::DKCReturns)
|
||||
{
|
||||
// Tex0
|
||||
if (VtxDesc & eTex0)
|
||||
if (VtxDesc & EVertexAttribute::Tex0)
|
||||
{
|
||||
if ((mFlags & eHasTex1) && (pMat->Options() & CMaterial::eShortTexCoord))
|
||||
if ((mFlags & EModelLoaderFlag::LightmapUVs) && (pMat->Options() & EMaterialOption::ShortTexCoord))
|
||||
Vtx.Tex[0] = mTex1[rModel.ReadShort() & 0xFFFF];
|
||||
else
|
||||
Vtx.Tex[0] = mTex0[rModel.ReadShort() & 0xFFFF];
|
||||
|
@ -185,7 +185,7 @@ SSurface* CModelLoader::LoadSurface(IInputStream& rModel)
|
|||
|
||||
// Tex1-7
|
||||
for (uint32 iTex = 1; iTex < 7; iTex++)
|
||||
if (VtxDesc & (eTex0 << iTex))
|
||||
if (VtxDesc & ((uint) EVertexAttribute::Tex0 << iTex))
|
||||
Vtx.Tex[iTex] = mTex0[rModel.ReadShort() & 0xFFFF];
|
||||
}
|
||||
|
||||
|
@ -194,7 +194,7 @@ SSurface* CModelLoader::LoadSurface(IInputStream& rModel)
|
|||
// Tex0-7
|
||||
for (uint32 iTex = 0; iTex < 7; iTex++)
|
||||
{
|
||||
if (VtxDesc & (eTex0 << iTex))
|
||||
if (VtxDesc & ((uint) EVertexAttribute::Tex0 << iTex))
|
||||
{
|
||||
if (!mSurfaceUsingTex1)
|
||||
Vtx.Tex[iTex] = mTex0[rModel.ReadShort() & 0xFFFF];
|
||||
|
@ -212,11 +212,11 @@ SSurface* CModelLoader::LoadSurface(IInputStream& rModel)
|
|||
|
||||
switch (Prim.Type)
|
||||
{
|
||||
case eGX_Triangles:
|
||||
case EPrimitiveType::Triangles:
|
||||
pSurf->TriangleCount += VertexCount / 3;
|
||||
break;
|
||||
case eGX_TriangleFan:
|
||||
case eGX_TriangleStrip:
|
||||
case EPrimitiveType::TriangleFan:
|
||||
case EPrimitiveType::TriangleStrip:
|
||||
pSurf->TriangleCount += VertexCount - 2;
|
||||
break;
|
||||
}
|
||||
|
@ -283,13 +283,13 @@ SSurface* CModelLoader::LoadAssimpMesh(const aiMesh *pkMesh, CMaterialSet *pSet)
|
|||
CMaterial *pMat = pSet->MaterialByIndex(pkMesh->mMaterialIndex);
|
||||
FVertexDescription Desc = pMat->VtxDesc();
|
||||
|
||||
if (Desc == eNoAttributes)
|
||||
if (Desc == (FVertexDescription) EVertexAttribute::None)
|
||||
{
|
||||
if (pkMesh->HasPositions()) Desc |= ePosition;
|
||||
if (pkMesh->HasNormals()) Desc |= eNormal;
|
||||
if (pkMesh->HasPositions()) Desc |= EVertexAttribute::Position;
|
||||
if (pkMesh->HasNormals()) Desc |= EVertexAttribute::Normal;
|
||||
|
||||
for (uint32 iUV = 0; iUV < pkMesh->GetNumUVChannels(); iUV++)
|
||||
Desc |= (eTex0 << iUV);
|
||||
Desc |= ((uint) EVertexAttribute::Tex0 << iUV);
|
||||
|
||||
pMat->SetVertexDescription(Desc);
|
||||
|
||||
|
@ -297,8 +297,8 @@ SSurface* CModelLoader::LoadAssimpMesh(const aiMesh *pkMesh, CMaterialSet *pSet)
|
|||
if (!pkMesh->HasNormals())
|
||||
{
|
||||
pMat->SetLightingEnabled(false);
|
||||
pMat->Pass(0)->SetColorInputs(eZeroRGB, eOneRGB, eKonstRGB, eZeroRGB);
|
||||
pMat->Pass(0)->SetRasSel(eRasColorNull);
|
||||
pMat->Pass(0)->SetColorInputs(kZeroRGB, kOneRGB, kKonstRGB, kZeroRGB);
|
||||
pMat->Pass(0)->SetRasSel(kRasColorNull);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -313,9 +313,9 @@ SSurface* CModelLoader::LoadAssimpMesh(const aiMesh *pkMesh, CMaterialSet *pSet)
|
|||
|
||||
// Check primitive type on first face
|
||||
uint32 NumIndices = pkMesh->mFaces[0].mNumIndices;
|
||||
if (NumIndices == 1) rPrim.Type = eGX_Points;
|
||||
else if (NumIndices == 2) rPrim.Type = eGX_Lines;
|
||||
else if (NumIndices == 3) rPrim.Type = eGX_Triangles;
|
||||
if (NumIndices == 1) rPrim.Type = EPrimitiveType::Points;
|
||||
else if (NumIndices == 2) rPrim.Type = EPrimitiveType::Lines;
|
||||
else if (NumIndices == 3) rPrim.Type = EPrimitiveType::Triangles;
|
||||
|
||||
// Generate bounding box, center point, and reflection projection
|
||||
pSurf->CenterPoint = CVector3f::skZero;
|
||||
|
@ -340,7 +340,7 @@ SSurface* CModelLoader::LoadAssimpMesh(const aiMesh *pkMesh, CMaterialSet *pSet)
|
|||
|
||||
// Set vertex/triangle count
|
||||
pSurf->VertexCount = pkMesh->mNumVertices;
|
||||
pSurf->TriangleCount = (rPrim.Type == eGX_Triangles ? pkMesh->mNumFaces : 0);
|
||||
pSurf->TriangleCount = (rPrim.Type == EPrimitiveType::Triangles ? pkMesh->mNumFaces : 0);
|
||||
|
||||
// Create primitive
|
||||
for (uint32 iFace = 0; iFace < pkMesh->mNumFaces; iFace++)
|
||||
|
@ -401,9 +401,9 @@ CModel* CModelLoader::LoadCMDL(IInputStream& rCMDL, CResourceEntry *pEntry)
|
|||
BlockCount = rCMDL.ReadLong();
|
||||
MatSetCount = rCMDL.ReadLong();
|
||||
|
||||
if (Flags & 0x1) Loader.mFlags |= eSkinnedModel;
|
||||
if (Flags & 0x2) Loader.mFlags |= eShortNormals;
|
||||
if (Flags & 0x4) Loader.mFlags |= eHasTex1;
|
||||
if (Flags & 0x1) Loader.mFlags |= EModelLoaderFlag::Skinned;
|
||||
if (Flags & 0x2) Loader.mFlags |= EModelLoaderFlag::HalfPrecisionNormals;
|
||||
if (Flags & 0x4) Loader.mFlags |= EModelLoaderFlag::LightmapUVs;
|
||||
}
|
||||
|
||||
// 0x9381000A - Donkey Kong Country Returns
|
||||
|
@ -416,9 +416,9 @@ CModel* CModelLoader::LoadCMDL(IInputStream& rCMDL, CResourceEntry *pEntry)
|
|||
MatSetCount = rCMDL.ReadLong();
|
||||
|
||||
// todo: unknown flags
|
||||
Loader.mFlags = eShortNormals | eHasTex1;
|
||||
if (Flags & 0x10) Loader.mFlags |= eHasVisGroups;
|
||||
if (Flags & 0x20) Loader.mFlags |= eShortPositions;
|
||||
Loader.mFlags = EModelLoaderFlag::HalfPrecisionNormals | EModelLoaderFlag::LightmapUVs;
|
||||
if (Flags & 0x10) Loader.mFlags |= EModelLoaderFlag::VisibilityGroups;
|
||||
if (Flags & 0x20) Loader.mFlags |= EModelLoaderFlag::HalfPrecisionPositions;
|
||||
|
||||
// Visibility group data
|
||||
// Skipping for now - should read in eventually
|
||||
|
@ -498,8 +498,8 @@ CModel* CModelLoader::LoadWorldModel(IInputStream& rMREA, CSectionMgrIn& rBlockM
|
|||
CModelLoader Loader;
|
||||
Loader.mpSectionMgr = &rBlockMgr;
|
||||
Loader.mVersion = Version;
|
||||
Loader.mFlags = eShortNormals;
|
||||
if (Version != EGame::CorruptionProto) Loader.mFlags |= eHasTex1;
|
||||
Loader.mFlags = EModelLoaderFlag::HalfPrecisionNormals;
|
||||
if (Version != EGame::CorruptionProto) Loader.mFlags |= EModelLoaderFlag::LightmapUVs;
|
||||
Loader.mMaterials.resize(1);
|
||||
Loader.mMaterials[0] = &rMatSet;
|
||||
|
||||
|
@ -531,10 +531,10 @@ CModel* CModelLoader::LoadCorruptionWorldModel(IInputStream& rMREA, CSectionMgrI
|
|||
CModelLoader Loader;
|
||||
Loader.mpSectionMgr = &rBlockMgr;
|
||||
Loader.mVersion = Version;
|
||||
Loader.mFlags = eShortNormals;
|
||||
Loader.mFlags = EModelLoaderFlag::HalfPrecisionNormals;
|
||||
Loader.mMaterials.resize(1);
|
||||
Loader.mMaterials[0] = &rMatSet;
|
||||
if (Version == EGame::DKCReturns) Loader.mFlags |= eHasTex1;
|
||||
if (Version == EGame::DKCReturns) Loader.mFlags |= EModelLoaderFlag::LightmapUVs;
|
||||
|
||||
// Corruption/DKCR MREAs split the mesh header and surface offsets away from the actual geometry data so I need two section numbers to read it
|
||||
rBlockMgr.ToSection(HeaderSecNum);
|
||||
|
|
|
@ -11,19 +11,20 @@
|
|||
|
||||
#include <assimp/scene.h>
|
||||
|
||||
enum class EModelLoaderFlag
|
||||
{
|
||||
None = 0x0,
|
||||
HalfPrecisionPositions = 0x1,
|
||||
HalfPrecisionNormals = 0x2,
|
||||
LightmapUVs = 0x4,
|
||||
VisibilityGroups = 0x8,
|
||||
Skinned = 0x10
|
||||
};
|
||||
DECLARE_FLAGS_ENUMCLASS(EModelLoaderFlag, FModelLoaderFlags)
|
||||
|
||||
class CModelLoader
|
||||
{
|
||||
public:
|
||||
enum EModelFlag
|
||||
{
|
||||
eNoFlags = 0x0,
|
||||
eShortPositions = 0x1,
|
||||
eShortNormals = 0x2,
|
||||
eHasTex1 = 0x4,
|
||||
eHasVisGroups = 0x8,
|
||||
eSkinnedModel = 0x10
|
||||
};
|
||||
DECLARE_FLAGS(EModelFlag, FModelFlags)
|
||||
|
||||
private:
|
||||
TResPtr<CModel> mpModel;
|
||||
|
@ -43,7 +44,7 @@ private:
|
|||
uint32 mSurfaceCount;
|
||||
std::vector<uint32> mSurfaceOffsets;
|
||||
|
||||
FModelFlags mFlags;
|
||||
FModelLoaderFlags mFlags;
|
||||
|
||||
CModelLoader();
|
||||
~CModelLoader();
|
||||
|
|
|
@ -34,28 +34,28 @@ public:
|
|||
{
|
||||
switch (pEntry->ResourceType())
|
||||
{
|
||||
case eAnimation: return new CAnimation(pEntry);
|
||||
case eAnimEventData: return new CAnimEventData(pEntry);
|
||||
case eAnimSet: return new CAnimSet(pEntry);
|
||||
case eArea: return new CGameArea(pEntry);
|
||||
case eAudioMacro: return new CAudioMacro(pEntry);
|
||||
case eAudioGroup: return new CAudioGroup(pEntry);
|
||||
case eAudioLookupTable: return new CAudioLookupTable(pEntry);
|
||||
case eCharacter: return new CAnimSet(pEntry);
|
||||
case eDynamicCollision: return new CCollisionMeshGroup(pEntry);
|
||||
case eDependencyGroup: return new CDependencyGroup(pEntry);
|
||||
case eFont: return new CFont(pEntry);
|
||||
case eMapArea: return new CMapArea(pEntry);
|
||||
case eModel: return new CModel(pEntry);
|
||||
case eScan: return new CScan(pEntry);
|
||||
case eSkeleton: return new CSkeleton(pEntry);
|
||||
case eSkin: return new CSkin(pEntry);
|
||||
case eSourceAnimData: return new CSourceAnimData(pEntry);
|
||||
case eStaticGeometryMap: return new CPoiToWorld(pEntry);
|
||||
case eStringList: return new CStringList(pEntry);
|
||||
case eStringTable: return new CStringTable(pEntry);
|
||||
case eTexture: return new CTexture(pEntry);
|
||||
case eWorld: return new CWorld(pEntry);
|
||||
case EResourceType::Animation: return new CAnimation(pEntry);
|
||||
case EResourceType::AnimEventData: return new CAnimEventData(pEntry);
|
||||
case EResourceType::AnimSet: return new CAnimSet(pEntry);
|
||||
case EResourceType::Area: return new CGameArea(pEntry);
|
||||
case EResourceType::AudioMacro: return new CAudioMacro(pEntry);
|
||||
case EResourceType::AudioGroup: return new CAudioGroup(pEntry);
|
||||
case EResourceType::AudioLookupTable: return new CAudioLookupTable(pEntry);
|
||||
case EResourceType::Character: return new CAnimSet(pEntry);
|
||||
case EResourceType::DynamicCollision: return new CCollisionMeshGroup(pEntry);
|
||||
case EResourceType::DependencyGroup: return new CDependencyGroup(pEntry);
|
||||
case EResourceType::Font: return new CFont(pEntry);
|
||||
case EResourceType::MapArea: return new CMapArea(pEntry);
|
||||
case EResourceType::Model: return new CModel(pEntry);
|
||||
case EResourceType::Scan: return new CScan(pEntry);
|
||||
case EResourceType::Skeleton: return new CSkeleton(pEntry);
|
||||
case EResourceType::Skin: return new CSkin(pEntry);
|
||||
case EResourceType::SourceAnimData: return new CSourceAnimData(pEntry);
|
||||
case EResourceType::StaticGeometryMap: return new CPoiToWorld(pEntry);
|
||||
case EResourceType::StringList: return new CStringList(pEntry);
|
||||
case EResourceType::StringTable: return new CStringTable(pEntry);
|
||||
case EResourceType::Texture: return new CTexture(pEntry);
|
||||
case EResourceType::World: return new CWorld(pEntry);
|
||||
default: return nullptr; // should it return a CResource instead?
|
||||
}
|
||||
}
|
||||
|
@ -68,38 +68,38 @@ public:
|
|||
|
||||
switch (pEntry->ResourceType())
|
||||
{
|
||||
case eAnimation: pRes = CAnimationLoader::LoadANIM(rInput, pEntry); break;
|
||||
case eAnimEventData: pRes = CAnimEventLoader::LoadEVNT(rInput, pEntry); break;
|
||||
case eAnimSet: pRes = CAnimSetLoader::LoadANCS(rInput, pEntry); break;
|
||||
case eArea: pRes = CAreaLoader::LoadMREA(rInput, pEntry); break;
|
||||
case eAudioMacro: pRes = CUnsupportedFormatLoader::LoadCAUD(rInput, pEntry); break;
|
||||
case eAudioGroup: pRes = CAudioGroupLoader::LoadAGSC(rInput, pEntry); break;
|
||||
case eAudioLookupTable: pRes = CAudioGroupLoader::LoadATBL(rInput, pEntry); break;
|
||||
case eBinaryData: pRes = CUnsupportedFormatLoader::LoadDUMB(rInput, pEntry); break;
|
||||
case eCharacter: pRes = CAnimSetLoader::LoadCHAR(rInput, pEntry); break;
|
||||
case eDependencyGroup: pRes = CDependencyGroupLoader::LoadDGRP(rInput, pEntry); break;
|
||||
case eDynamicCollision: pRes = CCollisionLoader::LoadDCLN(rInput, pEntry); break;
|
||||
case eFont: pRes = CFontLoader::LoadFONT(rInput, pEntry); break;
|
||||
case eGuiFrame: pRes = CUnsupportedFormatLoader::LoadFRME(rInput, pEntry); break;
|
||||
case eHintSystem: pRes = CUnsupportedFormatLoader::LoadHINT(rInput, pEntry); break;
|
||||
case eMapArea: pRes = CUnsupportedFormatLoader::LoadMAPA(rInput, pEntry); break;
|
||||
case eMapWorld: pRes = CUnsupportedFormatLoader::LoadMAPW(rInput, pEntry); break;
|
||||
case eMapUniverse: pRes = CUnsupportedFormatLoader::LoadMAPU(rInput, pEntry); break;
|
||||
case eMidi: pRes = CUnsupportedFormatLoader::LoadCSNG(rInput, pEntry); break;
|
||||
case eModel: pRes = CModelLoader::LoadCMDL(rInput, pEntry); break;
|
||||
case eRuleSet: pRes = CUnsupportedFormatLoader::LoadRULE(rInput, pEntry); break;
|
||||
case eScan: pRes = CScanLoader::LoadSCAN(rInput, pEntry); break;
|
||||
case eSkeleton: pRes = CSkeletonLoader::LoadCINF(rInput, pEntry); break;
|
||||
case eSkin: pRes = CSkinLoader::LoadCSKR(rInput, pEntry); break;
|
||||
case eSourceAnimData: pRes = CAnimSetLoader::LoadSAND(rInput, pEntry); break;
|
||||
case eStateMachine2: pRes = CUnsupportedFormatLoader::LoadFSM2(rInput, pEntry); break;
|
||||
case eStaticGeometryMap: pRes = CPoiToWorldLoader::LoadEGMC(rInput, pEntry); break;
|
||||
case eStringList: pRes = CAudioGroupLoader::LoadSTLC(rInput, pEntry); break;
|
||||
case eStringTable: pRes = CStringLoader::LoadSTRG(rInput, pEntry); break;
|
||||
case eTexture: pRes = CTextureDecoder::LoadTXTR(rInput, pEntry); break;
|
||||
case eWorld: pRes = CWorldLoader::LoadMLVL(rInput, pEntry); break;
|
||||
case EResourceType::Animation: pRes = CAnimationLoader::LoadANIM(rInput, pEntry); break;
|
||||
case EResourceType::AnimEventData: pRes = CAnimEventLoader::LoadEVNT(rInput, pEntry); break;
|
||||
case EResourceType::AnimSet: pRes = CAnimSetLoader::LoadANCS(rInput, pEntry); break;
|
||||
case EResourceType::Area: pRes = CAreaLoader::LoadMREA(rInput, pEntry); break;
|
||||
case EResourceType::AudioMacro: pRes = CUnsupportedFormatLoader::LoadCAUD(rInput, pEntry); break;
|
||||
case EResourceType::AudioGroup: pRes = CAudioGroupLoader::LoadAGSC(rInput, pEntry); break;
|
||||
case EResourceType::AudioLookupTable: pRes = CAudioGroupLoader::LoadATBL(rInput, pEntry); break;
|
||||
case EResourceType::BinaryData: pRes = CUnsupportedFormatLoader::LoadDUMB(rInput, pEntry); break;
|
||||
case EResourceType::Character: pRes = CAnimSetLoader::LoadCHAR(rInput, pEntry); break;
|
||||
case EResourceType::DependencyGroup: pRes = CDependencyGroupLoader::LoadDGRP(rInput, pEntry); break;
|
||||
case EResourceType::DynamicCollision: pRes = CCollisionLoader::LoadDCLN(rInput, pEntry); break;
|
||||
case EResourceType::Font: pRes = CFontLoader::LoadFONT(rInput, pEntry); break;
|
||||
case EResourceType::GuiFrame: pRes = CUnsupportedFormatLoader::LoadFRME(rInput, pEntry); break;
|
||||
case EResourceType::HintSystem: pRes = CUnsupportedFormatLoader::LoadHINT(rInput, pEntry); break;
|
||||
case EResourceType::MapArea: pRes = CUnsupportedFormatLoader::LoadMAPA(rInput, pEntry); break;
|
||||
case EResourceType::MapWorld: pRes = CUnsupportedFormatLoader::LoadMAPW(rInput, pEntry); break;
|
||||
case EResourceType::MapUniverse: pRes = CUnsupportedFormatLoader::LoadMAPU(rInput, pEntry); break;
|
||||
case EResourceType::Midi: pRes = CUnsupportedFormatLoader::LoadCSNG(rInput, pEntry); break;
|
||||
case EResourceType::Model: pRes = CModelLoader::LoadCMDL(rInput, pEntry); break;
|
||||
case EResourceType::RuleSet: pRes = CUnsupportedFormatLoader::LoadRULE(rInput, pEntry); break;
|
||||
case EResourceType::Scan: pRes = CScanLoader::LoadSCAN(rInput, pEntry); break;
|
||||
case EResourceType::Skeleton: pRes = CSkeletonLoader::LoadCINF(rInput, pEntry); break;
|
||||
case EResourceType::Skin: pRes = CSkinLoader::LoadCSKR(rInput, pEntry); break;
|
||||
case EResourceType::SourceAnimData: pRes = CAnimSetLoader::LoadSAND(rInput, pEntry); break;
|
||||
case EResourceType::StateMachine2: pRes = CUnsupportedFormatLoader::LoadFSM2(rInput, pEntry); break;
|
||||
case EResourceType::StaticGeometryMap: pRes = CPoiToWorldLoader::LoadEGMC(rInput, pEntry); break;
|
||||
case EResourceType::StringList: pRes = CAudioGroupLoader::LoadSTLC(rInput, pEntry); break;
|
||||
case EResourceType::StringTable: pRes = CStringLoader::LoadSTRG(rInput, pEntry); break;
|
||||
case EResourceType::Texture: pRes = CTextureDecoder::LoadTXTR(rInput, pEntry); break;
|
||||
case EResourceType::World: pRes = CWorldLoader::LoadMLVL(rInput, pEntry); break;
|
||||
|
||||
case eStateMachine:
|
||||
case EResourceType::StateMachine:
|
||||
// AFSM currently unsupported
|
||||
if (pEntry->Game() <= EGame::Echoes)
|
||||
pRes = new CDependencyGroup(pEntry);
|
||||
|
@ -109,17 +109,17 @@ public:
|
|||
pRes = CUnsupportedFormatLoader::LoadFSMC(rInput, pEntry);
|
||||
break;
|
||||
|
||||
case eBurstFireData:
|
||||
case eParticle:
|
||||
case eParticleElectric:
|
||||
case eParticleSorted:
|
||||
case eParticleSpawn:
|
||||
case eParticleSwoosh:
|
||||
case eParticleDecal:
|
||||
case eParticleWeapon:
|
||||
case eParticleCollisionResponse:
|
||||
case eParticleTransform:
|
||||
case eUserEvaluatorData:
|
||||
case EResourceType::BurstFireData:
|
||||
case EResourceType::Particle:
|
||||
case EResourceType::ParticleElectric:
|
||||
case EResourceType::ParticleSorted:
|
||||
case EResourceType::ParticleSpawn:
|
||||
case EResourceType::ParticleSwoosh:
|
||||
case EResourceType::ParticleDecal:
|
||||
case EResourceType::ParticleWeapon:
|
||||
case EResourceType::ParticleCollisionResponse:
|
||||
case EResourceType::ParticleTransform:
|
||||
case EResourceType::UserEvaluatorData:
|
||||
pRes = CUnsupportedParticleLoader::LoadParticle(rInput, pEntry);
|
||||
break;
|
||||
|
||||
|
|
|
@ -9,15 +9,15 @@ CScanLoader::CScanLoader()
|
|||
CScan* CScanLoader::LoadScanMP1(IInputStream& rSCAN)
|
||||
{
|
||||
// Basic support at the moment - don't read animation/scan image data
|
||||
mpScan->mFrameID = CAssetID(rSCAN, e32Bit);
|
||||
mpScan->mpStringTable = gpResourceStore->LoadResource(rSCAN.ReadLong(), eStringTable);
|
||||
mpScan->mFrameID = CAssetID(rSCAN, k32Bit);
|
||||
mpScan->mpStringTable = gpResourceStore->LoadResource(rSCAN.ReadLong(), EResourceType::StringTable);
|
||||
mpScan->mIsSlow = (rSCAN.ReadLong() != 0);
|
||||
mpScan->mCategory = (CScan::ELogbookCategory) rSCAN.ReadLong();
|
||||
mpScan->mIsImportant = (rSCAN.ReadByte() == 1);
|
||||
|
||||
for (uint32 iImg = 0; iImg < 4; iImg++)
|
||||
{
|
||||
mpScan->mScanImageTextures[iImg] = CAssetID(rSCAN, e32Bit);
|
||||
mpScan->mScanImageTextures[iImg] = CAssetID(rSCAN, k32Bit);
|
||||
rSCAN.Seek(0x18, SEEK_CUR);
|
||||
}
|
||||
|
||||
|
@ -116,7 +116,7 @@ void CScanLoader::LoadParamsMP2(IInputStream& rSCAN, uint16 NumProperties)
|
|||
switch (PropertyID)
|
||||
{
|
||||
case 0x2F5B6423:
|
||||
mpScan->mpStringTable = gpResourceStore->LoadResource(rSCAN.ReadLong(), eStringTable);
|
||||
mpScan->mpStringTable = gpResourceStore->LoadResource(rSCAN.ReadLong(), EResourceType::StringTable);
|
||||
break;
|
||||
|
||||
case 0xC308A322:
|
||||
|
@ -199,7 +199,7 @@ void CScanLoader::LoadParamsMP2(IInputStream& rSCAN, uint16 NumProperties)
|
|||
rSCAN.GoTo(Next);
|
||||
}
|
||||
|
||||
mpScan->mCategory = CScan::eNone;
|
||||
mpScan->mCategory = CScan::ELogbookCategory::None;
|
||||
}
|
||||
|
||||
void CScanLoader::LoadParamsMP3(IInputStream& rSCAN, uint16 NumProperties)
|
||||
|
@ -214,7 +214,7 @@ void CScanLoader::LoadParamsMP3(IInputStream& rSCAN, uint16 NumProperties)
|
|||
switch (PropertyID)
|
||||
{
|
||||
case 0x2F5B6423:
|
||||
mpScan->mpStringTable = gpResourceStore->LoadResource(rSCAN.ReadLongLong(), eStringTable);
|
||||
mpScan->mpStringTable = gpResourceStore->LoadResource(rSCAN.ReadLongLong(), EResourceType::Scan);
|
||||
break;
|
||||
|
||||
case 0xC308A322:
|
||||
|
@ -229,7 +229,7 @@ void CScanLoader::LoadParamsMP3(IInputStream& rSCAN, uint16 NumProperties)
|
|||
rSCAN.GoTo(Next);
|
||||
}
|
||||
|
||||
mpScan->mCategory = CScan::eNone;
|
||||
mpScan->mCategory = CScan::ELogbookCategory::None;
|
||||
}
|
||||
|
||||
void CScanLoader::LoadScanInfoSecondaryModel(IInputStream& rSCAN, CScan::SScanInfoSecondaryModel& rSecondaryModel)
|
||||
|
|
|
@ -49,37 +49,37 @@ CTexture* CTextureDecoder::CreateTexture()
|
|||
pTex->mWidth = mWidth;
|
||||
pTex->mHeight = mHeight;
|
||||
pTex->mNumMipMaps = mNumMipMaps;
|
||||
pTex->mLinearSize = (uint32) (mWidth * mHeight * gskPixelsToBytes[mTexelFormat]);
|
||||
pTex->mLinearSize = (uint32) (mWidth * mHeight * gskPixelsToBytes[(int) mTexelFormat]);
|
||||
pTex->mpImgDataBuffer = mpDataBuffer;
|
||||
pTex->mImgDataSize = mDataBufferSize;
|
||||
pTex->mBufferExists = true;
|
||||
|
||||
switch (mTexelFormat)
|
||||
{
|
||||
case eGX_I4:
|
||||
case eGX_I8:
|
||||
case eGX_IA4:
|
||||
case eGX_IA8:
|
||||
pTex->mTexelFormat = eLuminanceAlpha;
|
||||
case ETexelFormat::GX_I4:
|
||||
case ETexelFormat::GX_I8:
|
||||
case ETexelFormat::GX_IA4:
|
||||
case ETexelFormat::GX_IA8:
|
||||
pTex->mTexelFormat = ETexelFormat::LuminanceAlpha;
|
||||
break;
|
||||
case eGX_RGB565:
|
||||
pTex->mTexelFormat = eRGB565;
|
||||
case ETexelFormat::GX_RGB565:
|
||||
pTex->mTexelFormat = ETexelFormat::RGB565;
|
||||
break;
|
||||
case eGX_C4:
|
||||
case eGX_C8:
|
||||
if (mPaletteFormat == ePalette_IA8) pTex->mTexelFormat = eLuminanceAlpha;
|
||||
if (mPaletteFormat == ePalette_RGB565) pTex->mTexelFormat = eRGB565;
|
||||
if (mPaletteFormat == ePalette_RGB5A3) pTex->mTexelFormat = eRGBA8;
|
||||
case ETexelFormat::GX_C4:
|
||||
case ETexelFormat::GX_C8:
|
||||
if (mPaletteFormat == EGXPaletteFormat::IA8) pTex->mTexelFormat = ETexelFormat::LuminanceAlpha;
|
||||
if (mPaletteFormat == EGXPaletteFormat::RGB565) pTex->mTexelFormat = ETexelFormat::RGB565;
|
||||
if (mPaletteFormat == EGXPaletteFormat::RGB5A3) pTex->mTexelFormat = ETexelFormat::RGBA8;
|
||||
break;
|
||||
case eGX_RGB5A3:
|
||||
case eGX_RGBA8:
|
||||
pTex->mTexelFormat = eRGBA8;
|
||||
case ETexelFormat::GX_RGB5A3:
|
||||
case ETexelFormat::GX_RGBA8:
|
||||
pTex->mTexelFormat = ETexelFormat::RGBA8;
|
||||
break;
|
||||
case eGX_CMPR:
|
||||
pTex->mTexelFormat = eDXT1;
|
||||
case ETexelFormat::GX_CMPR:
|
||||
pTex->mTexelFormat = ETexelFormat::DXT1;
|
||||
break;
|
||||
case eDXT1:
|
||||
pTex->mTexelFormat = eDXT1;
|
||||
case ETexelFormat::DXT1:
|
||||
pTex->mTexelFormat = ETexelFormat::DXT1;
|
||||
pTex->mLinearSize = mWidth * mHeight / 2;
|
||||
break;
|
||||
default:
|
||||
|
@ -108,7 +108,7 @@ CTexture* CTextureDecoder::DoFullDecode(IInputStream& rTXTR, CResourceEntry *pEn
|
|||
Decoder.FullDecodeGXTexture(rTXTR);
|
||||
|
||||
CTexture *pTexture = Decoder.CreateTexture();
|
||||
pTexture->mTexelFormat = eRGBA8;
|
||||
pTexture->mTexelFormat = ETexelFormat::RGBA8;
|
||||
return pTexture;
|
||||
}
|
||||
|
||||
|
@ -136,17 +136,17 @@ void CTextureDecoder::ReadTXTR(IInputStream& rTXTR)
|
|||
mNumMipMaps = rTXTR.ReadLong();
|
||||
|
||||
// For C4 and C8 images, read palette
|
||||
if ((mTexelFormat == eGX_C4) || (mTexelFormat == eGX_C8))
|
||||
if ((mTexelFormat == ETexelFormat::GX_C4) || (mTexelFormat == ETexelFormat::GX_C8))
|
||||
{
|
||||
mHasPalettes = true;
|
||||
mPaletteFormat = EGXPaletteFormat(rTXTR.ReadLong());
|
||||
rTXTR.Seek(0x4, SEEK_CUR);
|
||||
|
||||
uint32 PaletteEntryCount = (mTexelFormat == eGX_C4) ? 16 : 256;
|
||||
uint32 PaletteEntryCount = (mTexelFormat == ETexelFormat::GX_C4) ? 16 : 256;
|
||||
mPalettes.resize(PaletteEntryCount * 2);
|
||||
rTXTR.ReadBytes(mPalettes.data(), mPalettes.size());
|
||||
|
||||
mPaletteInput.SetData(mPalettes.data(), mPalettes.size(), IOUtil::eBigEndian);
|
||||
mPaletteInput.SetData(mPalettes.data(), mPalettes.size(), EEndian::BigEndian);
|
||||
}
|
||||
else mHasPalettes = false;
|
||||
}
|
||||
|
@ -214,28 +214,28 @@ void CTextureDecoder::PartialDecodeGXTexture(IInputStream& TXTR)
|
|||
uint32 ImageSize = TXTR.Tell() - ImageStart;
|
||||
TXTR.Seek(ImageStart, SEEK_SET);
|
||||
|
||||
mDataBufferSize = ImageSize * (gskOutputBpp[mTexelFormat] / gskSourceBpp[mTexelFormat]);
|
||||
if ((mHasPalettes) && (mPaletteFormat == ePalette_RGB5A3)) mDataBufferSize *= 2;
|
||||
mDataBufferSize = ImageSize * (gskOutputBpp[(int) mTexelFormat] / gskSourceBpp[(int) mTexelFormat]);
|
||||
if ((mHasPalettes) && (mPaletteFormat == EGXPaletteFormat::RGB5A3)) mDataBufferSize *= 2;
|
||||
mpDataBuffer = new uint8[mDataBufferSize];
|
||||
|
||||
CMemoryOutStream Out(mpDataBuffer, mDataBufferSize, IOUtil::kSystemEndianness);
|
||||
CMemoryOutStream Out(mpDataBuffer, mDataBufferSize, EEndian::SystemEndian);
|
||||
|
||||
// Initializing more stuff before we start the mipmap loop
|
||||
uint32 MipW = mWidth, MipH = mHeight;
|
||||
uint32 MipOffset = 0;
|
||||
|
||||
uint32 BWidth = gskBlockWidth[mTexelFormat];
|
||||
uint32 BHeight = gskBlockHeight[mTexelFormat];
|
||||
uint32 BWidth = gskBlockWidth[(int) mTexelFormat];
|
||||
uint32 BHeight = gskBlockHeight[(int) mTexelFormat];
|
||||
|
||||
uint32 PixelStride = gskOutputPixelStride[mTexelFormat];
|
||||
if (mHasPalettes && (mPaletteFormat == ePalette_RGB5A3))
|
||||
uint32 PixelStride = gskOutputPixelStride[(int) mTexelFormat];
|
||||
if (mHasPalettes && (mPaletteFormat == EGXPaletteFormat::RGB5A3))
|
||||
PixelStride = 4;
|
||||
|
||||
// With CMPR, we're using a little trick.
|
||||
// CMPR stores pixels in 8x8 blocks, with four 4x4 subblocks.
|
||||
// An easy way to convert it is to pretend each block is 2x2 and each subblock is one pixel.
|
||||
// So to do that we need to calculate the "new" dimensions of the image, 1/4 the size of the original.
|
||||
if (mTexelFormat == eGX_CMPR) {
|
||||
if (mTexelFormat == ETexelFormat::GX_CMPR) {
|
||||
MipW /= 4;
|
||||
MipH /= 4;
|
||||
}
|
||||
|
@ -261,33 +261,33 @@ void CTextureDecoder::PartialDecodeGXTexture(IInputStream& TXTR)
|
|||
uint32 DstPos = ((iImgY * MipW) + iImgX) * PixelStride;
|
||||
Out.Seek(MipOffset + DstPos, SEEK_SET);
|
||||
|
||||
if (mTexelFormat == eGX_I4) ReadPixelsI4(TXTR, Out);
|
||||
else if (mTexelFormat == eGX_I8) ReadPixelI8(TXTR, Out);
|
||||
else if (mTexelFormat == eGX_IA4) ReadPixelIA4(TXTR, Out);
|
||||
else if (mTexelFormat == eGX_IA8) ReadPixelIA8(TXTR, Out);
|
||||
else if (mTexelFormat == eGX_C4) ReadPixelsC4(TXTR, Out);
|
||||
else if (mTexelFormat == eGX_C8) ReadPixelC8(TXTR, Out);
|
||||
else if (mTexelFormat == eGX_RGB565) ReadPixelRGB565(TXTR, Out);
|
||||
else if (mTexelFormat == eGX_RGB5A3) ReadPixelRGB5A3(TXTR, Out);
|
||||
else if (mTexelFormat == eGX_RGBA8) ReadPixelRGBA8(TXTR, Out);
|
||||
else if (mTexelFormat == eGX_CMPR) ReadSubBlockCMPR(TXTR, Out);
|
||||
if (mTexelFormat == ETexelFormat::GX_I4) ReadPixelsI4(TXTR, Out);
|
||||
else if (mTexelFormat == ETexelFormat::GX_I8) ReadPixelI8(TXTR, Out);
|
||||
else if (mTexelFormat == ETexelFormat::GX_IA4) ReadPixelIA4(TXTR, Out);
|
||||
else if (mTexelFormat == ETexelFormat::GX_IA8) ReadPixelIA8(TXTR, Out);
|
||||
else if (mTexelFormat == ETexelFormat::GX_C4) ReadPixelsC4(TXTR, Out);
|
||||
else if (mTexelFormat == ETexelFormat::GX_C8) ReadPixelC8(TXTR, Out);
|
||||
else if (mTexelFormat == ETexelFormat::GX_RGB565) ReadPixelRGB565(TXTR, Out);
|
||||
else if (mTexelFormat == ETexelFormat::GX_RGB5A3) ReadPixelRGB5A3(TXTR, Out);
|
||||
else if (mTexelFormat == ETexelFormat::GX_RGBA8) ReadPixelRGBA8(TXTR, Out);
|
||||
else if (mTexelFormat == ETexelFormat::GX_CMPR) ReadSubBlockCMPR(TXTR, Out);
|
||||
|
||||
// I4 and C4 have 4bpp images, so I'm forced to read two pixels at a time.
|
||||
if ((mTexelFormat == eGX_I4) || (mTexelFormat == eGX_C4)) iImgX++;
|
||||
if ((mTexelFormat == ETexelFormat::GX_I4) || (mTexelFormat == ETexelFormat::GX_C4)) iImgX++;
|
||||
|
||||
// Check if we're at the end of the file.
|
||||
if (TXTR.EoF()) BreakEarly = true;
|
||||
}
|
||||
if (BreakEarly) break;
|
||||
}
|
||||
if (mTexelFormat == eGX_RGBA8) TXTR.Seek(0x20, SEEK_CUR);
|
||||
if (mTexelFormat == ETexelFormat::GX_RGBA8) TXTR.Seek(0x20, SEEK_CUR);
|
||||
if (BreakEarly) break;
|
||||
}
|
||||
if (BreakEarly) break;
|
||||
}
|
||||
|
||||
uint32 MipSize = (uint32) (MipW * MipH * gskPixelsToBytes[mTexelFormat]);
|
||||
if (mTexelFormat == eGX_CMPR) MipSize *= 16; // Since we're pretending the image is 1/4 its actual size, we have to multiply the size by 16 to get the correct offset
|
||||
uint32 MipSize = (uint32) (MipW * MipH * gskPixelsToBytes[(int) mTexelFormat]);
|
||||
if (mTexelFormat == ETexelFormat::GX_CMPR) MipSize *= 16; // Since we're pretending the image is 1/4 its actual size, we have to multiply the size by 16 to get the correct offset
|
||||
|
||||
MipOffset += MipSize;
|
||||
MipW /= 2;
|
||||
|
@ -305,23 +305,23 @@ void CTextureDecoder::FullDecodeGXTexture(IInputStream& rTXTR)
|
|||
uint32 ImageSize = rTXTR.Tell() - ImageStart;
|
||||
rTXTR.Seek(ImageStart, SEEK_SET);
|
||||
|
||||
mDataBufferSize = ImageSize * (32 / gskSourceBpp[mTexelFormat]);
|
||||
mDataBufferSize = ImageSize * (32 / gskSourceBpp[(int) mTexelFormat]);
|
||||
mpDataBuffer = new uint8[mDataBufferSize];
|
||||
|
||||
CMemoryOutStream Out(mpDataBuffer, mDataBufferSize, IOUtil::kSystemEndianness);
|
||||
CMemoryOutStream Out(mpDataBuffer, mDataBufferSize, EEndian::SystemEndian);
|
||||
|
||||
// Initializing more stuff before we start the mipmap loop
|
||||
uint32 MipW = mWidth, MipH = mHeight;
|
||||
uint32 MipOffset = 0;
|
||||
|
||||
uint32 BWidth = gskBlockWidth[mTexelFormat];
|
||||
uint32 BHeight = gskBlockHeight[mTexelFormat];
|
||||
uint32 BWidth = gskBlockWidth[(int) mTexelFormat];
|
||||
uint32 BHeight = gskBlockHeight[(int) mTexelFormat];
|
||||
|
||||
// With CMPR, we're using a little trick.
|
||||
// CMPR stores pixels in 8x8 blocks, with four 4x4 subblocks.
|
||||
// An easy way to convert it is to pretend each block is 2x2 and each subblock is one pixel.
|
||||
// So to do that we need to calculate the "new" dimensions of the image, 1/4 the size of the original.
|
||||
if (mTexelFormat == eGX_CMPR)
|
||||
if (mTexelFormat == ETexelFormat::GX_CMPR)
|
||||
{
|
||||
MipW /= 4;
|
||||
MipH /= 4;
|
||||
|
@ -334,45 +334,45 @@ void CTextureDecoder::FullDecodeGXTexture(IInputStream& rTXTR)
|
|||
for (uint32 iImgY = iBlockY; iImgY < iBlockY + BHeight; iImgY++) {
|
||||
for (uint32 iImgX = iBlockX; iImgX < iBlockX + BWidth; iImgX++)
|
||||
{
|
||||
uint32 DstPos = (mTexelFormat == eGX_CMPR) ? ((iImgY * (MipW * 4)) + iImgX) * 16 : ((iImgY * MipW) + iImgX) * 4;
|
||||
uint32 DstPos = (mTexelFormat == ETexelFormat::GX_CMPR) ? ((iImgY * (MipW * 4)) + iImgX) * 16 : ((iImgY * MipW) + iImgX) * 4;
|
||||
Out.Seek(MipOffset + DstPos, SEEK_SET);
|
||||
|
||||
// I4/C4/CMPR require reading more than one pixel at a time
|
||||
if (mTexelFormat == eGX_I4)
|
||||
if (mTexelFormat == ETexelFormat::GX_I4)
|
||||
{
|
||||
uint8 Byte = rTXTR.ReadByte();
|
||||
Out.WriteLong( DecodePixelI4(Byte, 0).ToLongARGB() );
|
||||
Out.WriteLong( DecodePixelI4(Byte, 1).ToLongARGB() );
|
||||
}
|
||||
else if (mTexelFormat == eGX_C4)
|
||||
else if (mTexelFormat == ETexelFormat::GX_C4)
|
||||
{
|
||||
uint8 Byte = rTXTR.ReadByte();
|
||||
Out.WriteLong( DecodePixelC4(Byte, 0, mPaletteInput).ToLongARGB() );
|
||||
Out.WriteLong( DecodePixelC4(Byte, 1, mPaletteInput).ToLongARGB() );
|
||||
}
|
||||
else if (mTexelFormat == eGX_CMPR) DecodeSubBlockCMPR(rTXTR, Out, (uint16) (MipW * 4));
|
||||
else if (mTexelFormat == ETexelFormat::GX_CMPR) DecodeSubBlockCMPR(rTXTR, Out, (uint16) (MipW * 4));
|
||||
|
||||
else
|
||||
{
|
||||
CColor Pixel;
|
||||
|
||||
if (mTexelFormat == eGX_I8) Pixel = DecodePixelI8(rTXTR.ReadByte());
|
||||
else if (mTexelFormat == eGX_IA4) Pixel = DecodePixelIA4(rTXTR.ReadByte());
|
||||
else if (mTexelFormat == eGX_IA8) Pixel = DecodePixelIA8(rTXTR.ReadShort());
|
||||
else if (mTexelFormat == eGX_C8) Pixel = DecodePixelC8(rTXTR.ReadByte(), mPaletteInput);
|
||||
else if (mTexelFormat == eGX_RGB565) Pixel = DecodePixelRGB565(rTXTR.ReadShort());
|
||||
else if (mTexelFormat == eGX_RGB5A3) Pixel = DecodePixelRGB5A3(rTXTR.ReadShort());
|
||||
else if (mTexelFormat == eGX_RGBA8) Pixel = CColor(rTXTR, true);
|
||||
if (mTexelFormat == ETexelFormat::GX_I8) Pixel = DecodePixelI8(rTXTR.ReadByte());
|
||||
else if (mTexelFormat == ETexelFormat::GX_IA4) Pixel = DecodePixelIA4(rTXTR.ReadByte());
|
||||
else if (mTexelFormat == ETexelFormat::GX_IA8) Pixel = DecodePixelIA8(rTXTR.ReadShort());
|
||||
else if (mTexelFormat == ETexelFormat::GX_C8) Pixel = DecodePixelC8(rTXTR.ReadByte(), mPaletteInput);
|
||||
else if (mTexelFormat == ETexelFormat::GX_RGB565) Pixel = DecodePixelRGB565(rTXTR.ReadShort());
|
||||
else if (mTexelFormat == ETexelFormat::GX_RGB5A3) Pixel = DecodePixelRGB5A3(rTXTR.ReadShort());
|
||||
else if (mTexelFormat == ETexelFormat::GX_RGBA8) Pixel = CColor(rTXTR, true);
|
||||
|
||||
Out.WriteLong(Pixel.ToLongARGB());
|
||||
}
|
||||
}
|
||||
}
|
||||
if (mTexelFormat == eGX_RGBA8) rTXTR.Seek(0x20, SEEK_CUR);
|
||||
if (mTexelFormat == ETexelFormat::GX_RGBA8) rTXTR.Seek(0x20, SEEK_CUR);
|
||||
}
|
||||
|
||||
uint32 MipSize = MipW * MipH * 4;
|
||||
if (mTexelFormat == eGX_CMPR) MipSize *= 16;
|
||||
if (mTexelFormat == ETexelFormat::GX_CMPR) MipSize *= 16;
|
||||
|
||||
MipOffset += MipSize;
|
||||
MipW /= 2;
|
||||
|
@ -396,7 +396,7 @@ void CTextureDecoder::DecodeDDS(IInputStream& rDDS)
|
|||
else mDataBufferSize *= 4;
|
||||
mpDataBuffer = new uint8[mDataBufferSize];
|
||||
|
||||
CMemoryOutStream Out(mpDataBuffer, mDataBufferSize, IOUtil::kSystemEndianness);
|
||||
CMemoryOutStream Out(mpDataBuffer, mDataBufferSize, EEndian::SystemEndian);
|
||||
|
||||
// Initializing more stuff before we start the mipmap loop
|
||||
uint32 MipW = mWidth, MipH = mHeight;
|
||||
|
@ -487,9 +487,9 @@ void CTextureDecoder::DecodeDDS(IInputStream& rDDS)
|
|||
}
|
||||
|
||||
if (mDDSInfo.Format == SDDSInfo::DXT1)
|
||||
mTexelFormat = eDXT1;
|
||||
mTexelFormat = ETexelFormat::DXT1;
|
||||
else
|
||||
mTexelFormat = eGX_RGBA8;
|
||||
mTexelFormat = ETexelFormat::GX_RGBA8;
|
||||
}
|
||||
|
||||
// ************ READ PIXELS (PARTIAL DECODE) ************
|
||||
|
@ -567,9 +567,9 @@ void CTextureDecoder::ReadPixelC8(IInputStream& rSrc, IOutputStream& rDst)
|
|||
|
||||
mPaletteInput.Seek(Index * 2, SEEK_SET);
|
||||
|
||||
if (mPaletteFormat == ePalette_IA8) ReadPixelIA8(mPaletteInput, rDst);
|
||||
else if (mPaletteFormat == ePalette_RGB565) ReadPixelRGB565(mPaletteInput, rDst);
|
||||
else if (mPaletteFormat == ePalette_RGB5A3) ReadPixelRGB5A3(mPaletteInput, rDst);
|
||||
if (mPaletteFormat == EGXPaletteFormat::IA8) ReadPixelIA8(mPaletteInput, rDst);
|
||||
else if (mPaletteFormat == EGXPaletteFormat::RGB565) ReadPixelRGB565(mPaletteInput, rDst);
|
||||
else if (mPaletteFormat == EGXPaletteFormat::RGB5A3) ReadPixelRGB5A3(mPaletteInput, rDst);
|
||||
}
|
||||
|
||||
void CTextureDecoder::ReadPixelRGB565(IInputStream& rSrc, IOutputStream& rDst)
|
||||
|
@ -659,18 +659,18 @@ CColor CTextureDecoder::DecodePixelC4(uint8 Byte, uint8 WhichPixel, IInputStream
|
|||
Byte &= 0xF;
|
||||
|
||||
rPaletteStream.Seek(Byte * 2, SEEK_SET);
|
||||
if (mPaletteFormat == ePalette_IA8) return DecodePixelIA8(rPaletteStream.ReadShort());
|
||||
else if (mPaletteFormat == ePalette_RGB565) return DecodePixelIA8(rPaletteStream.ReadShort());
|
||||
else if (mPaletteFormat == ePalette_RGB5A3) return DecodePixelIA8(rPaletteStream.ReadShort());
|
||||
if (mPaletteFormat == EGXPaletteFormat::IA8) return DecodePixelIA8(rPaletteStream.ReadShort());
|
||||
else if (mPaletteFormat == EGXPaletteFormat::RGB565) return DecodePixelIA8(rPaletteStream.ReadShort());
|
||||
else if (mPaletteFormat == EGXPaletteFormat::RGB5A3) return DecodePixelIA8(rPaletteStream.ReadShort());
|
||||
else return CColor::skTransparentBlack;
|
||||
}
|
||||
|
||||
CColor CTextureDecoder::DecodePixelC8(uint8 Byte, IInputStream& rPaletteStream)
|
||||
{
|
||||
rPaletteStream.Seek(Byte * 2, SEEK_SET);
|
||||
if (mPaletteFormat == ePalette_IA8) return DecodePixelIA8(rPaletteStream.ReadShort());
|
||||
else if (mPaletteFormat == ePalette_RGB565) return DecodePixelIA8(rPaletteStream.ReadShort());
|
||||
else if (mPaletteFormat == ePalette_RGB5A3) return DecodePixelIA8(rPaletteStream.ReadShort());
|
||||
if (mPaletteFormat == EGXPaletteFormat::IA8) return DecodePixelIA8(rPaletteStream.ReadShort());
|
||||
else if (mPaletteFormat == EGXPaletteFormat::RGB565) return DecodePixelIA8(rPaletteStream.ReadShort());
|
||||
else if (mPaletteFormat == EGXPaletteFormat::RGB5A3) return DecodePixelIA8(rPaletteStream.ReadShort());
|
||||
else return CColor::skTransparentBlack;
|
||||
}
|
||||
|
||||
|
|
|
@ -176,7 +176,7 @@ CDependencyGroup* CUnsupportedFormatLoader::LoadFRME(IInputStream& rFRME, CResou
|
|||
// Model
|
||||
else if (WidgetType == FOURCC('MODL'))
|
||||
{
|
||||
pGroup->AddDependency( CAssetID(rFRME, e32Bit) ); // CMDL
|
||||
pGroup->AddDependency( CAssetID(rFRME, k32Bit) ); // CMDL
|
||||
rFRME.Seek(0x8, SEEK_CUR);
|
||||
}
|
||||
|
||||
|
@ -184,12 +184,12 @@ CDependencyGroup* CUnsupportedFormatLoader::LoadFRME(IInputStream& rFRME, CResou
|
|||
else if (WidgetType == FOURCC('TXPN'))
|
||||
{
|
||||
rFRME.Seek(0x14, SEEK_CUR);
|
||||
pGroup->AddDependency( CAssetID(rFRME, e32Bit) ); // FONT
|
||||
pGroup->AddDependency( CAssetID(rFRME, k32Bit) ); // FONT
|
||||
rFRME.Seek(0x32, SEEK_CUR);
|
||||
|
||||
if (Version == 1)
|
||||
{
|
||||
pGroup->AddDependency( CAssetID(rFRME, e32Bit) ); // FONT
|
||||
pGroup->AddDependency( CAssetID(rFRME, k32Bit) ); // FONT
|
||||
rFRME.Seek(0x8, SEEK_CUR);
|
||||
}
|
||||
}
|
||||
|
@ -197,7 +197,7 @@ CDependencyGroup* CUnsupportedFormatLoader::LoadFRME(IInputStream& rFRME, CResou
|
|||
// Image Pane
|
||||
else if (WidgetType == FOURCC('IMGP'))
|
||||
{
|
||||
pGroup->AddDependency( CAssetID(rFRME, e32Bit) ); // TXTR
|
||||
pGroup->AddDependency( CAssetID(rFRME, k32Bit) ); // TXTR
|
||||
if (rFRME.ReadLong() != 0xFFFFFFFF) DEBUG_BREAK;
|
||||
rFRME.Seek(0x4, SEEK_CUR);
|
||||
|
||||
|
@ -210,7 +210,7 @@ CDependencyGroup* CUnsupportedFormatLoader::LoadFRME(IInputStream& rFRME, CResou
|
|||
// Energy Bar
|
||||
else if (WidgetType == FOURCC('ENRG'))
|
||||
{
|
||||
pGroup->AddDependency( CAssetID(rFRME, e32Bit) ); // TXTR
|
||||
pGroup->AddDependency( CAssetID(rFRME, k32Bit) ); // TXTR
|
||||
}
|
||||
|
||||
// Slider Group
|
||||
|
@ -438,7 +438,7 @@ CMapArea* CUnsupportedFormatLoader::LoadMAPA(IInputStream& /*rMAPA*/, CResourceE
|
|||
CAssetID MapWorldID;
|
||||
uint32 WorldIndex = -1;
|
||||
|
||||
for (TResourceIterator<eMapWorld> It; It; ++It)
|
||||
for (TResourceIterator<EResourceType::MapWorld> It; It; ++It)
|
||||
{
|
||||
CDependencyGroup *pGroup = (CDependencyGroup*) It->Load();
|
||||
|
||||
|
@ -459,7 +459,7 @@ CMapArea* CUnsupportedFormatLoader::LoadMAPA(IInputStream& /*rMAPA*/, CResourceE
|
|||
// Find a world that contains this MapWorld
|
||||
if (WorldIndex != -1)
|
||||
{
|
||||
for (TResourceIterator<eWorld> It; It; ++It)
|
||||
for (TResourceIterator<EResourceType::World> It; It; ++It)
|
||||
{
|
||||
CWorld *pWorld = (CWorld*) It->Load();
|
||||
CDependencyGroup *pMapWorld = (CDependencyGroup*) pWorld->MapWorld();
|
||||
|
@ -490,7 +490,7 @@ CDependencyGroup* CUnsupportedFormatLoader::LoadMAPW(IInputStream& rMAPW, CResou
|
|||
// Version check
|
||||
uint32 AreasStart = rMAPW.Tell();
|
||||
rMAPW.Seek(NumAreas * 4, SEEK_CUR);
|
||||
EIDLength IDLength = (rMAPW.EoF() || rMAPW.ReadLong() == 0xFFFFFFFF ? e32Bit : e64Bit);
|
||||
EIDLength IDLength = (rMAPW.EoF() || rMAPW.ReadLong() == 0xFFFFFFFF ? k32Bit : k64Bit);
|
||||
rMAPW.Seek(AreasStart, SEEK_SET);
|
||||
|
||||
// Read MAPA IDs
|
||||
|
@ -542,7 +542,7 @@ CDependencyGroup* CUnsupportedFormatLoader::LoadRULE(IInputStream& rRULE, CResou
|
|||
uint32 IDOffset = rRULE.Tell();
|
||||
rRULE.Seek(0x4, SEEK_CUR);
|
||||
uint32 RuleSetCount = rRULE.ReadShort();
|
||||
EIDLength IDLength = (RuleSetCount > 0xFF ? e64Bit : e32Bit);
|
||||
EIDLength IDLength = (RuleSetCount > 0xFF ? k64Bit : k32Bit);
|
||||
rRULE.Seek(IDOffset, SEEK_SET);
|
||||
|
||||
// Read rule ID
|
||||
|
|
|
@ -16,19 +16,19 @@ void CWorldLoader::LoadPrimeMLVL(IInputStream& rMLVL)
|
|||
// Header
|
||||
if (mVersion < EGame::CorruptionProto)
|
||||
{
|
||||
mpWorld->mpWorldName = gpResourceStore->LoadResource(rMLVL.ReadLong(), eStringTable);
|
||||
if (mVersion == EGame::Echoes) mpWorld->mpDarkWorldName = gpResourceStore->LoadResource(rMLVL.ReadLong(), eStringTable);
|
||||
mpWorld->mpWorldName = gpResourceStore->LoadResource(rMLVL.ReadLong(), EResourceType::StringTable);
|
||||
if (mVersion == EGame::Echoes) mpWorld->mpDarkWorldName = gpResourceStore->LoadResource(rMLVL.ReadLong(), EResourceType::StringTable);
|
||||
if (mVersion >= EGame::Echoes) mpWorld->mTempleKeyWorldIndex = rMLVL.ReadLong();
|
||||
if (mVersion >= EGame::Prime) mpWorld->mpSaveWorld = gpResourceStore->LoadResource(rMLVL.ReadLong(), eSaveWorld);
|
||||
mpWorld->mpDefaultSkybox = gpResourceStore->LoadResource(rMLVL.ReadLong(), eModel);
|
||||
if (mVersion >= EGame::Prime) mpWorld->mpSaveWorld = gpResourceStore->LoadResource(rMLVL.ReadLong(), EResourceType::SaveWorld);
|
||||
mpWorld->mpDefaultSkybox = gpResourceStore->LoadResource(rMLVL.ReadLong(), EResourceType::Model);
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
mpWorld->mpWorldName = gpResourceStore->LoadResource(rMLVL.ReadLongLong(), eStringTable);
|
||||
mpWorld->mpWorldName = gpResourceStore->LoadResource(rMLVL.ReadLongLong(), EResourceType::StringTable);
|
||||
rMLVL.Seek(0x4, SEEK_CUR); // Skipping unknown value
|
||||
mpWorld->mpSaveWorld = gpResourceStore->LoadResource(rMLVL.ReadLongLong(), eSaveWorld);
|
||||
mpWorld->mpDefaultSkybox = gpResourceStore->LoadResource(rMLVL.ReadLongLong(), eModel);
|
||||
mpWorld->mpSaveWorld = gpResourceStore->LoadResource(rMLVL.ReadLongLong(), EResourceType::SaveWorld);
|
||||
mpWorld->mpDefaultSkybox = gpResourceStore->LoadResource(rMLVL.ReadLongLong(), EResourceType::Model);
|
||||
}
|
||||
|
||||
// Memory relays - only in MP1
|
||||
|
@ -132,7 +132,7 @@ void CWorldLoader::LoadPrimeMLVL(IInputStream& rMLVL)
|
|||
}
|
||||
|
||||
// MapWorld
|
||||
mpWorld->mpMapWorld = gpResourceStore->LoadResource( CAssetID(rMLVL, mVersion), eMapWorld );
|
||||
mpWorld->mpMapWorld = gpResourceStore->LoadResource( CAssetID(rMLVL, mVersion), EResourceType::MapWorld );
|
||||
rMLVL.Seek(0x5, SEEK_CUR); // Unknown values which are always 0
|
||||
|
||||
// Audio Groups - we don't need this info as we regenerate it on cook
|
||||
|
@ -200,7 +200,7 @@ void CWorldLoader::LoadReturnsMLVL(IInputStream& rMLVL)
|
|||
rData.ShinyGoldTime = rMLVL.ReadFloat();
|
||||
}
|
||||
|
||||
mpWorld->mpSaveWorld = gpResourceStore->LoadResource(rMLVL.ReadLongLong(), eSaveWorld);
|
||||
mpWorld->mpSaveWorld = gpResourceStore->LoadResource(rMLVL.ReadLongLong(), EResourceType::SaveWorld);
|
||||
mpWorld->mpDefaultSkybox = gpResourceStore->LoadResource<CModel>(rMLVL.ReadLongLong());
|
||||
|
||||
// Areas
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
|
||||
class CBasicModel : public CResource
|
||||
{
|
||||
DECLARE_RESOURCE_TYPE(eModel)
|
||||
DECLARE_RESOURCE_TYPE(Model)
|
||||
protected:
|
||||
CAABox mAABox;
|
||||
uint32 mVertexCount;
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue