Collision flags and SFX type handling

This commit is contained in:
Phillip Stephens 2016-12-25 23:58:44 -08:00
parent bc89518c9d
commit 7b79e52740
13 changed files with 134 additions and 26 deletions

View File

@ -7,11 +7,17 @@ namespace DNAMP1
void DeafBabe::BlenderInit(hecl::BlenderConnection::PyOutStream& os)
{
os << "TYPE_COLORS = {'Ground':(1.0, 0.43, 0.15),\n"
os << "TYPE_COLORS = {'NoSFX':(0.0, 0.0, 0.0),\n"
" 'Ground':(1.0, 0.43, 0.15),\n"
" 'Wood':(0.305, 0.159, 0.033),\n"
" 'Stone':(0.28, 0.28, 0.28),\n"
" 'Hard Stone':(0.1, 0.1, 0.1),\n"
" 'Ice':(0.0, 0.1, 0.1),\n"
" 'Metal':(0.5, 0.5, 0.5),\n"
" 'Leaves':(0.61, 0.03, 0.05)}\n"
" 'Grass':(0.0, 0.42, 0.01),"
" 'Lava':(0.8, 0.15, 0.0),"
" 'Mud':(0.119, 0.056, 0.023),"
" 'Goo':(0.026, 0.467, 0.186),"
" 'Sand':(0.539, 0.445, 0.216)}\n"
"\n"
"# Diffuse Color Maker\n"
"def make_color(index, mat_type, name):\n"
@ -24,28 +30,88 @@ void DeafBabe::BlenderInit(hecl::BlenderConnection::PyOutStream& os)
"\n"
"bpy.types.Material.retro_collision_type = bpy.props.IntProperty(name='Retro: Collsion Type')\n"
"bpy.types.Material.retro_projectile_passthrough = bpy.props.BoolProperty(name='Retro: Projectile Passthrough')\n"
"bpy.types.Material.retro_ai_passthrough = bpy.props.BoolProperty(name='Retro: AI Passthrough')\n"
"bpy.types.Material.retro_camera_passthrough = bpy.props.BoolProperty(name='Retro: Camera Passthrough')\n"
"bpy.types.Material.retro_half_pipe = bpy.props.BoolProperty(name='Retro: Half Pipe')\n"
"bpy.types.Material.retro_solid = bpy.props.BoolProperty(name='Retro: Solid')\n"
"bpy.types.Material.retro_scan_passthrough = bpy.props.BoolProperty(name='Retro: Scan Passthrough')\n"
"bpy.types.Material.retro_no_walk = bpy.props.BoolProperty(name='Retro: No Walk')\n"
"\n"
"material_dict = {}\n"
"material_index = []\n"
"def get_type_id(data):\n"
"\n"
" ret = 0\n"
" for i in range(1, 24):\n"
" if i == 5 or i == 13 or i in range(18, 22):\n"
" continue\n"
" if ((data >> i) & 1):\n"
" ret = i\n"
" return ret\n"
"\n"
"def select_material(data):\n"
"\n"
" type_id = data & 0xff\n"
" type_id = get_type_id(data)\n"
" mat_type = str(type_id)\n"
" if type_id == 1:\n"
" if type_id == 0:\n"
" mat_type = 'NoSFX'\n"
" if type_id == 1 or type_id == 14 or type_id == 22 or type_id == 23:\n"
" mat_type = 'Ground'\n"
" elif type_id == 3:\n"
" mat_type = 'Stone'\n"
" elif type_id == 4:\n"
" mat_type = 'Hard Stone'\n"
" elif type_id == 5:\n"
" elif type_id == 2 or type_id == 6:\n"
" mat_type = 'Metal'\n"
" elif type_id == 9:\n"
" mat_type = 'Leaves'\n"
" elif type_id == 3 or type_id == 8:\n"
" mat_type = 'Grass'\n"
" elif type_id == 4 or type_id == 11:\n"
" mat_type = 'Ice'\n"
" elif type_id == 12:\n"
" mat_type = 'Mud'\n"
" elif type_id == 7:\n"
" mat_type = 'Wood'\n"
" elif type_id == 9 or type_id == 10:\n"
" mat_type = 'Lava'\n"
" elif type_id == 15 or type_id == 16:\n"
" mat_type = 'Goo'\n"
" elif type_id == 17:\n"
" mat_type = 'Sand'\n"
"\n"
" mat_flags = ''\n"
" if ((data >> 0) & 1):\n"
" mat_flags += 'u0'\n"
" if ((data >> 5) & 1):\n"
" mat_flags += 'u5'\n"
" if ((data >> 13) & 1):\n"
" mat_flags += 'H'\n"
" if ((data >> 18) & 1):\n"
" mat_name = mat_type + ' Fire Through'\n"
" else:\n"
" mat_name = mat_type\n"
" mat_flags += 'P'\n"
" if ((data >> 19) & 1):\n"
" mat_flags += 'K'\n"
" if ((data >> 20) & 1):\n"
" mat_flags += 'u20'\n"
" if ((data >> 21) & 1):\n"
" mat_flags += 'C'\n"
" if ((data >> 22) & 1):\n"
" mat_flags += 'u22'\n"
" if ((data >> 23)& 1):\n"
" mat_flags += 'u23'\n"
" if ((data >> 24) & 1):\n"
" mat_flags += 'A'\n"
" if ((data >> 26) & 1):\n"
" mat_flags += 'u26'\n"
" if ((data >> 27) & 1):\n"
" mat_flags += 'S'\n"
" if ((data >> 28) & 1):\n"
" mat_flags += 'u28'\n"
" if ((data >> 29) & 1):\n"
" mat_flags += 'u29'\n"
" if ((data >> 30) & 1):\n"
" mat_flags += 'N'\n"
" if ((data >> 31) & 1):\n"
" mat_flags += 'u31'\n"
"\n"
" if len(mat_flags) > 0:\n"
" mat_flags = ' ' + mat_flags\n"
"\n"
" mat_name = mat_type + mat_flags\n"
"\n"
" if mat_name in material_index:\n"
" return material_index.index(mat_name)\n"
@ -55,7 +121,13 @@ void DeafBabe::BlenderInit(hecl::BlenderConnection::PyOutStream& os)
" else:\n"
" mat = make_color(len(material_dict), mat_type, mat_name)\n"
" mat.retro_collision_type = type_id\n"
" mat.retro_half_pipe = ((data >> 13) & 1)\n"
" mat.retro_projectile_passthrough = ((data >> 18) & 1)\n"
" mat.retro_solid = ((data >> 19) & 1)\n"
" mat.retro_camera_passthrough = ((data >> 21) & 1)\n"
" mat.retro_ai_passthrough = ((data >> 24) & 1)\n"
" mat.retro_scan_passthrough = ((data >> 27) & 1)\n"
" mat.retro_no_walk = ((data >> 30) & 1)\n"
" material_dict[mat_name] = mat\n"
" material_index.append(mat_name)\n"
" return len(material_index)-1\n"

View File

@ -63,6 +63,7 @@ bool MLVL::Cook(const hecl::ProjectPath& outPath, const hecl::ProjectPath& inPat
SAVW savw = {};
savw.header.magic = 0xC001D00D;
savw.header.version = 0x3;
std::unordered_set<UniqueID32> addedScans;
size_t areaIdx = 0;
size_t nameOffset = 0;
@ -256,7 +257,6 @@ bool MLVL::Cook(const hecl::ProjectPath& outPath, const hecl::ProjectPath& inPat
}
/* Cull duplicate scans and add to list */
std::unordered_set<UniqueID32> addedScans;
for (const Scan& scan : scans)
{
if (!scan.scanId)

View File

@ -13,9 +13,6 @@ class CPersistentOptions
bool x0_[98] = {};
bool x68_[64] = {};
std::vector<std::pair<ResId, TEditorId>> xac_cinematicStates; /* (MLVL, Cinematic) */
u32 xb0_ = 0;
u32 xb4_ = 0;
u32 xb8_ = 0;
u32 xbc_ = 0;
u32 xc0_ = 0;
u32 xc4_ = 0;

View File

@ -72,6 +72,7 @@ class CGameState
friend class CStateManager;
bool x0_[128] = {};
u32 x80_;
ResId x84_mlvlId = -1;
std::vector<CWorldState> x88_worldStates;
std::shared_ptr<CPlayerState> x98_playerState;

View File

@ -9,4 +9,24 @@ CCollisionSurface::CCollisionSurface(const zeus::CVector3f& a, const zeus::CVect
x24_flags(flags)
{
}
zeus::CVector3f CCollisionSurface::GetNormal() const
{
zeus::CVector3f v1 = ((xc_b - x0_a) * ((x18_c - x0_a) * (xc_b - x0_a))) - (x18_c - x0_a);
return zeus::CUnitVector3f({v1.y, v1.z, v1.x}, true);
}
zeus::CVector3f CCollisionSurface::GetVert(s32 idx) const
{
if (idx < 0 || idx > 3)
return zeus::CVector3f::skZero;
return (&x0_a)[idx];
}
zeus::CPlane CCollisionSurface::GetPlane() const
{
zeus::CVector3f norm = GetNormal();
return {norm, norm.dot(x0_a)};
}
}

View File

@ -15,7 +15,11 @@ class CCollisionSurface
public:
CCollisionSurface(const zeus::CVector3f&, const zeus::CVector3f&, const zeus::CVector3f&, u32);
zeus::CVector3f GetPoint(u32) const;
zeus::CVector3f GetNormal() const;
zeus::CVector3f GetVert(s32) const;
zeus::CVector3f GetPoint(s32) const;
zeus::CPlane GetPlane() const;
u32 GetSurfaceFlags() const;
};
}

View File

@ -100,7 +100,7 @@ public:
x0_list &= ~(other.x0_list);
}
bool HasMaterial(EMaterialTypes type)
bool HasMaterial(EMaterialTypes type) const
{
return (x0_list & (1ull << u64(type))) != 0;
}

