Exemplo n.º 1
0
 public float border;  // Distance from bottom of the glasses to the bottom edge of screen.
 public void UpdateProfile()
 {
     MojingLog.LogTrace("Screen size old: " + width + " x " + height);
     MojingSDK.Unity_GetScreenSize(ref width, ref height);
     MojingLog.LogTrace("Screen size new: " + width + " x " + height);
     border = 0;
 }
Exemplo n.º 2
0
 public void UpdateProfile()
 {
     MojingLog.LogTrace("Mojing.Lens.UpdateProfile");
     FOV         = MojingSDK.Unity_GetGlassesFOV();
     Separation  = MojingSDK.Unity_GetGlassesSeparation();
     DistortionR = MojingSDK.Unity_GetDistortionR();
 }
Exemplo n.º 3
0
 public void updateController(Device dev, int id)
 {
     // MojingLog.LogTrace("dev: " + dev.name+ ",  weapon:  "+ weapon.name);
     if (null != dev)
     {
         dev.connected = true;
         //MojingLog.LogTrace("dev.connected:  " + dev.connected);
         if (!dev.connected)
         { // 设备没有连上,先进行连接
             MojingLog.LogTrace("connectDevice: " + connectDevice(dev.id) + ",  dev.id: " + dev.id);
             if (connectDevice(dev.id))
             {
                 dev.connected = true;
             }
         }
         else
         {   // 连接上了,更新设备位置
             //MojingSDK.Unity_Device_GetInfo(dev.id, _quartArray, _angularArray, _linearArray, _posArray, _keyAray);
             MojingSDK.Unity_Device_GetFixCurrentInfo(dev.id, _quartArray, _angularArray, _linearArray, _posArray, _keyAray);
             QuartArray[id]   = new Quaternion(_quartArray[0], _quartArray[1], _quartArray[2], _quartArray[3]);
             AngularArray[id] = new Vector3(_angularArray[0], _angularArray[1], _angularArray[2]);
             LinearArray[id]  = new Vector3(_linearArray[0], _linearArray[1], _linearArray[2]);
             //Debug.Log("ID: " + dev.id + "Quaternion:" + QuartArray[id]
             //        + "\n" + "angularArray:" + AngularArray[id]
             //        + "\n" + "angularArray:" + LinearArray[id]);
             MojingSDK.Unity_Device_GetFixInfo(dev.id, _quartArray, _angularArray, _linearArray, _posArray);
             FixQuate[id] = new Quaternion(_quartArray[0], _quartArray[1], _quartArray[2], _quartArray[3]);
         }
     }
 }
Exemplo n.º 4
0
    public void queryDeviceList()
    {
        MojingLog.LogTrace("Enter queryDeviceList");
        if (!_javaInit)
        {
            return;
        }
//#if UNITY_ANDROID && !UNITY_EDITOR
//        string jsonStr = _javaClass.CallStatic<string>("getDeviceList");
//#else
        string jsonStr = "{ \"ClassName\":\"DeviceList\",\"DeviceList\":[{\"ID\":1,\"DeviceName\":\"AirMouse\",\"Connect\":1},{\"ID\":2,\"DeviceName\":\"AirMouse\",\"Connect\":1}]}";

//#endif
        MojingLog.LogTrace("json=" + jsonStr);
        DeviceJson devList = JsonMapper.ToObject <DeviceJson>(jsonStr);

        if (devList != null)
        {
            _deviceList.Clear();

            MojingLog.LogTrace("DeviceList count=" + devList.DeviceList.Count);

            for (int i = 0; i < devList.DeviceList.Count; ++i)
            {
                Device dev = new Device(devList.DeviceList[i]);
                _deviceList.Add(dev);
                MojingLog.LogTrace("DeviceList " + i + "  ID: " + dev.id + ", name: " + dev.name + ", connectable: " + dev.connectable + ", connected: " + dev.connected);
            }
            DevNum = _deviceList.Count;
        }
    }
