Exemple #1
0
    // Update is called once per frame
    public void UpdateTask()
    {
        float DeltaTime = Time.deltaTime;

        //m_Timer.Update(DeltaTime);
        DeviceInput.Update();
        Smoothed.SetTimeStep(DeltaTime);
        //ClearString();

        SOrientation AccMagOrientation = DeviceInput.AccMagOrientation;
        Quaternion   RotationChange    = DeviceInput.GetRotationChange(DeltaTime);

        SOrientation Orientation;

        if (DeviceInput.HasGyro)
        {
            m_SensorFusion.Update(AccMagOrientation, RotationChange, 0.9f);
        }
        m_SmoothedOrientation.Update(AccMagOrientation);

        if (m_UseSensorFusion)
        {
            Orientation = m_SensorFusion.Orientation;
        }
        else
        {
            Orientation = m_SmoothedOrientation.Orientation;
        }
        m_DebugText.PrintText(Orientation);
        m_DebugText.NewLine();
        float heading = Orientation.Yaw;
        float pitch   = Orientation.Pitch;
        float tilt    = Orientation.Roll;
        int   iFocus  = -1;

        for (int i = 0; i < 4; i++)
        {
            // TaskPanel
            float Dist = Panels[i].UpdateAngles(heading, pitch);
            if (!Panels[i].IsFinished())
            {
                if (m_Distance >= Dist && m_Distance >= Mathf.Abs(tilt))
                {
                    iFocus = i;
                    if (0.6f < Panels[i].GetFocusTime())
                    {
                        TakePicture(i);
                    }
                    else
                    {
                        Panels[i].SetStatus(TaskPanel.ETaskStatus.TS_Focus, m_FlashingFocus);
                    }
                }
                else
                {
                    Panels[i].SetStatus(TaskPanel.ETaskStatus.TS_Pending);
                }
            }
        }

        bool bAllFinished = IsAllFinished();

        if (bAllFinished)
        {
            m_bTakingPointPhoto = true;
        }


        if (m_bTakingPointPhoto)
        {
            m_CompassStrip.SetActive(false);
            m_ButtonTakePicture.SetActive(true);
        }
        else
        {
            m_CompassStrip.SetActive(true);
            m_ButtonTakePicture.SetActive(false);
        }



        if (bAllFinished || m_bTakingPointPhoto)
        {
            StatusText.text = m_StringTakePhoto;
        }
        else if (iFocus >= 0)
        {
            StatusText.text = m_StringHoldStill;//"Halten Sie das Handy kurz ruhig" ;
            if (iFocus >= 0 && m_SnapIfAccurate)
            {
                tilt = 0.0f;
                float SnappedHeading = Panels[iFocus].Heading;
                float SnappedPitch   = Panels[iFocus].Pitch;
                for (int i = 0; i < 4; i++)
                {
                    Panels[i].UpdateAngles(SnappedHeading, SnappedPitch);
                }
            }
        }
        else if (Mathf.Abs(tilt) > 20.0f)
        {
            StatusText.text = m_StringLandscape;//"Halte das Handy im Landschaftsmodus" ;
        }
        else
        {
            StatusText.text = m_StringFocus;//"Bringe die roten Quadrate in den Rahmen um Fotos nach Norden, Osten, Süden und Westen zu machen";
        }
        m_DebugText.PrintText("iFocus", iFocus);

        float RotZ = Div.getClamped(-2.0f * tilt, -35.0f, 35.0f);

        transform.localRotation = Quaternion.Euler(0.0f, 0.0f, RotZ);
    }