Leapmotion demo
- Overview
- Download Links
- User Manual
- Documentation
Leapmotion Unity3D Demo Package
The leapmotion Demo package is a package to be used in Unity3D. This demo allows you to fully integrate your leapmotion with unity3D as long as you use the Reh@panel tool.
Developed by: Tatiana Vieira, Yuri Almeida
Here you can download all the tools you will need to reproduce our demo with your own leapmotion.
Requirements to use the package
- Make sure you have the Leapmotion SDK installed – Download Link here
- Plug in your leapmotion to the PC
- Make sure that it is sending information by UDP to port 1202 (To change this port check our User Manual section). You can use the Reh@panel to do this – Download Link here and documentation here
- Run the Unity3D scene
Download Links
Latest Stable Version:
Latest Stable Version (build):
- Demos Launcher_01_2018 (you don’t need Unity3D to run this example)
Importing the package
- Create a new project
- Import the package LeapmotionDemo.unitypackage
- Assets -> Import package -> Custom Package
Requirements to use the package
- Make sure you have the Leapmotion SDK installed – Download Link here
- Plug in your leapmotion to the PC
- Make sure that it is sending information by UDP to port 1202 (To change this port see below).
- You can use the Reh@panel to do this – Download Link here and documentation here
Testing the scene
- Open the Scene
- Neurehab -> Demo Leapmotion-> Scenes -> LeapmotionDemo
- Make sure you fulfill all the requirements
- Press Play
1 – UDP | Gameobject that has the UDP connection Information. You can change the UDP port here |
2 – Components | Gameobject that has the Leapmotion.cs script |
3 – Leapmotion Prefab | Prefab that has the LeapmotionUnity.cs script. This prefab will only appear in the scene when you have pressed Play |
1 – Number Of Samples | The number of data samples to save for each data input. In the end returns the average of that data input. |
2 – Position Multiplier | Multiplies the position that is receiving for this value. This is useful when you have a game world scale that differs from the real world. |
3 – Prefab parent | The Gameobject parent where the device prefabs are going to be instantiated. Each instantiated prefab represents a Leapmotion that is sending data by UDP. |
4 – Prefabs | The list of prefabs that can be instantiated. |
5 – Time to Live | The maximum time in seconds that a prefab can wait for new data before it is destroyed. |
1 – Additional Rotation | Additional rotation to add to the bones |
2 – Update Position | True if you want to update the object position according to what it is being received |
3 – Update Rotation | True if you want to update the object rotation according to what it is being received |
4 – Available Data | All the data that we are receiving from a Leapmotion. You will notice that leapmotion sends data from the joints and not from the bones themselves. For example, the palm is the articulation (wrist) but the bone that is referenced is the hand. If you want to add a new avatar, you should always take this into account. |
public void UpdateHandRotation()
{
if (Arm != null) {
Arm.transform.rotation =
HandGameobject.transform.rotation * //reference object gameobject (in this case the hand)
GenericDeviceData.GetRotation(LeapMotionBones.forearm.ToString()) * //rotation that comes from leapmotion (world rotation)
_initialRotations[(int) LeapMotionBones.forearm]; //initial rotation of the forearm inside unity
....
}
To be able to access any values data that the Leapmotion is sending, you will need to know two things: the label of the information you want to access and the type of that information. Then, using the LeapmotionUnity.cs script, you can find all this information by accessing the GenericDeviceData Dictionaries as shown below:
GenericDeviceData.Get[INFORMATION_TYPE](“[INFORMATION_LABEL]”);
For example, to access the Leapmotion hand rotation value which is labeled as ‘palm’ and is of the type rotation, you can:
GenericDeviceData.GetRotation(“palm”);
Current Leapmotion protocol values
Information Label [INFORMATION_LABEL] | Information Type [INFORMATION_TYPE] |
forearm | position |
rotation | |
palm | position |
rotation | |
thumb_bone1 | position |
rotation | |
thumb_bone2 | position |
rotation | |
thumb_bone3 | position |
rotation | |
index_bone1 | position |
rotation | |
index_bone2 | position |
rotation | |
index_bone3 | position |
rotation | |
middle_bone1 | position |
rotation | |
middle_bone2 | position |
rotation | |
middle_bone3 | position |
rotation | |
ring_bone1 | position |
rotation | |
ring_bone2 | position |
rotation | |
ring_bone3 | position |
rotation | |
pinky_bone1 | position |
rotation | |
pinky_bone2 | position |
rotation | |
pinky_bone3 | position |
rotation |
In the Rehapanel protocol, parameters are things that always present no matter if it is sending a position, rotation, value or bool. For more information on the Rehapanel read here.
To be able to access any parameters data that the Leapmotion is sending, you will need to know the parameter name. Then, using the LeapmotionUnity.cs script, you can find all this information by accessing the GenericDeviceData.GetParameters(“parameterNameHere”) as shown below:
GenericDeviceData.GetParameters(“[PARAMETER_NAME]”)
For example, to access the Leapmotion hand side parameter which is labeled as “side”, you can do:
var handSide = GenericDeviceData.GetParameter(“side”);
Current Kinect parameters
Name [PARAMETER_NAME] | Description |
Id | The GenericDeviceData ID. |
Side | Which hand the GenericDeviceData belogs to. Can be left or right. |