Leap Motion Control Update Help Question w/code

So with the help of another person I was able to get the leap to initialize in Blender. Which for those who dont know the Leap is a motion control device. I made a video talking about it.

This is the code I’m dealing with. http://www.pasteall.org/40527/python

So through some vector math I’m able to get the Leap coordinates to Blender space in the game engine but I’m wanting to extend this functionality to the main interface or at least to a rig in the BGE and make a boxing game or something like that.

But if I understand the script correctly its making a new object for every reading to display the object instead of making an instance and just updating its x and y. I am just wondering what you would do as far as making the readings come out in another format in which I would be able to interact with bones. (I hope I worded that right) Anyways this might not be the right board for a python / BGE question but its worth a shot.

Im hoping that by controlling bones i could do motion tracking for at least the hands animation of a character. Or cue demolitions for an animation by playing the same speed in the BGE/.

just to help make the script a little more clear the “HandModel” and “FingerModel” are pieces of geometry on another layer.

just another quick question. Im trying to use the Studio Tools Demo DOF filter to make it follow the hand

while the code doesnt say much

the focus is set by another module which would have been logic in the original file.

so to make it follow the position of the hand i would make a proxy hand then set it to follow that in my init file?

In their script it goes as follows

def focus():
focus_obj = G.cam.getScreenRay(logic.mouse.position[0], logic.mouse.position[1], 100)
if focus_obj:
print(‘focus set to’)
dist = (focus_obj.worldPosition - G.cam.worldPosition).length -0.5 # in front of obj
G.focus_target = (G.far * (dist - G.near)) / (dist * (G.far - G.near))

but i dont think im reading the correct part of I am not understanding it. Im sure its the latter.

Hi MasterXeon,
Just to say, I’m looking into integrating the Leap into the BGE too. I’ll no doubt be running into similar problems to you shortly. I’ve some Python experience so might be able to help out on that front.
I’m working on a Windows 7 64 bit machine. What OS are you using?


I had a quick look at the code.
It looks good so far even if it would benefit when refactored into several functions. It will reduce duplicated code as well.

What is “obj[“controller”]” ? it seems not to be a game object. (it can easily be confused with SCA_Controller)

i believe that is what the dictionary is named. But that part isnt giving me any issues.

so heres the main portion of the code that provides the DOF to the DOF custom brick


i am wanting to somehow reroute that to allow me to control the dof with my hand. Any ideas?

this is the original blend. Ive been trying to reverse engineer it and study the fascinating setup.


maybe help you this demo where you controlling dof with a ball and you can turn on/off the range visualization.