示例#1
0
 void Update()
 {
     //Draw angular acceleration curve
     AppendImageBuffer(X_List, Y_List, Z_List, MojingController.AngularArray[0].x, MojingController.AngularArray[0].y, MojingController.AngularArray[0].z);
     //GetComponent<Renderer>().material.mainTexture = tex;
     MojingSDK.Unity_SetOverlay3D(MojingSDK.TEXTURE_BOTH_EYE, texID, HEADCTRL_WIDTH, HEADCTRL_HEIGHT, CenterPointer.position.magnitude);
 }
示例#2
0
    // If TW, ATW or needDistortion enable, render by MojingSDK, Call MojingSDK.Unity_SetOverlay
    void DrawOverlay()
    {
        if (tex)
        {
            if (Mojing.SDK.NeedDistortion)
            {
                //  MojingSDK.Unity_SetOverlay3D(MojingSDK.TEXTURE_BOTH_EYE, IntPtr.Zero, 0.04f, 0.04f, CenterPointer.transform.position.magnitude);

                if (MoveViewFree)
                {
                    MojingSDK.Unity_SetOverlay3D(MojingSDK.TEXTURE_LEFT_EYE, texID, HEADCTRL_WIDTH, HEADCTRL_HEIGHT, Vector3.Distance(LCamera.transform.position, CenterPointer.position));
                    MojingSDK.Unity_SetOverlay3D(MojingSDK.TEXTURE_RIGHT_EYE, texID, HEADCTRL_WIDTH, HEADCTRL_HEIGHT, Vector3.Distance(RCamera.transform.position, CenterPointer.position));
                }
                else
                {
                    float x = Mathf.Clamp(1 - HeadCtrlOffset.x / size, HalfHeadCtrlWidth, 1 - HalfHeadCtrlWidth) - HalfHeadCtrlWidth;
                    float y = Mathf.Clamp(HeadCtrlOffset.y / size, HalfHeadCtrlHeight, 1 - HalfHeadCtrlHeight) - HalfHeadCtrlHeight;

                    MojingSDK.Unity_SetOverlay3D_V2(MojingSDK.TEXTURE_LEFT_EYE, texID, x, y, HEADCTRL_WIDTH, HEADCTRL_HEIGHT, Vector3.Distance(LCamera.transform.position, CenterPointer.position));
                    MojingSDK.Unity_SetOverlay3D_V2(MojingSDK.TEXTURE_RIGHT_EYE, texID, x, y, HEADCTRL_WIDTH, HEADCTRL_HEIGHT, Vector3.Distance(RCamera.transform.position, CenterPointer.position));
                }

                /*------
                *   iEyeType:1----Left camera viewport draw
                *           2----Right camera viewport draw
                *           3---- Both left camera and right camera viewports draw
                *   ------*/
            }
        }
        else
        {
            Debug.Log("There is no Texture!");
        }
    }
示例#3
0
    // If TW, ATW or needDistortion enable, render by MojingSDK, Call MojingSDK.Unity_SetOverlay
    void DrawOverlay()
    {
        if (tex)
        {
            if (Mojing.SDK.NeedDistortion)
            {
                //MojingSDK.Unity_SetOverlay3D(3, texID, 0.04f, 0.04f, CenterPointer.transform.position.magnitude);
                if (SystemInfo.graphicsDeviceType == UnityEngine.Rendering.GraphicsDeviceType.Metal)
                {
                    Graphics.Blit(tex, texRend);
                    MojingSDK.Unity_SetOverlay3D_Metal(1, texRendPtr, 0.04f, 0.04f, Vector3.Distance(LCamera.transform.position, CenterPointer.position));
                    MojingSDK.Unity_SetOverlay3D_Metal(2, texRendPtr, 0.04f, 0.04f, Vector3.Distance(RCamera.transform.position, CenterPointer.position));
                }
                else
                {
                    MojingSDK.Unity_SetOverlay3D(1, texID, 0.04f, 0.04f, Vector3.Distance(LCamera.transform.position, CenterPointer.position));
                    MojingSDK.Unity_SetOverlay3D(2, texID, 0.04f, 0.04f, Vector3.Distance(RCamera.transform.position, CenterPointer.position));

                    /*------
                    *  iEyeType:1----Left camera viewport draw
                    *         2----Right camera viewport draw
                    *         3---- Both left camera and right camera viewports draw
                    *  ------*/
                }
            }
        }
        else
        {
            Debug.Log("There is no Texture!");
        }
    }