Exemplo n.º 5
0
 void Awake()
 {
     MojingLog.LogTrace("Enter MojingVRHead.Awake");
     gameObject.SetActive(ConfigItem.MojingSDKActive);
     sdk = Mojing.SDK;
     if (MojingSDK.cur_GlassKey == "")
     {
         //sdk.GlassesKey = Mojing.glassesKeyList[1];
         sdk.GlassesKey         = GetCurrentGlasses(GlassesType);
         MojingSDK.cur_GlassKey = sdk.GlassesKey;
     }
     else
     {
         sdk.GlassesKey = MojingSDK.cur_GlassKey;
     }
     Debug.Log(MojingSDK.GetSDKVersion());
     MyTr = this.transform;
     MojingLog.LogTrace("Leave MojingVRHead.Awake");
     if (ConfigItem.ScreenNeverSleep)
     {
         Screen.sleepTimeout = SleepTimeout.NeverSleep;
     }
     else
     {
         Screen.sleepTimeout = SleepTimeout.SystemSetting;
     }
 }
Exemplo n.º 6
0
    public static bool Unity_EnterMojingWorld(string sGlassesName, bool bMultithread, bool bTimeWarp)
    {
        MojingLog.LogTrace("---> Unity_EnterMojingWorld");

        bool bUseMetal = false;

        if (SystemInfo.graphicsDeviceType == UnityEngine.Rendering.GraphicsDeviceType.Metal)
        {
            bUseMetal = true;
        }
        if (Unity_SetMojingWorld(sGlassesName, bMultithread, bTimeWarp, bUseMetal))
        {
            MojingLog.LogTrace("---> Unity_SetMojingWorld ok");
#if UNITY_EDITOR || UNITY_STANDALONE_WIN
            if (SystemInfo.graphicsDeviceType == UnityEngine.Rendering.GraphicsDeviceType.OpenGL2)
            {
                Unity_IssuePluginEvent((int)UnityEventID.EnterMojingWorld);
            }
#else
            Unity_IssuePluginEvent((int)UnityEventID.EnterMojingWorld);
#endif
            return(true);
        }
        return(false);
    }
Exemplo n.º 7
0
    public static Products GetProducts(string strManufacturerKey, string strLanguageCodeByISO963)
    {
        try
        {
            string   json = GetProductList(strManufacturerKey, strLanguageCodeByISO963);
            Products list = JsonMapper.ToObject <Products>(json);

            foreach (ProductInfo product in list.ProductList)
            {
                product.GlassList = GetGlasses(product.KEY, strLanguageCodeByISO963);
                foreach (GlassInfo glass in product.GlassList.GlassList)
                {
                    if (glass.Display == null || glass.Display == "")
                    {
                        glass.Display = product.Display;
                    }
                    else
                    {
                        glass.Display = product.Display + " " + glass.Display;
                    }
                }
            }
            return(list);
        }
        catch (Exception e)
        {
            MojingLog.LogTrace(e.ToString());
        }
        return(null);
    }
Exemplo n.º 8
0
    public static Products GetProducts(string strManufacturerKey, string strLanguageCodeByISO963)
    {
        try
        {
            string   json = GetProductList(strManufacturerKey, strLanguageCodeByISO963);
            Products list = JsonMapper.ToObject <Products>(json);

            for (int i = 0; i < list.ProductList.Count; i++)
            {
                list.ProductList[i].GlassList = GetGlasses(list.ProductList[i].KEY, strLanguageCodeByISO963);
                for (int j = 0; j < list.ProductList[i].GlassList.GlassList.Count; j++)
                {
                    if (list.ProductList[i].GlassList.GlassList[j].Display == null || list.ProductList[i].GlassList.GlassList[j].Display == "")
                    {
                        list.ProductList[i].GlassList.GlassList[j].Display = list.ProductList[i].Display;
                    }
                    else
                    {
                        list.ProductList[i].GlassList.GlassList[j].Display = list.ProductList[i].Display + " " + list.ProductList[i].GlassList.GlassList[j].Display;
                        //MojingLog.LogTrace("To get glass list of " + list.ProductList[i].GlassList.GlassList[j].Display);
                    }
                }
            }
            return(list);
        }
        catch (Exception e)
        {
            MojingLog.LogTrace(e.ToString());
        }
        return(null);
    }
