Commit 489631e6 authored by Bruno Laurencich's avatar Bruno Laurencich

transmit distance

parent 165a40bd
......@@ -105,6 +105,8 @@ class Chord_Properties(bpy.types.AddonPreferences):
send_rot = props.BoolProperty( name="Send rotation", default = True )
send_pos = props.BoolProperty( name="Send position", default = False )
send_vel = props.BoolProperty( name="Send velocity", default = False )
send_dist = props.BoolProperty( name="Send Distance", default = False )
# props = props.EnumProperty(\
......@@ -135,6 +137,18 @@ class Chord_Scene_Properties(bpy.types.PropertyGroup):
description="An empty that have as children sensor helper objects",
type=bpy.types.Object)#, update=target_update
d1 = bpy.props.PointerProperty(name = "Target distance object #1",
description="An object to reference the distance from a bone",
type=bpy.types.Object)
d2 = bpy.props.PointerProperty(name = "Target distance object #2",
description="An object to reference the distance from a bone",
type=bpy.types.Object)
d3 = bpy.props.PointerProperty(name = "Target distance object #3",
description="An object to reference the distance from a bone",
type=bpy.types.Object)
# ====== End of GLOBAL PROPERTIES =======
# =======================================
......
No preview for this file type
......@@ -188,6 +188,15 @@ class Chord_send_panel(bpy.types.Panel):
layout.prop(self.chord_global.send, "send_rot", text="Rotation")
layout.prop(self.chord_global.send, "send_pos", text="Position")
layout.prop(self.chord_global.send, "send_vel", text="Velocity")
layout.prop(self.chord_global.send, "send_dist", text="Distance")
if self.chord_global.send.send_dist:
layout.prop(context.scene.chordata, "d1", text="Target #1")
layout.prop(context.scene.chordata, "d2", text="Target #2")
layout.prop(context.scene.chordata, "d3", text="Target #3")
......
......@@ -141,10 +141,12 @@ def init_osc(options):
last_positions = {}
def send_Armature(arm, options):
#TODO: this works, but the implementation could be much more elegant.. (and performative)
global INIT
if not INIT: return
global last_positions
msgs = []
chord_scene = bpy.context.scene.chordata
for b in arm.pose.bones:
if not b.transmit_bone: continue
if options.send_rot:
......@@ -166,6 +168,23 @@ def send_Armature(arm, options):
last_positions[b.name] = b.tail.copy()
if options.send_dist:
w_tail = arm.location + b.tail
if chord_scene.d1:
dist = w_tail - chord_scene.d1.location
msgs.append(oscbuildparse.OSCMessage("/Chordata/dist_1/"+b.name,
None, [dist.length]))
if chord_scene.d2:
dist = w_tail - chord_scene.d2.location
msgs.append(oscbuildparse.OSCMessage("/Chordata/dist_2/"+b.name,
None, [dist.length]))
if chord_scene.d3:
dist = w_tail - chord_scene.d3.location
msgs.append(oscbuildparse.OSCMessage("/Chordata/dist_3/"+b.name,
None, [dist.length]))
if not msgs: return
bun = oscbuildparse.OSCBundle(oscbuildparse.OSC_IMMEDIATELY, msgs)
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