metaforce/DataSpec/DNAMP1/ScriptObjects/Platform.cpp

32 lines
1.1 KiB
C++
Raw Normal View History

2017-12-29 08:08:12 +00:00
#include "Platform.hpp"
#include "hecl/Blender/Connection.hpp"
2018-12-08 05:30:43 +00:00
namespace DataSpec::DNAMP1 {
2017-12-29 08:08:12 +00:00
2018-12-08 05:30:43 +00:00
zeus::CAABox Platform::getVISIAABB(hecl::blender::Token& btok) const {
hecl::blender::Connection& conn = btok.getBlenderConnection();
zeus::CAABox aabbOut;
2017-12-29 08:08:12 +00:00
2019-07-20 04:27:21 +00:00
if (model.isValid()) {
2018-12-08 05:30:43 +00:00
hecl::ProjectPath path = UniqueIDBridge::TranslatePakIdToPath(model);
conn.openBlend(path);
hecl::blender::DataStream ds = conn.beginData();
auto aabb = ds.getMeshAABB();
aabbOut = zeus::CAABox(aabb.first, aabb.second);
2019-07-20 04:27:21 +00:00
} else if (animationParameters.animationCharacterSet.isValid()) {
2018-12-08 05:30:43 +00:00
hecl::ProjectPath path = UniqueIDBridge::TranslatePakIdToPath(animationParameters.animationCharacterSet);
conn.openBlend(path.getWithExtension(".blend", true));
2018-12-08 05:30:43 +00:00
hecl::blender::DataStream ds = conn.beginData();
auto aabb = ds.getMeshAABB();
aabbOut = zeus::CAABox(aabb.first, aabb.second);
}
2017-12-29 08:08:12 +00:00
2018-12-08 05:30:43 +00:00
if (aabbOut.min.x() > aabbOut.max.x())
return {};
2017-12-29 08:08:12 +00:00
2018-12-08 05:30:43 +00:00
zeus::CTransform xf = ConvertEditorEulerToTransform4f(scale, orientation, location);
return aabbOut.getTransformedAABox(xf);
2017-12-29 08:08:12 +00:00
}
2018-12-08 05:30:43 +00:00
} // namespace DataSpec::DNAMP1