Exemplo n.º 9
0
    void Awake()
    {
#if DEBUG
        MojingLog.LogTrace("MojingSDK Unity Build in DEBUG Mode");
#else
        MojingLog.LogTrace("MojingSDK Unity Build in RELEASE Mode");
#endif
        Screen.orientation = ScreenOrientation.LandscapeLeft;
        //UnityEditor.PlayerSettings.MTRendering = true;
        MojingLog.LogTrace("Enter MojingVRHead.Awake");
        gameObject.SetActive(ConfigItem.MojingSDKActive);
        sdk = Mojing.SDK;
        if (MojingSDK.cur_GlassKey == "")
        {
            //sdk.GlassesKey = Mojing.glassesKeyList[1];
            GetsdkGlassKey(GlassesType);
        }
        else
        {
            sdk.GlassesKey = MojingSDK.cur_GlassKey;
        }
        MojingLog.LogTrace("MojingSDK Glasses KEY: " + sdk.GlassesKey
                           + ",MojingSDK Version: " + MojingSDK.GetSDKVersion());
        Debug.Log("MojingSDK Glasses KEY: " + sdk.GlassesKey
                  + ",MojingSDK Version: " + MojingSDK.GetSDKVersion());
        if (ConfigItem.ScreenNeverSleep)
        {
            Screen.sleepTimeout = SleepTimeout.NeverSleep;
        }
        else
        {
            Screen.sleepTimeout = SleepTimeout.SystemSetting;
        }
        MojingLog.LogTrace("Leave MojingVRHead.Awake");
    }
Exemplo n.º 10
0
 void OnDestroy()
 {
     MojingLog.LogTrace("Enter Mojing.OnDestroy");
     if (sdk == this)
     {
         sdk = null;
     }
     MojingLog.LogTrace("Leave Mojing.OnDestroy");
 }
Exemplo n.º 11
0
 public static bool Unity_EnterMojingWorld(string sGlassesName, bool bUseTimeWarp)
 {
     MojingLog.LogTrace("---> Unity_EnterMojingWorld");
     if (Unity_SetMojingWorld(sGlassesName, bUseTimeWarp))
     {
         MojingLog.LogTrace("---> Unity_SetMojingWorld ok");
         GL.IssuePluginEvent((int)UnityEventID.EnterMojingWorld);
         return(true);
     }
     return(false);
 }
Exemplo n.º 12
0
 void OnPause()
 {
     MojingLog.LogTrace("Enter Mojing.OnPause");
     isPaused = true;
     StopAllCoroutines();
     MojingLog.LogTrace("Mojing.OnPause---StopAllCoroutines");
     g_bStartEndofFrame = false;
     MojingSDK.Unity_LeaveMojingWorld();
     MojingLog.LogTrace("Mojing.OnPause---Unity_LeaveMojingWorld");
     MojingLog.LogTrace("Leave Mojing.OnPause");
 }
Exemplo n.º 13
0
    //展开二级菜单后,选择更换glasses
    public void ChangeGlass(string glassName)
    {
        OpenGlassMenu();
        string sNewKey = GetGlassKeyByName(glassName);

        if (MojingSDK.cur_GlassKey != sNewKey)
        {
            MojingSDK.cur_GlassKey = sNewKey;
            Mojing.SDK.GlassesKey  = MojingSDK.cur_GlassKey;
        }
        MojingLog.LogTrace("new Glasses Name:" + glassName + ", new Glasses Key:" + MojingSDK.cur_GlassKey);
    }
Exemplo n.º 14
0
 public static void Unity_StartBacker(int width, int height, backerInfo[] info, int infolen)
 {
     MojingLog.LogTrace("Unity_StartBacker_Unity_StartBacker");
     Unity_SetStartBacker(width, height, info, infolen);
     try
     {
         Unity_IssuePluginEvent((int)UnityEventID.BackerTexture);
     }
     catch (Exception e)
     {
         MojingLog.LogError(e.ToString());
     }
 }