示例#4
0
    void Update()
    {
        count++;
        float interp     = Time.deltaTime / (0.5f + Time.deltaTime);
        float currentFPS = 1.0f / Time.deltaTime;

        if (count >= 5)
        {
            fps        = Mathf.Lerp(fps, currentFPS, interp);
            text1.text = "Fps:" + Mathf.RoundToInt(fps)
                         + ", " + "Time:" + Mathf.RoundToInt(Time.time)
#if !UNITY_EDITOR && UNITY_ANDROID
                         + "\n" + "Cap:" + GetBatteryCapacity()
                         + ", " + "Current:" + GetElectricCurrent()
                         + "\n" + "GPUF:" + GetGPUFreq()
                         + ", " + "GPUT:" + GetGPUTemperature()
                         + "\n" + "CPUF:" + GetCPUFreq()
                         + "\n" + "CPUT:" + GetCPUTemperature()
#endif
            ;

            //MojingLog.LogTrace("帧率:" + Mathf.RoundToInt(fps)
            //    + ",时长:" + Mathf.RoundToInt(Time.time)
            //    + ",电量:" + battery_capacity
            //    + ",电流:" + current_electric
            //    + ",GPU频率:" + gpu_frequency
            //    + ",GPU温度:" + gpu_temperature
            //    + ",CPU频率:" + cpu_frequency
            //    + ",CPU温度:" + cpu_temperature);
            count = 0;
        }
#if !UNITY_EDITOR && UNITY_IOS
        if (SystemInfo.graphicsDeviceType == UnityEngine.Rendering.GraphicsDeviceType.Metal && !UIScreen.IsCreated())
        {
            UIScreen.Create();
        }
#endif
        if (Mojing.SDK.NeedDistortion && UIScreen.IsCreated())
        {
            if (SystemInfo.graphicsDeviceType == UnityEngine.Rendering.GraphicsDeviceType.Metal)
            {
                texID = UIScreen.colorBuffer.GetNativeRenderBufferPtr();
                MojingSDK.Unity_SetOverlay3D(MojingSDK.TEXTURE_BOTH_EYE | MojingSDK.TEXTURE_IS_UNITY_METAL_RENDER_TEXTURE, texID, 1, 1, CenterPointer.position.magnitude);
            }
            else
            {
                MojingSDK.Unity_SetOverlay3D(MojingSDK.TEXTURE_BOTH_EYE, texID, 1, 1, CenterPointer.position.magnitude);
            }
        }
    }
    // If UseTimeWarp or needDistortion enable, render by MojingSDK, Call MojingSDK.Unity_SetOverlay
    void DrawOverlay()
    {
        if (tex)
        {
            if (ConfigItem.bUseTimeWarp || Mojing.SDK.NeedDistortion)
            {
                MojingSDK.Unity_SetOverlay3D(3, texID, 0.04f, 0.04f, CenterPointer.transform.position.magnitude);

                /*------
                *  iEyeType:1----Left camera viewport draw
                *         2----Right camera viewport draw
                *         3---- Both left camera and right camera viewports draw
                *  ------*/
            }
        }
        else
        {
            Debug.Log("There is no Texture!");
        }
    }
