mirror of
https://github.com/AxioDL/metaforce.git
synced 2025-12-09 02:27:43 +00:00
Humungous refactor
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
|
||||
#include "DNACommon.hpp"
|
||||
#include "BlenderConnection.hpp"
|
||||
#include "CVector3f.hpp"
|
||||
#include "zeus/CVector3f.hpp"
|
||||
|
||||
namespace DataSpec
|
||||
{
|
||||
@@ -11,31 +11,23 @@ namespace DNAMLVL
|
||||
{
|
||||
|
||||
template <class PAKRouter, typename MLVL>
|
||||
bool ReadMLVLToBlender(HECL::BlenderConnection& conn,
|
||||
bool ReadMLVLToBlender(hecl::BlenderConnection& conn,
|
||||
const MLVL& mlvl,
|
||||
const HECL::ProjectPath& outPath,
|
||||
const hecl::ProjectPath& outPath,
|
||||
PAKRouter& pakRouter,
|
||||
const typename PAKRouter::EntryType& entry,
|
||||
bool force,
|
||||
std::function<void(const HECL::SystemChar*)> fileChanged)
|
||||
std::function<void(const hecl::SystemChar*)> fileChanged)
|
||||
{
|
||||
/* Rename MLVL for consistency */
|
||||
HECL::ProjectPath mlvlPath(outPath.getParentPath(), _S("!world.blend"));
|
||||
if (!force && mlvlPath.getPathType() == HECL::ProjectPath::Type::File)
|
||||
hecl::ProjectPath mlvlPath(outPath.getParentPath(), _S("!world.blend"));
|
||||
if (!force && mlvlPath.getPathType() == hecl::ProjectPath::Type::File)
|
||||
return true;
|
||||
|
||||
/* Link Skybox CMDL */
|
||||
const typename PAKRouter::EntryType* skyboxEntry = pakRouter.lookupEntry(mlvl.worldSkyboxId);
|
||||
if (skyboxEntry)
|
||||
{
|
||||
HECL::ProjectPath skyboxPath = pakRouter.getWorking(skyboxEntry);
|
||||
HECL::ProjectPath(outPath.getParentPath(), _S("!skybox.blend")).makeLinkTo(skyboxPath);
|
||||
}
|
||||
|
||||
/* Create World Blend */
|
||||
if (!conn.createBlend(mlvlPath, HECL::BlenderConnection::BlendType::World))
|
||||
if (!conn.createBlend(mlvlPath, hecl::BlenderConnection::BlendType::World))
|
||||
return false;
|
||||
HECL::BlenderConnection::PyOutStream os = conn.beginPythonOut(true);
|
||||
hecl::BlenderConnection::PyOutStream os = conn.beginPythonOut(true);
|
||||
os.format("import bpy\n"
|
||||
"import bmesh\n"
|
||||
"from mathutils import Matrix\n"
|
||||
@@ -52,7 +44,7 @@ bool ReadMLVLToBlender(HECL::BlenderConnection& conn,
|
||||
for (const auto& area : mlvl.areas)
|
||||
{
|
||||
const typename PAKRouter::EntryType* mreaEntry = pakRouter.lookupEntry(area.areaMREAId);
|
||||
HECL::SystemUTF8View areaDirName(*mreaEntry->unique.m_areaName);
|
||||
hecl::SystemUTF8View areaDirName(*mreaEntry->unique.m_areaName);
|
||||
|
||||
os.AABBToBMesh(area.aabb[0], area.aabb[1]);
|
||||
os.format("box_mesh = bpy.data.meshes.new('''%s''')\n"
|
||||
@@ -76,14 +68,14 @@ bool ReadMLVLToBlender(HECL::BlenderConnection& conn,
|
||||
for (const auto& dock : area.docks)
|
||||
{
|
||||
os << "bm = bmesh.new()\n";
|
||||
Zeus::CVector3f pvAvg;
|
||||
zeus::CVector3f pvAvg;
|
||||
for (const atVec3f& pv : dock.planeVerts)
|
||||
pvAvg += pv;
|
||||
pvAvg /= dock.planeVerts.size();
|
||||
int idx = 0;
|
||||
for (const atVec3f& pv : dock.planeVerts)
|
||||
{
|
||||
Zeus::CVector3f pvRel = Zeus::CVector3f(pv) - pvAvg;
|
||||
zeus::CVector3f pvRel = zeus::CVector3f(pv) - pvAvg;
|
||||
os.format("bm.verts.new((%f,%f,%f))\n"
|
||||
"bm.verts.ensure_lookup_table()\n",
|
||||
pvRel[0], pvRel[1], pvRel[2]);
|
||||
|
||||
Reference in New Issue
Block a user