Set up game-neutral collision materials; Jump Not Allowed flag now flags that surface as unstandable; other minor fixes
This commit is contained in:
parent
be40dfdf02
commit
08dee84367
|
@ -15,6 +15,9 @@ layout(std140) uniform MVPBlock
|
||||||
mat4 ProjMtx;
|
mat4 ProjMtx;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
uniform bool IsFloor;
|
||||||
|
uniform bool IsUnstandable;
|
||||||
|
|
||||||
// Main
|
// Main
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
|
@ -31,4 +34,9 @@ void main()
|
||||||
float Alpha = (-LightDot + 1.0) / 2;
|
float Alpha = (-LightDot + 1.0) / 2;
|
||||||
float LightAlpha = mix(kLightColorMin, kLightColorMax, Alpha);
|
float LightAlpha = mix(kLightColorMin, kLightColorMax, Alpha);
|
||||||
LightColor = vec4(LightAlpha, LightAlpha, LightAlpha, 1.0);
|
LightColor = vec4(LightAlpha, LightAlpha, LightAlpha, 1.0);
|
||||||
|
|
||||||
|
// If this is not a floor, make the surface significantly darker
|
||||||
|
// The surface is considered a floor if IsFloor is true OR if the floor normal Z is greater than 0.85
|
||||||
|
float FloorMul = (!IsUnstandable && (IsFloor || RawNormal.z > 0.85)) ? 1.0 : 0.5;
|
||||||
|
LightColor *= FloorMul;
|
||||||
}
|
}
|
||||||
|
|
|
@ -196,7 +196,8 @@ HEADERS += \
|
||||||
Resource/Factory/CSkinLoader.h \
|
Resource/Factory/CSkinLoader.h \
|
||||||
Render/EDepthGroup.h \
|
Render/EDepthGroup.h \
|
||||||
Scene/CScriptAttachNode.h \
|
Scene/CScriptAttachNode.h \
|
||||||
ScriptExtra/CSandwormExtra.h
|
ScriptExtra/CSandwormExtra.h \
|
||||||
|
Resource/CCollisionMaterial.h
|
||||||
|
|
||||||
# Source Files
|
# Source Files
|
||||||
SOURCES += \
|
SOURCES += \
|
||||||
|
@ -283,4 +284,5 @@ SOURCES += \
|
||||||
Resource/Factory/CSkinLoader.cpp \
|
Resource/Factory/CSkinLoader.cpp \
|
||||||
Resource/Model/EVertexAttribute.cpp \
|
Resource/Model/EVertexAttribute.cpp \
|
||||||
Scene/CScriptAttachNode.cpp \
|
Scene/CScriptAttachNode.cpp \
|
||||||
ScriptExtra/CSandwormExtra.cpp
|
ScriptExtra/CSandwormExtra.cpp \
|
||||||
|
Resource/CCollisionMaterial.cpp
|
||||||
|
|
|
@ -329,14 +329,23 @@ void CDrawUtil::UseTextureShader(const CColor& TintColor)
|
||||||
CMaterial::KillCachedMaterial();
|
CMaterial::KillCachedMaterial();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CDrawUtil::UseCollisionShader(const CColor& TintColor /*= CColor::skWhite*/)
|
void CDrawUtil::UseCollisionShader(bool IsFloor, bool IsUnstandable, const CColor& TintColor /*= CColor::skWhite*/)
|
||||||
{
|
{
|
||||||
Init();
|
Init();
|
||||||
mpCollisionShader->SetCurrent();
|
mpCollisionShader->SetCurrent();
|
||||||
|
|
||||||
|
// Force blend mode to opaque + set alpha to 0 to ensure collision geometry isn't bloomed
|
||||||
|
glBlendFuncSeparate(GL_ONE, GL_ZERO, GL_ZERO, GL_ZERO);
|
||||||
|
|
||||||
static GLuint TintColorLoc = mpCollisionShader->GetUniformLocation("TintColor");
|
static GLuint TintColorLoc = mpCollisionShader->GetUniformLocation("TintColor");
|
||||||
glUniform4f(TintColorLoc, TintColor.R, TintColor.G, TintColor.B, TintColor.A);
|
glUniform4f(TintColorLoc, TintColor.R, TintColor.G, TintColor.B, TintColor.A);
|
||||||
|
|
||||||
|
static GLuint IsFloorLoc = mpCollisionShader->GetUniformLocation("IsFloor");
|
||||||
|
glUniform1i(IsFloorLoc, IsFloor ? 1 : 0);
|
||||||
|
|
||||||
|
static GLuint IsUnstandableLoc = mpCollisionShader->GetUniformLocation("IsUnstandable");
|
||||||
|
glUniform1i(IsUnstandableLoc, IsUnstandable ? 1 : 0);
|
||||||
|
|
||||||
CMaterial::KillCachedMaterial();
|
CMaterial::KillCachedMaterial();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -89,7 +89,7 @@ public:
|
||||||
static void UseColorShaderLighting(const CColor& Color);
|
static void UseColorShaderLighting(const CColor& Color);
|
||||||
static void UseTextureShader();
|
static void UseTextureShader();
|
||||||
static void UseTextureShader(const CColor& TintColor);
|
static void UseTextureShader(const CColor& TintColor);
|
||||||
static void UseCollisionShader(const CColor& TintColor = CColor::skWhite);
|
static void UseCollisionShader(bool IsFloor, bool IsUnstandable, const CColor& TintColor = CColor::skWhite);
|
||||||
|
|
||||||
static CShader* GetTextShader();
|
static CShader* GetTextShader();
|
||||||
static void LoadCheckerboardTexture(u32 GLTextureUnit);
|
static void LoadCheckerboardTexture(u32 GLTextureUnit);
|
||||||
|
|
|
@ -6,21 +6,24 @@
|
||||||
#include <Math/CMatrix4f.h>
|
#include <Math/CMatrix4f.h>
|
||||||
#include <Math/CRay.h>
|
#include <Math/CRay.h>
|
||||||
|
|
||||||
enum ECollisionDrawMode
|
|
||||||
{
|
|
||||||
eCDM_Default,
|
|
||||||
eCDM_TintSurfaceType
|
|
||||||
};
|
|
||||||
|
|
||||||
struct SCollisionRenderSettings
|
struct SCollisionRenderSettings
|
||||||
{
|
{
|
||||||
ECollisionDrawMode DrawMode;
|
|
||||||
u64 HighlightMask;
|
u64 HighlightMask;
|
||||||
u64 HideMask;
|
u64 HideMask;
|
||||||
bool DrawWireframe;
|
bool DrawWireframe;
|
||||||
|
bool DrawBackfaces;
|
||||||
|
bool DrawAreaCollisionBounds;
|
||||||
|
bool TintWithSurfaceColor;
|
||||||
|
bool TintUnwalkableTris;
|
||||||
|
|
||||||
SCollisionRenderSettings()
|
SCollisionRenderSettings()
|
||||||
: DrawMode(eCDM_TintSurfaceType), HighlightMask(0), HideMask(0), DrawWireframe(false) {}
|
: HighlightMask(0)
|
||||||
|
, HideMask(0)
|
||||||
|
, DrawWireframe(true)
|
||||||
|
, DrawBackfaces(false)
|
||||||
|
, DrawAreaCollisionBounds(true)
|
||||||
|
, TintWithSurfaceColor(true)
|
||||||
|
, TintUnwalkableTris(false) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct SViewInfo
|
struct SViewInfo
|
||||||
|
|
|
@ -0,0 +1,66 @@
|
||||||
|
#include "CCollisionMaterial.h"
|
||||||
|
#include "EGame.h"
|
||||||
|
#include <map>
|
||||||
|
|
||||||
|
ECollisionFlag CCollisionMaterial::SurfaceType(EGame Game) const
|
||||||
|
{
|
||||||
|
// Arrays determining the type hierarchy for each game.
|
||||||
|
// Flags earlier in the list take priority over flags later in the list.
|
||||||
|
static const ECollisionFlag skPrimeTypeHierarchy[] = {
|
||||||
|
eCF_Organic, eCF_Wood, eCF_Sand, eCF_Shield, eCF_Glass, eCF_Mud, eCF_SlowMud,
|
||||||
|
eCF_Snow, eCF_Lava, eCF_Dirt, eCF_Phazon, eCF_MetalGrating, eCF_Ice, eCF_Grass,
|
||||||
|
eCF_Metal, eCF_Stone
|
||||||
|
};
|
||||||
|
static const ECollisionFlag skEchoesTypeHierarchy[] = {
|
||||||
|
eCF_Rubber, eCF_Organic, eCF_Wood, eCF_Web, eCF_MothSeedOrganics, eCF_Sand,
|
||||||
|
eCF_Shield, eCF_Fabric, eCF_Snow, eCF_Glass, eCF_AltMetal, eCF_Dirt, eCF_Phazon,
|
||||||
|
eCF_MetalGrating, eCF_Ice, eCF_Grass, eCF_Metal, eCF_Stone
|
||||||
|
};
|
||||||
|
|
||||||
|
// Determine which list we should use.
|
||||||
|
const ECollisionFlag* pkFlagArray;
|
||||||
|
u32 Num;
|
||||||
|
|
||||||
|
if (Game <= ePrime)
|
||||||
|
{
|
||||||
|
pkFlagArray = skPrimeTypeHierarchy;
|
||||||
|
Num = sizeof(skPrimeTypeHierarchy) / sizeof(ECollisionFlag);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
pkFlagArray = skEchoesTypeHierarchy;
|
||||||
|
Num = sizeof(skEchoesTypeHierarchy) / sizeof(ECollisionFlag);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Locate type.
|
||||||
|
for (u32 iType = 0; iType < Num; iType++)
|
||||||
|
{
|
||||||
|
if (*this & pkFlagArray[iType])
|
||||||
|
return pkFlagArray[iType];
|
||||||
|
}
|
||||||
|
return eCF_Unknown;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Type-to-color mappings
|
||||||
|
const std::map<ECollisionFlag, CColor> gkTypeToColor = {
|
||||||
|
{ eCF_Stone, CColor::Integral(220, 215, 160) }, // Brownish/greenish color
|
||||||
|
{ eCF_Metal, CColor::Integral(110, 110, 110) }, // Dark gray
|
||||||
|
{ eCF_Grass, CColor::Integral( 90, 150, 70) }, // Green
|
||||||
|
{ eCF_Ice, CColor::Integral(200, 255, 255) }, // Light blue
|
||||||
|
{ eCF_MetalGrating, CColor::Integral(170, 170, 170) }, // Gray
|
||||||
|
{ eCF_Phazon, CColor::Integral( 0, 128, 255) }, // Blue
|
||||||
|
{ eCF_Dirt, CColor::Integral(150, 130, 120) }, // Brownish-gray
|
||||||
|
{ eCF_Lava, CColor::Integral(200, 30, 30) }, // Red
|
||||||
|
{ eCF_Snow, CColor::Integral(230, 255, 255) }, // *Very* light blue
|
||||||
|
{ eCF_Glass, CColor::Integral( 20, 255, 190) }, // Greenish blue
|
||||||
|
{ eCF_Shield, CColor::Integral(230, 250, 60) }, // Yellow
|
||||||
|
{ eCF_Sand, CColor::Integral(230, 200, 170) }, // Light brown
|
||||||
|
{ eCF_Wood, CColor::Integral(190, 140, 105) }, // Brown
|
||||||
|
{ eCF_Organic, CColor::Integral(130, 130, 250) } // Purple
|
||||||
|
};
|
||||||
|
CColor CCollisionMaterial::SurfaceColor(EGame Game) const
|
||||||
|
{
|
||||||
|
ECollisionFlag SurfType = SurfaceType(Game);
|
||||||
|
auto FindColor = gkTypeToColor.find(SurfType);
|
||||||
|
return (FindColor == gkTypeToColor.end() ? CColor::skWhite : FindColor->second);
|
||||||
|
}
|
|
@ -0,0 +1,64 @@
|
||||||
|
#ifndef CCOLLISIONMATERIAL
|
||||||
|
#define CCOLLISIONMATERIAL
|
||||||
|
|
||||||
|
#include "EGame.h"
|
||||||
|
#include <Common/CColor.h>
|
||||||
|
#include <Common/Flags.h>
|
||||||
|
|
||||||
|
// Game-neutral collision property flags.
|
||||||
|
// IMPORTANT: This is an incomplete list. Keep in mind that MP2, MP3, and DKCR store
|
||||||
|
// collision materials via a 64-bit flag where every bit is used, and some flags differ
|
||||||
|
// between games. Therefore a single enum doesn't have the resolution to represent EVERY
|
||||||
|
// flag from EVERY game. In the future, the storage medium needs to be changed to a struct,
|
||||||
|
// OR we need to be okay with excluding certain flags (which we probably are, because a
|
||||||
|
// lot of them aren't meant to be used by collision geometry, such as the "Player" flag).
|
||||||
|
enum ECollisionFlag
|
||||||
|
{
|
||||||
|
eCF_Unknown = 0x00000001,
|
||||||
|
eCF_Stone = 0x00000002,
|
||||||
|
eCF_Metal = 0x00000004,
|
||||||
|
eCF_Grass = 0x00000008,
|
||||||
|
eCF_Ice = 0x00000010,
|
||||||
|
eCF_MetalGrating = 0x00000020,
|
||||||
|
eCF_Phazon = 0x00000040,
|
||||||
|
eCF_Dirt = 0x00000080,
|
||||||
|
eCF_Lava = 0x00000100,
|
||||||
|
eCF_AltMetal = 0x00000200,
|
||||||
|
eCF_Snow = 0x00000400,
|
||||||
|
eCF_Fabric = 0x00000800,
|
||||||
|
eCF_SlowMud = 0x00001000,
|
||||||
|
eCF_Mud = 0x00002000,
|
||||||
|
eCF_Glass = 0x00004000,
|
||||||
|
eCF_Shield = 0x00008000,
|
||||||
|
eCF_Sand = 0x00010000,
|
||||||
|
eCF_MothSeedOrganics = 0x00020000,
|
||||||
|
eCF_Web = 0x00040000,
|
||||||
|
eCF_Wood = 0x00080000,
|
||||||
|
eCF_Organic = 0x00100000,
|
||||||
|
eCF_Rubber = 0x00200000,
|
||||||
|
eCF_ShootThru = 0x00400000,
|
||||||
|
eCF_CameraThru = 0x00800000,
|
||||||
|
eCF_ScanThru = 0x01000000,
|
||||||
|
eCF_AiWalkThru = 0x02000000,
|
||||||
|
eCF_FlippedTri = 0x04000000,
|
||||||
|
eCF_Floor = 0x08000000,
|
||||||
|
eCF_AiBlock = 0x10000000,
|
||||||
|
eCF_JumpNotAllowed = 0x20000000,
|
||||||
|
eCF_SpiderBall = 0x40000000,
|
||||||
|
eCF_WallJump = 0x80000000
|
||||||
|
};
|
||||||
|
|
||||||
|
class CCollisionMaterial : public TFlags<ECollisionFlag>
|
||||||
|
{
|
||||||
|
friend class CCollisionLoader;
|
||||||
|
u64 mRawFlags;
|
||||||
|
|
||||||
|
public:
|
||||||
|
ECollisionFlag SurfaceType(EGame Game) const;
|
||||||
|
CColor SurfaceColor(EGame Game) const;
|
||||||
|
|
||||||
|
inline u64 RawFlags() const { return mRawFlags; }
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // CCOLLISIONMATERIAL
|
||||||
|
|
|
@ -73,7 +73,7 @@ void CCollisionMesh::BufferGL()
|
||||||
Verts[2] = pLineB->Vertices[1];
|
Verts[2] = pLineB->Vertices[1];
|
||||||
|
|
||||||
// Some faces have a property that indicates they need to be inverted
|
// Some faces have a property that indicates they need to be inverted
|
||||||
if (GetMaterial(pFace->MaterialIdx).FlippedTri)
|
if (GetMaterial(pFace->MaterialIdx) & eCF_FlippedTri)
|
||||||
{
|
{
|
||||||
u16 V0 = Verts[0];
|
u16 V0 = Verts[0];
|
||||||
Verts[0] = Verts[2];
|
Verts[0] = Verts[2];
|
||||||
|
|
|
@ -1,22 +1,12 @@
|
||||||
#ifndef CCOLLISIONMESH_H
|
#ifndef CCOLLISIONMESH_H
|
||||||
#define CCOLLISIONMESH_H
|
#define CCOLLISIONMESH_H
|
||||||
|
|
||||||
|
#include "CCollisionMaterial.h"
|
||||||
#include "CResource.h"
|
#include "CResource.h"
|
||||||
#include "Core/OpenGL/CVertexBuffer.h"
|
#include "Core/OpenGL/CVertexBuffer.h"
|
||||||
#include "Core/OpenGL/CIndexBuffer.h"
|
#include "Core/OpenGL/CIndexBuffer.h"
|
||||||
#include <Math/CAABox.h>
|
#include <Math/CAABox.h>
|
||||||
|
|
||||||
struct SCollisionMaterial
|
|
||||||
{
|
|
||||||
// todo: figure out what the other properties are
|
|
||||||
u64 RawFlags;
|
|
||||||
bool AiWalkThru;
|
|
||||||
bool FlippedTri;
|
|
||||||
bool ShootThru;
|
|
||||||
bool CameraThru;
|
|
||||||
bool Solid;
|
|
||||||
};
|
|
||||||
|
|
||||||
class CCollisionMesh
|
class CCollisionMesh
|
||||||
{
|
{
|
||||||
friend class CCollisionLoader;
|
friend class CCollisionLoader;
|
||||||
|
@ -71,7 +61,7 @@ class CCollisionMesh
|
||||||
|
|
||||||
CAABox mAABox;
|
CAABox mAABox;
|
||||||
CCollisionOctree *mpOctree;
|
CCollisionOctree *mpOctree;
|
||||||
std::vector<SCollisionMaterial> mMaterials;
|
std::vector<CCollisionMaterial> mMaterials;
|
||||||
std::vector<CCollisionVertex> mCollisionVertices;
|
std::vector<CCollisionVertex> mCollisionVertices;
|
||||||
std::vector<CCollisionLine> mCollisionLines;
|
std::vector<CCollisionLine> mCollisionLines;
|
||||||
std::vector<CCollisionFace> mCollisionFaces;
|
std::vector<CCollisionFace> mCollisionFaces;
|
||||||
|
@ -92,7 +82,8 @@ public:
|
||||||
void DrawWireframe();
|
void DrawWireframe();
|
||||||
|
|
||||||
inline u32 NumMaterials() const { return mMaterials.size(); }
|
inline u32 NumMaterials() const { return mMaterials.size(); }
|
||||||
inline SCollisionMaterial& GetMaterial(u32 Index) { return mMaterials[Index]; }
|
inline CCollisionMaterial& GetMaterial(u32 Index) { return mMaterials[Index]; }
|
||||||
|
inline const CAABox& BoundingBox() const { return mAABox; }
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // CCOLLISIONMESH_H
|
#endif // CCOLLISIONMESH_H
|
||||||
|
|
|
@ -38,24 +38,74 @@ void CCollisionLoader::ParseOBBNode(IInputStream& rDCLN)
|
||||||
|
|
||||||
void CCollisionLoader::ReadPropertyFlags(IInputStream& rSrc)
|
void CCollisionLoader::ReadPropertyFlags(IInputStream& rSrc)
|
||||||
{
|
{
|
||||||
SCollisionMaterial Material;
|
CCollisionMaterial Material;
|
||||||
|
u64 RawFlags = (mVersion <= ePrime ? rSrc.ReadLong() : rSrc.ReadLongLong());
|
||||||
|
Material.mRawFlags = RawFlags;
|
||||||
|
|
||||||
if (mVersion == ePrime)
|
if (mVersion <= ePrime)
|
||||||
{
|
{
|
||||||
Material.RawFlags = rSrc.ReadLong();
|
if (RawFlags & 0x00000001) Material |= eCF_Unknown;
|
||||||
Material.FlippedTri = (Material.RawFlags >> 25) & 0x1;
|
if (RawFlags & 0x00000002) Material |= eCF_Stone;
|
||||||
|
if (RawFlags & 0x00000004) Material |= eCF_Metal;
|
||||||
|
if (RawFlags & 0x00000008) Material |= eCF_Grass;
|
||||||
|
if (RawFlags & 0x00000010) Material |= eCF_Ice;
|
||||||
|
if (RawFlags & 0x00000040) Material |= eCF_MetalGrating;
|
||||||
|
if (RawFlags & 0x00000080) Material |= eCF_Phazon;
|
||||||
|
if (RawFlags & 0x00000100) Material |= eCF_Dirt;
|
||||||
|
if (RawFlags & 0x00000200) Material |= eCF_Lava;
|
||||||
|
if (RawFlags & 0x00000800) Material |= eCF_Snow;
|
||||||
|
if (RawFlags & 0x00001000) Material |= eCF_SlowMud;
|
||||||
|
if (RawFlags & 0x00004000) Material |= eCF_Mud;
|
||||||
|
if (RawFlags & 0x00008000) Material |= eCF_Glass;
|
||||||
|
if (RawFlags & 0x00010000) Material |= eCF_Shield;
|
||||||
|
if (RawFlags & 0x00020000) Material |= eCF_Sand;
|
||||||
|
if (RawFlags & 0x00040000) Material |= eCF_ShootThru;
|
||||||
|
if (RawFlags & 0x00200000) Material |= eCF_CameraThru;
|
||||||
|
if (RawFlags & 0x00400000) Material |= eCF_Wood;
|
||||||
|
if (RawFlags & 0x00800000) Material |= eCF_Organic;
|
||||||
|
if (RawFlags & 0x02000000) Material |= eCF_FlippedTri;
|
||||||
|
if (RawFlags & 0x08000000) Material |= eCF_ScanThru;
|
||||||
|
if (RawFlags & 0x10000000) Material |= eCF_AiWalkThru;
|
||||||
|
if (RawFlags & 0x80000000) Material |= eCF_Floor;
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (mVersion == eEchoes)
|
else if (mVersion <= eCorruption)
|
||||||
{
|
{
|
||||||
Material.RawFlags = rSrc.ReadLongLong();
|
if (RawFlags & 0x00000001) Material |= eCF_Unknown;
|
||||||
Material.FlippedTri = (Material.RawFlags >> 24) & 0x1;
|
if (RawFlags & 0x00000002) Material |= eCF_Stone;
|
||||||
|
if (RawFlags & 0x00000004) Material |= eCF_Metal;
|
||||||
|
if (RawFlags & 0x00000008) Material |= eCF_Grass;
|
||||||
|
if (RawFlags & 0x00000010) Material |= eCF_Ice;
|
||||||
|
if (RawFlags & 0x00000040) Material |= eCF_MetalGrating;
|
||||||
|
if (RawFlags & 0x00000080) Material |= eCF_Phazon;
|
||||||
|
if (RawFlags & 0x00000100) Material |= eCF_Dirt;
|
||||||
|
if (RawFlags & 0x00000200) Material |= eCF_AltMetal;
|
||||||
|
if (RawFlags & 0x00000400) Material |= eCF_Glass;
|
||||||
|
if (RawFlags & 0x00000800) Material |= eCF_Snow;
|
||||||
|
if (RawFlags & 0x00001000) Material |= eCF_Fabric;
|
||||||
|
if (RawFlags & 0x00010000) Material |= eCF_Shield;
|
||||||
|
if (RawFlags & 0x00020000) Material |= eCF_Sand;
|
||||||
|
if (RawFlags & 0x00040000) Material |= eCF_MothSeedOrganics;
|
||||||
|
if (RawFlags & 0x00080000) Material |= eCF_Web;
|
||||||
|
if (RawFlags & 0x00100000) Material |= eCF_ShootThru;
|
||||||
|
if (RawFlags & 0x00200000) Material |= eCF_CameraThru;
|
||||||
|
if (RawFlags & 0x00400000) Material |= eCF_Wood;
|
||||||
|
if (RawFlags & 0x00800000) Material |= eCF_Organic;
|
||||||
|
if (RawFlags & 0x01000000) Material |= eCF_FlippedTri;
|
||||||
|
if (RawFlags & 0x02000000) Material |= eCF_Rubber;
|
||||||
|
if (RawFlags & 0x08000000) Material |= eCF_ScanThru;
|
||||||
|
if (RawFlags & 0x10000000) Material |= eCF_AiWalkThru;
|
||||||
|
if (RawFlags & 0x80000000) Material |= eCF_Floor;
|
||||||
|
|
||||||
|
if (RawFlags & 0x0001000000000000) Material |= eCF_AiBlock;
|
||||||
|
if (RawFlags & 0x0400000000000000) Material |= eCF_JumpNotAllowed;
|
||||||
|
if (RawFlags & 0x2000000000000000) Material |= eCF_SpiderBall;
|
||||||
|
if (RawFlags & 0x4000000000000000) Material |= eCF_WallJump;
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (mVersion == eReturns)
|
else if (mVersion == eReturns)
|
||||||
{
|
{
|
||||||
Material.RawFlags = rSrc.ReadLongLong();
|
if (RawFlags & 0x10000000) Material |= eCF_FlippedTri;
|
||||||
Material.FlippedTri = (Material.RawFlags >> 28) & 0x1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
mpMesh->mMaterials.push_back(Material);
|
mpMesh->mMaterials.push_back(Material);
|
||||||
|
|
|
@ -160,6 +160,7 @@ CResource* CScriptTemplate::FindDisplayAsset(CPropertyStruct *pProperties, u32&
|
||||||
|
|
||||||
for (auto it = mAssets.begin(); it != mAssets.end(); it++)
|
for (auto it = mAssets.begin(); it != mAssets.end(); it++)
|
||||||
{
|
{
|
||||||
|
if (it->AssetType == SEditorAsset::eCollision) continue;
|
||||||
CResource *pRes = nullptr;
|
CResource *pRes = nullptr;
|
||||||
|
|
||||||
// File
|
// File
|
||||||
|
|
|
@ -37,6 +37,13 @@ void CCollisionNode::Draw(FRenderOptions /*Options*/, int /*ComponentIndex*/, ER
|
||||||
glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
|
glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
|
||||||
glDepthMask(GL_TRUE);
|
glDepthMask(GL_TRUE);
|
||||||
|
|
||||||
|
// Turn off backface culling
|
||||||
|
EGame CollisionGame = mpCollision->Game();
|
||||||
|
bool ForceDisableBackfaceCull = (rkViewInfo.CollisionSettings.DrawBackfaces || CollisionGame == eReturns) && glIsEnabled(GL_CULL_FACE);
|
||||||
|
|
||||||
|
if (ForceDisableBackfaceCull)
|
||||||
|
glDisable(GL_CULL_FACE);
|
||||||
|
|
||||||
CColor BaseTint = TintColor(rkViewInfo);
|
CColor BaseTint = TintColor(rkViewInfo);
|
||||||
|
|
||||||
for (u32 iMesh = 0; iMesh < mpCollision->NumMeshes(); iMesh++)
|
for (u32 iMesh = 0; iMesh < mpCollision->NumMeshes(); iMesh++)
|
||||||
|
@ -45,63 +52,22 @@ void CCollisionNode::Draw(FRenderOptions /*Options*/, int /*ComponentIndex*/, ER
|
||||||
|
|
||||||
for (u32 iMat = 0; iMat < pMesh->NumMaterials(); iMat++)
|
for (u32 iMat = 0; iMat < pMesh->NumMaterials(); iMat++)
|
||||||
{
|
{
|
||||||
SCollisionMaterial& rMat = pMesh->GetMaterial(iMat);
|
CCollisionMaterial& rMat = pMesh->GetMaterial(iMat);
|
||||||
|
|
||||||
if (rkViewInfo.CollisionSettings.HideMask != 0 && (rMat.RawFlags & rkViewInfo.CollisionSettings.HideMask) == rkViewInfo.CollisionSettings.HideMask)
|
if (rkViewInfo.CollisionSettings.HideMask != 0 && (rMat.RawFlags() & rkViewInfo.CollisionSettings.HideMask) == rkViewInfo.CollisionSettings.HideMask)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
CColor Tint = BaseTint;
|
CColor Tint = BaseTint;
|
||||||
|
|
||||||
if (rkViewInfo.CollisionSettings.HighlightMask != 0 && (rMat.RawFlags & rkViewInfo.CollisionSettings.HighlightMask) == rkViewInfo.CollisionSettings.HighlightMask)
|
if (rkViewInfo.CollisionSettings.HighlightMask != 0 && (rMat.RawFlags() & rkViewInfo.CollisionSettings.HighlightMask) == rkViewInfo.CollisionSettings.HighlightMask)
|
||||||
Tint *= CColor::skRed;
|
Tint *= CColor::skRed;
|
||||||
|
|
||||||
else if (mpCollision->Game() <= ePrime && rkViewInfo.CollisionSettings.DrawMode == eCDM_TintSurfaceType)
|
else if (CollisionGame != eReturns && rkViewInfo.CollisionSettings.TintWithSurfaceColor)
|
||||||
{
|
Tint *= rMat.SurfaceColor(CollisionGame);
|
||||||
// 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);
|
bool IsFloor = (rkViewInfo.CollisionSettings.TintUnwalkableTris ? rMat.HasFlag(eCF_Floor) : true);
|
||||||
|
bool IsUnstandable = (rkViewInfo.CollisionSettings.TintUnwalkableTris ? rMat.HasFlag(eCF_JumpNotAllowed) : false);
|
||||||
|
CDrawUtil::UseCollisionShader(IsFloor, IsUnstandable, Tint);
|
||||||
pMesh->DrawMaterial(iMat);
|
pMesh->DrawMaterial(iMat);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -111,6 +77,16 @@ void CCollisionNode::Draw(FRenderOptions /*Options*/, int /*ComponentIndex*/, ER
|
||||||
CDrawUtil::UseColorShader(CColor::skTransparentBlack);
|
CDrawUtil::UseColorShader(CColor::skTransparentBlack);
|
||||||
mpCollision->DrawWireframe();
|
mpCollision->DrawWireframe();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Restore backface culling setting
|
||||||
|
if (ForceDisableBackfaceCull)
|
||||||
|
glEnable(GL_CULL_FACE);
|
||||||
|
|
||||||
|
// Draw collision bounds for area collision
|
||||||
|
// note: right now checking parent is the best way to check whether this node is area collision instead of actor collision
|
||||||
|
// actor collision will have a script node parent whereas area collision will have a root node parent
|
||||||
|
if (rkViewInfo.CollisionSettings.DrawAreaCollisionBounds && Parent()->NodeType() == eRootNode)
|
||||||
|
CDrawUtil::DrawWireCube( mpCollision->MeshByIndex(0)->BoundingBox(), CColor::skRed );
|
||||||
}
|
}
|
||||||
|
|
||||||
SRayIntersection CCollisionNode::RayNodeIntersectTest(const CRay& /*rkRay*/, u32 /*AssetID*/, const SViewInfo& /*rkViewInfo*/)
|
SRayIntersection CCollisionNode::RayNodeIntersectTest(const CRay& /*rkRay*/, u32 /*AssetID*/, const SViewInfo& /*rkViewInfo*/)
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLabel" name="AboutLabel">
|
<widget class="QLabel" name="AboutLabel">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string><html><head/><body><p><span style=" font-size:12pt; font-weight:600;">%APP_FULL_NAME%</span></p><p>%APP_NAME% is developed by <span style=" font-weight:600;">Parax</span>.<br/>All the games it edits are developed by <span style=" font-weight:600;">Retro Studios</span> and published by <span style=" font-weight:600;">Nintendo</span>.</p><p>Special thanks to:</p><p><ul><li> The community at <span style=" font-weight:600;">Metroid2002</span> that contributed to reverse engineering the game and documenting its internals and file formats; in particular, <span style=" font-weight:600;">Antidote</span> and <span style=" font-weight:600;">jackoalan</span>, among others!</li><li> <span style=" font-weight:600;">Miles: </span>In addition to helping reverse engineer a few formats (in particular MLVL and MREA), also contributed greatly to putting together the script object templates and documenting object properties.</li><li> <span style=" font-weight:600;">Bearborg:</span> Lots of testing and feedback, plus the UI icons and some script object assets.</li><li> <span style=" font-weight:600;">Omega: </span>Script object assets.</li></ul>Check the <a href="http://www.metroid2002.com/retromodding/wiki/Retro_Modding_Wiki">Retro Modding Wiki</a> for file format documentation.</p><p>%APP_NAME% uses <span style=" font-weight:600;">Assimp</span> (Open Asset Import Library).<br/>Copyright © 2006-2015 assimp team<br/>All rights reserved.</p></body></html></string>
|
<string><html><head/><body><p><span style=" font-size:12pt; font-weight:600;">%APP_FULL_NAME%</span></p><p>%APP_NAME% is developed by <span style=" font-weight:600;">Aruki</span>.<br/>All the games it edits are developed by <span style=" font-weight:600;">Retro Studios</span> and published by <span style=" font-weight:600;">Nintendo</span>.</p><p>Special thanks to:</p><p><ul><li> The community at <span style=" font-weight:600;">Metroid2002</span> that contributed to reverse engineering the game and documenting its internals and file formats; in particular, <span style=" font-weight:600;">Antidote</span> and <span style=" font-weight:600;">jackoalan</span>, among others!</li><li> <span style=" font-weight:600;">Claris: </span>In addition to helping reverse engineer a few formats (in particular MLVL and MREA), also contributed greatly to putting together the script object templates and documenting object properties.</li><li> <span style=" font-weight:600;">Bearborg:</span> Lots of testing and feedback, plus the UI icons and some script object assets.</li><li> <span style=" font-weight:600;">Omega: </span>Script object assets.</li></ul>Check the <a href="http://www.metroid2002.com/retromodding/wiki/Retro_Modding_Wiki">Retro Modding Wiki</a> for file format documentation.</p><p>%APP_NAME% uses <span style=" font-weight:600;">Assimp</span> (Open Asset Import Library).<br/>Copyright © 2006-2015 assimp team<br/>All rights reserved.</p></body></html></string>
|
||||||
</property>
|
</property>
|
||||||
<property name="wordWrap">
|
<property name="wordWrap">
|
||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
|
|
Loading…
Reference in New Issue