2
0
mirror of https://github.com/AxioDL/metaforce.git synced 2025-12-08 20:27:43 +00:00

Add VISIGen utility

This commit is contained in:
Jack Andersen
2017-02-23 22:28:44 -10:00
parent 50fe6d34ab
commit ccbd19b9ea
21 changed files with 1578 additions and 15 deletions

View File

@@ -16,7 +16,7 @@ struct Actor : IScriptObject
Value<atVec3f> orientation;
Value<atVec3f> scale;
Value<atVec3f> collisionExtent;
Value<atVec3f> centroid;
Value<atVec3f> collisionOffset;
Value<float> unknown2;
Value<float> unknown3;
HealthInfo healthInfo;
@@ -64,6 +64,36 @@ struct Actor : IScriptObject
{
actorParameters.scanIDs(scansOut);
}
zeus::CAABox getVISIAABB(hecl::BlenderToken& btok) const
{
hecl::BlenderConnection& conn = btok.getBlenderConnection();
zeus::CAABox aabbOut;
if (model)
{
hecl::ProjectPath path = UniqueIDBridge::TranslatePakIdToPath(model);
conn.openBlend(path);
hecl::BlenderConnection::DataStream ds = conn.beginData();
auto aabb = ds.getMeshAABB();
aabbOut = zeus::CAABox(aabb.first, aabb.second);
}
else if (animationParameters.animationCharacterSet)
{
hecl::ProjectPath path = UniqueIDBridge::TranslatePakIdToPath(
animationParameters.animationCharacterSet);
conn.openBlend(path.getWithExtension(_S(".blend"), true));
hecl::BlenderConnection::DataStream ds = conn.beginData();
auto aabb = ds.getMeshAABB();
aabbOut = zeus::CAABox(aabb.first, aabb.second);
}
if (aabbOut.min.x > aabbOut.max.x)
return {};
zeus::CTransform xf = ConvertEditorEulerToTransform4f(scale, orientation, location);
return aabbOut.getTransformedAABox(xf);
}
};
}
}

View File

@@ -50,6 +50,13 @@ struct DamageableTrigger : IScriptObject
g_curSpec->flattenDependencies(texture2, pathsOut);
g_curSpec->flattenDependencies(texture3, pathsOut);
}
zeus::CAABox getVISIAABB(hecl::BlenderToken& btok) const
{
zeus::CVector3f halfExtent = zeus::CVector3f(volume) / 2.f;
zeus::CVector3f loc(location);
return zeus::CAABox(loc - halfExtent, loc + halfExtent);
}
};
}
}

View File

@@ -19,8 +19,8 @@ struct DoorArea : IScriptObject
AnimationParameters animationParameters;
ActorParameters actorParameters;
Value<atVec3f> unknown1;
Value<atVec3f> unknown2;
Value<atVec3f> unknown3;
Value<atVec3f> collisionExtent;
Value<atVec3f> collisionOffset;
Value<bool> unknown4;
Value<bool> unknown5;
Value<bool> unknown6;
@@ -49,6 +49,28 @@ struct DoorArea : IScriptObject
{
actorParameters.scanIDs(scansOut);
}
zeus::CAABox getVISIAABB(hecl::BlenderToken& btok) const
{
hecl::BlenderConnection& conn = btok.getBlenderConnection();
zeus::CAABox aabbOut;
if (animationParameters.animationCharacterSet)
{
hecl::ProjectPath path = UniqueIDBridge::TranslatePakIdToPath(
animationParameters.animationCharacterSet);
conn.openBlend(path.getWithExtension(_S(".blend"), true));
hecl::BlenderConnection::DataStream ds = conn.beginData();
auto aabb = ds.getMeshAABB();
aabbOut = zeus::CAABox(aabb.first, aabb.second);
}
if (aabbOut.min.x > aabbOut.max.x)
return {};
zeus::CTransform xf = ConvertEditorEulerToTransform4f(scale, orientation, location);
return aabbOut.getTransformedAABox(xf);
}
};
}
}

View File

