mirror of https://github.com/AxioDL/metaforce.git
MREA fixes, some script constructors
This commit is contained in:
parent
e923d83617
commit
5277d445d3
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -137,6 +137,9 @@ struct MREA
|
|||
const ColMesh& cMesh,
|
||||
const std::vector<Light>& lights,
|
||||
hecl::BlenderToken& btok);
|
||||
|
||||
static bool CookPath(const hecl::ProjectPath& outPath,
|
||||
const hecl::ProjectPath& inPath);
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -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<std::string> meshes = ds.getMeshList();
|
||||
std::vector<Mesh> meshCompiles;
|
||||
meshCompiles.reserve(meshes.size());
|
||||
|
||||
std::experimental::optional<ColMesh> 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<Light> 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<std::string> meshes = ds.getMeshList();
|
||||
std::vector<Mesh> meshCompiles;
|
||||
meshCompiles.reserve(meshes.size());
|
||||
|
||||
std::experimental::optional<ColMesh> 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<Light> 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,
|
||||
|
|
|
@ -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<std::mutex> lk(const_cast<ProjectResourceFactoryBase*>(this)->m_backgroundIndexMutex);
|
||||
SObjectTag searchTag = {FourCC(), id};
|
||||
|
|
|
@ -68,6 +68,7 @@ CStateManager::CStateManager(const std::weak_ptr<CRelayTracker>& 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<TEditorId, TUniqueId> 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 ; i<leftover ; ++i)
|
||||
in.readByte();
|
||||
|
||||
if (error || ent == nullptr)
|
||||
{
|
||||
LogModule.report(logvisor::Fatal, "Script load error");
|
||||
return {kInvalidEditorId, kInvalidUniqueId};
|
||||
}
|
||||
else
|
||||
return {id, ent->GetUniqueId()};
|
||||
}
|
||||
|
|
|
@ -58,8 +58,9 @@ CAreaOctTree::Node CAreaOctTree::Node::GetChild(int idx) const
|
|||
}
|
||||
else if (type == ETreeType::Leaf)
|
||||
{
|
||||
const zeus::CAABox* aabb = reinterpret_cast<const zeus::CAABox*>(m_ptr + offsets[idx] + 36);
|
||||
return Node(aabb, *aabb, m_owner, ETreeType::Leaf);
|
||||
const float* aabb = reinterpret_cast<const float*>(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<u16*>(ptr);
|
||||
*typeBits = hecl::SBig(*typeBits);
|
||||
u32* offsets = reinterpret_cast<u32*>(ptr + 4);
|
||||
|
||||
for (int i=0 ; i<8 ; ++i)
|
||||
{
|
||||
Node::ETreeType ctype = Node::ETreeType((*typeBits >> (2 * i)) & 0x3);
|
||||
u32* offsets = reinterpret_cast<u32*>(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<zeus::CAABox*>(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<float*>(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<u16*>(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<u8[]>&& 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<u8*>(x20_treeBuf), treeType);
|
||||
|
||||
{
|
||||
x28_materials.reserve(matCount);
|
||||
athena::io::MemoryReader r(materials, matCount * 4);
|
||||
for (u32 i=0 ; i<matCount ; ++i)
|
||||
x28_materials.push_back(r.readUint32Big());
|
||||
}
|
||||
for (u32 i=0 ; i<matCount ; ++i)
|
||||
const_cast<u32*>(x28_materials)[i] = hecl::SBig(x28_materials[i]);
|
||||
|
||||
{
|
||||
x3c_edges.reserve(edgeCount);
|
||||
athena::io::MemoryReader r(edges, edgeCount * 4);
|
||||
for (u32 i=0 ; i<edgeCount ; ++i)
|
||||
x3c_edges.emplace_back(r);
|
||||
}
|
||||
for (u32 i=0 ; i<edgeCount ; ++i)
|
||||
const_cast<CCollisionEdge*>(x3c_edges)[i].swapBig();
|
||||
|
||||
{
|
||||
x44_polyEdges.reserve(polyCount);
|
||||
athena::io::MemoryReader r(polyEdges, polyCount * 2);
|
||||
for (u32 i=0 ; i<polyCount ; ++i)
|
||||
x44_polyEdges.push_back(r.readUint16Big());
|
||||
}
|
||||
for (u32 i=0 ; i<polyCount ; ++i)
|
||||
const_cast<u16*>(x44_polyEdges)[i] = hecl::SBig(x44_polyEdges[i]);
|
||||
|
||||
{
|
||||
x4c_verts.reserve(vertCount);
|
||||
athena::io::MemoryReader r(verts, vertCount * 12);
|
||||
for (u32 i=0 ; i<vertCount ; ++i)
|
||||
x4c_verts.push_back(zeus::CVector3f::ReadBig(r));
|
||||
}
|
||||
for (u32 i=0 ; i<vertCount*3 ; ++i)
|
||||
const_cast<float*>(x4c_verts)[i] = hecl::SBig(x4c_verts[i]);
|
||||
}
|
||||
|
||||
std::unique_ptr<CAreaOctTree> CAreaOctTree::MakeFromMemory(const void* buf, unsigned int size)
|
||||
std::unique_ptr<CAreaOctTree> 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<const u8*>(buf) + r.position();
|
||||
const u8* cur = reinterpret_cast<const u8*>(buf) + 8 + r.position();
|
||||
|
||||
std::unique_ptr<u8[]> treeBuf(new u8[treeSize]);
|
||||
memmove(treeBuf.get(), cur, treeSize);
|
||||
const u8* treeBuf = cur;
|
||||
cur += treeSize;
|
||||
|
||||
u32 matCount = hecl::SBig(*reinterpret_cast<const u32*>(cur));
|
||||
|
@ -187,10 +171,9 @@ std::unique_ptr<CAreaOctTree> CAreaOctTree::MakeFromMemory(const void* buf, unsi
|
|||
|
||||
u32 vertCount = hecl::SBig(*reinterpret_cast<const u32*>(cur));
|
||||
cur += 4;
|
||||
const zeus::CVector3f* vertBuf = reinterpret_cast<const zeus::CVector3f*>(cur);
|
||||
cur += polyCount * 2;
|
||||
const float* vertBuf = reinterpret_cast<const float*>(cur);
|
||||
|
||||
return std::make_unique<CAreaOctTree>(aabb, nodeType, reinterpret_cast<const u8*>(buf), std::move(treeBuf),
|
||||
return std::make_unique<CAreaOctTree>(aabb, nodeType, reinterpret_cast<const u8*>(buf + 8), treeBuf,
|
||||
matCount, matBuf, vertMatsBuf, edgeMatsBuf, polyMatsBuf,
|
||||
edgeCount, edgeBuf, polyCount, polyBuf, vertCount, vertBuf);
|
||||
}
|
||||
|
|
|
@ -95,30 +95,34 @@ public:
|
|||
zeus::CAABox x0_aabb;
|
||||
Node::ETreeType x18_treeType;
|
||||
const u8* x1c_buf;
|
||||
std::unique_ptr<u8[]> x20_treeBuf;
|
||||
const u8* x20_treeBuf;
|
||||
u32 x24_matCount;
|
||||
std::vector<u32> x28_materials;
|
||||
const u32* x28_materials;
|
||||
const u8* x2c_vertMats;
|
||||
const u8* x30_edgeMats;
|
||||
const u8* x34_polyMats;
|
||||
u32 x38_edgeCount;
|
||||
std::vector<CCollisionEdge> x3c_edges;
|
||||
const CCollisionEdge* x3c_edges;
|
||||
u32 x40_polyCount;
|
||||
std::vector<u16> x44_polyEdges;
|
||||
const u16* x44_polyEdges;
|
||||
u32 x48_vertCount;
|
||||
std::vector<zeus::CVector3f> 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<u8[]>&& 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<CAreaOctTree> MakeFromMemory(const void* buf, unsigned int size);
|
||||
static std::unique_ptr<CAreaOctTree> MakeFromMemory(const u8* buf, unsigned int size);
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -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) {}
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -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__
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue