From 5277d445d3d3afc62609918787399e4632a7174b Mon Sep 17 00:00:00 2001 From: Jack Andersen Date: Mon, 27 Feb 2017 21:31:14 -1000 Subject: [PATCH] MREA fixes, some script constructors --- DataSpec/DNAMP1/MREA.cpp | 39 ++++++++++-- DataSpec/DNAMP1/MREA.hpp | 3 + DataSpec/SpecMP1.cpp | 67 +++++++++++--------- Editor/ProjectResourceFactoryBase.cpp | 13 +++- Runtime/CStateManager.cpp | 9 ++- Runtime/Collision/CAreaOctTree.cpp | 81 ++++++++++-------------- Runtime/Collision/CAreaOctTree.hpp | 26 ++++---- Runtime/Collision/CCollisionEdge.cpp | 10 --- Runtime/Collision/CCollisionEdge.hpp | 10 ++- Runtime/World/CActorParameters.hpp | 6 +- Runtime/World/CHealthInfo.cpp | 7 ++- Runtime/World/CMakeLists.txt | 1 + Runtime/World/CScriptDebris.cpp | 32 +++++----- Runtime/World/CScriptDebris.hpp | 7 +-- Runtime/World/CScriptSteam.cpp | 14 +++++ Runtime/World/CScriptSteam.hpp | 19 ++++++ Runtime/World/ScriptLoader.cpp | 90 ++++++++++++++++++++++++++- 17 files changed, 301 insertions(+), 133 deletions(-) create mode 100644 Runtime/World/CScriptSteam.cpp create mode 100644 Runtime/World/CScriptSteam.hpp diff --git a/DataSpec/DNAMP1/MREA.cpp b/DataSpec/DNAMP1/MREA.cpp index 1aeafa69c..8f3b8a18b 100644 --- a/DataSpec/DNAMP1/MREA.cpp +++ b/DataSpec/DNAMP1/MREA.cpp @@ -1,5 +1,6 @@ #include "MREA.hpp" #include "SCLY.hpp" +#include "PATH.hpp" #include "DeafBabe.hpp" #include "../DNACommon/BabeDead.hpp" #include "zeus/Math.hpp" @@ -433,9 +434,9 @@ bool MREA::PCCook(const hecl::ProjectPath& outPath, /* VISI */ hecl::ProjectPath visiMetadataPath(areaDirPath, _S("!visi.yaml")); + bool visiGood = false; if (visiMetadataPath.isFile()) { - bool good = false; athena::io::FileReader visiReader(visiMetadataPath.getAbsolutePath()); athena::io::YAMLDocReader r; if (r.parse(&visiReader)) @@ -514,18 +515,19 @@ bool MREA::PCCook(const hecl::ProjectPath& outPath, size_t length = r.length(); secs.emplace_back(length, 0); r.readBytesToBuf(secs.back().data(), length); - good = true; + visiGood = true; } } - if (!good) - secs.emplace_back(4, 0); } + if (!visiGood) + secs.emplace_back(4, 0); /* PATH */ { + UniqueID32 pathId = inPath.ensureAuxInfo(_S("PATH")); secs.emplace_back(4, 0); athena::io::MemoryWriter w(secs.back().data(), secs.back().size()); - w.writeUint32Big(0xffffffff); /* Empty (for now) */ + pathId.write(w); } /* Assemble sizes and add padding */ @@ -550,5 +552,32 @@ bool MREA::PCCook(const hecl::ProjectPath& outPath, return true; } +bool MREA::CookPath(const hecl::ProjectPath& outPath, + const hecl::ProjectPath& inPath) +{ + PATH path = {}; + path.version = 4; + path.unkStructCount = 1; + path.unkStructs.emplace_back(); + PATH::UnknownStruct& s = path.unkStructs.back(); + s.unk1 = 1; + s.unk2[0] = {FLT_MAX, FLT_MAX, FLT_MAX}; + s.unk2[1] = {FLT_MIN, FLT_MIN, FLT_MIN}; + s.unk2[2] = {0.f, 0.f, 0.f}; + for (int i=0 ; i<8 ; ++i) + s.unk3[i] = ~0; + s.unk4 = 0; + s.unk5 = 0; + + athena::io::FileWriter w(outPath.getAbsolutePath()); + path.write(w); + int64_t rem = w.position() % 32; + if (rem) + for (int64_t i=0 ; i<32-rem ; ++i) + w.writeBytes((atInt8*)"\xff", 1); + + return true; +} + } } diff --git a/DataSpec/DNAMP1/MREA.hpp b/DataSpec/DNAMP1/MREA.hpp index f11da16ae..b2992c5f5 100644 --- a/DataSpec/DNAMP1/MREA.hpp +++ b/DataSpec/DNAMP1/MREA.hpp @@ -137,6 +137,9 @@ struct MREA const ColMesh& cMesh, const std::vector& lights, hecl::BlenderToken& btok); + + static bool CookPath(const hecl::ProjectPath& outPath, + const hecl::ProjectPath& inPath); }; } diff --git a/DataSpec/SpecMP1.cpp b/DataSpec/SpecMP1.cpp index 276808900..3739057c9 100644 --- a/DataSpec/SpecMP1.cpp +++ b/DataSpec/SpecMP1.cpp @@ -525,7 +525,11 @@ struct SpecMP1 : SpecBase } return {SBIG('ANCS'), path.hash().val32()}; case hecl::BlenderConnection::BlendType::Area: + { + if (hecl::StringUtils::EndsWith(path.getAuxInfo(), _S("PATH"))) + return {SBIG('PATH'), path.hash().val32()}; return {SBIG('MREA'), path.hash().val32()}; + } case hecl::BlenderConnection::BlendType::World: { if (path.getAuxInfo().size()) @@ -713,37 +717,44 @@ struct SpecMP1 : SpecBase void cookArea(const hecl::ProjectPath& out, const hecl::ProjectPath& in, BlendStream& ds, bool fast, hecl::BlenderToken& btok, FCookProgress progress) { - std::vector meshes = ds.getMeshList(); - std::vector meshCompiles; - meshCompiles.reserve(meshes.size()); - - std::experimental::optional colMesh; - - for (const std::string& mesh : meshes) + if (hecl::StringUtils::EndsWith(in.getAuxInfo(), _S("PATH"))) { - hecl::SystemStringView meshSys(mesh); - if (!mesh.compare("CMESH")) - { - colMesh = ds.compileColMesh(mesh); - progress(_S("Collision Mesh")); - continue; - } - meshCompiles.push_back(ds.compileMesh( - mesh, fast ? hecl::HMDLTopology::Triangles : hecl::HMDLTopology::TriStrips, -1, - [&](int surfCount) { progress(hecl::SysFormat(_S("%s %d"), meshSys.c_str(), surfCount).c_str()); })); + DNAMP1::MREA::CookPath(out, in); } - - if (!colMesh) - Log.report(logvisor::Fatal, _S("unable to find mesh named 'CMESH' in %s"), in.getAbsolutePath().c_str()); - - std::vector lights = ds.compileLights(); - - ds.close(); - - if (m_pc) - DNAMP1::MREA::PCCook(out, in, meshCompiles, *colMesh, lights, btok); else - DNAMP1::MREA::Cook(out, in, meshCompiles, *colMesh, lights); + { + std::vector meshes = ds.getMeshList(); + std::vector meshCompiles; + meshCompiles.reserve(meshes.size()); + + std::experimental::optional colMesh; + + for (const std::string& mesh : meshes) + { + hecl::SystemStringView meshSys(mesh); + if (!mesh.compare("CMESH")) + { + colMesh = ds.compileColMesh(mesh); + progress(_S("Collision Mesh")); + continue; + } + meshCompiles.push_back(ds.compileMesh( + mesh, fast ? hecl::HMDLTopology::Triangles : hecl::HMDLTopology::TriStrips, -1, + [&](int surfCount) { progress(hecl::SysFormat(_S("%s %d"), meshSys.c_str(), surfCount).c_str()); })); + } + + if (!colMesh) + Log.report(logvisor::Fatal, _S("unable to find mesh named 'CMESH' in %s"), in.getAbsolutePath().c_str()); + + std::vector lights = ds.compileLights(); + + ds.close(); + + if (m_pc) + DNAMP1::MREA::PCCook(out, in, meshCompiles, *colMesh, lights, btok); + else + DNAMP1::MREA::Cook(out, in, meshCompiles, *colMesh, lights); + } } void cookWorld(const hecl::ProjectPath& out, const hecl::ProjectPath& in, BlendStream& ds, bool fast, diff --git a/Editor/ProjectResourceFactoryBase.cpp b/Editor/ProjectResourceFactoryBase.cpp index 1aa8eb39f..909057107 100644 --- a/Editor/ProjectResourceFactoryBase.cpp +++ b/Editor/ProjectResourceFactoryBase.cpp @@ -246,6 +246,17 @@ bool ProjectResourceFactoryBase::AddFileToIndex(const hecl::ProjectPath& path, pathTag = {SBIG('AGSC'), asGlob.hash().val32()}; useGlob = true; } + else if (pathTag.type == SBIG('MREA')) + { + hecl::ProjectPath subPath = path.ensureAuxInfo(_S("PATH")); + SObjectTag pathTag = BuildTagFromPath(subPath, m_backgroundBlender); + m_tagToPath[pathTag] = subPath; + m_pathToTag[subPath.hash()] = pathTag; + WriteTag(cacheWriter, pathTag, subPath); +#if DUMP_CACHE_FILL + DumpCacheAdd(pathTag, subPath); +#endif + } /* Cache in-memory */ const hecl::ProjectPath& usePath = useGlob ? asGlob : path; @@ -889,7 +900,7 @@ const urde::SObjectTag* ProjectResourceFactoryBase::GetResourceIdByName(const ch FourCC ProjectResourceFactoryBase::GetResourceTypeById(ResId id) const { if ((id & 0xffffffff) == 0xffffffff || !id) - Log.report(logvisor::Fatal, "attempted to access null id"); + return {}; std::unique_lock lk(const_cast(this)->m_backgroundIndexMutex); SObjectTag searchTag = {FourCC(), id}; diff --git a/Runtime/CStateManager.cpp b/Runtime/CStateManager.cpp index 4cd932cdf..ef4ea40e9 100644 --- a/Runtime/CStateManager.cpp +++ b/Runtime/CStateManager.cpp @@ -68,6 +68,7 @@ CStateManager::CStateManager(const std::weak_ptr& relayTracker, x90c_loaderFuncs[int(EScriptObjectType::Platform)] = ScriptLoader::LoadPlatform; x90c_loaderFuncs[int(EScriptObjectType::Sound)] = ScriptLoader::LoadSound; x90c_loaderFuncs[int(EScriptObjectType::Generator)] = ScriptLoader::LoadGenerator; + x90c_loaderFuncs[int(EScriptObjectType::Dock)] = ScriptLoader::LoadDock; x90c_loaderFuncs[int(EScriptObjectType::Camera)] = ScriptLoader::LoadCamera; x90c_loaderFuncs[int(EScriptObjectType::CameraWaypoint)] = ScriptLoader::LoadCameraWaypoint; x90c_loaderFuncs[int(EScriptObjectType::NewIntroBoss)] = ScriptLoader::LoadNewIntroBoss; @@ -599,12 +600,18 @@ std::pair CStateManager::LoadScriptObject(TAreaId aid, ESc else error = true; - u32 leftover = length - (in.position() - startPos); + u32 readAmt = in.position() - startPos; + if (readAmt > length) + LogModule.report(logvisor::Fatal, "Script object overread"); + u32 leftover = length - readAmt; for (u32 i=0 ; iGetUniqueId()}; } diff --git a/Runtime/Collision/CAreaOctTree.cpp b/Runtime/Collision/CAreaOctTree.cpp index fae0deffc..f889ac77d 100644 --- a/Runtime/Collision/CAreaOctTree.cpp +++ b/Runtime/Collision/CAreaOctTree.cpp @@ -58,8 +58,9 @@ CAreaOctTree::Node CAreaOctTree::Node::GetChild(int idx) const } else if (type == ETreeType::Leaf) { - const zeus::CAABox* aabb = reinterpret_cast(m_ptr + offsets[idx] + 36); - return Node(aabb, *aabb, m_owner, ETreeType::Leaf); + const float* aabb = reinterpret_cast(m_ptr + offsets[idx] + 36); + zeus::CAABox aabbObj(aabb[0], aabb[1], aabb[2], aabb[3], aabb[4], aabb[5]); + return Node(aabb, aabbObj, m_owner, ETreeType::Leaf); } else { @@ -73,24 +74,24 @@ void CAreaOctTree::SwapTreeNode(u8* ptr, Node::ETreeType type) { u16* typeBits = reinterpret_cast(ptr); *typeBits = hecl::SBig(*typeBits); + u32* offsets = reinterpret_cast(ptr + 4); for (int i=0 ; i<8 ; ++i) { Node::ETreeType ctype = Node::ETreeType((*typeBits >> (2 * i)) & 0x3); - u32* offsets = reinterpret_cast(ptr + 4); offsets[i] = hecl::SBig(offsets[i]); SwapTreeNode(ptr + offsets[i] + 36, ctype); } } else if (type == Node::ETreeType::Leaf) { - zeus::CAABox* aabb = reinterpret_cast(ptr); - aabb->min[0] = hecl::SBig(aabb->min[0]); - aabb->min[1] = hecl::SBig(aabb->min[1]); - aabb->min[2] = hecl::SBig(aabb->min[2]); - aabb->max[0] = hecl::SBig(aabb->max[0]); - aabb->max[1] = hecl::SBig(aabb->max[1]); - aabb->max[2] = hecl::SBig(aabb->max[2]); + float* aabb = reinterpret_cast(ptr); + aabb[0] = hecl::SBig(aabb[0]); + aabb[1] = hecl::SBig(aabb[1]); + aabb[2] = hecl::SBig(aabb[2]); + aabb[3] = hecl::SBig(aabb[3]); + aabb[4] = hecl::SBig(aabb[4]); + aabb[5] = hecl::SBig(aabb[5]); u16* countIdxs = reinterpret_cast(ptr + 24); *countIdxs = hecl::SBig(*countIdxs); @@ -99,60 +100,43 @@ void CAreaOctTree::SwapTreeNode(u8* ptr, Node::ETreeType type) } } -CAreaOctTree::CAreaOctTree(const zeus::CAABox& aabb, Node::ETreeType treeType, const u8* buf, std::unique_ptr&& treeBuf, +CAreaOctTree::CAreaOctTree(const zeus::CAABox& aabb, Node::ETreeType treeType, const u8* buf, const u8* treeBuf, u32 matCount, const u32* materials, const u8* vertMats, const u8* edgeMats, const u8* polyMats, u32 edgeCount, const CCollisionEdge* edges, u32 polyCount, const u16* polyEdges, - u32 vertCount, const zeus::CVector3f* verts) -: x0_aabb(aabb), x18_treeType(treeType), x1c_buf(buf), x20_treeBuf(std::move(treeBuf)), - x24_matCount(matCount), x2c_vertMats(vertMats), + u32 vertCount, const float* verts) +: x0_aabb(aabb), x18_treeType(treeType), x1c_buf(buf), x20_treeBuf(treeBuf), + x24_matCount(matCount), x28_materials(materials), x2c_vertMats(vertMats), x30_edgeMats(edgeMats), x34_polyMats(polyMats), x38_edgeCount(edgeCount), - x40_polyCount(polyCount), - x48_vertCount(vertCount) + x3c_edges(edges), x40_polyCount(polyCount), x44_polyEdges(polyEdges), + x48_vertCount(vertCount), x4c_verts(verts) { - SwapTreeNode(x20_treeBuf.get(), treeType); + SwapTreeNode(const_cast(x20_treeBuf), treeType); - { - x28_materials.reserve(matCount); - athena::io::MemoryReader r(materials, matCount * 4); - for (u32 i=0 ; i(x28_materials)[i] = hecl::SBig(x28_materials[i]); - { - x3c_edges.reserve(edgeCount); - athena::io::MemoryReader r(edges, edgeCount * 4); - for (u32 i=0 ; i(x3c_edges)[i].swapBig(); - { - x44_polyEdges.reserve(polyCount); - athena::io::MemoryReader r(polyEdges, polyCount * 2); - for (u32 i=0 ; i(x44_polyEdges)[i] = hecl::SBig(x44_polyEdges[i]); - { - x4c_verts.reserve(vertCount); - athena::io::MemoryReader r(verts, vertCount * 12); - for (u32 i=0 ; i(x4c_verts)[i] = hecl::SBig(x4c_verts[i]); } -std::unique_ptr CAreaOctTree::MakeFromMemory(const void* buf, unsigned int size) +std::unique_ptr CAreaOctTree::MakeFromMemory(const u8* buf, unsigned int size) { - athena::io::MemoryReader r(buf, size); + athena::io::MemoryReader r(buf + 8, size - 8); r.readUint32Big(); r.readUint32Big(); zeus::CAABox aabb; aabb.readBoundingBoxBig(r); Node::ETreeType nodeType = Node::ETreeType(r.readUint32Big()); u32 treeSize = r.readUint32Big(); - const u8* cur = reinterpret_cast(buf) + r.position(); + const u8* cur = reinterpret_cast(buf) + 8 + r.position(); - std::unique_ptr treeBuf(new u8[treeSize]); - memmove(treeBuf.get(), cur, treeSize); + const u8* treeBuf = cur; cur += treeSize; u32 matCount = hecl::SBig(*reinterpret_cast(cur)); @@ -187,10 +171,9 @@ std::unique_ptr CAreaOctTree::MakeFromMemory(const void* buf, unsi u32 vertCount = hecl::SBig(*reinterpret_cast(cur)); cur += 4; - const zeus::CVector3f* vertBuf = reinterpret_cast(cur); - cur += polyCount * 2; + const float* vertBuf = reinterpret_cast(cur); - return std::make_unique(aabb, nodeType, reinterpret_cast(buf), std::move(treeBuf), + return std::make_unique(aabb, nodeType, reinterpret_cast(buf + 8), treeBuf, matCount, matBuf, vertMatsBuf, edgeMatsBuf, polyMatsBuf, edgeCount, edgeBuf, polyCount, polyBuf, vertCount, vertBuf); } diff --git a/Runtime/Collision/CAreaOctTree.hpp b/Runtime/Collision/CAreaOctTree.hpp index c051fd9da..7dea68816 100644 --- a/Runtime/Collision/CAreaOctTree.hpp +++ b/Runtime/Collision/CAreaOctTree.hpp @@ -95,30 +95,34 @@ public: zeus::CAABox x0_aabb; Node::ETreeType x18_treeType; const u8* x1c_buf; - std::unique_ptr x20_treeBuf; + const u8* x20_treeBuf; u32 x24_matCount; - std::vector x28_materials; + const u32* x28_materials; const u8* x2c_vertMats; const u8* x30_edgeMats; const u8* x34_polyMats; u32 x38_edgeCount; - std::vector x3c_edges; + const CCollisionEdge* x3c_edges; u32 x40_polyCount; - std::vector x44_polyEdges; + const u16* x44_polyEdges; u32 x48_vertCount; - std::vector x4c_verts; + const float* x4c_verts; void SwapTreeNode(u8* ptr, Node::ETreeType type); public: - CAreaOctTree(const zeus::CAABox& aabb, Node::ETreeType treeType, const u8* buf, std::unique_ptr&& treeBuf, + CAreaOctTree(const zeus::CAABox& aabb, Node::ETreeType treeType, const u8* buf, const u8* treeBuf, u32 matCount, const u32* materials, const u8* vertMats, const u8* edgeMats, const u8* polyMats, u32 edgeCount, const CCollisionEdge* edges, u32 polyCount, const u16* polyEdges, - u32 vertCount, const zeus::CVector3f* verts); + u32 vertCount, const float* verts); - Node GetRootNode() const { return Node(x20_treeBuf.get(), x0_aabb, *this, x18_treeType); } - const u8* GetTreeMemory() const { return x20_treeBuf.get(); } - const zeus::CVector3f& GetVert(int idx) const { return x4c_verts[idx]; } + Node GetRootNode() const { return Node(x20_treeBuf, x0_aabb, *this, x18_treeType); } + const u8* GetTreeMemory() const { return x20_treeBuf; } + zeus::CVector3f GetVert(int idx) const + { + const float* vert = &x4c_verts[idx * 3]; + return zeus::CVector3f(vert[0], vert[1], vert[2]); + } const CCollisionEdge& GetEdge(int idx) const { return x3c_edges[idx]; } u32 GetEdgeMaterial(int idx) const { return x28_materials[x30_edgeMats[idx]]; } u32 GetTriangleMaterial(int idx) const { return x28_materials[x34_polyMats[idx]]; } @@ -129,7 +133,7 @@ public: const u16* GetTriangleVertexIndices(u16 idx) const; const u16* GetTriangleEdgeIndices(u16 idx) const; - static std::unique_ptr MakeFromMemory(const void* buf, unsigned int size); + static std::unique_ptr MakeFromMemory(const u8* buf, unsigned int size); }; } diff --git a/Runtime/Collision/CCollisionEdge.cpp b/Runtime/Collision/CCollisionEdge.cpp index fa3d14521..9191dd11d 100644 --- a/Runtime/Collision/CCollisionEdge.cpp +++ b/Runtime/Collision/CCollisionEdge.cpp @@ -7,14 +7,4 @@ CCollisionEdge::CCollisionEdge(CInputStream& in) x0_index1 = in.readUint16Big(); x2_index2 = in.readUint16Big(); } - -u16 CCollisionEdge::GetVertIndex1() const -{ - return x0_index1; -} - -u16 CCollisionEdge::GetVertIndex2() const -{ - return x2_index2; -} } diff --git a/Runtime/Collision/CCollisionEdge.hpp b/Runtime/Collision/CCollisionEdge.hpp index ff5c94a97..2af14cde6 100644 --- a/Runtime/Collision/CCollisionEdge.hpp +++ b/Runtime/Collision/CCollisionEdge.hpp @@ -13,8 +13,14 @@ public: CCollisionEdge()=default; CCollisionEdge(CInputStream&); - u16 GetVertIndex1() const; - u16 GetVertIndex2() const; + u16 GetVertIndex1() const { return x0_index1; } + u16 GetVertIndex2() const { return x2_index2; } + + void swapBig() + { + x0_index1 = hecl::SBig(x0_index1); + x2_index2 = hecl::SBig(x2_index2); + } }; } diff --git a/Runtime/World/CActorParameters.hpp b/Runtime/World/CActorParameters.hpp index 300dfb919..69a5d8f24 100644 --- a/Runtime/World/CActorParameters.hpp +++ b/Runtime/World/CActorParameters.hpp @@ -20,9 +20,9 @@ class CActorParameters bool b2 : 1; bool b3 : 1; bool b4 : 1; - float x5c_; - float x60_; - float x64_; + float x5c_ = 0.f; + float x60_ = 0.f; + float x64_ = 0.f; public: CActorParameters() : b1(true), b2(false), b3(false), b4(false) {} diff --git a/Runtime/World/CHealthInfo.cpp b/Runtime/World/CHealthInfo.cpp index 33b84aaf8..7b07fbc69 100644 --- a/Runtime/World/CHealthInfo.cpp +++ b/Runtime/World/CHealthInfo.cpp @@ -4,7 +4,10 @@ namespace urde { CHealthInfo::CHealthInfo(CInputStream& in) -: x0_health(in.readFloatBig()), - x4_knockbackResistance(in.readFloatBig()) {} +{ + in.readUint32Big(); + x0_health = in.readFloatBig(); + x4_knockbackResistance = in.readFloatBig(); +} } diff --git a/Runtime/World/CMakeLists.txt b/Runtime/World/CMakeLists.txt index dd6db68da..c9ec6fec1 100644 --- a/Runtime/World/CMakeLists.txt +++ b/Runtime/World/CMakeLists.txt @@ -35,6 +35,7 @@ set(WORLD_SOURCES CScriptTimer.hpp CScriptTimer.cpp CScriptCounter.hpp CScriptCounter.cpp CScriptEffect.hpp CScriptEffect.cpp + CScriptSteam.hpp CScriptSteam.cpp CScriptPlatform.hpp CScriptPlatform.cpp CScriptSound.hpp CScriptSound.cpp CScriptGenerator.hpp CScriptGenerator.cpp diff --git a/Runtime/World/CScriptDebris.cpp b/Runtime/World/CScriptDebris.cpp index 98dbae738..36b213af4 100644 --- a/Runtime/World/CScriptDebris.cpp +++ b/Runtime/World/CScriptDebris.cpp @@ -8,28 +8,30 @@ CScriptDebris::CScriptDebris(TUniqueId uid, const std::string& name, const CEnti CModelData&& mData, const CActorParameters& aParams, ResId, const zeus::CVector3f&, float, const zeus::CVector3f&, const zeus::CColor&, float f1, float f2, float f3, CScriptDebris::EScaleType, bool, bool, bool active) - : CPhysicsActor(uid, active, name, info, xf, std::move(mData), - CMaterialList(EMaterialTypes::Solid, EMaterialTypes::Debris), - mData.GetBounds(xf.getRotation()), SMoverData(f2), aParams, 0.3, 0.1) +: CPhysicsActor(uid, active, name, info, xf, std::move(mData), + CMaterialList(EMaterialTypes::Solid, EMaterialTypes::Debris), + mData.GetBounds(xf.getRotation()), SMoverData(f2), aParams, 0.3f, 0.1f) { } +CScriptDebris::CScriptDebris(TUniqueId uid, const std::string& name, const CEntityInfo& info, const zeus::CTransform& xf, + CModelData&& mData, const CActorParameters& aParams, float, float, float, float, float, + float, float, float, float, const zeus::CColor&, const zeus::CColor&, float, + const zeus::CVector3f&, const zeus::CVector3f&, float, float, + const zeus::CVector3f&, u32, const zeus::CVector3f&, bool, bool, + CScriptDebris::EOrientationType, u32, const zeus::CVector3f&, bool, bool, + CScriptDebris::EOrientationType, u32, const zeus::CVector3f&, CScriptDebris::EOrientationType, + bool, bool, bool, bool active) +: CPhysicsActor(uid, active, name, info, xf, std::move(mData), + CMaterialList(EMaterialTypes::Solid, EMaterialTypes::Debris), + mData.GetBounds(xf.getRotation()), SMoverData(1.f), aParams, 0.3f, 0.1f) +{ +} + void CScriptDebris::Accept(IVisitor& visitor) { visitor.Visit(this); } -#if 0 -CScriptDebris::CScriptDebris(TUniqueId, const std::string&, const CEntityInfo&, const zeus::CTransform&, CModelData&&, - const CActorParameters&, float, float, float, float, float, float, float, float, float, - const zeus::CColor&, const zeus::CColor&, float, const zeus::CVector3f&, const zeus::CVector3f&, - float, float, const zeus::CVector3f&, u32, const zeus::CVector3f&, bool, bool, - CScriptDebris::EOrientationType, u32, const zeus::CVector3f&, bool, bool, - CScriptDebris::EOrientationType, u32, const zeus::CVector3f&, CScriptDebris::EOrientationType, - bool, bool, bool) -{ -} -#endif - } diff --git a/Runtime/World/CScriptDebris.hpp b/Runtime/World/CScriptDebris.hpp index c1076c7c8..ebf5b0acd 100644 --- a/Runtime/World/CScriptDebris.hpp +++ b/Runtime/World/CScriptDebris.hpp @@ -23,15 +23,14 @@ public: const CActorParameters&, ResId, const zeus::CVector3f&, float, const zeus::CVector3f&, const zeus::CColor&, float, float, float, EScaleType, bool, bool, bool); - void Accept(IVisitor& visitor); -#if 0 CScriptDebris(TUniqueId, const std::string&, const CEntityInfo&, const zeus::CTransform&, CModelData&&, const CActorParameters&, float, float, float, float, float, float, float, float, float, const zeus::CColor&, const zeus::CColor&, float, const zeus::CVector3f&, const zeus::CVector3f&, float, float, const zeus::CVector3f&, u32, const zeus::CVector3f&, bool, bool, EOrientationType, u32, const zeus::CVector3f&, bool, bool, EOrientationType, u32, const zeus::CVector3f&, EOrientationType, - bool, bool, bool); -#endif + bool, bool, bool, bool); + + void Accept(IVisitor& visitor); }; } diff --git a/Runtime/World/CScriptSteam.cpp b/Runtime/World/CScriptSteam.cpp new file mode 100644 index 000000000..255fcbe51 --- /dev/null +++ b/Runtime/World/CScriptSteam.cpp @@ -0,0 +1,14 @@ +#include "CScriptSteam.hpp" + +namespace urde +{ + +CScriptSteam::CScriptSteam(TUniqueId uid, const std::string& name, const CEntityInfo& info, const zeus::CVector3f& pos, + const zeus::CAABox& aabb, const CDamageInfo& dInfo, const zeus::CVector3f& orientedForce, + ETriggerFlags flags, bool active, ResId, float, float, float, float, bool) +: CScriptTrigger(uid, name, info, pos, aabb, dInfo, orientedForce, flags, active, false, false) +{ + +} + +} diff --git a/Runtime/World/CScriptSteam.hpp b/Runtime/World/CScriptSteam.hpp new file mode 100644 index 000000000..291f6cceb --- /dev/null +++ b/Runtime/World/CScriptSteam.hpp @@ -0,0 +1,19 @@ +#ifndef __URDE_CSCRIPTSTEAM_HPP__ +#define __URDE_CSCRIPTSTEAM_HPP__ + +#include "CScriptTrigger.hpp" + +namespace urde +{ + +class CScriptSteam : public CScriptTrigger +{ +public: + CScriptSteam(TUniqueId, const std::string& name, const CEntityInfo& info, const zeus::CVector3f& pos, + const zeus::CAABox&, const CDamageInfo& dInfo, const zeus::CVector3f& orientedForce, + ETriggerFlags flags, bool active, ResId, float, float, float, float, bool); +}; + +} + +#endif // __URDE_CSCRIPTSTEAM_HPP__ diff --git a/Runtime/World/ScriptLoader.cpp b/Runtime/World/ScriptLoader.cpp index db565e2b5..6a2e615eb 100644 --- a/Runtime/World/ScriptLoader.cpp +++ b/Runtime/World/ScriptLoader.cpp @@ -44,6 +44,7 @@ #include "CScriptCameraBlurKeyframe.hpp" #include "CScriptDamageableTrigger.hpp" #include "CScriptDebris.hpp" +#include "CScriptSteam.hpp" #include "CScriptDistanceFog.hpp" #include "CScriptDockAreaChange.hpp" #include "CScriptActorRotate.hpp" @@ -1612,12 +1613,97 @@ CEntity* ScriptLoader::LoadMetroidAlpha(CStateManager& mgr, CInputStream& in, in CEntity* ScriptLoader::LoadDebrisExtended(CStateManager& mgr, CInputStream& in, int propCount, const CEntityInfo& info) { - return nullptr; + if (!EnsurePropertyCount(propCount, 39, "DebrisExtended")) + return nullptr; + + SScaledActorHead aHead = LoadScaledActorHead(in, mgr); + + float f1 = in.readFloatBig(); + float f2 = in.readFloatBig(); + float f3 = in.readFloatBig(); + float f4 = in.readFloatBig(); + float f5 = in.readFloatBig(); + float f6 = in.readFloatBig(); + float f7 = in.readFloatBig(); + float f8 = in.readFloatBig(); + float f9 = in.readFloatBig(); + + zeus::CColor c1 = zeus::CColor::ReadRGBABig(in); + zeus::CColor c2 = zeus::CColor::ReadRGBABig(in); + + float f10 = in.readFloatBig(); + + zeus::CVector3f v1 = zeus::CVector3f::ReadBig(in); + + float f11 = in.readFloatBig(); + float f12 = in.readFloatBig(); + + zeus::CVector3f v2 = zeus::CVector3f::ReadBig(in); + + ResId model = in.readUint32Big(); + + CActorParameters aParam = LoadActorParameters(in); + + ResId particle1 = in.readUint32Big(); + zeus::CVector3f particle1Scale = zeus::CVector3f::ReadBig(in); + bool particle1B1 = in.readBool(); + bool particle1B2 = in.readBool(); + CScriptDebris::EOrientationType particle1W = CScriptDebris::EOrientationType(in.readUint32Big()); + + ResId particle2 = in.readUint32Big(); + zeus::CVector3f particle2Scale = zeus::CVector3f::ReadBig(in); + bool particle2B1 = in.readBool(); + bool particle2B2 = in.readBool(); + CScriptDebris::EOrientationType particle2W = CScriptDebris::EOrientationType(in.readUint32Big()); + + ResId particle3 = in.readUint32Big(); + zeus::CVector3f particle3Scale = zeus::CVector3f::ReadBig(in); + CScriptDebris::EOrientationType particle3W = CScriptDebris::EOrientationType(in.readUint32Big()); + + bool b1 = in.readBool(); + bool b2 = in.readBool(); + bool b3 = in.readBool(); + bool b4 = in.readBool(); + + CModelData modelData; + if (g_ResFactory->GetResourceTypeById(model)) + modelData = CModelData(CStaticRes(model, aHead.x40_scale)); + + return new CScriptDebris(mgr.AllocateUniqueId(), aHead.x0_name, info, aHead.x10_transform, + std::move(modelData), aParam, f1, f2, f3, f4, f5, f6, f7, f8, f9, + c1, c2, f10, aHead.x40_scale, v1, f11, f12, v2, + particle1, particle1Scale, particle1B1, particle1B2, particle1W, + particle2, particle2Scale, particle2B1, particle2B2, particle2W, + particle3, particle3Scale, particle3W, b1, b2, b3, b4); } CEntity* ScriptLoader::LoadSteam(CStateManager& mgr, CInputStream& in, int propCount, const CEntityInfo& info) { - return nullptr; + if (!EnsurePropertyCount(propCount, 11, "Steam")) + return nullptr; + + std::string name = mgr.HashInstanceName(in); + + zeus::CVector3f v1 = zeus::CVector3f::ReadBig(in); + zeus::CVector3f v2 = zeus::CVector3f::ReadBig(in); + + CDamageInfo dInfo(in); + + zeus::CVector3f v3 = zeus::CVector3f::ReadBig(in); + + ETriggerFlags w1 = ETriggerFlags(in.readUint32Big()); + bool b1 = in.readBool(); + u32 w2 = in.readUint32Big(); + float f1 = in.readFloatBig(); + float f2 = in.readFloatBig(); + float f3 = in.readFloatBig(); + float f4 = in.readFloatBig(); + bool b2 = in.readBool(); + + zeus::CAABox aabb(-v2 * 0.5f, v2 * 0.5f); + + return new CScriptSteam(mgr.AllocateUniqueId(), name, info, v1, aabb, dInfo, + v3, w1, b1, w2, f1, f2, f3, f4, b2); } CEntity* ScriptLoader::LoadRipple(CStateManager& mgr, CInputStream& in, int propCount, const CEntityInfo& info)