Hello Ventuzians!
THE FORUMS ARE CLOSED!

Please join our discord server HERE!! << click me :D

We are shutting our Ventuz Forum, but don't worry, it will all be archived for you to search in if you have a query. From now on, please add all your comments, questions or observations into our Discord Server

Thanks for the great time - see you on discord!!
Dee, Karol, Daniel and the whoooole Product and Support team!

...Use LeapMotion in Ventuz

Q and A about functionality and how to solve a special task for your application.

Moderator: Support

User avatar
ErikB
Posts: 212
Joined: 10 Jan 2012, 12:52

...Use LeapMotion in Ventuz

Post by ErikB » 07 Oct 2013, 20:11

How To Use Leap Motion in Ventuz (the 12 Step Program):

CAVEAT: Requires some understanding of C# and some gray matter. Also, this is meant as a basic quick how-to not an exhaustive analysis. We take no responsibility for you doing something stupid, or for actually following this to the letter and it still resulting in a cataclysmic implosion of doom and despair.

Here we go:
  • download the Leap Motion SDK
  • Install the C# assemblies in your Windows GAC
  • [list]
  • To do this, find the LeapCSharp.Net4.0.dll and LeapCSharp.Net3.5.dll in the LeapSDK/lib folder
  • Install them using the gacutil.exe tool that comes with Visual Studio or the Microsoft SDK (google to find out more)
  • Open a cmd window as administrator, go to where gacutil is (often in C:\Program Files (x86)\microsoft SDK\something..)
  • The syntax is gacutil.exe –i C:\fishstick\spoon\LeapCSharp.Net4.0.dll
  • Repeat above for 3.5.dll
[*]Now you should have the hard part completed.
[*]Copy the Leapd.dll and Leap.dll (and maybe LeapCSharp.dll?) into your Ventuz folder.
[*]Done! Now Leap is useable by Ventuz. Congratulations.
[*] Oh. You want more?
[*] Okay, fine. Fire up the Leap Drivers.
[*] Next start a Ventuz Scene and get a text node and an axis and create a script node.
[*] Add the Leap Assembly to your script
  • Open the script node and click on References on the bottom of the left panel
  • Right click on GAC Assemblies and click Add Reference
  • Find LeapCsharp.NET4.0 and click okay
  • Done
[*] Steal the Leap Motion Code to get you started
  • Open the CSharp example in the LeapSDK folder and copy it
  • Paste it into the Ventuz script, not deleting any of the Ventuz stuff.
[*] Now you just need to figure out where things go
  • Let’s start easy
  • Comment out the whole class Sample bit they gave you, we don’t need that for now. (or delete it, if you prefer, but we’re going to be stealing that stuff, so might want to keep it around). But leave the SampleListener class uncommented, we need that!
  • From the sample class, steal the lines:
    • Code: Select all

      SampleListener listener = new SampleListener();
      Controller controller = new Controller();
    • And paste them above private bool changed; in your class Script bit
    • Code: Select all

      Add controller.AddListener(listener);
      to your Script() section.
    • In the Dispose() section, add

      Code: Select all

      controller.RemoveListener(listener); 
      controller.Dispose();
    • Done
  • Now we need it to do something.
  • Add an Output Variable to the Script
    • Click on custom model, outputs, then add a float called Fingers
  • Now, add the following to the top of the Generate() section (before the if bit) (code is all stolen from the Sample class):
    • Code: Select all

      Frame frame = controller.Frame();
      Hand hand = frame.Hands[0];
      FingerList fingers = hand.Fingers;
      Fingers = fingers.Count;
      changed = true;
  • Unless you (or I) have made a Fubar, you can save and close, and if your leapmotion is connected, the script will be outputting the number of fingers – bind that to the text node and voila, you have Leap Motion in Ventuz (a bit un-sexy, I know, but hey, first steps, right?)
[*] Now that you know how to do the basics, go to town and steal other code bits, like the gestures, or the position or rotation of the hands, etc.
[*] Go forth. Write if you find work.[/list][/list]

