diff --git a/hecl/blender/BlenderConnection.cpp b/hecl/blender/BlenderConnection.cpp index 677a6aa4b..776c16270 100644 --- a/hecl/blender/BlenderConnection.cpp +++ b/hecl/blender/BlenderConnection.cpp @@ -372,6 +372,7 @@ static const char* BlendTypeStrs[] = "MESH", "ACTOR", "AREA", + "WORLD", nullptr }; @@ -455,8 +456,8 @@ void BlenderConnection::deleteBlend() } } -void BlenderConnection::PyOutStream::linkBlend(const std::string& target, - const std::string& objName, +void BlenderConnection::PyOutStream::linkBlend(const char* target, + const char* objName, bool link) { format("if '%s' not in bpy.data.scenes:\n" @@ -476,8 +477,27 @@ void BlenderConnection::PyOutStream::linkBlend(const std::string& target, "else:\n" " obj = bpy.data.objects['%s']\n" "\n", - objName.c_str(), target.c_str(), link?"True":"False", - objName.c_str(), objName.c_str(), target.c_str(), objName.c_str()); + objName, target, link?"True":"False", + objName, objName, target, objName); +} + +void BlenderConnection::PyOutStream::linkBackground(const char* target, + const char* sceneName) +{ + format("if '%s' not in bpy.data.scenes:\n" + " with bpy.data.libraries.load('''%s''', link=True, relative=True) as (data_from, data_to):\n" + " data_to.scenes = data_from.scenes\n" + " obj_scene = None\n" + " for scene in data_to.scenes:\n" + " if scene.name == '%s':\n" + " obj_scene = scene\n" + " break\n" + " if not obj_scene:\n" + " raise RuntimeError('''unable to find %s in %s. try deleting it and restart the extract.''')\n" + "\n" + "bpy.context.scene.background_set = bpy.data.scenes['%s']\n", + sceneName, target, + sceneName, sceneName, target, sceneName); } BlenderConnection::DataStream::Mesh::Mesh diff --git a/hecl/blender/BlenderConnection.hpp b/hecl/blender/BlenderConnection.hpp index 5fdd1d10d..0484d6331 100644 --- a/hecl/blender/BlenderConnection.hpp +++ b/hecl/blender/BlenderConnection.hpp @@ -37,7 +37,8 @@ public: TypeNone, TypeMesh, TypeActor, - TypeArea + TypeArea, + TypeWorld }; private: bool m_lock = false; @@ -163,7 +164,56 @@ public: this->write(result, length); free(result); } - void linkBlend(const std::string& target, const std::string& objName, bool link=true); + void linkBlend(const char* target, const char* objName, bool link=true); + void linkBackground(const char* target, const char* sceneName); + + void AABBToBMesh(const atVec3f& min, const atVec3f& max) + { + format("bm = bmesh.new()\n" + "bm.verts.new((%f,%f,%f))\n" + "bm.verts.new((%f,%f,%f))\n" + "bm.verts.new((%f,%f,%f))\n" + "bm.verts.new((%f,%f,%f))\n" + "bm.verts.new((%f,%f,%f))\n" + "bm.verts.new((%f,%f,%f))\n" + "bm.verts.new((%f,%f,%f))\n" + "bm.verts.new((%f,%f,%f))\n" + "bm.verts.ensure_lookup_table()\n" + "bm.edges.new((bm.verts[0], bm.verts[1]))\n" + "bm.edges.new((bm.verts[0], bm.verts[2]))\n" + "bm.edges.new((bm.verts[0], bm.verts[4]))\n" + "bm.edges.new((bm.verts[3], bm.verts[1]))\n" + "bm.edges.new((bm.verts[3], bm.verts[2]))\n" + "bm.edges.new((bm.verts[3], bm.verts[7]))\n" + "bm.edges.new((bm.verts[5], bm.verts[1]))\n" + "bm.edges.new((bm.verts[5], bm.verts[4]))\n" + "bm.edges.new((bm.verts[5], bm.verts[7]))\n" + "bm.edges.new((bm.verts[6], bm.verts[2]))\n" + "bm.edges.new((bm.verts[6], bm.verts[4]))\n" + "bm.edges.new((bm.verts[6], bm.verts[7]))\n", + min.vec[0], min.vec[1], min.vec[2], + max.vec[0], min.vec[1], min.vec[2], + min.vec[0], max.vec[1], min.vec[2], + max.vec[0], max.vec[1], min.vec[2], + min.vec[0], min.vec[1], max.vec[2], + max.vec[0], min.vec[1], max.vec[2], + min.vec[0], max.vec[1], max.vec[2], + max.vec[0], max.vec[1], max.vec[2]); + } + + void centerView() + { + *this << "bpy.context.user_preferences.view.smooth_view = 0\n" + "for window in bpy.context.window_manager.windows:\n" + " screen = window.screen\n" + " for area in screen.areas:\n" + " if area.type == 'VIEW_3D':\n" + " for region in area.regions:\n" + " if region.type == 'WINDOW':\n" + " override = {'scene': bpy.context.scene, 'window': window, 'screen': screen, 'area': area, 'region': region}\n" + " bpy.ops.view3d.view_all(override)\n" + " break\n"; + } class ANIMOutStream { diff --git a/hecl/blender/CMakeLists.txt b/hecl/blender/CMakeLists.txt index 72213c640..280d8d4a0 100644 --- a/hecl/blender/CMakeLists.txt +++ b/hecl/blender/CMakeLists.txt @@ -8,7 +8,8 @@ list(APPEND PY_SOURCES hecl/sact/__init__.py hecl/sact/SACTAction.py hecl/sact/SACTSubtype.py - hecl/srea/__init__.py) + hecl/srea/__init__.py + hecl/swld/__init__.py) bintoc(hecl_blendershell.c hecl_blendershell.py HECL_BLENDERSHELL) diff --git a/hecl/blender/hecl/__init__.py b/hecl/blender/hecl/__init__.py index 2b3029187..4d92c4e72 100644 --- a/hecl/blender/hecl/__init__.py +++ b/hecl/blender/hecl/__init__.py @@ -9,7 +9,7 @@ bl_info = { "category": "System"} # Package import -from . import hmdl, sact, srea, Nodegrid, Patching +from . import hmdl, sact, srea, swld, Nodegrid, Patching Nodegrid = Nodegrid.Nodegrid import bpy, os, sys from bpy.app.handlers import persistent @@ -20,7 +20,8 @@ hecl_typeS = [ ('NONE', "None", "Active scene not using HECL", None), ('MESH', "Mesh", "Active scene represents an HMDL Mesh", hmdl.draw), ('ACTOR', "Actor", "Active scene represents a HECL Actor", sact.draw), -('AREA', "Area", "Active scene represents a HECL Area", srea.draw)] +('AREA', "Area", "Active scene represents a HECL Area", srea.draw), +('WORLD', "World", "Active scene represents a HECL World", swld.draw)] # Main Scene Panel class hecl_scene_panel(bpy.types.Panel): diff --git a/hecl/blender/hecl/swld/__init__.py b/hecl/blender/hecl/swld/__init__.py new file mode 100644 index 000000000..5c9da0bc6 --- /dev/null +++ b/hecl/blender/hecl/swld/__init__.py @@ -0,0 +1,8 @@ + +# Cook +def cook(writebuf): + pass + +# Panel draw +def draw(layout, context): + pass diff --git a/hecl/extern/Athena b/hecl/extern/Athena index e86169148..f46edcd4b 160000 --- a/hecl/extern/Athena +++ b/hecl/extern/Athena @@ -1 +1 @@ -Subproject commit e8616914801e274155bfe8d9fe3353448f0ec219 +Subproject commit f46edcd4b8cc6d3d49e7967c3710e0b39b925ba7