Ejemplo n.º 1
0
 public void RegisterSphere(string key, Vector3 position, float radius, Leap.Unity.Chirality c, float lossy_x, Mesh m)
 {
     if (c == Leap.Unity.Chirality.Left)
     {
         // Add to the left hand
         left_hand[key] = new Sphere(position, radius, _sphere_material, lossy_x);
     }
     else
     {
         // Add to the right hand
         right_hand[key] = new Sphere(position, radius, _sphere_material, lossy_x);
     }
 }
Ejemplo n.º 2
0
 public void RegisterCylinder(string key, Vector3 pos_a, Vector3 pos_b, Leap.Unity.Chirality c, int layer, float lossy_x, float lossy_y, float length)
 {
     if (c == Leap.Unity.Chirality.Left)
     {
         // Add to the left hand
         left_hand[key] = new Cylinder(pos_a, pos_b, length, _cyl_material, lossy_x, lossy_y, layer);
     }
     else
     {
         // Add to the right hand
         right_hand[key] = new Cylinder(pos_a, pos_b, length, _cyl_material, lossy_x, lossy_y, layer);
     }
 }
Ejemplo n.º 3
0
    private void SaveHand(Leap.Unity.Chirality c)
    {
        Dictionary <string, Drawable> save_dict;

        if (c == Leap.Unity.Chirality.Left)
        {
            save_dict = left_hand;
        }
        else
        {
            save_dict = right_hand;
        }

        Hand    h          = new Hand();
        Vector3 offset_pos = (save_dict["palm"] as Sphere).position;

        foreach (KeyValuePair <string, Drawable> kvp in save_dict)
        {
            if (kvp.Value is Sphere)
            {
                Sphere s = kvp.Value as Sphere;
                s.position -= offset_pos;
                h.spheres.Add(s);
            }
            else
            {
                Cylinder cyl = kvp.Value as Cylinder;
                cyl.position_a -= offset_pos;
                cyl.position_b -= offset_pos;
                h.cylinders.Add(cyl);
            }
        }
        string json_hand = JsonUtility.ToJson(h, true);

        string sceneDataFileName = "hand_" + System.DateTime.UtcNow.Millisecond.ToString() + ".json";
        string filePath          = Path.Combine(Application.dataPath, sceneDataFileName);

        Debug.Log(sceneDataFileName);
        File.WriteAllText(filePath, json_hand);
    }