User avatar
squiggle
Posts: 31
Joined: 18 Jan 2012, 17:54

Re: ...Use LeapMotion in Ventuz

Post by squiggle » 08 Oct 2013, 16:37

ask, and ye shall receive :-)
thanks,
sq

MrTompkins

Re: ...Use LeapMotion in Ventuz

Post by MrTompkins » 13 Oct 2013, 08:06

Hello Erik,
first of all thank you very much for this post.
Almost everything looks fine but I only have one little problem.
I cannot add LeapCSharp.Net4.0 as a reference although it was successfully installed with gacutil.exe.

I can see LeapCSharp.Net3.5 inside my GAC assambly folder on C:\windows\assembly and
LeapCSharp.Net4.0 is inside C:\Windows\Microsoft.NET\assembly\GAC_MSIL\LeapCSharp.NET4.0\v4.0_0.0.0.0__6e1b1368e71eba9b.

It looks like Ventuz has only access to C:\windows\assembly?!
Is there a way to show ventuz the right location of the LeapCSharp.Net4.0.dll?
Or how should I solve this little issue?

I guess the missing LeapCSharp.Net4.0 is causing the following error message:
...'Leap.Controller' does not contain a definition for 'Addlistiner'

I hope you or someone else can help me because I need to run ventuz with the LeapMotionController... ;-)

MrTompkins

Re: ...Use LeapMotion in Ventuz

Post by MrTompkins » 13 Oct 2013, 08:13

I just saw the mistake...there is a huge difference between:
Addlistener = AddListener

The Script is working now...lets see the results.
Thanks again!

gabrielefx
Posts: 169
Joined: 16 Mar 2012, 19:01

Re: ...Use LeapMotion in Ventuz

Post by gabrielefx » 13 Oct 2013, 08:44

is this the first step to embed a leap motion node in Ventuz 4?

I will pay for this node.

regards

Christian Krix Schmidt
Posts: 290
Joined: 18 Jan 2012, 11:36
Location: Dubai, United Arab Emirates
Contact:

Re: ...Use LeapMotion in Ventuz

Post by Christian Krix Schmidt » 13 Oct 2013, 11:32

This is so you can hook up Leap Motion to Ventuz using the Script node.
But maybe someone here on the forum will create an implementation for you.

User avatar
ErikB
Posts: 212
Joined: 10 Jan 2012, 12:52

Re: ...Use LeapMotion in Ventuz

Post by ErikB » 13 Oct 2013, 11:49

MrTompkins wrote:I just saw the mistake...there is a huge difference between:
Addlistener = AddListener

The Script is working now...lets see the results.
Thanks again!
Oopsie, thanks for that. Fixed in main.

-E

User avatar
ErikB
Posts: 212
Joined: 10 Jan 2012, 12:52

Re: ...Use LeapMotion in Ventuz

Post by ErikB » 13 Oct 2013, 11:52

gabrielefx wrote:is this the first step to embed a leap motion node in Ventuz 4?

I will pay for this node.

regards
This is how to get a LeapMotion connected to Ventuz 3 or 4. We will not be making a dedicated node in the foreseeable future, given that it is relatively straightforward to do this way. You can also use a TUIO, WIndowsTouch or OSC bridge if you prefer - look on the LeapMotion forums to see what is available.

MrTompkins

Re: ...Use LeapMotion in Ventuz

Post by MrTompkins » 20 Oct 2013, 14:12

Hello who ever can and want to help me, ;-)
I am not really a "C Sharp Programmer" but I try my best to understand the whole thing at least in Ventuz.
I Google since almost a week and I can't find the solution or I just don't see it. ;-)

So far I get some values from Leap to Ventuz:
Fingers, Hands, PosX, PosY, PosZ, Pitch, Roll, Yaw, Circle.Progress, CircleRadius, Swipe.Left, Swipe.Right, Swipe.Up, Swipe.Down & Swipe.Speed.
I need some more time to implement more stuff.