View File

@ -7,6 +7,9 @@ namespace urde
struct CGuiWidgetDrawParms
{
float x0_alphaMod;
float x4_;
float x8_;
float xc_;
};
}

View File

@ -195,6 +195,7 @@ public:
bool GetCardFreeBytes();
void HandleCardError(CMemoryCardSys::ECardResult result, EState state);
void Update();
void ClearError() { x14_error = EError::OK; }
static bool IsCardBusy(EState v)
{

View File

@ -5,6 +5,7 @@
#include "GuiSys/CGuiFrame.hpp"
#include "GuiSys/CGuiTableGroup.hpp"
#include "GuiSys/CGuiTextPane.hpp"
#include "GuiSys/CGuiWidgetDrawParms.hpp"
namespace urde
{
@ -190,12 +191,12 @@ CSaveUI::UIType CSaveUI::SelectUIType() const
void CSaveUI::FinishedLoading()
{
}
void CSaveUI::Draw() const
{
//if (x50_loadedFrame)
//x50_loadedFrame->Draw(CGuiWidgetDrawParams::Default());
}
void CSaveUI::DoAdvance(CGuiTableGroup* caller)

View File

@ -130,7 +130,16 @@ void CPlayer::UpdateFootstepBounds(const CFinalInput& input, CStateManager&, flo
u16 CPlayer::GetMaterialSoundUnderPlayer(CStateManager& mgr, const u16*, int, u16) { return 0; }
u16 CPlayer::SfxIdFromMaterial(const CMaterialList&, const u16*, u16) { return 0; }
u16 CPlayer::SfxIdFromMaterial(const CMaterialList& mat, const u16* idList, u32 tableLen, u16 defId)
{
u16 id = defId;
for (u32 i = 0 ; i < tableLen; ++i)
{
if (mat.HasMaterial(EMaterialTypes(i)) && idList[i] != 0xFFFF)
id = idList[i];
}
return id;
}
void CPlayer::UpdateCrosshairsState(const CFinalInput&) {}

View File

@ -229,7 +229,7 @@ public:
void SetVisorSteam(float, float, float, u32, bool);
void UpdateFootstepBounds(const CFinalInput& input, CStateManager&, float);
u16 GetMaterialSoundUnderPlayer(CStateManager& mgr, const u16*, int, u16);
u16 SfxIdFromMaterial(const CMaterialList&, const u16*, u16);
u16 SfxIdFromMaterial(const CMaterialList&, const u16*, u32, u16);
void UpdateCrosshairsState(const CFinalInput&);
void UpdateVisorTransition(float, CStateManager& mgr);
void UpdateVisorState(const CFinalInput&, float, CStateManager& mgr);

2
hecl

@ -1 +1 @@
Subproject commit c0847d1dac4311702e9bcb518ad2804834411c12
Subproject commit fb7db9cfca9d2e6ba1ffee70d934a875bd89e0bd