示例#6
0
    //private void onDeviceAttachedCallback(bool obj)
    //{
    //    if (obj)
    //    {
    //        switchMat.SetColor("_Color", Color.green);
    //        info.text = MojingInputManager.Instance.device_name_attach + " connected";
    //    }
    //    else
    //    {
    //        switchMat.SetColor("_Color", Color.red);
    //        info.text = "Device disconnected";
    //    }
    //}

    void Update()
    {
        if (CrossPlatformInputManager.GetButton("LEFT"))
        {
            UI[0].sizeDelta = new Vector2(60, 60);
        }
        else if (CrossPlatformInputManager.GetButtonUp("LEFT"))
        {
            UI[0].sizeDelta = new Vector2(50, 50);
        }

        if (CrossPlatformInputManager.GetButton("RIGHT"))
        {
            UI[1].sizeDelta = new Vector2(60, 60);
        }
        else if (CrossPlatformInputManager.GetButtonUp("RIGHT"))
        {
            UI[1].sizeDelta = new Vector2(50, 50);
        }

        if (CrossPlatformInputManager.GetButton("UP"))
        {
            UI[2].sizeDelta = new Vector2(60, 60);
        }
        else if (CrossPlatformInputManager.GetButtonUp("UP"))
        {
            UI[2].sizeDelta = new Vector2(50, 50);
        }

        if (CrossPlatformInputManager.GetButton("DOWN"))
        {
            UI[3].sizeDelta = new Vector2(60, 60);
        }
        else if (CrossPlatformInputManager.GetButtonUp("DOWN"))
        {
            UI[3].sizeDelta = new Vector2(50, 50);
        }
        if (CrossPlatformInputManager.GetButton("VOLUME_UP"))
        {
            UI[4].sizeDelta = new Vector2(60, 60);
        }
        else if (CrossPlatformInputManager.GetButtonUp("VOLUME_UP"))
        {
            UI[4].sizeDelta = new Vector2(50, 50);
        }

        if (CrossPlatformInputManager.GetButton("VOLUME_DOWN"))
        {
            UI[5].sizeDelta = new Vector2(60, 60);
        }
        else if (CrossPlatformInputManager.GetButtonUp("VOLUME_DOWN"))
        {
            UI[5].sizeDelta = new Vector2(50, 50);
        }
        if (CrossPlatformInputManager.GetButton("C") || CrossPlatformInputManager.GetButton("B"))
        {
            UI[6].sizeDelta = new Vector2(60, 60);
        }
        else if (CrossPlatformInputManager.GetButtonUp("C") || CrossPlatformInputManager.GetButtonUp("B"))
        {
            UI[6].sizeDelta = new Vector2(50, 50);
        }
        if (CrossPlatformInputManager.GetButton("OK") || CrossPlatformInputManager.GetButton("A"))
        {
            UI[7].sizeDelta = new Vector2(60, 60);
        }
        else if (CrossPlatformInputManager.GetButtonUp("OK") || CrossPlatformInputManager.GetButtonUp("A"))
        {
            UI[7].sizeDelta = new Vector2(50, 50);
        }
        if (CrossPlatformInputManager.GetAxis("Horizontal") != 0)
        {
            touchpad_x.text = "x轴:  " + CrossPlatformInputManager.GetAxis("Horizontal");
        }
        if (CrossPlatformInputManager.GetAxis("Vertical") != 0)
        {
            touchpad_y.text = "y轴:  " + CrossPlatformInputManager.GetAxis("Vertical");
        }
        if (Mojing.SDK.NeedDistortion)
        {
            MojingSDK.Unity_SetOverlay3D(MojingSDK.TEXTURE_BOTH_EYE, texID, 1, 1, CenterPointer.position.magnitude);
        }
    }
示例#7
0
 void OnDestroy()
 {
     MojingSDK.Unity_SetOverlay3D(MojingSDK.TEXTURE_BOTH_EYE, IntPtr.Zero, 1, 1, 1);
 }
 void OnDestroy()
 {
     MojingSDK.Unity_SetOverlay3D(3, 0, 1, 1, 1);
 }
示例#9
0
 void OnDestroy()
 {
     UICamera.targetTexture = null;
     UIScreen.Release();
     MojingSDK.Unity_SetOverlay3D(MojingSDK.TEXTURE_BOTH_EYE, IntPtr.Zero, 1, 1, 1);
 }