+ function_enum = [('0',"pass along",""),
+ ('1',"",""),
+ ('2',"",""),
+ ('3',"","")]
+
+ def encode_obj(_,node,node_def):
+ #{
+ node.classtype = 109
+
+ obj = node_def['obj']
+
+ if obj.cv_data.target: _.next[0] = obj.cv_data.target.cv_data.uid
+ if obj.cv_data.target1: _.next[1] = obj.cv_data.target1.cv_data.uid
+ if obj.cv_data.target2: _.next[2] = obj.cv_data.target2.cv_data.uid
+ if obj.cv_data.target3: _.next[3] = obj.cv_data.target3.cv_data.uid
+ #}
+
+ @staticmethod
+ def editor_interface( layout, obj ):
+ #{
+ layout.label( text="The split signals will run in order" )
+ layout.prop( obj.cv_data, "target", text="#0" )
+ layout.prop( obj.cv_data, "target1", text="#1" )
+ layout.prop( obj.cv_data, "target2", text="#2" )
+ layout.prop( obj.cv_data, "target3", text="#3" )
+ #}
+
+ @staticmethod
+ def draw_scene_helpers( obj ):
+ #{
+ global cv_view_verts, cv_view_colours
+
+ c0 = (1,0.5,0.2,1)
+ c1 = (0.8,1,0.1,1)
+ c2 = (0.3,0.9,0.4,1)
+ c3 = (0.1,0.4,1.0,1)
+
+ if obj.cv_data.target:
+ cv_draw_arrow( obj.location, obj.cv_data.target.location, c0, 0.7 )
+ if obj.cv_data.target1:
+ cv_draw_arrow( obj.location, obj.cv_data.target1.location, c1, 0.7 )
+ if obj.cv_data.target2:
+ cv_draw_arrow( obj.location, obj.cv_data.target2.location, c2, 0.7 )
+ if obj.cv_data.target3:
+ cv_draw_arrow( obj.location, obj.cv_data.target3.location, c3, 0.7 )
+ #}
+#}
+
+# Class type 106
+#
+# Purpose:
+#
+class classtype_soundscape(Structure):
+#{
+ _pack_ = 1
+ _fields_ = [("max_instances",c_uint32),
+ ("allow_transitions",c_uint32),
+ ("transition_duration",c_float),
+ ("label",c_uint32)]
+
+ function_enum = [('0',"play",""),
+ ('1',"set position",""),
+ ('2',"",""),
+ ('3',"","")]
+
+ def encode_obj(_,node,node_def):
+ #{
+ node.classtype = 106
+
+ obj = node_def['obj']
+
+ _.max_instances = obj.cv_data.intp
+ _.allow_transitions = obj.cv_data.bp0
+ _.transition_duration = obj.cv_data.fltp
+ _.label = encoder_process_pstr( obj.cv_data.strp )
+ #}
+
+ @staticmethod
+ def editor_interface( layout, obj ):
+ #{
+ layout.prop( obj.cv_data, "intp", text="max instances" )
+ layout.prop( obj.cv_data, "strp", text="label" )
+
+ box = layout.box()
+ box.label( text="If its a 3d sound, where can it spawn?" )
+ box.prop( obj.cv_data, "bp1", text="Only in water" )
+ box.prop( obj.cv_data, "bp2", text="Only on grass" )
+ box.prop( obj.cv_data, "bp3", text="Only on wood" )
+
+ box = layout.box()
+ box.prop( obj.cv_data, "bp0", text="allow transitions" )
+
+ row = box.row()
+ if not obj.cv_data.bp0:
+ row.enabled=False
+ row.prop( obj.cv_data, "fltp", text="transition duration" )
+ #}
+#}
+
+class classtype_logic_chances(Structure):
+#{
+ _pack_ = 1
+ _fields_ = [("targets",c_uint32*2),
+ ("p",c_float)]
+
+ function_enum = [('0',"pass along",""),
+ ('1',"set ratio",""),
+ ('2',"",""),
+ ('3',"","")]
+
+ def encode_obj(_,node,node_def):
+ #{
+ node.classtype = 107
+
+ obj = node_def['obj']
+
+ if obj.cv_data.target: _.targets[0] = obj.cv_data.target.cv_data.uid
+ if obj.cv_data.target1: _.targets[1] = obj.cv_data.target1.cv_data.uid
+
+ _.p = obj.cv_data.fltp
+ #}
+
+ @staticmethod
+ def editor_interface( layout, obj ):
+ #{
+ box = layout.box()
+ box.prop( obj.cv_data, "target", text="red" )
+ box.prop( obj.cv_data, "target1", text="black" )
+ box.prop( obj.cv_data, "fltp", text="p(red)" )
+ #}
+
+ @staticmethod
+ def draw_scene_helpers( obj ):
+ #{
+ global cv_view_verts, cv_view_colours
+
+ red = (1,0,0,1)
+ black = (0,0,0,1)
+
+ if obj.cv_data.target:
+ cv_draw_arrow( obj.location, obj.cv_data.target.location, red, 0.7 )
+ if obj.cv_data.target1:
+ cv_draw_arrow( obj.location, obj.cv_data.target1.location, black, 0.7 )
+ #}
+#}
+
+# Classtype 102 [ DEPRECATED ]
+#
+# Purpose: sends a signal to another entity
+#
+class classtype_logic_relay(Structure):
+#{
+ _pack_ = 1
+ _fields_ = [("targets",c_uint32*4)]
+
+ def encode_obj(_, node,node_def ):
+ #{
+ node.classtype = 102
+ obj = node_def['obj']
+ if obj.cv_data.target:
+ _.targets[0] = obj.cv_data.target.cv_data.uid
+ if obj.cv_data.target1:
+ _.targets[1] = obj.cv_data.target1.cv_data.uid
+ if obj.cv_data.target2:
+ _.targets[2] = obj.cv_data.target2.cv_data.uid
+ if obj.cv_data.target3:
+ _.targets[3] = obj.cv_data.target3.cv_data.uid
+ #}
+
+ @staticmethod
+ def draw_scene_helpers( obj ):
+ #{
+ global cv_view_verts, cv_view_colours
+
+ if obj.cv_data.target:
+ cv_draw_arrow( obj.location, obj.cv_data.target.location, [1,1,1,1] )
+ if obj.cv_data.target1:
+ cv_draw_arrow( obj.location, obj.cv_data.target1.location, [1,1,1,1] )
+ if obj.cv_data.target2:
+ cv_draw_arrow( obj.location, obj.cv_data.target2.location, [1,1,1,1] )
+ if obj.cv_data.target3:
+ cv_draw_arrow( obj.location, obj.cv_data.target3.location, [1,1,1,1] )
+ #}
+
+ @staticmethod
+ def editor_interface( layout, obj ):
+ #{
+ layout.prop( obj.cv_data, "target", text="Triggers" )
+ layout.prop( obj.cv_data, "target1", text="Triggers" )
+ layout.prop( obj.cv_data, "target2", text="Triggers" )
+ layout.prop( obj.cv_data, "target3", text="Triggers" )
+ #}
+#}
+
+# Classtype 14
+#
+# Purpose: Plays some audio (44100hz .ogg vorbis only)
+# NOTE: There is a 32mb limit on the audio buffer, world audio is
+# decompressed and stored in signed 16 bit integers (2 bytes)
+# per sample.
+#
+# volume: not used if has 3D flag
+# flags:
+# AUDIO_FLAG_LOOP 0x1
+# AUDIO_FLAG_SPACIAL_3D 0x4 (Probably what you want)
+# AUDIO_FLAG_AUTO_START 0x8 (Play when the world starts)
+# ......
+# the rest are just internal flags, only use the above 3.
+#
+class classtype_audio(Structure):
+#{
+ _pack_ = 1
+ _fields_ = [("pstr_file",c_uint32),
+ ("flags",c_uint32),
+ ("volume",c_float)]
+
+ def encode_obj(_, node,node_def ):
+ #{
+ node.classtype = 14
+
+ obj = node_def['obj']
+
+ _.pstr_file = encoder_process_pstr( obj.cv_data.strp )
+
+ flags = 0x00
+ if obj.cv_data.bp0: flags |= 0x1
+ if obj.cv_data.bp1: flags |= 0x4
+ if obj.cv_data.bp2: flags |= 0x8
+
+ if obj.cv_data.audio_format == 'stereo':
+ flags |= 0x200
+ if obj.cv_data.audio_format == 'remain compressed':
+ flags |= 0x400
+ if obj.cv_data.audio_format == 'synthetic bird':
+ flags |= 0x1000
+
+ _.flags = flags
+ _.volume = obj.cv_data.fltp
+ #}
+
+ @staticmethod
+ def editor_interface( layout, obj ):
+ #{
+ layout.prop( obj.cv_data, "strp", text = "File (.ogg)" )
+
+ layout.prop( obj.cv_data, "bp0", text = "Looping" )
+ layout.prop( obj.cv_data, "bp1", text = "3D Audio" )
+ layout.prop( obj.cv_data, "bp2", text = "Auto Start" )
+ layout.prop( obj.cv_data, "audio_format" )
+
+ layout.prop( obj.cv_data, "fltp", text = "Volume (0-1)" )
+ #}
+
+ @staticmethod
+ def draw_scene_helpers( obj ):
+ #{
+ global cv_view_verts, cv_view_colours
+
+ cv_draw_sphere( obj.location, obj.scale[0], [1,1,0,1] )
+ #}
+#}
+
+
+# Classtype 200
+#
+# Purpose: world light
+#
+class classtype_world_light( Structure ):
+#{
+ _pack_ = 1
+ _fields_ = [("type",c_uint32),
+ ("colour",c_float*4),
+ ("angle",c_float),
+ ("range",c_float)]
+
+ def encode_obj(_, node, node_def):
+ #{
+ node.classtype = 200
+
+ obj = node_def['obj']
+ data = obj.data
+ _.colour[0] = data.color[0]
+ _.colour[1] = data.color[1]
+ _.colour[2] = data.color[2]
+ _.colour[3] = data.energy
+ _.range = data.cutoff_distance # this has to be manually set
+ # TODO: At some point, automate a min
+ # threshold value
+
+ if obj.data.type == 'POINT':
+ #{
+ _.type = 0
+ _.angle = 0.0
+ #}
+ elif obj.data.type == 'SPOT':
+ #{
+ _.type = 1
+ _.angle = data.spot_size*0.5
+ #}
+
+ if data.cv_data.bp0:
+ _.type += 2
+ #}
+
+ @staticmethod
+ def editor_interface( layout, obj ):
+ #{
+ pass
+ #}
+#}
+
+# Classtype 201
+#
+# Purpose: lighting settings for world
+#
+class classtype_lighting_info(Structure):
+#{
+ _pack_ = 1
+ _fields_ = [("colours",(c_float*3)*3),
+ ("directions",(c_float*2)*3),
+ ("states",c_uint32*3),
+ ("shadow_spread",c_float),
+ ("shadow_length",c_float),
+ ("ambient",c_float*3)]
+
+ def encode_obj(_, node, node_def):
+ #{
+ node.classtype = 201
+
+ # TODO
+ #}
+
+ @staticmethod
+ def editor_interface( layout, obj ):
+ #{
+ pass
+ #}
+#}
+
+class classtype_spawn_link(Structure):
+#{
+ _pack_ = 1
+ _fields_ = [("connections",c_uint32*4)]
+
+ def encode_obj(_, node,node_def ):
+ #{
+ node.classtype = 0
+ #}
+
+ @staticmethod
+ def editor_interface( layout, obj ):
+ #{
+ pass
+ #}
+
+ @staticmethod
+ def draw_scene_helpers( obj ):
+ #{
+ global cv_view_verts, cv_view_colours
+
+ count = 0
+
+ for obj1 in bpy.context.collection.objects:
+ #{
+ if (obj1.cv_data.classtype != 'classtype_spawn_link') and \
+ (obj1.cv_data.classtype != 'classtype_spawn') :
+ continue
+
+ if (obj1.location - obj.location).length < 40.0:
+ #{
+ cv_draw_line( obj.location, obj1.location, [1,1,1,1] )
+ count +=1
+ #}
+
+ if count == 4:
+ break
+ #}
+
+ cv_draw_sphere( obj.location, 20.0, [0.5,0,0.2,0.4] )
+ #}
+#}
+
+# ---------------------------------------------------------------------------- #
+# #
+# Compiler section #
+# #
+# ---------------------------------------------------------------------------- #
+
+# Current encoder state
+#
+g_encoder = None
+
+# Reset encoder
+#
+def encoder_init( collection ):
+#{
+ global g_encoder
+
+ g_encoder = \