I can fly really smooth (with damper) thru a room BUT and now my question:
How can I save/cache my last hand position and continue at the same place/position I left when I'm using my hand again???
All values are jumping to the default every time my hand is leaving the LeapMotion range.
All values should stay at the latest position!

Thanks for help.

P.S. @gabrielefx:
I might can give you the code as soon as everything is done and running fine.
It will take some time.

User avatar
florian
Posts: 58
Joined: 18 Feb 2012, 19:42

Re: ...Use LeapMotion in Ventuz

Post by florian » 20 Oct 2013, 21:43

Hey !
Thanks Erik for releasing this step by step tutorial

In my search, i found an Leap Motion to OSC !
https://github.com/morphiccreative/leapOSC

Here's some output... this output up to 4 hands and 20 fingers !

Code: Select all

OSC Name	Leap Motion Data Value			Measurement Unit

// Frame Data
/ID:		frame.id()
/TS:		frame.timestamp()
/HC:		frame.hands().count()
/FC:		frame.fingers().count()
/TC:		frame.tools().count()

//Gesture Data
/CircleID:				    gesture.id()
/CircleState:			    gesture.state(
/CircleProgress:		  circle.progress()
/CircleRadius:			  circle.radius()
/CircleAngle:			    sweptAngle

/SwipeID:				      gesture.id()
/SwipeState:			    gesture.state()
/SwipeDirectionX:		  swipe.direction().x
/SwipeDirectionY:		  swipe.direction().y
/SwipeDirectionZ:		  swipe.direction().z
/SwipeSpeed:			    swipe.speed()

/KeyTapID:				    gesture.id()
/KeyTapState:			    gesture.state()
/KeyTapPositionX:		  tap.position().x
/KeyTapPositionY:		  tap.position().y
/KeyTapPositionZ:		  tap.position().z
/KeyTapDirectionX:	  tap.direction().x
/KeyTapDirectionY:	  tap.direction().y
/KeyTapDirectionZ:	  tap.direction().z

/ScreenTapID:			    gesture.id()
/ScreenTapState:		  gesture.state()
/ScreenTapPositionX:	screentap.position().x
/ScreenTapPositionY:	screentap.position().y
/ScreenTapPositionZ:	screentap.position().z
/ScreenTapDirectionX:	screentap.direction().x
/ScreenTapDirectionY:	screentap.direction().y
/ScreenTapDirectionZ:	screentap.direction().z


// Hand One Data
/H1FC:		handonefingers.count()
/H1PPX:		handone.palmPosition().x		//(mm)
/H1PPY:		handone.palmPosition().y		//(mm)
/H1PPZ:		handone.palmPosition().z		//(mm)
/H1PVX:		handone.palmVelocity().x		//(mm/s)
/H1PVY:		handone.palmVelocity().y		//(mm/s)
/H1PVZ:		handone.palmVelocity().z		//(mm/s)
/H1NVP:		handonenormalvector.pitch()		//(deg)
/H1NVR:		handonenormalvector.roll()		//(deg)
/H1NVY:		handonenormalvector.yaw()		//(deg)
/H1DP:		handonedirection.pitch()		//(deg)
/H1DR:		handonedirection.roll()			//(deg)
/H1DY:		handonedirection.yaw()			//(deg)
/H1SCX:		handone.sphereCenter().x		//(mm)
/H1SCY:		handone.sphereCenter().y		//(mm)
/H1SCZ:		handone.sphereCenter().z		//(mm)
/H1SR:		handone.sphereRadius()			//(mm)
/H1FAPX:	handonefingersavgPos.x			//(mm)
/H1FAPY:	handonefingersavgPos.y			//(mm)
/H1FAPZ:	handonefingersavgPos.z			//(mm)
/H1F0L:		handonefingers[0].length()		//(mm)
/H1F0W:		handonefingers[0].width()		//(mm)
/H1F0DP:	handonefingers[0].direction().pitch()	//(deg)
/H1F0DR:	handonefingers[0].direction().roll()	//(deg)
/H1F0DY:	handonefingers[0].direction().yaw()	//(deg)
/H1F0TPX:	handonefingers[0].tipPosition().x	//(mm)
/H1F0TPY:	handonefingers[0].tipPosition().y	//(mm)
/H1F0TPZ:	handonefingers[0].tipPosition().z	//(mm)
/H1F0TVX:	handonefingers[0].tipVelocity().x	//(mm/s)
/H1F0TVY:	handonefingers[0].tipVelocity().y	//(mm/s)
/H1F0TVZ:	handonefingers[0].tipVelocity().z	//(mm/s)
/H1F1L:		handonefingers[1].length()		//(mm)
/H1F1W:		handonefingers[1].width()		//(mm)
/H1F1DP:	handonefingers[1].direction().pitch()	//(deg)
/H1F1DR:	handonefingers[1].direction().roll()	//(deg)
/H1F1DY:	handonefingers[1].direction().yaw()	//(deg)
/H1F1TPX:	handonefingers[1].tipPosition().x	//(mm)
/H1F1TPY:	handonefingers[1].tipPosition().y	//(mm)
/H1F1TPZ:	handonefingers[1].tipPosition().z	//(mm)
/H1F1TVX:	handonefingers[1].tipVelocity().x	//(mm/s)
/H1F1TVY:	handonefingers[1].tipVelocity().y	//(mm/s)
/H1F1TVZ:	handonefingers[1].tipVelocity().z	//(mm/s)
/H1F2L:		handonefingers[2].length()		//(mm)
/H1F2W:		handonefingers[2].width()		//(mm)
/H1F2DP:	handonefingers[2].direction().pitch()	//(deg)
/H1F2DR:	handonefingers[2].direction().roll()	//(deg)
/H1F2DY:	handonefingers[2].direction().yaw()	//(deg)
/H1F2TPX:	handonefingers[2].tipPosition().x	//(mm)
/H1F2TPY:	handonefingers[2].tipPosition().y	//(mm)
/H1F2TPZ:	handonefingers[2].tipPosition().z	//(mm)
/H1F2TVX:	handonefingers[2].tipVelocity().x	//(mm/s)
/H1F2TVY:	handonefingers[2].tipVelocity().y	//(mm/s)
/H1F2TVZ:	handonefingers[2].tipVelocity().z	//(mm/s)
/H1F3L:		handonefingers[3].length()		//(mm)
/H1F3W:		handonefingers[3].width()		//(mm)
/H1F3DP:	handonefingers[3].direction().pitch()	//(deg)
/H1F3DR:	handonefingers[3].direction().roll()	//(deg)
/H1F3DY:	handonefingers[3].direction().yaw()	//(deg)
/H1F3TPX:	handonefingers[3].tipPosition().x	//(mm)
/H1F3TPY:	handonefingers[3].tipPosition().y	//(mm)
/H1F3TPZ:	handonefingers[3].tipPosition().z	//(mm)
/H1F3TVX:	handonefingers[3].tipVelocity().x	//(mm/s)
/H1F3TVY:	handonefingers[3].tipVelocity().y	//(mm/s)
/H1F3TVZ:	handonefingers[3].tipVelocity().z	//(mm/s)
/H1F4L:		handonefingers[4].length()		//(mm)
/H1F4W:		handonefingers[4].width()		//(mm)
/H1F4DP:	handonefingers[4].direction().pitch()	//(deg)
/H1F4DR:	handonefingers[4].direction().roll()	//(deg)
/H1F4DY:	handonefingers[4].direction().yaw()	//(deg)
/H1F4TPX:	handonefingers[4].tipPosition().x	//(mm)
/H1F4TPY:	handonefingers[4].tipPosition().y	//(mm)
/H1F4TPZ:	handonefingers[4].tipPosition().z	//(mm)
/H1F4TVX:	handonefingers[4].tipVelocity().x	//(mm/s)
/H1F4TVY:	handonefingers[4].tipVelocity().y	//(mm/s)
/H1F4TVZ:	handonefingers[4].tipVelocity().z	//(mm/s)
Florian

Post Reply