@@ -267,5 +267,16 @@ const std::vector<const struct ScriptObjectSpec*> SCRIPT_OBJECT_DB =
&priv::WorldTeleporterx62Ent,
};
zeus::CTransform ConvertEditorEulerToTransform4f(const zeus::CVector3f& scale,
const zeus::CVector3f& orientation,
const zeus::CVector3f& position)
{
return zeus::CTransform::RotateZ(zeus::degToRad(orientation.z)) *
zeus::CTransform::RotateY(zeus::degToRad(orientation.y)) *
zeus::CTransform::RotateX(zeus::degToRad(orientation.x)) *
zeus::CTransform::Scale(scale) +
position;
}
}
}

View File

@@ -3,12 +3,18 @@
#include "../../DNACommon/DNACommon.hpp"
#include "../DNAMP1.hpp"
#include "../SAVW.hpp"
#include "zeus/CAABox.hpp"
#include <stdio.h>
namespace DataSpec
{
namespace DNAMP1
{
zeus::CTransform ConvertEditorEulerToTransform4f(const zeus::CVector3f& scale,
const zeus::CVector3f& orientation,
const zeus::CVector3f& position);
struct IScriptObject : BigYAML
{
DECL_YAML
@@ -32,6 +38,7 @@ struct IScriptObject : BigYAML
virtual void nameIDs(PAKRouter<PAKBridge>& pakRouter) const {}
virtual void gatherDependencies(std::vector<hecl::ProjectPath>& pathsOut) const {}
virtual void gatherScans(std::vector<Scan>& scansOut) const {}
virtual zeus::CAABox getVISIAABB(hecl::BlenderToken& btok) const { return {}; }
};
}
}

View File

@@ -66,6 +66,36 @@ struct Platform : IScriptObject
{
actorParameters.scanIDs(scansOut);
}
zeus::CAABox getVISIAABB(hecl::BlenderToken& btok) const
{
hecl::BlenderConnection& conn = btok.getBlenderConnection();
zeus::CAABox aabbOut;
if (model)
{
hecl::ProjectPath path = UniqueIDBridge::TranslatePakIdToPath(model);
conn.openBlend(path);
hecl::BlenderConnection::DataStream ds = conn.beginData();
auto aabb = ds.getMeshAABB();
aabbOut = zeus::CAABox(aabb.first, aabb.second);
}
else if (animationParameters.animationCharacterSet)
{
hecl::ProjectPath path = UniqueIDBridge::TranslatePakIdToPath(
animationParameters.animationCharacterSet);
conn.openBlend(path.getWithExtension(_S(".blend"), true));
hecl::BlenderConnection::DataStream ds = conn.beginData();
auto aabb = ds.getMeshAABB();
aabbOut = zeus::CAABox(aabb.first, aabb.second);
}
if (aabbOut.min.x > aabbOut.max.x)
return {};
zeus::CTransform xf = ConvertEditorEulerToTransform4f(scale, orientation, location);
return aabbOut.getTransformedAABox(xf);
}
};
}
}

View File

@@ -21,6 +21,13 @@ struct Trigger : IScriptObject
Value<bool> active;
Value<bool> unknown2;
Value<bool> unknown3;
zeus::CAABox getVISIAABB(hecl::BlenderToken& btok) const
{
zeus::CVector3f halfExtent = zeus::CVector3f(volume) / 2.f;
zeus::CVector3f loc(location);
return zeus::CAABox(loc - halfExtent, loc + halfExtent);
}
};
}
}

View File

@@ -173,6 +173,13 @@ struct Water : IScriptObject
g_curSpec->flattenDependencies(particle4, pathsOut);
g_curSpec->flattenDependencies(particle5, pathsOut);
}
zeus::CAABox getVISIAABB(hecl::BlenderToken& btok) const
{
zeus::CVector3f halfExtent = zeus::CVector3f(volume) / 2.f;
zeus::CVector3f loc(location);
return zeus::CAABox(loc - halfExtent, loc + halfExtent);
}
};
}
}