@ -25,8 +25,6 @@ from ...addon_prefs import game_versions
from . . . exporter import ExportError , utils
from . . . exporter import ExportError , utils
from . base import PlasmaModifierProperties , PlasmaModifierLogicWiz , PlasmaModifierUpgradable
from . base import PlasmaModifierProperties , PlasmaModifierLogicWiz , PlasmaModifierUpgradable
from . . . import idprops
from . . . import idprops
from . . . helpers import TemporaryObject
journal_pfms = {
journal_pfms = {
pvPots : {
pvPots : {
@ -198,7 +196,7 @@ class PlasmaJournalBookModifier(PlasmaModifierProperties, PlasmaModifierLogicWiz
get = _get_translation , set = _set_translation ,
get = _get_translation , set = _set_translation ,
options = set ( ) )
options = set ( ) )
def export ( self , exporter , bo , s o ) :
def pre_ export( self , exporter , bo ) :
our_versions = ( globals ( ) [ j ] for j in self . versions )
our_versions = ( globals ( ) [ j ] for j in self . versions )
version = exporter . mgr . getVer ( )
version = exporter . mgr . getVer ( )
if version not in our_versions :
if version not in our_versions :
@ -217,32 +215,21 @@ class PlasmaJournalBookModifier(PlasmaModifierProperties, PlasmaModifierLogicWiz
exporter . locman . add_journal ( self . key_name , i . language , i . text_id , indent = 2 )
exporter . locman . add_journal ( self . key_name , i . language , i . text_id , indent = 2 )
if self . clickable_region is None :
if self . clickable_region is None :
# Create a region for the clickable's condition
with utils . bmesh_object ( " {} _Journal_ClkRgn " . format ( self . key_name ) ) as ( rgn_obj , bm ) :
rgn_mesh = bpy . data . meshes . new ( " {} _Journal_ClkRgn " . format ( self . key_name ) )
self . temp_rgn = bpy . data . objects . new ( " {} _Journal_ClkRgn " . format ( self . key_name ) , rgn_mesh )
bm = bmesh . new ( )
bmesh . ops . create_cube ( bm , size = ( 6.0 ) )
bmesh . ops . create_cube ( bm , size = ( 6.0 ) )
bmesh . ops . transform ( bm , matrix = mathutils . Matrix . Translation ( bo . location - self . temp_rgn . location ) , space = self . temp_rgn . matrix_world , verts = bm . verts )
bmesh . ops . transform ( bm , matrix = mathutils . Matrix . Translation ( bo . location - rgn_obj . location ) ,
bm . to_mesh ( rgn_mesh )
space = rgn_obj . matrix_world , verts = bm . verts )
bm . free ( )
rgn_obj . plasma_object . enabled = True
rgn_obj . hide_render = True
# No need to enable the object as a Plasma object; we're exported automatically as part of the node tree.
yield rgn_obj
# It does need a page, however, so we'll put it in the same place as the journal object itself.
self . temp_rgn . plasma_object . page = bo . plasma_object . page
bpy . context . scene . objects . link ( self . temp_rgn )
else :
else :
# Use the region provided
# Use the region provided
self . temp_ rgn = self . clickable_region
rgn_obj = self . clickable_region
# Generate the logic nodes
# Generate the logic nodes
with self . generate_logic ( bo , age_name = exporter . age_name , version = version ) as tree :
yield self . convert_logic ( bo , age_name = exporter . age_name , rgn_obj = rgn_obj , version = version )
tree . export ( exporter , bo , so )
# Get rid of our temporary clickable region
def logicwiz ( self , bo , tree , age_name , rgn_obj , version ) :
if self . clickable_region is None :
bpy . context . scene . objects . unlink ( self . temp_rgn )
def logicwiz ( self , bo , tree , age_name , version ) :
nodes = tree . nodes
nodes = tree . nodes
# Assign journal script based on target version
# Assign journal script based on target version
@ -261,13 +248,13 @@ class PlasmaJournalBookModifier(PlasmaModifierProperties, PlasmaModifierLogicWiz
journalnode . update ( )
journalnode . update ( )
if version < = pvPots :
if version < = pvPots :
self . _create_pots_nodes ( bo , nodes , journalnode , age_name )
self . _create_pots_nodes ( bo , nodes , journalnode , age_name , rgn_obj )
else :
else :
self . _create_moul_nodes ( bo , nodes , journalnode , age_name )
self . _create_moul_nodes ( bo , nodes , journalnode , age_name , rgn_obj )
def _create_pots_nodes ( self , clickable_object , nodes , journalnode , age_name ) :
def _create_pots_nodes ( self , clickable_object , nodes , journalnode , age_name , rgn_obj ) :
clickable_region = nodes . new ( " PlasmaClickableRegionNode " )
clickable_region = nodes . new ( " PlasmaClickableRegionNode " )
clickable_region . region_object = self . temp_ rgn
clickable_region . region_object = rgn_obj
facing_object = nodes . new ( " PlasmaFacingTargetNode " )
facing_object = nodes . new ( " PlasmaFacingTargetNode " )
facing_object . directional = False
facing_object . directional = False
@ -295,9 +282,9 @@ class PlasmaJournalBookModifier(PlasmaModifierProperties, PlasmaModifierLogicWiz
height . link_output ( journalnode , " pfm " , " BookHeight " )
height . link_output ( journalnode , " pfm " , " BookHeight " )
height . value_float = self . book_scale_h / 100.0
height . value_float = self . book_scale_h / 100.0
def _create_moul_nodes ( self , clickable_object , nodes , journalnode , age_name ) :
def _create_moul_nodes ( self , clickable_object , nodes , journalnode , age_name , rgn_obj ) :
clickable_region = nodes . new ( " PlasmaClickableRegionNode " )
clickable_region = nodes . new ( " PlasmaClickableRegionNode " )
clickable_region . region_object = self . temp_ rgn
clickable_region . region_object = rgn_obj
facing_object = nodes . new ( " PlasmaFacingTargetNode " )
facing_object = nodes . new ( " PlasmaFacingTargetNode " )
facing_object . directional = False
facing_object . directional = False
@ -456,22 +443,33 @@ class PlasmaLinkingBookModifier(PlasmaModifierProperties, PlasmaModifierLogicWiz
default = 255 ,
default = 255 ,
subtype = " UNSIGNED " )
subtype = " UNSIGNED " )
def export ( self , exporter , bo , so ) :
def _check_version ( self , * args ) - > bool :
our_versions = ( globals ( ) [ j ] for j in self . versions )
our_versions = frozenset ( ( globals ( ) [ j ] for j in self . versions ) )
version = exporter . mgr . getVer ( )
return frozenset ( args ) & our_versions
if version not in our_versions :
def pre_export ( self , exporter , bo ) :
if not self . _check_version ( exporter . mgr . getVer ( ) ) :
# We aren't needed here
# We aren't needed here
exporter . report . port ( " Object ' {} ' has a LinkingBookMod not enabled for export to the selected engine. Skipping. " ,
exporter . report . port ( " Object ' {} ' has a LinkingBookMod not enabled for export to the selected engine. Skipping. " ,
bo . name , indent = 2 )
self . id_data . name , indent = 2 )
return
return
if self . clickable is None :
# Auto-generate a six-foot cube region around the clickable if none was provided.
raise ExportError ( " {} : Linking Book modifier requires a clickable! " , bo . name )
if self . clickable_region is None :
with utils . bmesh_object ( " {} _LinkingBook_ClkRgn " . format ( self . key_name ) ) as ( rgn_obj , bm ) :
bmesh . ops . create_cube ( bm , size = ( 6.0 ) )
rgn_offset = mathutils . Matrix . Translation ( self . clickable . location - bo . location )
bmesh . ops . transform ( bm , matrix = rgn_offset , space = bo . matrix_world , verts = bm . verts )
rgn_obj . plasma_object . enabled = True
rgn_obj . hide_render = True
yield rgn_obj
else :
rgn_obj = self . clickable_region
if self . seek_point is None :
yield self . convert_logic ( bo , age_name = exporter . age_name , version = exporter . mgr . getVer ( ) , region = rgn_obj )
raise ExportError ( " {} : Linking Book modifier requires a seek point! " , bo . name )
if version < = pvPots :
def export ( self , exporter , bo , so ) :
if self . _check_version ( pvPrime , pvPots ) :
# Create ImageLibraryMod in which to store the Cover, Linking Panel, and Stamp images
# Create ImageLibraryMod in which to store the Cover, Linking Panel, and Stamp images
ilmod = exporter . mgr . find_create_object ( plImageLibMod , so = so , name = self . key_name )
ilmod = exporter . mgr . find_create_object ( plImageLibMod , so = so , name = self . key_name )
@ -481,23 +479,9 @@ class PlasmaLinkingBookModifier(PlasmaModifierProperties, PlasmaModifierLogicWiz
exporter . mesh . material . export_prepared_image ( owner = ilmod , image = image ,
exporter . mesh . material . export_prepared_image ( owner = ilmod , image = image ,
allowed_formats = { " JPG " , " PNG " } , extension = " hsm " )
allowed_formats = { " JPG " , " PNG " } , extension = " hsm " )
# Auto-generate a six-foot cube region around the clickable if none was provided.
def harvest_actors ( self ) :
if self . clickable_region is None :
if self . seek_point is not None :
# Create a region for the clickable's condition
yield self . seek_point . name
def _make_rgn ( bm ) :
bmesh . ops . create_cube ( bm , size = ( 6.0 ) )
rgn_offset = mathutils . Matrix . Translation ( self . clickable . location - bo . location )
bmesh . ops . transform ( bm , matrix = rgn_offset , space = bo . matrix_world , verts = bm . verts )
with utils . bmesh_temporary_object ( " {} _LinkingBook_ClkRgn " . format ( self . key_name ) ,
_make_rgn , self . clickable . plasma_object . page ) as temp_rgn :
# Generate the logic nodes
self . export_logic ( exporter , bo , so , age_name = exporter . age_name , version = version ,
region = temp_rgn )
else :
# Generate the logic nodes
self . export_logic ( exporter , bo , so , age_name = exporter . age_name , version = version ,
region = self . clickable_region )
def logicwiz ( self , bo , tree , age_name , version , region ) :
def logicwiz ( self , bo , tree , age_name , version , region ) :
nodes = tree . nodes
nodes = tree . nodes
@ -655,6 +639,8 @@ class PlasmaLinkingBookModifier(PlasmaModifierProperties, PlasmaModifierLogicWiz
linking_panel_name . value = self . link_destination if self . link_destination else self . age_name
linking_panel_name . value = self . link_destination if self . link_destination else self . age_name
linking_panel_name . link_output ( linkingnode , " pfm " , " TargetAge " )
linking_panel_name . link_output ( linkingnode , " pfm " , " TargetAge " )
def harvest_actors ( self ) :
def sanity_check ( self ) :
if self . seek_point is not None :
if self . clickable is None :
yield self . seek_point . name
raise ExportError ( " {} : Linking Book modifier requires a clickable! " , self . id_data . name )
if self . seek_point is None :
raise ExportError ( " {} : Linking Book modifier requires a seek point! " , self . id_data . name )