public Data() { eye = WVR_Eye.WVR_Eye_Left; camera = null; wvrCamera = null; cmdBuf = null; mesh = null; }
void MyRenderEye(WaveVR_Render render, WVR_Eye eye, WaveVR_Camera wvrCamera) { if (eye == WVR_Eye.WVR_Eye_Both) { return; } var camera = wvrCamera.GetCamera(); canvas.worldCamera = camera; canvas.renderMode = RenderMode.ScreenSpaceCamera; }
private WaveVR_Camera CreateEye(WVR_Eye eye) { Log.d(LOG_TAG, "CreateEye(" + eye + ")+"); bool isleft = eye == WVR_Eye.WVR_Eye_Left; WaveVR_Camera vrcamera = isleft ? lefteye : righteye; Camera camera; if (vrcamera == null) { string eyename = isleft ? OBJ_NAME_LEFT_EYE : OBJ_NAME_RIGHT_EYE; GameObject go = new GameObject(eyename); go.transform.SetParent(transform, false); camera = go.AddComponent <Camera>(); camera.nearClipPlane = GetComponent <Camera>().nearClipPlane; camera.farClipPlane = GetComponent <Camera>().farClipPlane; go.AddComponent <FlareLayer>(); go.AddComponent <GUILayer>(); vrcamera = go.AddComponent <WaveVR_Camera>(); } else { camera = vrcamera.GetComponent <Camera>(); } if (Application.isEditor) { camera.transform.localPosition = new Vector3(isleft ? -ipd / 2 : ipd / 2, 0, 0.15f); } else { camera.transform.localPosition = eyes[isleft ? 0 : 1].pos; } vrcamera.eye = eye; camera.enabled = false; if (Application.isEditor) { camera.projectionMatrix = GetEditorProjection(eye); } else { camera.projectionMatrix = GetProjection(eye); } Log.d(LOG_TAG, "CreateEye(" + eye + ")-"); return(vrcamera); }
public void SendRenderTexturePtr(WaveVR_Render render, WVR_Eye eye, WaveVR_Camera wvrCamera) { if (connectType != 1) { return; // USB } if (!enablePreview) { return; } //if () only 1 time if (!isLeftReady && eye == WVR_Eye.WVR_Eye_Left) { rt_L = wvrCamera.GetCamera().targetTexture; if (rt_L != null) { rt[0] = rt_L.GetNativeTexturePtr(); Debug.LogWarning("rt[0] : " + rt[0]); isLeftReady = true; lastUpdateTime = 0; } else { Debug.LogWarning("rt_L == null"); } } if (!isRightReady && eye == WVR_Eye.WVR_Eye_Right) { rt_R = wvrCamera.GetCamera().targetTexture; if (rt_R != null) { rt[1] = rt_R.GetNativeTexturePtr(); Debug.LogWarning("rt[1] : " + rt[1]); isRightReady = true; lastUpdateTime = 0; } else { Debug.LogWarning("rt_R == null"); } } if (isLeftReady && isRightReady) { if (mFPS == 0) { if (Application.targetFrameRate > 0 && Application.targetFrameRate < 99) { mFPS = Application.targetFrameRate; } else { mFPS = 75; } Debug.LogWarning("mFPS is changed to " + mFPS); } long currentTime = getCurrentTimeMillis(); if (currentTime - lastUpdateTime >= (1000 / mFPS)) { if (eye == WVR_Eye.WVR_Eye_Left) { var height = wvrCamera.GetCamera().targetTexture.height; if ((height % 2) != 0) { Debug.LogWarning("RenderTexture height is odd, skip."); return; } var l1 = wvrCamera.GetCamera().targetTexture.GetNativeTexturePtr(); if (l1 != rt[0]) { Debug.LogWarning("left native pointer changed"); isLeftReady = false; isRightReady = false; return; } leftCall = true; } if (eye == WVR_Eye.WVR_Eye_Right) { var height = wvrCamera.GetCamera().targetTexture.height; if ((height % 2) != 0) { Debug.LogWarning("RenderTexture height is odd, skip."); return; } var r1 = wvrCamera.GetCamera().targetTexture.GetNativeTexturePtr(); if (r1 != rt[1]) { Debug.LogWarning("right native pointer changed"); isLeftReady = false; isRightReady = false; return; } rightCall = true; } if (leftCall && rightCall) { lastUpdateTime = currentTime; if (WVR_DirectPreview.WVR_SetRenderImageHandles(rt)) { // Debug.LogWarning("callback successfully"); } else { Debug.LogWarning("callback fail"); } leftCall = false; rightCall = false; } } } }