mirror of https://github.com/AxioDL/metaforce.git
parent
01f5b513d4
commit
4428f67998
|
@ -561,6 +561,9 @@ public:
|
|||
bool silenceWarnings=false,
|
||||
bool currentPAK=false) const
|
||||
{
|
||||
if (!entry)
|
||||
return nullptr;
|
||||
|
||||
if (!m_bridges)
|
||||
LogDNACommon.report(LogVisor::FatalError,
|
||||
"PAKRouter::build() must be called before PAKRouter::lookupEntry()");
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
#include "FRME.hpp"
|
||||
#include "../DNACommon/TXTR.hpp"
|
||||
|
||||
namespace Retro
|
||||
{
|
||||
|
@ -269,8 +270,10 @@ bool FRME::Extract(const SpecBase &dataSpec, PAKEntryReadStream &rs, const HECL:
|
|||
|
||||
HECL::BlenderConnection& conn = HECL::BlenderConnection::SharedConnection();
|
||||
|
||||
#if 0
|
||||
if (!force && outPath.getPathType() == HECL::ProjectPath::Type::File)
|
||||
return true;
|
||||
#endif
|
||||
|
||||
if (!conn.createBlend(outPath, HECL::BlenderConnection::BlendType::Frame))
|
||||
return false;
|
||||
|
@ -295,16 +298,27 @@ bool FRME::Extract(const SpecBase &dataSpec, PAKEntryReadStream &rs, const HECL:
|
|||
"angle = Quaternion((0.0, 0.0, 0.0), 0)\n";
|
||||
if (w.type == SBIG('CAMR'))
|
||||
{
|
||||
using CAMRInfo = FRME::Widget::CAMRInfo;
|
||||
using CAMRInfo = Widget::CAMRInfo;
|
||||
os.format("cam = bpy.data.cameras.new(name='%s')\n"
|
||||
"binding = cam\n", w.header.name.c_str());
|
||||
CAMRInfo* info = dynamic_cast<CAMRInfo*>(w.widgetInfo.get());
|
||||
if (info)
|
||||
{
|
||||
if (info->projectionType == CAMRInfo::ProjectionType::Orthographic)
|
||||
os << "cam.type = 'ORTHO'\n";
|
||||
{
|
||||
CAMRInfo::OrthographicProjection* proj = dynamic_cast<CAMRInfo::OrthographicProjection*>(info->projection.get());
|
||||
os.format("cam.type = 'ORTHO'\n");
|
||||
}
|
||||
else if (info->projectionType == CAMRInfo::ProjectionType::Perspective)
|
||||
os << "cam.type = 'PERSP'\n";
|
||||
{
|
||||
CAMRInfo::PerspectiveProjection* proj = dynamic_cast<CAMRInfo::PerspectiveProjection*>(info->projection.get());
|
||||
os.format("cam.type = 'PERSP'\n"
|
||||
"cam.lens_unit = 'FOV'\n"
|
||||
"cam.angle = math.radians(%f)\n"
|
||||
"cam.clip_start = %f\n"
|
||||
"cam.clip_end = %f\n",
|
||||
proj->fov, proj->znear, proj->zfar);
|
||||
}
|
||||
}
|
||||
os << "angle = Quaternion((1.0, 0.0, 0.0), math.radians(90.0))\n";
|
||||
}
|
||||
|
@ -314,24 +328,71 @@ bool FRME::Extract(const SpecBase &dataSpec, PAKEntryReadStream &rs, const HECL:
|
|||
w.header.name.c_str());
|
||||
|
||||
|
||||
os.format("obj = bpy.data.objects.new(name='%s', object_data=binding)\n"
|
||||
"obj.retro_widget_type = '%s'\n"
|
||||
os.format("frme_obj = bpy.data.objects.new(name='%s', object_data=binding)\n"
|
||||
"frme_obj.retro_widget_type = '%s'\n"
|
||||
"parentName = '%s'\n"
|
||||
"if parentName not in bpy.data.objects:\n"
|
||||
" obj.retro_widget_parent = parentName\n"
|
||||
" frme_obj.retro_widget_parent = parentName\n"
|
||||
"else:\n"
|
||||
" obj.parent = bpy.data.objects[parentName]\n"
|
||||
"mtx = Matrix(((%f,%f,%f,%f),(%f,%f,%f,%f),(%f,%f,%f,%f),(0.0,0.0,0.0,1.0)))\n"
|
||||
" frme_obj.parent = bpy.data.objects[parentName]\n",
|
||||
w.header.name.c_str(), w.type.toString().c_str(), w.header.parent.c_str());
|
||||
|
||||
if (w.type == SBIG('MODL'))
|
||||
{
|
||||
using MODLInfo = FRME::Widget::MODLInfo;
|
||||
MODLInfo* info = dynamic_cast<MODLInfo*>(w.widgetInfo.get());
|
||||
HECL::ProjectPath modelPath = pakRouter.getWorking(info->model);
|
||||
const typename PAKRouter<PAKBridge>::EntryType* cmdlE = pakRouter.lookupEntry(info->model, nullptr, true, true);
|
||||
|
||||
os.linkBlend(modelPath.getAbsolutePathUTF8().c_str(),
|
||||
pakRouter.getBestEntryName(*cmdlE).c_str(), false);
|
||||
|
||||
os << "print(obj.name)\n"
|
||||
"if obj.name not in bpy.context.scene.objects:\n"
|
||||
" bpy.context.scene.objects.link(obj)\n"
|
||||
"obj.parent = frme_obj\n"
|
||||
"obj.hide = False\n";
|
||||
}
|
||||
else if (w.type == SBIG('IMGP'))
|
||||
{
|
||||
using IMGPInfo = Widget::IMGPInfo;
|
||||
IMGPInfo* info = dynamic_cast<IMGPInfo*>(w.widgetInfo.get());
|
||||
if (info && info->texture)
|
||||
{
|
||||
std::string texName = pakRouter.getBestEntryName(info->texture);
|
||||
const NOD::Node* node;
|
||||
const typename PAKRouter<PAKBridge>::EntryType* texEntry = pakRouter.lookupEntry(info->texture, &node);
|
||||
HECL::ProjectPath txtrPath = pakRouter.getWorking(texEntry);
|
||||
if (txtrPath.getPathType() == HECL::ProjectPath::Type::None)
|
||||
{
|
||||
PAKEntryReadStream rs = texEntry->beginReadStream(*node);
|
||||
TXTR::Extract(rs, txtrPath);
|
||||
}
|
||||
HECL::SystemString resPath = pakRouter.getResourceRelativePath(entry, info->texture);
|
||||
HECL::SystemUTF8View resPathView(resPath);
|
||||
os.format("if '%s' in bpy.data.images:\n"
|
||||
" image = bpy.data.images['%s']\n"
|
||||
"else:\n"
|
||||
" image = bpy.data.images.load('''//%s''')\n"
|
||||
" image.name = '%s'\n"
|
||||
"frme_obj.empty_draw_type = 'IMAGE'\n"
|
||||
"frme_obj.data = image\n"
|
||||
"angle = Quaternion((1.0, 0.0, 0.0), math.radians(90.0))\n",
|
||||
texName.c_str(), texName.c_str(),
|
||||
resPathView.str().c_str(), texName.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
os.format("mtx = Matrix(((%f,%f,%f,%f),(%f,%f,%f,%f),(%f,%f,%f,%f),(0.0,0.0,0.0,1.0)))\n"
|
||||
"mtxd = mtx.decompose()\n"
|
||||
"obj.rotation_mode = 'QUATERNION'\n"
|
||||
"obj.location = mtxd[0]\n"
|
||||
"obj.rotation_quaternion = mtxd[1] * angle\n"
|
||||
"obj.scale = mtxd[2]\n",
|
||||
w.header.name.c_str(), w.type.toString().c_str(), w.header.parent.c_str(),
|
||||
"frme_obj.rotation_mode = 'QUATERNION'\n"
|
||||
"frme_obj.location = mtxd[0]\n"
|
||||
"frme_obj.rotation_quaternion = mtxd[1] * angle\n"
|
||||
"frme_obj.scale = mtxd[2]\n"
|
||||
"bpy.context.scene.objects.link(frme_obj)\n",
|
||||
w.basis[0].vec[0], w.basis[0].vec[1], w.basis[0].vec[2],w.origin.vec[0],
|
||||
w.basis[1].vec[0], w.basis[1].vec[1], w.basis[1].vec[2],w.origin.vec[1],
|
||||
w.basis[2].vec[0], w.basis[2].vec[1], w.basis[2].vec[2],w.origin.vec[2]);
|
||||
os << "bpy.context.scene.objects.link(obj)\n";
|
||||
}
|
||||
|
||||
os.centerView();
|
||||
|
|
|
@ -104,7 +104,7 @@ struct MLVL : BigYAML
|
|||
{
|
||||
MLVL mlvl;
|
||||
mlvl.read(rs);
|
||||
FILE* fp = HECL::Fopen(outPath.getAbsolutePath().c_str(), _S("wb"));
|
||||
FILE* fp = HECL::Fopen(outPath.getWithExtension(_S(".yaml"), true).getAbsolutePath().c_str(), _S("wb"));
|
||||
mlvl.toYAMLFile(fp);
|
||||
fclose(fp);
|
||||
HECL::BlenderConnection& conn = HECL::BlenderConnection::SharedConnection();
|
||||
|
|
|
@ -88,7 +88,7 @@ struct MLVL : BigYAML
|
|||
{
|
||||
MLVL mlvl;
|
||||
mlvl.read(rs);
|
||||
FILE* fp = HECL::Fopen(outPath.getWithExtension(_S(".yaml")).getAbsolutePath().c_str(), _S("wb"));
|
||||
FILE* fp = HECL::Fopen(outPath.getWithExtension(_S(".yaml"), true).getAbsolutePath().c_str(), _S("wb"));
|
||||
mlvl.toYAMLFile(fp);
|
||||
fclose(fp);
|
||||
HECL::BlenderConnection& conn = HECL::BlenderConnection::SharedConnection();
|
||||
|
|
2
hecl
2
hecl
|
@ -1 +1 @@
|
|||
Subproject commit 966ec1ab3323d6f4e4352eb459ba60523f8d8440
|
||||
Subproject commit 4d49e81a9523c671651ba00c426fccb946c370ae
|
Loading…
Reference in New Issue