Forum Discussion

🚨 This forum is archived and read-only. To submit a forum post, please visit our new Developer Forum. 🚨
sh0v0r's avatar
sh0v0r
Protege
12 years ago

A Simple Way to Disable Tracking...

I wanted to be able to lock the camera to a specific orientation during particular scenes and needed to prevent the tracker from rotating the cameras. This is the way I did it if anyone else needs to do this. Note once you do this you can then animate the Parent Controller to transform the cameras location/orientation.

1: Add a Bool to OVRCameraController


// Do we track the sensor or just look straight forward, default true
public bool Tracking = true;


2: Add a UI Toggle in the OVRCameraControllerEditor


m_Component.Chromatic = EditorGUILayout.Toggle ("Chromatic", m_Component.Chromatic);
m_Component.Tracking = EditorGUILayout.Toggle ("Tracking", m_Component.Tracking); // HERE!


3: Edit the SetOrientation Call Conditions in OVRCamera


// OnPreCull
void OnPreCull()
{
// NOTE: Setting the camera here increases latency, but ensures
// that all Unity sub-systems that rely on camera location before
// being set to render are satisfied.
if (CameraController.CallInPreRender == false && CameraController.Tracking) // HERE...
SetCameraOrientation();

}

// OnPreRender
void OnPreRender()
{
// NOTE: Better latency performance here, but messes up water rendering and other
// systems that rely on the camera to be set before PreCull takes place.
if (CameraController.CallInPreRender == true && CameraController.Tracking) // AND HERE
SetCameraOrientation();

if(CameraController.WireMode == true)
GL.wireframe = true;

// Set new buffers and clear color and depth
if(CameraTexture != null)
{
Graphics.SetRenderTarget(CameraTexture);
GL.Clear (true, true, gameObject.camera.backgroundColor);
}
}

7 Replies

Replies have been turned off for this discussion
  • I'm curious why you would ever disable tracking. It feels absolutely terrible when you hit a loading screen or cutscene that doesn't allow you to move your head, even if it is just subtle movements.
  • I agree with sinoth. You shouldn't disable the head tracker. Never. Well, except if your game is called "Don't Vomit". From my short experience with the rift, a disabled tracker is really the worst thing you can experience while watching a 3D scene. I did the test. It really hurts the brain. :oops:
  • Caine's avatar
    Caine
    Honored Guest
    Thank you sh0v0r! I'll actually be able to use this - you can get your 'head' lopped off in my project and people had commented it was kinda strange to have tracking once the head was rolling on the ground :)
  • "sinoth" wrote:
    I'm curious why you would ever disable tracking. It feels absolutely terrible when you hit a loading screen or cutscene that doesn't allow you to move your head, even if it is just subtle movements.


    Yeah I agree that does feel odd, I am experimenting with some things that I need to ensure the player is looking at something specific, particularly for Menu/UI interactions that are not attached to the camera but part of the environment.
  • "Caine" wrote:
    Thank you sh0v0r! I'll actually be able to use this - you can get your 'head' lopped off in my project and people had commented it was kinda strange to have tracking once the head was rolling on the ground :)

    You're right. My statement was a bit too general. In some cases (like yours) it seems to make sense to disable head tracking but I really didn't like my experiment with disabled head tracking while watching at a normal 3d scene. :)

    "sh0v0r" wrote:
    Yeah I agree that does feel odd, I am experimenting with some things that I need to ensure the player is looking at something specific, particularly for Menu/UI interactions that are not attached to the camera but part of the environment.

    Just a theoric idea but I don't know if it makes sense in your case : may be you could use a visual effect. For example, the scene could be temporarily darkened while the place holding the menu/ui is lighted, or the vision of the player could be temporarily blured except at the direction he should look (but not sure this solution would produce a nice psychological effect :lol: ) .. The best solution will surely depend on the context of the game and the moment at which this effect has to happen.

  • sh0v0r said:

    I wanted to be able to lock the camera to a specific orientation during particular scenes and needed to prevent the tracker from rotating the cameras. This is the way I did it if anyone else needs to do this. Note once you do this you can then animate the Parent Controller to transform the cameras location/orientation.



    1: Add a Bool to OVRCameraController


        // Do we track the sensor or just look straight forward, default true
    public bool Tracking = true;



    2: Add a UI Toggle in the OVRCameraControllerEditor


        m_Component.Chromatic = EditorGUILayout.Toggle ("Chromatic", m_Component.Chromatic);
    m_Component.Tracking = EditorGUILayout.Toggle ("Tracking", m_Component.Tracking); // HERE!



    3: Edit the SetOrientation Call Conditions in OVRCamera


    	// OnPreCull
    void OnPreCull()
    {
    // NOTE: Setting the camera here increases latency, but ensures
    // that all Unity sub-systems that rely on camera location before
    // being set to render are satisfied.
    if (CameraController.CallInPreRender == false && CameraController.Tracking) // HERE...
    SetCameraOrientation();

    }

    // OnPreRender
    void OnPreRender()
    {
    // NOTE: Better latency performance here, but messes up water rendering and other
    // systems that rely on the camera to be set before PreCull takes place.
    if (CameraController.CallInPreRender == true && CameraController.Tracking) // AND HERE
    SetCameraOrientation();

    if(CameraController.WireMode == true)
    GL.wireframe = true;

    // Set new buffers and clear color and depth
    if(CameraTexture != null)
    {
    Graphics.SetRenderTarget(CameraTexture);
    GL.Clear (true, true, gameObject.camera.backgroundColor);
    }
    }



    Hello!

    I know, this thread is old, but I really need help regarding this. Can you tell me, if this is still working with Unity and the Oculus Rift CV1.
    I tried to hard to deactivate tracking (rotational part is the important thing for me) and ENABLE it with an external Motion Capturing System, but nothing leaded to a good result.

    So, again my question: Is this still working?
  • Does anyone know how to disable the movement of the Oculus Rift camera? that is to say that when the user moves his head he always focuses on the same object. Can you help me please?.