コード例 #1
0
 //This is the listener that is called by the event manager
 //It transforms and adds the received report to the reports list
 void Record(string name, VRPNButton.ButtonReport report)
 {
     if (firstReport)
     {
         firstTime_sec  = report.msg_time.tv_sec;
         firstTime_usec = report.msg_time.tv_usec;
         firstReport    = false;
     }
     if (report.msg_time.tv_usec < firstTime_usec)
     {
         report.msg_time.tv_sec  = report.msg_time.tv_sec - (firstTime_sec + 1);
         report.msg_time.tv_usec = (report.msg_time.tv_usec + 1000000) - firstTime_usec;
     }
     else
     {
         report.msg_time.tv_sec  = report.msg_time.tv_sec - firstTime_sec;
         report.msg_time.tv_usec = report.msg_time.tv_usec - firstTime_usec;
     }
     VRPNButton.ButtonReportNew newReport  = new VRPNButton.ButtonReportNew();
     VRPNManager.TimeValNew     newMsgTime = new VRPNManager.TimeValNew();
     newMsgTime.tv_sec  = (int)report.msg_time.tv_sec;
     newMsgTime.tv_usec = (int)report.msg_time.tv_usec;
     newReport.msg_time = newMsgTime;
     newReport.button   = report.button;
     newReport.state    = report.state;
     data.list.Add(newReport);
 }
コード例 #2
0
    //VRPNButtonRecording Constructor
    public VRPNButtonRecording(string nName, float nTime, VRPNButton.ButtonReports nData)
    {
        name       = nName;
        reportTime = nTime;
        data       = nData;

        e = data.list.GetEnumerator();

        while (e.MoveNext())
        {
            VRPNButton.ButtonReportNew report = e.Current;
            int test;
            if (!buttons.TryGetValue(report.button, out test))
            {
                buttons.Add(report.button, report.button);
            }
            lastTime = report.msg_time.tv_sec + (report.msg_time.tv_usec / 1000000f);
        }

        e = data.list.GetEnumerator();
    }
コード例 #3
0
    // Update is called once per frame
    void Update()
    {
        if (isPlaying)
        {
            float actualTime;
            float actualReportTime = 0f;
            bool  moreReports      = true;
            bool  alreadyAdvanced  = false;
            Dictionary <int, VRPNButton.ButtonReportNew> lastReports = new Dictionary <int, VRPNButton.ButtonReportNew>();

            if (firstReport)
            {
                firstReport = false;
                firstTime   = Time.time;
                if (e.MoveNext())
                {
                    actualReport = e.Current;
                }
                else
                {
                    isPlaying   = false;
                    moreReports = false;
                    firstReport = true;
                }
            }

            actualTime = Time.time - firstTime;

            //It seeks the last appropiate report for the actual time
            while (moreReports)
            {
                actualReportTime = actualReport.msg_time.tv_sec + (actualReport.msg_time.tv_usec / 1000000f);
                if (actualReportTime <= actualTime)
                {
                    VRPNButton.ButtonReportNew test;
                    if (lastReports.TryGetValue(actualReport.button, out test))
                    {
                        lastReports[actualReport.button] = actualReport;
                    }
                    else
                    {
                        lastReports.Add(actualReport.button, actualReport);
                    }
                    if (e.MoveNext())
                    {
                        actualReport    = e.Current;
                        alreadyAdvanced = true;
                    }
                    else
                    {
                        sendingReports(lastReports);

                        moreReports = false;
                        isPlaying   = false;
                        firstReport = true;
                    }
                }
                else if (alreadyAdvanced)
                {
                    sendingReports(lastReports);

                    moreReports = false;
                }
                else
                {
                    moreReports = false;
                }
            }
        }
    }
コード例 #4
0
ファイル: VRPNButtonPlay.cs プロジェクト: Calvino85/VRPN-Tool
    // Update is called once per frame
    void Update()
    {
        if (isPlaying)
        {
            float actualTime;
            float actualReportTime = 0f;
            bool moreReports = true;
            bool alreadyAdvanced = false;
            Dictionary<int, VRPNButton.ButtonReportNew> lastReports = new Dictionary<int, VRPNButton.ButtonReportNew>();

            if (firstReport)
            {
                firstReport = false;
                firstTime = Time.time;
                if (e.MoveNext())
                {
                    actualReport = e.Current;
                }
                else
                {
                    isPlaying = false;
                    moreReports = false;
                    firstReport = true;
                }
            }

            actualTime = Time.time - firstTime;

            //It seeks the last appropiate report for the actual time
            while (moreReports)
            {
                actualReportTime = actualReport.msg_time.tv_sec + (actualReport.msg_time.tv_usec / 1000000f);
                if (actualReportTime <= actualTime)
                {
                    VRPNButton.ButtonReportNew test;
                    if (lastReports.TryGetValue(actualReport.button, out test))
                    {
                        lastReports[actualReport.button] = actualReport;
                    }
                    else
                    {
                        lastReports.Add(actualReport.button, actualReport);
                    }
                    if (e.MoveNext())
                    {
                        actualReport = e.Current;
                        alreadyAdvanced = true;
                    }
                    else
                    {
                        sendingReports(lastReports);

                        moreReports = false;
                        isPlaying = false;
                        firstReport = true;
                    }
                }
                else if (alreadyAdvanced)
                {
                    sendingReports(lastReports);

                    moreReports = false;
                }
                else
                {
                    moreReports = false;
                }
            }
        }
    }
コード例 #5
0
ファイル: VRPNButtonSave.cs プロジェクト: Calvino85/VRPN-Tool
 //This is the listener that is called by the event manager
 //It transforms and adds the received report to the reports list
 void Record(string name, VRPNButton.ButtonReport report)
 {
     if (firstReport)
     {
         firstTime_sec = report.msg_time.tv_sec;
         firstTime_usec = report.msg_time.tv_usec;
         firstReport = false;
     }
     if (report.msg_time.tv_usec < firstTime_usec)
     {
         report.msg_time.tv_sec = report.msg_time.tv_sec - (firstTime_sec + 1);
         report.msg_time.tv_usec = (report.msg_time.tv_usec + 1000000) - firstTime_usec;
     }
     else
     {
         report.msg_time.tv_sec = report.msg_time.tv_sec - firstTime_sec;
         report.msg_time.tv_usec = report.msg_time.tv_usec - firstTime_usec;
     }
     VRPNButton.ButtonReportNew newReport = new VRPNButton.ButtonReportNew();
     VRPNManager.TimeValNew newMsgTime = new VRPNManager.TimeValNew();
     newMsgTime.tv_sec = (int)report.msg_time.tv_sec;
     newMsgTime.tv_usec = (int)report.msg_time.tv_usec;
     newReport.msg_time = newMsgTime;
     newReport.button = report.button;
     newReport.state = report.state;
     data.list.Add(newReport);
 }