Commit 165a40bd authored by Bruno Laurencich's avatar Bruno Laurencich

transmit velocity

parent 373adb70
......@@ -144,6 +144,9 @@ class Chord_Scene_Properties(bpy.types.PropertyGroup):
bpy.types.Bone.capture_bone = bpy.props.BoolProperty(name = "Capture Bone",
description = "Chordata will use this bone to place motion capture data", default = True)
bpy.types.PoseBone.transmit_bone = bpy.props.BoolProperty(name = "Transmit Bone",
description = "Output information of this bone throught OSC", default = False)
# ====== End of BONE PROPERTIES =======
......
No preview for this file type
......@@ -230,7 +230,8 @@ class Chord_advanced_panel(bpy.types.Panel):
if active_b:
box = layout.box()
box.label("Bone [%s]" % active_b.name)
box.prop(active_b, "capture_bone")
box.prop(active_b, "capture_bone", icon="POSE_DATA")
box.prop(target.pose.bones[active_b.name], "transmit_bone", icon="MAN_TRANS")
layout.label("Capture OSC pattern")
layout.prop(self.chord_global, "capture_quat_patt", text= "")
......
import bpy
# from mathutils import Vector
from mathutils import Vector
D=bpy.data
......@@ -138,13 +138,15 @@ def init_osc(options):
print("Not trasmitting OSC")
last_positions = {}
def send_Armature(arm, options):
global INIT
if not INIT: return
global last_positions
msgs = []
for b in arm.pose.bones:
if not b.transmit_bone: continue
if options.send_rot:
q = b.matrix.to_quaternion()
msgs.append(oscbuildparse.OSCMessage("/Chordata/"+b.name,
......@@ -155,7 +157,16 @@ def send_Armature(arm, options):
msgs.append(oscbuildparse.OSCMessage("/Chordata/position/"+b.name,
None, [pos[0], pos[1], pos[2]]))
if options.send_vel:
if b.name in last_positions.keys():
print(b.tail, last_positions[b.name])
vel = b.tail - last_positions[b.name]
msgs.append(oscbuildparse.OSCMessage("/Chordata/velocity/"+b.name,
None, [vel[0], vel[1], vel[2]]))
last_positions[b.name] = b.tail.copy()
if not msgs: return
bun = oscbuildparse.OSCBundle(oscbuildparse.OSC_IMMEDIATELY, msgs)
osc_send(bun, "chordata_client")
......@@ -164,6 +175,8 @@ def send_Armature(arm, options):
def clean():
global INIT
if not INIT: return
global last_positions
last_positions = {}
osch.get_channel("chordata_client").terminate()
INIT = False
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