コード例 #1
0
 /// <summary>
 /// Convert an array of float[3] positions taken from the DLL into a Vector3[].
 /// </summary>
 /// <param name="pos"></param>
 /// <returns></returns>
 public static Vector3[] ToUnityPosition(SenseGloveCs.Kinematics.Vect3D[] pos)
 {
     if (pos != null)
     {
         Vector3[] res = new Vector3[pos.Length];
         for (int f = 0; f < pos.Length; f++)
         {
             res[f] = SG_Util.ToUnityPosition(pos[f]);
         }
         return(res);
     }
     return(new Vector3[] { });
 }
コード例 #2
0
    /// <summary> Extract right-handed coordinate system data from the SenseGlove DLL and convert it into Unity values. </summary>
    /// <param name="data"></param>
    /// <param name="packets"></param>
    /// <param name="totalCSteps"></param>
    /// <param name="currCStep"></param>
    public SenseGlove_Data(SenseGloveCs.GloveData data)
    {
        if (data != null)
        {
            this.gloveSide = SenseGlove_Data.GetSide(data.kinematics.isRight);

            this.deviceID        = data.deviceID;
            this.firmwareVersion = data.firmwareVersion;
            this.gloveVersion    = data.deviceVersion;

            this.packetsPerSecond = data.samplesPerSec;

            this.commonOriginPos = SG_Util.ToUnityPosition(data.kinematics.gloveRelPos);
            this.commonOriginRot = SG_Util.ToUnityQuaternion(data.kinematics.gloveRelRot);

            this.UpdateVariables(data);
        }
    }
コード例 #3
0
    /// <summary> Fill the appropriate unity Quaternion and Vector3 arrays based on a single joing chain (finger or glove semgent) </summary>
    /// <param name="chain"></param>
    /// <param name="positions"></param>
    /// <param name="angles"></param>
    /// <param name="rotations"></param>
    /// <param name="lengths"></param>
    protected static void GetLinkVariables(ref SenseGloveCs.Kinematics.JointChain chain, ref Vector3[] positions, ref Vector3[] angles, ref Quaternion[] rotations, ref Vector3[] lengths)
    {
        int n = chain.joints.Length;

        positions = new Vector3[n];
        angles    = new Vector3[n];
        rotations = new Quaternion[n];
        lengths   = new Vector3[n - 1];

        for (int j = 0; j < n; j++)
        {
            positions[j] = SG_Util.ToUnityPosition(chain.joints[j].position);
            angles[j]    = SG_Util.ToUnityEuler(chain.joints[j].relativeAngle);
            rotations[j] = SG_Util.ToUnityQuaternion(chain.joints[j].rotation);
            if (j < n - 1)
            {
                lengths[j] = SG_Util.ToUnityPosition(chain.lengths[j]);
            }
        }
    }