Exemplo n.º 15
0
 public static bool IsInMojingWorld(string glassesKey)
 {
     MojingLog.LogTrace("IsInMojingWorld:" + Unity_IsInMojingWorld(glassesKey));
     if (Unity_IsInMojingWorld(glassesKey))
     {
         Initialized = true;
         return(true);
     }
     else
     {
         return(false);
     }
 }
Exemplo n.º 16
0
 void OnDestroy()
 {
     MojingLog.LogTrace("Enter Mojing.OnDestroy");
     if (sdk == this)
     {
         sdk = null;
     }
     MojingSDK.Initialized = false;
     MojingSDK.Unity_LeaveMojingWorld();
     StopAllCoroutines();
     g_bStartEndofFrame = false;
     MojingSDK.DestroyMojingWorld();
     MojingLog.LogTrace("Leave Mojing.OnDestroy");
 }
Exemplo n.º 17
0
 public static Glasses GetGlasses(string strProductKey, string strLanguageCodeByISO963)
 {
     try
     {
         string  json = GetGlassList(strProductKey, strLanguageCodeByISO963);
         Glasses list = JsonMapper.ToObject <Glasses>(json);
         return(list);
     }
     catch (Exception e)
     {
         MojingLog.LogTrace(e.ToString());
     }
     return(null);
 }
Exemplo n.º 18
0
    IEnumerator OnResume()
    {
        yield return(new WaitForSeconds(0.5f));

        if (!g_bStartEndofFrame)
        {
            EnterMojingWorld();
            getTextureID(iFrameIndex);
            g_bStartEndofFrame = true;
            StartCoroutine(EndOfFrame());
            isPaused = false;
            yield break;
        }
        MojingLog.LogTrace("Leave Mojing.OnResume");
    }
Exemplo n.º 19
0
 void OnDisable()
 {
     MojingLog.LogTrace("Enter Mojing.OnDisable");
     try
     {
         if (!bDuplicateMojing)
         {
             MojingSDK.Unity_LeaveMojingWorld();
             StopCoroutine("EndOfFrame");
         }
     }
     catch (Exception e)
     {
         MojingLog.LogError(e.ToString());
     }
     MojingLog.LogTrace("Leave Mojing.OnDisable");
 }
Exemplo n.º 20
0
    //private long frameCount = 0;
    IEnumerator EndOfFrame()
    {
        //frameCount = 0;
        MojingLog.LogTrace("Enter Mojing.EndOfFrame thread");
        while (true)
        {
            yield return(new WaitForEndOfFrame());

            if ((!bWaitForMojingWord) && VRModeEnabled && NeedDistortion)
            {
                if (m_bResetTextureId)
                {
                    int tID = MojingRender.StereoScreen[0].GetNativeTextureID();
                    int sID = MojingRender.StereoScreen[1].GetNativeTextureID();
                    if (tID == 0 || sID == 0)
                    {
                        // Skip a frame, the old texture id is invalid and no new texture id to use
                        //MojingLog.LogTrace("Skip a frame since texture id is zero: " + tID + "," + sID);
                        m_bResetTextureId = true;
                    }
                    else
                    {
                        if (_Last_left_TextureID != tID || _Last_right_TextureID != sID)
                        {
                            _Last_left_TextureID  = tID;
                            _Last_right_TextureID = sID;
                        }
                        //MojingLog.LogTrace("Set Texture ID: " + _Last_left_TextureID + "," + _Last_right_TextureID);
                        MojingSDK.SetTextureID(_Last_left_TextureID, _Last_right_TextureID);
                        MojingSDK.Unity_DistortFrame();
                        if (--m_ResetCount == 0)
                        {
                            m_bResetTextureId = false;
                        }
                    }
                }
                else
                {
                    //MojingLog.LogTrace("Read Texture ID = " + tID + ", " + sID + " while set Texture ID: " + _Last_left_TextureID + "," + _Last_right_TextureID);
                    MojingSDK.SetTextureID(_Last_left_TextureID, _Last_right_TextureID);
                    MojingSDK.Unity_DistortFrame();
                }
            }
        }
        //MojingLog.LogTrace("Leave Mojing.EndOfFrame thread");
    }
