- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi all,
I have just start developing my first RealSense application using Unity3D, however, we are facing an issue when trying to disable mirror mode for an AR application.
In the SDK Manual, there is PXCMCapture.Device.MirrorMode and PXCMCapture.Device.MirrorMode.MIRROR_MODE_DISABLED
If I try to call capture manager and set the devices Mirror Mode:
cManager.device.SetMirrorMode ( PXCMCapture.Device.MirrorMode.MIRROR_MODE_DISABLED);
By adding above statement in SenseToolkitManager.cs, I get an an error with a null reference exception for Capture Manager object...
I wonder where and how should the Mirror property be set?
Thanks in advance!
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I don't personally know about how the Mirror Mode works - maybe someone on this forum can help with that. There are alternatives to creating a mirror in Unity though if the Mirror Mode does not work out.
If you want to create a mirror that shows the user's RL body then you could create a large board by stretching and scaling a Cube object and apply something called a WebCamTexture to the surface of it so that the camera's video feed streams onto the board in place of the texture that you have placed on the board.
http://docs.unity3d.com/ScriptReference/WebCamTexture.html
If you want to put a view from a Unity game camera onto a mirror surface then you can use a RenderTexture.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
It is possible to flip the camera view horizontally and / or vertically using a script placed inside it. I found a JavaScript one on the net and tried it with my own mirror to confirm that it works.
Here's one that flips both horizontally and vertically.
// EXAMPLE WITH CAMERA UPSIDEDOWN function OnPreCull () { GetComponent.<Camera>().ResetWorldToCameraMatrix (); GetComponent.<Camera>().ResetProjectionMatrix (); GetComponent.<Camera>().projectionMatrix = GetComponent.<Camera>().projectionMatrix * Matrix4x4.Scale(Vector3 (-1, -1, 1)); } function OnPreRender () { GL.SetRevertBackfacing (true); } function OnPostRender () { GL.SetRevertBackfacing (false); } @script RequireComponent (Camera)
And here is the one that only flips horizontally.
// EXAMPLE WITH CAMERA UPSIDEDOWN function OnPreCull () { GetComponent.<Camera>().ResetWorldToCameraMatrix (); GetComponent.<Camera>().ResetProjectionMatrix (); GetComponent.<Camera>().projectionMatrix = GetComponent.<Camera>().projectionMatrix * Matrix4x4.Scale(Vector3 (1, -1, 1)); } function OnPreRender () { GL.SetRevertBackfacing (true); } function OnPostRender () { GL.SetRevertBackfacing (false); } @script RequireComponent (Camera)
Basically in the "Scale(Vector3 (1, -1, 1))" section, you can flip a particular axis by adding a minus sign in front of the '1' numbers in the bracket - the first being X, the second being Y and the third being Z.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Regarding disabling Mirror Mode: if your Mirror Mode script is inside an object, then disabling that object should also disable the visibility of any scripted effects generated by it.
The simple JavaScript script below can disable an object by un-ticking the tick-box at the very top of the Inspector panel that controls whether an object is active or not.
function Start () { gameObject.active = false; }
Place it inside the object containing your Mirror Mode script. If you want to make a separate script that makes the Mirror Mode object visible again, just change "false" in the above code to "true" so that it reads:
function Start () { gameObject.active = true; }
Edit: if you want an easy way of triggering an activation or deactivation script, you can link your script to a SendMessageAction script that is supplied with the RealSense Unity Toolkit. Then you could use a hand or face gesture to turn the Mirror Mode on and off.
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page