private void makeNewScreens() { var displayMgr = MiddleVR.VRDisplayMgr; // For each vrCameraStereo, make a new screen for the right eye for (uint i = 0, iEnd = displayMgr.GetCamerasNb(); i < iEnd; ++i) { vrCamera cam = displayMgr.GetCameraByIndex(i); if (cam.IsA("CameraStereo")) { vrCameraStereo stereoCam = displayMgr.GetCameraStereoById(cam.GetId()); vrScreen leftScreen = stereoCam.GetCameraLeft().GetScreen(); vrScreen rightScreen = displayMgr.CreateScreen(leftScreen.GetName() + "right"); leftScreen.SetName(leftScreen.GetName() + "left"); rightScreen.SetParent(leftScreen.GetParent()); rightScreen.SetHeight(leftScreen.GetHeight()); rightScreen.SetWidth(leftScreen.GetWidth()); rightScreen.SetFiltered(leftScreen.IsFiltered()); rightScreen.SetTracker(leftScreen.GetTracker()); rightScreen.SetPositionWorld(leftScreen.GetPositionWorld()); rightScreen.SetOrientationWorld(leftScreen.GetOrientationWorld()); stereoCam.GetCameraRight().SetScreen(rightScreen); } } }
void TestDisplay() { // 3D nodes vrNode3D node = null; vrCamera camera = null; vrCameraStereo scam = null; vrScreen screen = null; vrViewport vp = null; if (MiddleVR.VRDisplayMgr != null) { node = MiddleVR.VRDisplayMgr.GetNode("HeadNode"); if (node != null) { MiddleVRTools.Log("Found HeadNode"); } camera = MiddleVR.VRDisplayMgr.GetCamera("Camera0"); if (camera != null) { MiddleVRTools.Log("Found Camera0"); } scam = MiddleVR.VRDisplayMgr.GetCameraStereo("CameraStereo0"); if (scam != null) { MiddleVRTools.Log("Found CameraStereo0"); } screen = MiddleVR.VRDisplayMgr.GetScreen("Screen0"); if (screen != null) { MiddleVRTools.Log("Found Screen0"); } vp = MiddleVR.VRDisplayMgr.GetViewport("Viewport0"); if (vp != null) { MiddleVRTools.Log("Found Viewport0"); } } }
void Update() { vrKeyboard keyb = MiddleVR.VRDeviceMgr.GetKeyboard(); // Invert eye if (keyb != null && keyb.IsKeyToggled(MiddleVR.VRK_I) && (keyb.IsKeyPressed(MiddleVR.VRK_LSHIFT) || keyb.IsKeyPressed(MiddleVR.VRK_RSHIFT))) { // For each vrCameraStereo, invert inter eye distance uint camNb = MiddleVR.VRDisplayMgr.GetCamerasNb(); for (uint i = 0; i < camNb; ++i) { vrCamera cam = MiddleVR.VRDisplayMgr.GetCameraByIndex(i); if (cam.IsA("CameraStereo")) { vrCameraStereo stereoCam = MiddleVR.VRDisplayMgr.GetCameraStereo(cam.GetName()); stereoCam.SetInterEyeDistance(-stereoCam.GetInterEyeDistance()); } } } }
protected void Update() { vrKeyboard keyboard = MiddleVR.VRDeviceMgr.GetKeyboard(); // Invert eyes. if (keyboard != null && keyboard.IsKeyToggled(MiddleVR.VRK_I) && (keyboard.IsKeyPressed(MiddleVR.VRK_LSHIFT) || keyboard.IsKeyPressed(MiddleVR.VRK_RSHIFT))) { var displayMgr = MiddleVR.VRDisplayMgr; // For each vrCameraStereo, invert inter eye distance. for (uint i = 0, iEnd = displayMgr.GetCamerasNb(); i < iEnd; ++i) { vrCamera cam = displayMgr.GetCameraByIndex(i); if (cam.IsA("CameraStereo")) { vrCameraStereo stereoCam = displayMgr.GetCameraStereoById(cam.GetId()); stereoCam.SetInterEyeDistance(-stereoCam.GetInterEyeDistance()); } } } }
private void TestDisplay() { var displayMgr = MiddleVR.VRDisplayMgr; if (displayMgr != null) { vrNode3D node = displayMgr.GetNode("HeadNode"); if (node != null) { MVRTools.Log("Found HeadNode"); } vrCamera cam = displayMgr.GetCamera("Camera0"); if (cam != null) { MVRTools.Log("Found Camera0"); } vrCameraStereo sCam = displayMgr.GetCameraStereo("CameraStereo0"); if (sCam != null) { MVRTools.Log("Found CameraStereo0"); } vrScreen screen = displayMgr.GetScreen("Screen0"); if (screen != null) { MVRTools.Log("Found Screen0"); } vrViewport vp = displayMgr.GetViewport("Viewport0"); if (vp != null) { MVRTools.Log("Found Viewport0"); } } }
private void applyOffset() { var displayMgr = MiddleVR.VRDisplayMgr; // For each vrCameraStereo, apply the new transform matrix to right cameras screen for (uint i = 0, iEnd = displayMgr.GetCamerasNb(); i < iEnd; ++i) { vrCamera cam = displayMgr.GetCameraByIndex(i); if (cam.IsA("CameraStereo")) { vrCameraStereo stereoCam = displayMgr.GetCameraStereoById(cam.GetId()); vrVec3 pos = stereoCam.GetCameraRight().GetScreen().GetPositionLocal(); pos.SetX(pos.x() + xDist); pos.SetY(pos.y() + yDist); stereoCam.GetCameraRight().GetScreen().SetPositionLocal(pos); /* * stereoCam.GetCameraRight().SetPositionLocal(new vrVec3(xDist, yDist, 0)); * stereoCam.GetCameraRight().SetRollLocal(roll); * stereoCam.GetCameraRight().SetYawLocal(yaw); * if ((frameCounter / 4) > 20) * { * quat = stereoCam.GetCameraRight().GetOrientationLocal(); * frameCounter = 0; * } * else * frameCounter++; * GetComponent<TextMesh>().text = quat.x() + ", " + quat.y() + ", " + quat.z() + ", " + quat.w(); * quat.SetY(roll); * quat.SetZ(yaw); * stereoCam.GetCameraRight().SetOrientationLocal(quat); */ } } }