Exemplo n.º 21
0
    void OnLevelWasLoaded(int level)
    {
        try
        {
            MojingLog.LogTrace("Enter Mojing.OnLevelWasLoaded");

            if (!bDuplicateMojing)
            {
                heads         = FindObjectsOfType <MojingVRHead>();
                VRModeEnabled = MojingVRHead.Instance.VRModeEnabled;
            }
        }
        catch (Exception e)
        {
            MojingLog.LogError(e.ToString());
        }
    }
Exemplo n.º 22
0
    void OnEnable()
    {
        MojingLog.LogTrace("Enter Mojing.OnEnable");
        if (VRModeEnabled)
        {
            MojingSDK.Unity_EnterMojingWorld(GlassesKey, UseTimeWarp);
        }

#if UNITY_IOS
        MojingSDK.Unity_StartTracker(100);
#endif

        bWaitForMojingWord = true;
        heads = FindObjectsOfType <MojingVRHead>();
        //frameCount = 0;
        StartCoroutine("EndOfFrame");
        MojingLog.LogTrace("Leave Mojing.OnEnable  ");
    }
Exemplo n.º 23
0
 public static Manufacturers GetManufacturers(string strLanguageCodeByISO963)
 {
     try
     {
         string        json = GetManufacturerList(strLanguageCodeByISO963);
         Manufacturers list = JsonMapper.ToObject <Manufacturers>(json);
         for (int i = 0; i < list.ManufacturerList.Count; i++)
         {
             list.ManufacturerList[i].ProductList = GetProducts(list.ManufacturerList[i].KEY, strLanguageCodeByISO963);
         }
         return(list);
     }
     catch (Exception e)
     {
         MojingLog.LogTrace(e.ToString());
     }
     return(null);
 }
Exemplo n.º 24
0
    public static IEnumerator Unity_EnterMojingWorld(string sGlassesName, bool bTimeWarp, IntPtr pOtherParmams)
    {
        MojingLog.LogTrace("---> Unity_EnterMojingWorld");
        if (Unity_SetMojingWorld(sGlassesName, bTimeWarp, pOtherParmams))
        {
            yield return(new WaitUntil(() => Unity_CanEnterMojingWorld() == true));

#if UNITY_EDITOR || UNITY_STANDALONE_WIN
            if (SystemInfo.graphicsDeviceType == UnityEngine.Rendering.GraphicsDeviceType.OpenGL2 || SystemInfo.graphicsDeviceType == UnityEngine.Rendering.GraphicsDeviceType.OpenGLCore)
            {
                Unity_IssuePluginEvent((int)UnityEventID.EnterMojingWorld);
            }
#else
            Unity_IssuePluginEvent((int)UnityEventID.EnterMojingWorld);
#endif
            MojingLog.LogTrace("---> Unity_SetMojingWorld ok");
        }
    }
Exemplo n.º 25
0
    public void EnableEye(bool enable)
    {
        MojingLog.LogTrace("Enable Camera " + eye.ToString() + ": " + enable.ToString());
        enabled = enable;
        if (eye == Mojing.Eye.Left || eye == Mojing.Eye.Right)
        {
            // Setup FOV
            GetComponent <Camera>().fieldOfView = MojingSDK.Unity_GetGlassesFOV();

            //*****Solve the problem of splash screen when start up
            if (enable)
            {
                if (Mojing.SDK.NeedDistortion)
                {
#if UNITY_EDITOR_OSX
#elif UNITY_EDITOR || UNITY_STANDALONE_WIN
                    if (SystemInfo.graphicsDeviceType == UnityEngine.Rendering.GraphicsDeviceType.OpenGL2)
                    {
                        SetTargetTex(eye);
                    }
#else
                    SetTargetTex(eye);
#endif
                }
                else
                {
                    GetComponent <Camera>().targetTexture = null;
                }
            }
            //*****
            if ((!Mojing.SDK.bWaitForMojingWord) && Mojing.SDK.VRModeEnabled && Mojing.SDK.NeedDistortion)
            {
                GetComponent <Camera>().enabled = false;
            }
            else
            {
                GetComponent <Camera>().enabled = enable;
            }
        }
        else
        {
            GetComponent <Camera>().enabled = enable;
        }
    }
