I would suggest a solution like the following. Supposing your object holds the following script and just need one hand. Here, your object will be rotated according to your hand.
I didn't test this script, you may have to change little things according to your needs.
using UnityEngine;
using Leap;
public class LeapControled : MonoBehaviour
{
/// <summary>
/// The Leap controller.
/// </summary>
Controller controller;
/// <summary>
/// The current frame captured by the Leap Motion.
/// </summary>
Frame CurrentFrame
{
get { return ( IsReady ) ? controller.Frame() : null; }
}
/// <summary>
/// Gets the hands data captured from the Leap Motion.
/// </summary>
/// <value>
/// The hands data captured from the Leap Motion.
/// </value>
HandList Hands
{
get { return ( CurrentFrame != null && CurrentFrame.Hands.Count > 0 ) ? CurrentFrame.Hands : null; }
}
/// <summary>
/// Gets a value indicating whether the Leap Motion is ready.
/// </summary>
/// <value>
/// <c>true</c> if this instance is ready; otherwise, <c>false</c>.
/// </value>
bool IsReady
{
get { return ( controller != null && controller.Devices.Count > 0 && controller.IsConnected ); }
}
/// <summary>
/// Awake is called when the script instance is being loaded.
/// </summary>
void Awake()
{
controller = new Controller();
}
/// <summary>
/// Update function called every frame.
/// </summary>
void Update()
{
Hand mainHand; // The front most hand captured by the Leap Motion Controller
// Check if the Leap Motion Controller is ready
if ( !IsReady || Hands == null )
{
return;
}
mainHand = Hands.Frontmost;
transform.rotation = Quaternion.Euler( mainHand.Direction.Pitch, mainHand.Direction.Yaw, mainHand.PalmNormal.Roll );
// For relative orientation
// transform.rotation *= Quaternion.Euler( mainHand.Direction.Pitch, mainHand.Direction.Yaw, mainHand.PalmNormal.Roll );
}
}