Hello,
I created a scene where at the beginning a title is presented which disappears after 5 seconds and a video appears. When the video finishes, two buttons appear. When a button is clicked, an image appears and the button container disappears.
I tried to adapt this for a kinect azure interaction where I created the following:
the kinectazure TOP is connected to a kinectazure CHOP. There is also a mousein CHOP whose tx and ty channels were renamed to p1/hand_l:tx and p1/hand_l:ty as they are called in the kinectazure. The rename CHOP and the kinectazure CHOP are connected to a replace CHOP. In this way, the mouse simulates the hand movements of the kinect.
There is also a circle TOP connected to a transform TOP, null TOP and a container COMP called hand_cursor.
The replace CHOP is connected to a select CHOP which is connected to a null CHOP where the channels are connected with the x and y positions of the hand_cursor container. The null CHOP is connected to chopexecute DAT with the following code:
def onValueChange(channel: Channel, sampleIndex: int, val: float,
prev: float):
“”"
Called when a channel value changes.
Args:
channel: The Channel object which has changed
sampleIndex: The index of the changed sample
val: The numeric value of the changed sample
prev: The previous sample value
"""
#x = op('null7')['p1/hand_l:tx']
#y = op('null7')['p1/hand_l:ty']
#if 100 < x < 400 and 500 < y < 600:
# Cursor is over Button 1
#op('container3').par.display = True
#op('container3').par.display = False
# Get hand position
x = tdu.remap(
op('null7')['p1/hand_l:tx'],
-1, 1,
0, 1210
)
y = tdu.remap(
op('null7')['p1/hand_l:ty'],
-0.49, 0.525,
0, 650
)
# Print the position so we can check it
print("X:", x, "Y:", y)
# Button 1 area
button1 = (
270 < x < 1030 and
195 < y < 335
)
# Button 2 area
button2 = (
270 < x < 1030 and
40 < y < 180
)
# Previous states
wasButton1 = me.fetch('button1Hover', False)
wasButton2 = me.fetch('button2Hover', False)
# Cursor ENTERED Button 1
if button1 and not wasButton1:
print("BUTTON 1 CLICK")
op('container3').par.display = True
op('container4').par.display = False
# Hide the container holding the two buttons and hide the mouse cursor
op('container6').par.display = 0
op('hand_l_cursor').par.display = 0
# Cursor ENTERED Button 2
elif button2 and not wasButton2:
print("BUTTON 2 CLICK")
op('container4').par.display = True
op('container3').par.display = False
# Hide the container holding the two buttons and hide the mouse cursor
op('container6').par.display = 0
op('hand_l_cursor').par.enable = 0
# Button 1
#if button1:
#print("BUTTON 1 HOVER")
# Button 2
#if button2:
#print("BUTTON 2 HOVER")
return
Unfortunately, this doesn’t work properly. When the mouse cursor moves on one of the buttons, the associated image appears, and then the button container and the mouse cursor disappear, but you can still change the images when invisibly.
Can someone help in debugging so that when a button is clicked, the associated image appears and the button container and the mouse cursor disappear ?
beginningscene_kinect.toe (11.5 KB)
