Commit 17cfae9d authored by Bruno Laurencich's avatar Bruno Laurencich

split output

parent 489631e6
......@@ -97,6 +97,12 @@ class Chord_Properties(bpy.types.AddonPreferences):
items= u.transmition_methods() + [("none", "None", "None")] ,
default="none")
split_msg = props.BoolProperty( name="Split output in chunks",
description="""Split the retransmision on bundles containing a maximun number of messages.
Useful when the buffer of the receiving parts overflows""", default = False )
chunks_n = notochord_dest_port = props.IntProperty( name="Max elements per chunk", default = 5 )
ip_addr = props.StringProperty( default = "127.0.0.1" )
multicast_grp_addr = props.StringProperty( default = "239.0.0.2" )
dest_port = props.IntProperty( default = 7000 )
......
No preview for this file type
......@@ -195,6 +195,15 @@ class Chord_send_panel(bpy.types.Panel):
layout.prop(context.scene.chordata, "d2", text="Target #2")
layout.prop(context.scene.chordata, "d3", text="Target #3")
layout.label("Split output:")
row = layout.row()
container = row
if self.chord_global.send.split_msg:
container = row.split(percentage=0.6)
container.prop(self.chord_global.send, "split_msg")
if self.chord_global.send.split_msg:
container.prop(self.chord_global.send, "chunks_n", text="max")
......@@ -234,6 +243,9 @@ class Chord_advanced_panel(bpy.types.Panel):
layout.prop(self.chord_global, "notochord_hostname", text="")
target = context.scene.chordata.target
if target and target.mode == "POSE":
active_b = target.data.bones.active
if active_b:
......@@ -241,6 +253,10 @@ class Chord_advanced_panel(bpy.types.Panel):
box.label("Bone [%s]" % active_b.name)
box.prop(active_b, "capture_bone", icon="POSE_DATA")
box.prop(target.pose.bones[active_b.name], "transmit_bone", icon="MAN_TRANS")
box.label("Set transmit on:")
row = box.row(align=True)
row.operator("chordata.toggle_trans_bones", "All bones").clear = True
row.operator("chordata.toggle_trans_bones", "No bones").clear
layout.label("Capture OSC pattern")
layout.prop(self.chord_global, "capture_quat_patt", text= "")
......
......@@ -96,17 +96,39 @@ class Chord_Play_Animation(bpy.types.Operator):
osc_terminate()
class Chord_Play_Animation(bpy.types.Operator):
class Chord_Stop_Animation(bpy.types.Operator):
"""Stops the reproduction of the animation"""
bl_idname = "chordata.stop"
bl_label = "Chordata: Stops capture reproduction and transmition"
bl_options = {'REGISTER'}
def execute(self, context):
self.chord_global = context.user_preferences.addons[__package__].preferences
self.chord_global.playing = False
return {"FINISHED"}
class Chord_Toggle_Bones_Send(bpy.types.Operator):
"""Stops the reproduction of the animation"""
bl_idname = "chordata.toggle_trans_bones"
bl_label = "Chordata: Set or clear the transmission property of all the bones"
bl_options = {'REGISTER'}
clear = bpy.props.BoolProperty( default = False )
@classmethod
def poll(cls, context):
chord_global = context.user_preferences.addons[__package__].preferences
return context.scene.chordata.target != None
def execute(self, context):
arm = context.scene.chordata.target
for b in arm.pose.bones:
b.transmit_bone = self.clear
return {"FINISHED"}
INIT = False
def init_osc(options):
......@@ -140,6 +162,11 @@ def init_osc(options):
last_positions = {}
def chunks(l, n):
"""Yield successive n-sized chunks from l."""
for i in range(0, len(l), n):
yield l[i:i + n]
def send_Armature(arm, options):
#TODO: this works, but the implementation could be much more elegant.. (and performative)
global INIT
......@@ -151,7 +178,7 @@ def send_Armature(arm, options):
if not b.transmit_bone: continue
if options.send_rot:
q = b.matrix.to_quaternion()
msgs.append(oscbuildparse.OSCMessage("/Chordata/"+b.name,
msgs.append(oscbuildparse.OSCMessage("/Chordata/rotation/"+b.name,
None, [q[0], q[1], q[2], q[3]]))
if options.send_pos:
......@@ -186,7 +213,10 @@ def send_Armature(arm, options):
if not msgs: return
bun = oscbuildparse.OSCBundle(oscbuildparse.OSC_IMMEDIATELY, msgs)
chord_global = context.user_preferences.addons[__package__].preferences
if chord_global.send.split_msg:
for ch in chunks(msgs, chord_global.send.chunks_n):
bun = oscbuildparse.OSCBundle(oscbuildparse.OSC_IMMEDIATELY, ch)
osc_send(bun, "chordata_client")
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment