Exemple #1
0
        public string client_TestTrackIRData()
        {
            TrackIRClient.LPTRACKIRDATA pTID = new TrackIRClient.LPTRACKIRDATA();
            string result = "";

            if (this.NP_GetData(ref pTID) == TrackIRClient.NPRESULT.NP_OK)
            {
                if ((int)pTID.wNPStatus == (int)NPSTATUS.NPSTATUS_REMOTEACTIVE)
                {
                    if ((long)this.NPFrameSignature != (long)pTID.wPFrameSignature)
                    {
                        result = result + "Pitch: " + pTID.fNPPitch + "\r\n" +
                                 "Roll: " + pTID.fNPRoll + "\r\n" +
                                 "Yaw: " + pTID.fNPYaw + "\r\n" +
                                 "PosX: " + pTID.fNPX + "\r\n" +
                                 "PosY: " + pTID.fNPY + "\r\n" +
                                 "PosZ: " + pTID.fNPX + "\r\n";
                        this.NPFrameSignature = (ulong)pTID.wPFrameSignature;
                        this.NPStaleFrames    = 0UL;
                    }
                    else if (this.NPStaleFrames > 30UL)
                    {
                        result += "No New Data. Paused or Not Tracking?\r\n" +
                                  "Information NPStatus = " + pTID.wNPStatus + "\r\n";
                    }
                    else
                    {
                        ++this.NPStaleFrames;
                        result += "No New Data for " + this.NPStaleFrames + " frames\r\n" +
                                  "Information NPStatus = " + pTID.wNPStatus + "\r\n";
                    }
                }
            }
            else
            {
                result = result + "User Disabled";
            }
            return(result);
        }
Exemple #2
0
        // Update is called once per frame
        private void Update()
        {
            if (isRunning)
            {
                // Data for debugging output, can be removed if not debugging/testing
                data = trackIRclient.client_TestTrackIRData();

                // Data for head tracking
                TrackIRClient.LPTRACKIRDATA tid = trackIRclient.client_HandleTrackIRData();

                // Updates main camera, change to whatever
                Vector3 localPos    = trackedObject.localPosition;
                Vector3 localEulers = trackedObject.localRotation.eulerAngles;

                if (!useLimits)
                {
                    localPos.x = -tid.fNPX * positionMultiplier;
                    localPos.y = tid.fNPY * positionMultiplier;
                    localPos.z = -tid.fNPZ * positionMultiplier;

                    localEulers.y = -tid.fNPYaw * rotationMultiplier;
                    localEulers.x = tid.fNPPitch * rotationMultiplier;
                    localEulers.z = tid.fNPRoll * rotationMultiplier;
                }
                else
                {
                    localPos.x = Mathf.Clamp(-tid.fNPX * positionMultiplier, positionX.Lower, positionX.Upper);
                    localPos.y = Mathf.Clamp(tid.fNPY * positionMultiplier, positionY.Lower, positionY.Upper);
                    localPos.z = Mathf.Clamp(-tid.fNPZ * positionMultiplier, positionZ.Lower, positionZ.Upper);

                    localEulers.y = Mathf.Clamp(-tid.fNPYaw * rotationMultiplier, yawLimits.Lower, yawLimits.Upper);
                    localEulers.x = Mathf.Clamp(tid.fNPPitch * rotationMultiplier, pitchLimits.Lower, pitchLimits.Upper);
                    localEulers.z = Mathf.Clamp(tid.fNPRoll * rotationMultiplier, rollLimits.Lower, rollLimits.Upper);
                }

                trackedObject.localRotation = startRotation * Quaternion.Euler(localEulers);
                trackedObject.localPosition = startPosition + localPos;
            }
        }
Exemple #3
0
 public TrackIRClient.LPTRACKIRDATA client_HandleTrackIRData()
 {
     TrackIRClient.LPTRACKIRDATA pTID = new TrackIRClient.LPTRACKIRDATA();
     if (this.NP_GetData(ref pTID) != TrackIRClient.NPRESULT.NP_OK || (int)pTID.wNPStatus != 0)
     {
         return(pTID);
     }
     if ((long)this.NPFrameSignature != (long)pTID.wPFrameSignature)
     {
         this.NPFrameSignature = (ulong)pTID.wPFrameSignature;
         this.NPStaleFrames    = 0UL;
         return(pTID);
     }
     else
     {
         if (this.NPStaleFrames > 30UL)
         {
             return(pTID);
         }
         ++this.NPStaleFrames;
         return(pTID);
     }
 }
Exemple #4
0
        public string client_TestTrackIRData()
        {
            TrackIRClient.LPTRACKIRDATA pTID = new TrackIRClient.LPTRACKIRDATA();
            string str = "";

            if (this.NP_GetData(ref pTID) == TrackIRClient.NPRESULT.NP_OK)
            {
                if ((int)pTID.wNPStatus == 0)
                {
                    if ((long)this.NPFrameSignature != (long)pTID.wPFrameSignature)
                    {
                        str = string.Concat(new object[4]
                        {
                            (object)string.Concat(new object[4]
                            {
                                (object)string.Concat(new object[4]
                                {
                                    (object)string.Concat(new object[4]
                                    {
                                        (object)string.Concat(new object[4]
                                        {
                                            (object)string.Concat(new object[4]
                                            {
                                                (object)string.Concat(new object[4]
                                                {
                                                    (object)string.Concat(new object[4]
                                                    {
                                                        (object)str,
                                                        (object)"Pitch: ",
                                                        (object)pTID.fNPPitch,
                                                        (object)"\r\n"
                                                    }),
                                                    (object)"Roll: ",
                                                    (object)pTID.fNPRoll,
                                                    (object)"\r\n"
                                                }),
                                                (object)"Yaw: ",
                                                (object)pTID.fNPYaw,
                                                (object)"\r\n"
                                            }),
                                            (object)"PosX: ",
                                            (object)pTID.fNPX,
                                            (object)"\r\n"
                                        }),
                                        (object)"PosY: ",
                                        (object)pTID.fNPY,
                                        (object)"\r\n"
                                    }),
                                    (object)"PosZ: ",
                                    (object)pTID.fNPX,
                                    (object)"\r\n"
                                }),
                                (object)"Information NPStatus = ",
                                (object)pTID.wNPStatus,
                                (object)"\r\n"
                            }),
                            (object)"Frame: ",
                            (object)pTID.wPFrameSignature,
                            (object)"\r\n"
                        });
                        this.NPFrameSignature = (ulong)pTID.wPFrameSignature;
                        this.NPStaleFrames    = 0UL;
                    }
                    else if (this.NPStaleFrames > 30UL)
                    {
                        str = string.Concat(new object[4]
                        {
                            (object)(str + "No New Data. Paused or Not Tracking?"),
                            (object)"Information NPStatus = ",
                            (object)pTID.wNPStatus,
                            (object)"\r\n"
                        });
                    }
                    else
                    {
                        ++this.NPStaleFrames;
                        str = string.Concat(new object[4]
                        {
                            (object)string.Concat(new object[4]
                            {
                                (object)str,
                                (object)"No New Data for ",
                                (object)this.NPStaleFrames,
                                (object)" frames"
                            }),
                            (object)"Information NPStatus = ",
                            (object)pTID.wNPStatus,
                            (object)"\r\n"
                        });
                    }
                }
            }
            else
            {
                str = str + "User Disabled";
            }
            return(str);
        }