Exemple #1
0
            private static bool ExtractHandTrackerInfo(WVR_HandTrackerInfo_t handTrackerInfo, ref WVR_HandJoint[] jointMappingArray, ref ulong[] jointValidFlagArray)
            {
                if (handTrackerInfo.jointCount == 0)
                {
                    Debug.Log("ExtractHandTrackerInfo() WVR_GetHandTrackerInfo WVR_HandTrackerInfo_t jointCount SHOULD NOT be 0!!");
                    return(false);
                }

                // WVR_HandTrackerInfo_t.jointMappingArray
                if (jointMappingArray.Length != handTrackerInfo.jointCount)
                {
                    Debug.Log("ExtractHandTrackerInfo() The WVR_GetHandJointCount count (jointMappingArray) " + jointMappingArray.Length
                              + " differs from WVR_GetHandTrackerInfo WVR_HandTrackerInfo_t jointCount " + handTrackerInfo.jointCount);
                    jointMappingArray    = new WVR_HandJoint[handTrackerInfo.jointCount];
                    intJointMappingArray = new int[jointMappingArray.Length];
                }

                Marshal.Copy(handTrackerInfo.jointMappingArray, intJointMappingArray, 0, intJointMappingArray.Length);
                jointMappingArray = Array.ConvertAll(intJointMappingArray, delegate(int value) { return((WVR_HandJoint)value); });

                /*unsafe
                 * {
                 *  for (int i = 0; i < jointMappingArray.Length; i++)
                 *  {
                 *      jointMappingArray[i] = *(handTrackerInfo.jointMappingArray + i);
                 *  }
                 * }*/

                // WVR_HandTrackerInfo_t.jointValidFlagArray
                if (jointValidFlagArray.Length != handTrackerInfo.jointCount)
                {
                    Debug.Log("ExtractHandTrackerInfo() The WVR_GetHandJointCount count (jointValidFlagArray) " + jointValidFlagArray.Length
                              + " differs from WVR_GetHandTrackerInfo WVR_HandTrackerInfo_t jointCount " + handTrackerInfo.jointCount);
                    jointValidFlagArray = new ulong[handTrackerInfo.jointCount];
                    int jointValidFlagArrayByteLength = Buffer.ByteLength(jointValidFlagArray);
                    jointValidFlagArrayBytes = new byte[jointValidFlagArrayByteLength];
                }

                Marshal.Copy(handTrackerInfo.jointValidFlagArray, jointValidFlagArrayBytes, 0, jointValidFlagArrayBytes.Length);
                for (int byteIndex = 0; byteIndex < jointValidFlagArrayBytes.Length; byteIndex = byteIndex + 8)
                {
                    int i = (byteIndex / 8);
                    jointValidFlagArray[i] = BitConverter.ToUInt64(jointValidFlagArrayBytes, byteIndex);
                }

                /*unsafe
                 * {
                 *  for (int i = 0; i < jointValidFlagArray.Length; i++)
                 *  {
                 *      jointValidFlagArray[i] = *(handTrackerInfo.jointValidFlagArray + i);
                 *  }
                 * }*/

                return(true);
            }
Exemple #2
0
            private static void InitializeHandTrackerInfo(ref WVR_HandTrackerInfo_t handTrackerInfo, ref WVR_HandJoint[] jointMappingArray, ref ulong[] jointValidFlagArray, uint count)
            {
                handTrackerInfo.jointCount           = jointCount;
                handTrackerInfo.handModelTypeBitMask = 0;

                /// WVR_HandTrackerInfo_t.jointMappingArray
                jointMappingArray    = new WVR_HandJoint[jointCount];
                intJointMappingArray = new int[jointMappingArray.Length];
                intJointMappingArray = Array.ConvertAll(jointMappingArray, delegate(WVR_HandJoint value) { return((int)value); });
                handTrackerInfo.jointMappingArray = Marshal.AllocHGlobal(sizeof(int) * intJointMappingArray.Length);
                Marshal.Copy(intJointMappingArray, 0, handTrackerInfo.jointMappingArray, intJointMappingArray.Length);

                /*unsafe
                 * {
                 *  fixed (WVR_HandJoint* pJointMappingArray = jointMappingArray)
                 *  {
                 *      handTrackerInfo.jointMappingArray = pJointMappingArray;
                 *  }
                 * }*/

                /// WVR_HandTrackerInfo_t.jointValidFlagArray
                jointValidFlagArray = new ulong[jointCount];
                int jointValidFlagArrayByteLength = Buffer.ByteLength(jointValidFlagArray);

                jointValidFlagArrayBytes = new byte[jointValidFlagArrayByteLength];
                Buffer.BlockCopy(jointValidFlagArray, 0, jointValidFlagArrayBytes, 0, jointValidFlagArrayBytes.Length);

                handTrackerInfo.jointValidFlagArray = Marshal.AllocHGlobal(sizeof(byte) * jointValidFlagArrayBytes.Length);
                Marshal.Copy(jointValidFlagArrayBytes, 0, handTrackerInfo.jointValidFlagArray, jointValidFlagArrayBytes.Length);

                /*unsafe
                 * {
                 *  fixed (ulong* pHandJointsFlag = jointValidFlagArray)
                 *  {
                 *      handTrackerInfo.jointValidFlagArray = pHandJointsFlag;
                 *  }
                 * }*/
            }