void Update() { if (bWaitForMojingWord) { try { if (MojingSDK.IsInMojingWorld(sdk.GlassesKey)) { bWaitForMojingWord = false; MojingSDK.SetCenterLine(); NeedDistortion = MojingSDK.Unity_IsGlassesNeedDistortion(); UpdateProfile(); VRModeEnabled = MojingVRHead.Instance.VRModeEnabled; } } catch (Exception e) { MojingLog.LogError(e.ToString()); } } if (Screen.width != windowWidth || Screen.height != windowHeight) { MojingSDK.Unity_OnSurfaceChanged(Screen.width, Screen.height); windowWidth = Screen.width; windowHeight = Screen.height; } }
public void OnPreCull() { /* * if (!Mojing.SDK.NeedDistortion && Mojing.SDK.VRModeEnabled) * CurrentCamera.projectionMatrix = CreateMatrix(); * else * CurrentCamera.ResetProjectionMatrix(); */ if (Mojing.SDK.bWaitForMojingWord) { EnableEye(false); return; } if (CurrentCamera != null) { SetUpEye(); // --madi-- //mojing2 render directly if (!Mojing.SDK.NeedDistortion) { return; } SetTargetTex(eye); } else { MojingLog.LogError(eye.ToString() + ": no camera found."); } }
public static void SetTextureID(IntPtr left_textureID, IntPtr right_textureID) { try { Unity_SetTextureID(left_textureID, right_textureID); Unity_IssuePluginEvent((int)UnityEventID.SetTextureID); } catch (Exception e) { MojingLog.LogError(e.ToString()); } }
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()); } }
public void OnPreCull() { if (!Mojing.SDK.NeedDistortion && Mojing.SDK.VRModeEnabled) { GetComponent <Camera>().projectionMatrix = CreateMatrix(); } else { GetComponent <Camera>().ResetProjectionMatrix(); } if (Mojing.SDK.bWaitForMojingWord) { EnableEye(false); return; } if (GetComponent <Camera>() != null) { SetUpEye(); #if !UNITY_EDITOR && UNITY_ANDROID //mojing2 render directly if (!Mojing.SDK.NeedDistortion) { return; } if (MojingSDK.Unity_IsEnableATW()) { int iFrameIndex = 0; if (MojingSDK.Unity_IsATW_ON()) { // Unity_ATW_GetModelFrameIndex 接口中自带睡眠代码 iFrameIndex = MojingSDK.Unity_ATW_GetModelFrameIndex(); } switch (eye) { case Mojing.Eye.Left: GetComponent <Camera>().targetTexture = MojingRender.StereoScreen[iFrameIndex * 2]; break; case Mojing.Eye.Right: GetComponent <Camera>().targetTexture = MojingRender.StereoScreen[iFrameIndex * 2 + 1]; break; } } #endif } else { MojingLog.LogError(eye.ToString() + ": no camera found."); } }
public void UpdateState() { try { #if UNITY_EDITOR Quaternion rot; bool rolled = false; if (Input.GetKey(KeyCode.LeftAlt) || Input.GetKey(KeyCode.RightAlt)) { mouseX += Input.GetAxis("Mouse X") * 5; if (mouseX <= -180) { mouseX += 360; } else if (mouseX > 180) { mouseX -= 360; } mouseY -= Input.GetAxis("Mouse Y") * 2.4f; mouseY = Mathf.Clamp(mouseY, -85, 85); } else if (Input.GetKey(KeyCode.LeftControl) || Input.GetKey(KeyCode.RightControl)) { rolled = true; mouseZ += Input.GetAxis("Mouse X") * 5; mouseZ = Mathf.Clamp(mouseZ, -85, 85); } if (!rolled && autoUntiltHead) { // People don't usually leave their heads tilted to one side for long. mouseZ = Mathf.Lerp(mouseZ, 0, Time.deltaTime / (Time.deltaTime + 0.1f)); } rot = Quaternion.Euler(mouseY, mouseX, mouseZ); var neck = (rot * neckOffset - neckOffset.y * Vector3.up) * neckModelScale; headPose.Set(neck, rot); #else MojingSDK.Unity_getLastHeadView(ref headView); // Debug.Log("-----headView" + headView.ToString()); #if UNITY_ANDROID headPose.SetRightHanded(headView); #elif UNITY_IOS headPose.Set(headView); #endif #endif } catch (Exception e) { MojingLog.LogError(e.ToString()); } }
public static void SetTextureID(int left_textureID, int right_textureID) { try { //MojingLog.LogTrace("Set Texture ID = " + left_textureID.ToString()); //MojingLog.LogTrace("Set Texture ID = " + right_textureID.ToString()); Unity_SetTextureID(left_textureID, right_textureID); GL.IssuePluginEvent((int)UnityEventID.SetTextureID); } catch (Exception e) { MojingLog.LogError(e.ToString()); } }
public void OnPreCull() { if (Mojing.SDK.bWaitForMojingWord) { EnableEye(false); return; } if (GetComponent <Camera>() != null) { SetUpEye(); } else { MojingLog.LogError(eye.ToString() + ": no camera found."); } }
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()); } }
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"); }
void Update() { if (bWaitForMojingWord) { try { if (MojingSDK.Unity_IsInMojingWorld(sdk.GlassesKey)) { bWaitForMojingWord = false; MojingSDK.SetCenterLine(); NeedDistortion = MojingSDK.Unity_IsGlassesNeedDistortion(); UpdateProfile(); VRModeEnabled = vrModeEnabled; } } catch (Exception e) { MojingLog.LogError(e.ToString()); } } }
public override void Process() { try { pointerData.Reset(); // Find the gameObject which is in the ray of view pointerData.position = position; eventSystem.RaycastAll(pointerData, m_RaycastResultCache); pointerData.pointerCurrentRaycast = FindFirstRaycast(m_RaycastResultCache); m_RaycastResultCache.Clear(); GameObject go = pointerData.pointerCurrentRaycast.gameObject; // just do update work if the game object changed. if (go != lastGameObject) { // Send enter events and update the highlight. HandlePointerExitAndEnter(pointerData, go); // Update the current selection, or clear if it is no longer the current object. var selected = ExecuteEvents.GetEventHandler <ISelectHandler>(go); if (selected == eventSystem.currentSelectedGameObject) { ExecuteEvents.Execute(eventSystem.currentSelectedGameObject, GetBaseEventData(), ExecuteEvents.updateSelectedHandler); } else { eventSystem.SetSelectedGameObject(null, pointerData); } } // PlaceCursor(); HandleClick(); lastGameObject = go; } catch (Exception e) { MojingLog.LogError(e.ToString()); } }
void Awake() { MojingLog.LogTrace("Enter Mojing.Awake"); if (sdk == null) { MojingLog.LogWarn("Mojing SDK object is not sets."); sdk = this; #if UNITY_EDITOR_OSX #else #if UNITY_EDITOR || UNITY_STANDALONE_WIN || UNITY_IOS MojingSDK.Unity_Init("Unity " + Application.unityVersion, "C3845343263589043", "4117870080735505", "751db2db58cb82308d9c455c6d236a10", "http://fuwu.mojing.cn/api/appdownload", Screen.width, Screen.height, 320, 320, GetProfilePath(), IntPtr.Zero); #elif UNITY_ANDROID DisplayMetricsAndroid.InitDisplayMetricsAndroid(); AndroidJavaClass unityPlayer = new AndroidJavaClass("com.unity3d.player.UnityPlayer"); AndroidJavaObject activity = unityPlayer.GetStatic <AndroidJavaObject>("currentActivity"); MojingSDK.Unity_Init("Unity " + Application.unityVersion, "C3845343263589043", "3908657356234505", "faadffa1383206111ae162969b340ad9", "www.mojing.cn", DisplayMetricsAndroid.WidthPixels, DisplayMetricsAndroid.HeightPixels, DisplayMetricsAndroid.XDPI, DisplayMetricsAndroid.YDPI, GetProfilePath(), activity.GetRawObject()); #endif MojingSDK.Unity_OnSurfaceChanged(Screen.width, Screen.height); #endif #if !UNITY_EDITOR && UNITY_IOS MojingSDK.Unity_SetGamePadAxisMode(0); /* * mode: 0 --- default value, Send Axis's direction (LEFT/RIGHT/UP/DOWN/CENTER) * 1 --- Send Axis's position (x,y,z) * 2 --- Send both Axis's direction and postion */ #endif MojingSDK.Unity_SetEngineVersion("Unity " + Application.unityVersion); //DontDestroyOnLoad(sdk); //Remain Mojing GameObject even when change Scenes,just for Android } if (sdk != this) { MojingLog.LogWarn("Mojing SDK object should be a singleton."); bDuplicateMojing = true; enabled = false; return; } try { //清除Glasses列表 glassesNameList.Clear(); glassesKeyList.Clear(); //CreateDummyCamera(); #if UNITY_IOS Application.targetFrameRate = 60; #endif //StereoScreen = null; //解析json文件中的glass列表,获取glassesKeyList manufacturers_list = MojingSDK.GetManufacturers("zh"); for (int i = 0; i < manufacturers_list.ManufacturerList.Count; i++) { product_list = MojingSDK.GetProducts(manufacturers_list.ManufacturerList[i].KEY, "zh"); for (int j = 0; j < product_list.ProductList.Count; j++) { glasses_list = MojingSDK.GetGlasses(product_list.ProductList[j].KEY, "zh"); for (int k = 0; k < glasses_list.GlassList.Count; k++) { string GlassName = manufacturers_list.ManufacturerList[i].Display + " " + product_list.ProductList[j].Display + " " + glasses_list.GlassList[k].Display; string GlassKey = glasses_list.GlassList[k].KEY; string GlassID = manufacturers_list.ManufacturerList[i].ID + "/" + product_list.ProductList[j].ID + "/" + glasses_list.GlassList[k].ID; glassesKeyList.Add(GlassKey); glassesNameList.Add(GlassName); glassesIDList.Add(GlassID); glassesKey = FindGlassKey(manufacturers_list.ManufacturerList[i].ID, product_list.ProductList[j].ID, glasses_list.GlassList[k].ID); //glassesKey = GlassKey; //获取初始glassKey,mojingvrhead awake中用 } } } } catch (Exception e) { MojingLog.LogError(e.ToString()); } MojingLog.LogTrace("Leave Mojing.Awake"); }
void Awake() { m_bResetTextureId = true; if (sdk == null) { MojingLog.LogWarn("Mojing SDK object is not sets."); sdk = this; #if !UNITY_EDITOR && UNITY_IOS MojingSDK.Unity_Init("C3845343263589043", "3908040197953231", "8b20789122bae89442edadf780250ad5", "www.mojing.cn"); /* * mode: 0 --- default value, Send Axis's direction (LEFT/RIGHT/UP/DOWN/CENTER) * 1 --- Send Axis's position (x,y,z) * 2 --- Send both Axis's direction and postion */ MojingSDK.Unity_SetGamePadAxisMode(0); MojingSDK.Unity_OnSurfaceChanged(Screen.width, Screen.height); #endif MojingSDK.Unity_SetEngineVersion("Unity " + Application.unityVersion); //DontDestroyOnLoad(sdk); //Remain Mojing GameObject even when change Scenes,just for Android } if (sdk != this) { MojingLog.LogWarn("Mojing SDK object should be a singleton."); bDuplicateMojing = true; enabled = false; return; } try { //清除Glasses列表 glassesNameList.Clear(); glassesKeyList.Clear(); CreateDummyCamera(); Application.targetFrameRate = 60; //MojingRender.StereoScreen = null; //解析json文件中的glass列表,获取glassesKeyList manufacturers_list = MojingSDK.GetManufacturers("zh"); foreach (ManufacturerInfo MI in manufacturers_list.ManufacturerList) { product_list = MojingSDK.GetProducts(MI.KEY, "zh"); foreach (ProductInfo PI in product_list.ProductList) { glasses_list = MojingSDK.GetGlasses(PI.KEY, "zh"); foreach (GlassInfo GI in glasses_list.GlassList) { string GlassName = MI.Display + " " + PI.Display + " " + GI.Display; string GlassKey = GI.KEY; glassesKey = GlassKey; //获取初始glassKey,mojingvrhead awake中用 glassesKeyList.Add(GlassKey); glassesNameList.Add(GlassName); } } } } catch (Exception e) { MojingLog.LogError(e.ToString()); } MojingLog.LogTrace("Leave Mojing.Awake"); }
void Awake() { m_bResetTextureId = true; if (sdk == null) { MojingLog.LogWarn("Mojing SDK object is not sets."); sdk = this; #if UNITY_EDITOR_OSX #else #if UNITY_EDITOR || UNITY_STANDALONE_WIN MojingSDK.Unity_Init("C3845343263589043", "3956931912082870", "def5833993bbb001554ac192a79c9727", "www.mojing.cn", GetProfilePath()); #elif UNITY_IOS MojingSDK.Unity_Init("C3845343263589043", "3961565540023130", "f34c9b49192c5e6026f99125bdbabd27", "www.mojing.cn"); #endif MojingSDK.Unity_OnSurfaceChanged(Screen.width, Screen.height); #endif #if !UNITY_EDITOR && UNITY_IOS MojingSDK.Unity_SetGamePadAxisMode(0); /* * mode: 0 --- default value, Send Axis's direction (LEFT/RIGHT/UP/DOWN/CENTER) * 1 --- Send Axis's position (x,y,z) * 2 --- Send both Axis's direction and postion */ #endif MojingSDK.Unity_SetEngineVersion("Unity " + Application.unityVersion); //DontDestroyOnLoad(sdk); //Remain Mojing GameObject even when change Scenes,just for Android } if (sdk != this) { MojingLog.LogWarn("Mojing SDK object should be a singleton."); bDuplicateMojing = true; enabled = false; return; } try { //清除Glasses列表 glassesNameList.Clear(); glassesKeyList.Clear(); CreateDummyCamera(); Application.targetFrameRate = 60; //MojingRender.StereoScreen = null; //解析json文件中的glass列表,获取glassesKeyList manufacturers_list = MojingSDK.GetManufacturers("zh"); foreach (ManufacturerInfo MI in manufacturers_list.ManufacturerList) { product_list = MojingSDK.GetProducts(MI.KEY, "zh"); foreach (ProductInfo PI in product_list.ProductList) { glasses_list = MojingSDK.GetGlasses(PI.KEY, "zh"); foreach (GlassInfo GI in glasses_list.GlassList) { string GlassName = MI.Display + " " + PI.Display + " " + GI.Display; string GlassKey = GI.KEY; glassesKey = GlassKey; //获取初始glassKey,mojingvrhead awake中用 glassesKeyList.Add(GlassKey); glassesNameList.Add(GlassName); } } } } catch (Exception e) { MojingLog.LogError(e.ToString()); } LCamera = GameObject.Find("MojingMain/MojingVrHead/VR Camera Left").GetComponent <Camera>(); RCamera = GameObject.Find("MojingMain/MojingVrHead/VR Camera Right").GetComponent <Camera>(); MojingLog.LogTrace("Leave Mojing.Awake"); }