Added a basic UI to change collision render settings, added the ability to color collision based on the surface type

This commit is contained in:
parax0
2016-12-26 23:02:32 -07:00
parent 78baa42bce
commit be40dfdf02
13 changed files with 254 additions and 8 deletions

View File

@@ -6,6 +6,23 @@
#include <Math/CMatrix4f.h>
#include <Math/CRay.h>
enum ECollisionDrawMode
{
eCDM_Default,
eCDM_TintSurfaceType
};
struct SCollisionRenderSettings
{
ECollisionDrawMode DrawMode;
u64 HighlightMask;
u64 HideMask;
bool DrawWireframe;
SCollisionRenderSettings()
: DrawMode(eCDM_TintSurfaceType), HighlightMask(0), HideMask(0), DrawWireframe(false) {}
};
struct SViewInfo
{
class CScene *pScene;
@@ -14,6 +31,7 @@ struct SViewInfo
bool GameMode;
FShowFlags ShowFlags;
SCollisionRenderSettings CollisionSettings;
CFrustumPlanes ViewFrustum;
CMatrix4f RotationOnlyViewMatrix;
};

View File

@@ -3,6 +3,7 @@
#include "CResource.h"
#include "CCollisionMesh.h"
#include "EGame.h"
#include "TResPtr.h"
#include <vector>
@@ -10,6 +11,7 @@ class CCollisionMeshGroup : public CResource
{
DECLARE_RESOURCE_TYPE(eCollisionMeshGroup)
std::vector<CCollisionMesh*> mMeshes;
EGame mGame;
public:
CCollisionMeshGroup() {}
@@ -20,8 +22,11 @@ public:
delete *it;
}
inline EGame Game() const { return mGame; }
inline u32 NumMeshes() const { return mMeshes.size(); }
inline CCollisionMesh* MeshByIndex(u32 Index) const { return mMeshes[Index]; }
inline void SetGame(EGame Game) { mGame = Game; }
inline void AddMesh(CCollisionMesh *pMesh) { mMeshes.push_back(pMesh); }
inline void Draw()

View File

@@ -144,6 +144,7 @@ CCollisionMeshGroup* CCollisionLoader::LoadAreaCollision(IInputStream& rMREA)
loader.mVersion = GetFormatVersion(rMREA.ReadLong());
loader.mpGroup = new CCollisionMeshGroup;
loader.mpGroup->SetGame(loader.mVersion);
loader.mpMesh = new CCollisionMesh;
// Octree - structure is known, but not coding this right now
@@ -180,6 +181,7 @@ CCollisionMeshGroup* CCollisionLoader::LoadDCLN(IInputStream& rDCLN)
}
Loader.mVersion = GetFormatVersion(rDCLN.ReadLong());
Loader.mpGroup->SetGame(Loader.mVersion);
Loader.mpMesh = new CCollisionMesh;
Loader.mpMesh->mOctreeLoaded = false;

View File

@@ -45,13 +45,72 @@ void CCollisionNode::Draw(FRenderOptions /*Options*/, int /*ComponentIndex*/, ER
for (u32 iMat = 0; iMat < pMesh->NumMaterials(); iMat++)
{
CDrawUtil::UseCollisionShader(BaseTint);
SCollisionMaterial& rMat = pMesh->GetMaterial(iMat);
if (rkViewInfo.CollisionSettings.HideMask != 0 && (rMat.RawFlags & rkViewInfo.CollisionSettings.HideMask) == rkViewInfo.CollisionSettings.HideMask)
continue;
CColor Tint = BaseTint;
if (rkViewInfo.CollisionSettings.HighlightMask != 0 && (rMat.RawFlags & rkViewInfo.CollisionSettings.HighlightMask) == rkViewInfo.CollisionSettings.HighlightMask)
Tint *= CColor::skRed;
else if (mpCollision->Game() <= ePrime && rkViewInfo.CollisionSettings.DrawMode == eCDM_TintSurfaceType)
{
// Organic
if (rMat.RawFlags & 0x00800000)
Tint *= CColor::Integral(130, 130, 250); // Purple
// Wood
else if (rMat.RawFlags & 0x00400000)
Tint *= CColor::Integral(190, 140, 105); // Brown
// Sand
else if (rMat.RawFlags & 0x00020000)
Tint *= CColor::Integral(230, 200, 170); // Light Brown
// Shield
else if (rMat.RawFlags & 0x00010000)
Tint *= CColor::Integral(250, 230, 60); // Yellow
// Glass
else if (rMat.RawFlags & 0x00008000)
Tint *= CColor::Integral(20, 255, 190); // Greenish/Bluish
// Snow
else if (rMat.RawFlags & 0x00000800)
Tint *= CColor::Integral(230, 255, 255); // *Very* light blue
// Lava
else if (rMat.RawFlags & 0x00000200)
Tint *= CColor::Integral(200, 30, 30); // Red
// Rock
else if (rMat.RawFlags & 0x00000100)
Tint *= CColor::Integral(150, 130, 120); // Brownish-gray
// Phazon
else if (rMat.RawFlags & 0x00000080)
Tint *= CColor::Integral(0, 128, 255); // Blue
// Metal Grating
else if (rMat.RawFlags & 0x00000040)
Tint *= CColor::Integral(170, 170, 170); // Gray
// Ice
else if (rMat.RawFlags & 0x00000010)
Tint *= CColor::Integral(200, 255, 255); // Light blue
// Grass
else if (rMat.RawFlags & 0x00000008)
Tint *= CColor::Integral(90, 150, 70); // Green
// Metal
else if (rMat.RawFlags & 0x00000004)
Tint *= CColor::Integral(110, 110, 110); // Dark gray
// Stone
else if (rMat.RawFlags & 0x00000002)
Tint *= CColor::Integral(220, 215, 160); // Brown/green ish
}
CDrawUtil::UseCollisionShader(Tint);
pMesh->DrawMaterial(iMat);
}
}
//CDrawUtil::UseColorShader(CColor::skTransparentBlack);
//mpCollision->DrawWireframe();
if (rkViewInfo.CollisionSettings.DrawWireframe)
{
CDrawUtil::UseColorShader(CColor::skTransparentBlack);
mpCollision->DrawWireframe();
}
}
SRayIntersection CCollisionNode::RayNodeIntersectTest(const CRay& /*rkRay*/, u32 /*AssetID*/, const SViewInfo& /*rkViewInfo*/)