@ -43,9 +43,6 @@ class Exporter:
def run ( self ) :
with logger . ExportLogger ( self . _op . filepath ) as self . report :
self . report . msg ( " Exporting ' {} .age ' " , self . age_name )
start = time . perf_counter ( )
# Step 0: Init export resmgr and stuff
self . mgr = manager . ExportManager ( self )
self . mesh = mesh . MeshConverter ( self )
@ -54,6 +51,18 @@ class Exporter:
self . animation = animation . AnimationConverter ( self )
self . sumfile = sumfile . SumFile ( )
# Step 0.9: Init the progress mgr
self . report . progress_add_step ( " Collecting Objects " )
self . report . progress_add_step ( " Harvesting Actors " )
if self . _op . bake_lighting :
etlight . LightBaker . add_progress_steps ( self . report )
self . report . progress_add_step ( " Exporting Scene Objects " )
self . report . progress_add_step ( " Exporting Logic Nodes " )
self . report . progress_add_step ( " Finalizing Plasma Logic " )
self . report . progress_add_step ( " Exporting Textures " )
self . report . progress_add_step ( " Composing Geometry " )
self . report . progress_start ( " EXPORTING AGE " )
# Step 1: Create the age info and the pages
self . _export_age_info ( )
@ -90,17 +99,18 @@ class Exporter:
# Step 5.1: Save out the export report.
# If the export fails and this doesn't save, we have bigger problems than
# these little warnings and notices.
self . report . progress_end ( )
self . report . save ( )
# And finally we crow about how awesomely fast we are...
end = time . perf_counter ( )
self . report . msg ( " \n Exported {} .age in {:.2f} seconds " , self . age_name , end - start )
def _bake_static_lighting ( self ) :
oven = etlight . LightBaker ( self . report )
oven . bake_static_lighting ( self . _objects )
def _collect_objects ( self ) :
self . report . progress_advance ( )
self . report . progress_range = len ( bpy . data . objects )
inc_progress = self . report . progress_increment
# Grab a naive listing of enabled pages
age = bpy . context . scene . world . plasma_age
pages_enabled = frozenset ( [ page . name for page in age . pages if page . enabled ] )
@ -135,6 +145,7 @@ class Exporter:
self . _objects . append ( obj )
elif page not in all_pages :
error . add ( page , obj . name )
inc_progress ( )
error . raise_if_error ( )
def _export_age_info ( self ) :
@ -186,7 +197,11 @@ class Exporter:
return so . coord . object
def _export_scene_objects ( self ) :
self . report . progress_advance ( )
self . report . progress_range = len ( self . _objects )
inc_progress = self . report . progress_increment
log_msg = self . report . msg
for bl_obj in self . _objects :
log_msg ( " \n [SceneObject ' {} ' ] " . format ( bl_obj . name ) )
@ -213,6 +228,7 @@ class Exporter:
for mod in bl_obj . plasma_modifiers . modifiers :
log_msg ( " Exporting ' {} ' modifier " . format ( mod . bl_label ) , indent = 1 )
mod . export ( self , bl_obj , sceneobject )
inc_progress ( )
def _export_empty_blobj ( self , so , bo ) :
# We don't need to do anything here. This function just makes sure we don't error out
@ -230,18 +246,30 @@ class Exporter:
self . report . msg ( " No material(s) on the ObData, so no drawables " , indent = 1 )
def _export_referenced_node_trees ( self ) :
self . report . progress_advance ( )
self . report . progress_range = len ( self . want_node_trees )
inc_progress = self . report . progress_increment
self . report . msg ( " \n Checking Logic Trees... " )
need_to_export = ( ( name , bo , so ) for name , ( bo , so ) in self . want_node_trees . items ( )
if name not in self . node_trees_exported )
need_to_export = [ ( name , bo , so ) for name , ( bo , so ) in self . want_node_trees . items ( )
if name not in self . node_trees_exported ]
self . report . progress_value = len ( self . want_node_trees ) - len ( need_to_export )
for tree , bo , so in need_to_export :
self . report . msg ( " NodeTree ' {} ' " , tree , indent = 1 )
bpy . data . node_groups [ tree ] . export ( self , bo , so )
inc_progress ( )
def _harvest_actors ( self ) :
self . report . progress_advance ( )
self . report . progress_range = len ( self . _objects ) + len ( bpy . data . textures )
inc_progress = self . report . progress_increment
for bl_obj in self . _objects :
for mod in bl_obj . plasma_modifiers . modifiers :
if mod . enabled :
self . actors . update ( mod . harvest_actors ( ) )
inc_progress ( )
# This is a little hacky, but it's an edge case... I guess?
# We MUST have CoordinateInterfaces for EnvironmentMaps (DCMs, bah)
@ -251,6 +279,7 @@ class Exporter:
viewpt = envmap . viewpoint_object
if viewpt is not None :
self . actors . add ( viewpt . name )
inc_progress ( )
def has_coordiface ( self , bo ) :
if bo . type in { " CAMERA " , " EMPTY " , " LAMP " } :
@ -269,6 +298,10 @@ class Exporter:
return False
def _post_process_scene_objects ( self ) :
self . report . progress_advance ( )
self . report . progress_range = len ( self . _objects )
inc_progress = self . report . progress_increment
mat_mgr = self . mesh . material
for bl_obj in self . _objects :
sceneobject = self . mgr . find_object ( plSceneObject , bl = bl_obj )
@ -291,3 +324,4 @@ class Exporter:
proc = getattr ( mod , " post_export " , None )
if proc is not None :
proc ( self , bl_obj , sceneobject )
inc_progress ( )