Exemplo n.º 26
0
    public static Manufacturers GetManufacturers(string strLanguageCodeByISO963)
    {
        try
        {
            string        json = GetManufacturerList(strLanguageCodeByISO963);
            Manufacturers list = JsonMapper.ToObject <Manufacturers>(json);

            foreach (ManufacturerInfo manufacturer in list.ManufacturerList)
            {
                MojingLog.LogTrace("To get product list of " + manufacturer.Display);
                manufacturer.ProductList = GetProducts(manufacturer.KEY, strLanguageCodeByISO963);
            }
            return(list);
        }
        catch (Exception e)
        {
            MojingLog.LogTrace(e.ToString());
        }
        return(null);
    }
Exemplo n.º 27
0
    IEnumerator EndOfFrame()
    {
        MojingLog.LogTrace("Enter Mojing.EndOfFrame thread");
        while (true)
        {
            yield return(waitForEndOfFrame);

            if ((!bWaitForMojingWord) && MojingVRHead.Instance.VRModeEnabled && NeedDistortion)
            {
                getTextureID(iFrameIndex);
                MojingSDK.SetTextureID(tID, sID);
                MojingSDK.Unity_DistortFrame();
#if UNITY_ANDROID
                // iOS 不启用三缓冲
                iFrameIndex = ++iFrameIndex % (screenNum / 2);
#endif
            }
        }
        //MojingLog.LogTrace("Leave Mojing.EndOfFrame thread");
    }
Exemplo n.º 28
0
    void OnEnable()
    {
        MojingLog.LogTrace("Enter Mojing.OnEnable");
        if (MojingVRHead.Instance.VRModeEnabled)
        {
            EnterMojingWorld();
        }
#if UNITY_IOS
        MojingSDK.Unity_StartTracker(100);
#endif

        bWaitForMojingWord = true;
        heads = FindObjectsOfType <MojingVRHead>();
        if (!g_bStartEndofFrame)
        {
            g_bStartEndofFrame = true;
            getTextureID(iFrameIndex);
            StartCoroutine(EndOfFrame());
        }
        MojingLog.LogTrace("Leave Mojing.OnEnable");
    }
Exemplo n.º 29
0
    void OnEnable()
    {
        MojingLog.LogTrace("Enter Mojing.OnEnable");
        if (VRModeEnabled)
        {
            MojingSDK.Unity_EnterMojingWorld(GlassesKey, ConfigItem.MT_STATE, ConfigItem.TW_STATE);
            if (SystemInfo.graphicsDeviceType == UnityEngine.Rendering.GraphicsDeviceType.Metal && !MojingSDK.Unity_IsGlassesNeedDistortionByName(glassesKey) && !ConfigItem.TW_STATE)
            {
                MojingSDK.Unity_DestroyMetalLayer();
            }
        }

#if UNITY_IOS
        MojingSDK.Unity_StartTracker(100);
#endif

        bWaitForMojingWord = true;
        heads = FindObjectsOfType <MojingVRHead>();
        //frameCount = 0;
        StartCoroutine("EndOfFrame");
        MojingLog.LogTrace("Leave Mojing.OnEnable  ");
    }
Exemplo n.º 30
0
 public void EnableEye(bool enable)
 {
     MojingLog.LogTrace("Enable Camera " + eye + ": " + enable);
     enabled = enable;
     //if (eye == Mojing.Eye.Left || eye == Mojing.Eye.Right)
     {
         // Setup FOV
         CurrentCamera.fieldOfView = MojingSDK.Unity_GetGlassesFOV();
         //*****Solve the problem of splash screen when start up
         if (enable)
         {
             if (Mojing.SDK.NeedDistortion)
             {
                 SetTargetTex(eye);
             }
             else
             {
                 CurrentCamera.targetTexture = null;
                 // SetUpEye();
             }
         }
     }
     CurrentCamera.enabled = enable;
 }