|
|
@ -17,6 +17,7 @@ import bpy |
|
|
|
import os.path |
|
|
|
import os.path |
|
|
|
from PyHSPlasma import * |
|
|
|
from PyHSPlasma import * |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class ExportError(Exception): |
|
|
|
class ExportError(Exception): |
|
|
|
def __init__(self, value="Undefined Export Error"): |
|
|
|
def __init__(self, value="Undefined Export Error"): |
|
|
|
super(Exception, self).__init__(value) |
|
|
|
super(Exception, self).__init__(value) |
|
|
@ -24,7 +25,7 @@ class ExportError(Exception): |
|
|
|
|
|
|
|
|
|
|
|
class Exporter: |
|
|
|
class Exporter: |
|
|
|
def __init__(self, op): |
|
|
|
def __init__(self, op): |
|
|
|
self._op = op # Blender operator |
|
|
|
self._op = op # Blender operator |
|
|
|
|
|
|
|
|
|
|
|
# This stuff doesn't need to be static |
|
|
|
# This stuff doesn't need to be static |
|
|
|
self._nodes = {} |
|
|
|
self._nodes = {} |
|
|
@ -40,14 +41,13 @@ class Exporter: |
|
|
|
location = self._pages[bl.plasma_object.page] |
|
|
|
location = self._pages[bl.plasma_object.page] |
|
|
|
self.mgr.AddObject(location, pl) |
|
|
|
self.mgr.AddObject(location, pl) |
|
|
|
node = self._nodes[location] |
|
|
|
node = self._nodes[location] |
|
|
|
if node: # All objects must be in the scene node |
|
|
|
if node: # All objects must be in the scene node |
|
|
|
if isinstance(pl, plSceneObject): |
|
|
|
if isinstance(pl, plSceneObject): |
|
|
|
f = node.addSceneObject |
|
|
|
f = node.addSceneObject |
|
|
|
else: |
|
|
|
else: |
|
|
|
f = node.addPoolObject |
|
|
|
f = node.addPoolObject |
|
|
|
f(pl.key) |
|
|
|
f(pl.key) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@property |
|
|
|
@property |
|
|
|
def age_name(self): |
|
|
|
def age_name(self): |
|
|
|
return os.path.splitext(os.path.split(self._op.filepath)[1])[0] |
|
|
|
return os.path.splitext(os.path.split(self._op.filepath)[1])[0] |
|
|
@ -100,11 +100,11 @@ class Exporter: |
|
|
|
self._collect_objects() |
|
|
|
self._collect_objects() |
|
|
|
|
|
|
|
|
|
|
|
# Step 2: Collect some age information |
|
|
|
# Step 2: Collect some age information |
|
|
|
self._grab_age_info() # World Props -> plAgeInfo |
|
|
|
self._grab_age_info() # World Props -> plAgeInfo |
|
|
|
for page in bpy.context.scene.world.plasma_age.pages: |
|
|
|
for page in bpy.context.scene.world.plasma_age.pages: |
|
|
|
self._create_page(page.name, page.seq_suffix) |
|
|
|
self._create_page(page.name, page.seq_suffix) |
|
|
|
self._sanity_check_pages() |
|
|
|
self._sanity_check_pages() |
|
|
|
self._generate_builtins() # Creates BuiltIn and Textures |
|
|
|
self._generate_builtins() # Creates BuiltIn and Textures |
|
|
|
|
|
|
|
|
|
|
|
# Step 3: Export all the things! |
|
|
|
# Step 3: Export all the things! |
|
|
|
self._export_scene_objects() |
|
|
|
self._export_scene_objects() |
|
|
@ -123,7 +123,7 @@ class Exporter: |
|
|
|
age = bpy.context.scene.world.plasma_age |
|
|
|
age = bpy.context.scene.world.plasma_age |
|
|
|
self._age_info = plAgeInfo() |
|
|
|
self._age_info = plAgeInfo() |
|
|
|
self._age_info.dayLength = age.day_length |
|
|
|
self._age_info.dayLength = age.day_length |
|
|
|
self._age_info.lingerTime = 180 # this is fairly standard |
|
|
|
self._age_info.lingerTime = 180 # this is fairly standard |
|
|
|
self._age_info.name = self.age_name |
|
|
|
self._age_info.name = self.age_name |
|
|
|
self._age_info.seqPrefix = age.seq_prefix |
|
|
|
self._age_info.seqPrefix = age.seq_prefix |
|
|
|
self._age_info.startDateTime = age.start_time |
|
|
|
self._age_info.startDateTime = age.start_time |
|
|
@ -152,7 +152,8 @@ class Exporter: |
|
|
|
def _generate_builtins(self): |
|
|
|
def _generate_builtins(self): |
|
|
|
# Find the highest two available negative suffixes for BuiltIn and Textures |
|
|
|
# Find the highest two available negative suffixes for BuiltIn and Textures |
|
|
|
# This should generally always resolve to -2 and -1 |
|
|
|
# This should generally always resolve to -2 and -1 |
|
|
|
suffixes = []; _s = -1 |
|
|
|
suffixes = [] |
|
|
|
|
|
|
|
_s = -1 |
|
|
|
while len(suffixes) != 2: |
|
|
|
while len(suffixes) != 2: |
|
|
|
for location in self._pages.values(): |
|
|
|
for location in self._pages.values(): |
|
|
|
if location.page == _s: |
|
|
|
if location.page == _s: |
|
|
@ -166,7 +167,7 @@ class Exporter: |
|
|
|
builtin = self._create_page("BuiltIn", suffixes[1], True) |
|
|
|
builtin = self._create_page("BuiltIn", suffixes[1], True) |
|
|
|
pfm = plPythonFileMod("VeryVerySpecialPythonFileMod") |
|
|
|
pfm = plPythonFileMod("VeryVerySpecialPythonFileMod") |
|
|
|
pfm.filename = self.age_name |
|
|
|
pfm.filename = self.age_name |
|
|
|
self.mgr.AddObject(builtin, pfm) # add_object has lots of overhead |
|
|
|
self.mgr.AddObject(builtin, pfm) # add_object has lots of overhead |
|
|
|
sdlhook = plSceneObject("AgeSDLHook") |
|
|
|
sdlhook = plSceneObject("AgeSDLHook") |
|
|
|
sdlhook.addModifier(pfm.key) |
|
|
|
sdlhook.addModifier(pfm.key) |
|
|
|
self.mgr.AddObject(builtin, sdlhook) |
|
|
|
self.mgr.AddObject(builtin, sdlhook) |
|
|
@ -176,7 +177,7 @@ class Exporter: |
|
|
|
textures = self._create_page("Textures", suffixes[0], True) |
|
|
|
textures = self._create_page("Textures", suffixes[0], True) |
|
|
|
self._pages["Textures"] = textures |
|
|
|
self._pages["Textures"] = textures |
|
|
|
else: |
|
|
|
else: |
|
|
|
self._pages["Textures"] = None # probably easier than looping to find it |
|
|
|
self._pages["Textures"] = None # probably easier than looping to find it |
|
|
|
|
|
|
|
|
|
|
|
def _export_scene_objects(self): |
|
|
|
def _export_scene_objects(self): |
|
|
|
for bl_obj in self._objects: |
|
|
|
for bl_obj in self._objects: |
|
|
@ -211,7 +212,7 @@ class Exporter: |
|
|
|
def _write_pages(self): |
|
|
|
def _write_pages(self): |
|
|
|
dir = os.path.split(self._op.filepath)[0] |
|
|
|
dir = os.path.split(self._op.filepath)[0] |
|
|
|
for name, loc in self._pages.items(): |
|
|
|
for name, loc in self._pages.items(): |
|
|
|
page = self.mgr.FindPage(loc) # not cached because it's C++ owned |
|
|
|
page = self.mgr.FindPage(loc) # not cached because it's C++ owned |
|
|
|
# I know that plAgeInfo has its own way of doing this, but we'd have |
|
|
|
# I know that plAgeInfo has its own way of doing this, but we'd have |
|
|
|
# to do some looping and stuff. This is easier. |
|
|
|
# to do some looping and stuff. This is easier. |
|
|
|
if self.version <= pvMoul: |
|
|
|
if self.version <= pvMoul: |
|
|
|