Skip to main content
October 4, 2015

Anyone got working example with ovrLayerType_QuadHeadLocked?

Does anyone know of a publicly readable code example of a working Rift application that uses ovrLayerType_QuadHeadLocked or ovrLayerType_QuadInWorld?

I'm following the developer documentation at https://developer.oculus.com/documentat ... der_layers

I got my basic rendering working with SDK 0.7, and now I'm trying to add a second layer. I'm pretty much following the code example in the documentation (except the symbol "ovrLayerType_Quad" in the docs, does not appear to exist in SDK 0.7). I figure the "ovrLayerType_QuadHeadLocked" is probably more likely than "ovrLayerType_QuadInWorld" to lead to the first experience of "Hey I seem my layer actually rendering for the first time", but I have experimented with each, and I have yet to see any evidence of a second layer.

Sorry I don't have a complete code example at the moment. This is embedded in 100,000 lines of code. But if this problem drags on, I will probably try to implement a simple standalone example using the AWESOME PYTHON BINDINGS I recently made.


// Second Monoscopic Quad layer for menus
// Create HUD layer, fixed to the player's torso
hudLayer.Header.Type = ovrLayerType_QuadHeadLocked; // Was non-existent "ovrLayerType_Quad" in the docs...
hudLayer.Header.Flags = ovrLayerFlag_TextureOriginAtBottomLeft | ovrLayerFlag_HighQuality;
hudLayer.ColorTexture = hudTextureSet; // single texture for both eyes;
// 50cm in front and 20cm down from the player's nose,
// fixed relative to their torso.
float hudScale = 1.0f;
hudLayer.QuadPoseCenter.Position.x = 0.00f * hudScale;
hudLayer.QuadPoseCenter.Position.y = -0.20f * hudScale;
hudLayer.QuadPoseCenter.Position.z = -0.50f * hudScale;
hudLayer.QuadPoseCenter.Orientation = ovrQuatf();
// HUD is 50cm wide, 30cm tall.
hudLayer.QuadSize.x = 0.50f * hudScale;
hudLayer.QuadSize.y = 0.30f * hudScale;
// Display all of the HUD texture.
hudLayer.Viewport.Pos.x = 0.0f;
hudLayer.Viewport.Pos.y = 0.0f;
hudLayer.Viewport.Size.w = 1.0f;
hudLayer.Viewport.Size.h = 1.0f;

    9 replies

    Inspiring
    December 19, 2015
    It seems you are missing ovrViewScaleDesc

    ovrViewScaleDesc viewScaleDesc;
    viewScaleDesc.HmdSpaceToWorldScaleInMeters = 1.0f;
    viewScaleDesc.HmdToEyeViewOffset[0] = hmdToEyeViewOffset[0];
    viewScaleDesc.HmdToEyeViewOffset[1] = hmdToEyeViewOffset[1];


    Also
    hudLayer.Header.Flags = ovrLayerFlag_HeadLocked;
    is now a Flag for usage with
    hudLayer.Header.Type = ovrLayerType_Quad;


    - beside this, I also did not get it to work. guess there is no official information about this - the SDK states there is the capability of Quad rendering, but maybe it is one of these pitfalls again were you can waste a week or two trying out why quad rendering is not working and then get information the SDK states wrong about availability of this feature...

    PS: before I a am about to waste a week or two because of bugs in the SDK (again!), it would be great to get an official statement on this!
    joan
    Up and Coming
    December 19, 2015
    OculusWorldDemo makes use of it.

    Hit TAB to raise the main menu then Layers, set Layers Enabled to ON, then set World Layer Enabled to ON. The quad is floating beside the staircase.

    Do a search in OculusWorldDemo.cpp, it starts line 2087, several demo layers use this type.
    Inspiring
    December 20, 2015
    Thank you very much, got it working now. Seems one line from the Oculus Documentation was the "hint" that killed it

    hudLayer.QuadPoseCenter.Orientation = ovrQuatf();


    Is not giving you a neutral whatever rotation, but an completely invalid quaternion, leading to a non rendered/visible QuadLayer. Why for sake does anybody add such a nonsense to the very one documentation example if it is working worse than guessing...
    kojack
    Honored Contributor
    December 21, 2015
    That's odd. Looking at the source, ovrQuatf() should be returning a valid unit length identity quaternion. Is the value something other than wxyz=1,0,0,0?
    Author: Oculus Monitor , Auto Oculus Touch , Forum Dark Mode , Phantom Touch Remover , X-Plane Fixer Hardware: Threadripper 1950x, MSI Gaming Trio 2080TI, Asrock X399 Taich Headsets: Wrap 1200VR, DK1, DK2, CV1, Rift-S, GearVR, Go, Quest, Quest 2, Reverb G2, Quest 3
    Inspiring
    December 21, 2015
    Nope, its all Zeros... just made an output directly after assigning, quad was gone again...

    ...and looking at the code, I have no idea how w could/should become 1 by itself...


    /// A quaternion rotation.
    typedef struct OVR_ALIGNAS(4) ovrQuatf_
    {
    float x, y, z, w;
    } ovrQuatf;
    kojack
    Honored Contributor
    December 21, 2015
    Ah, yep, you're right. I was looking in the C++ quaternion code (which has a valid constructor setting w to 1), not the C code (which is of course just an uninitialised struct). Assigning ovrQuatf() to anything is pointless.

    The Quat class in OVR_Math.h has a C compatibility cast operator that gives an ovrQuatf, so you could probably do:
    hudLayer.QuadPoseCenter.Orientation = Quat();
    although I haven't tried.
    Author: Oculus Monitor , Auto Oculus Touch , Forum Dark Mode , Phantom Touch Remover , X-Plane Fixer Hardware: Threadripper 1950x, MSI Gaming Trio 2080TI, Asrock X399 Taich Headsets: Wrap 1200VR, DK1, DK2, CV1, Rift-S, GearVR, Go, Quest, Quest 2, Reverb G2, Quest 3
    Inspiring
    December 21, 2015
    Thx. I just assigned the values by hand. No problem assigning a quaternion, just a bit frustrating seeing a 2 billion $ funding not being able to test the very simplest of Documentation leading to developers sometimes loosing weeks (as with that totally useless 0.7 release) - that is how one can save this little extra cost of verifying a manual... how great private developers loosing time is nothing OculusVR has to pay for...
    Inspiring
    December 21, 2015
    I will have someone fix this. Thanks for bringing it up.
    AMD Ryzen 7 1800X | MSI X370 Titanium | G.Skill 16GB DDR4 3200 | EVGA SuperNOVA 1000 | Corsair Hydro H110i Gigabyte RX Vega 64 x2 | Samsung 960 Evo M.2 500GB | Seagate FireCuda SSHD 2TB | Phanteks ENTHOO EVOLV
    Inspiring
    January 4, 2016
    Its been two weeks, and the Documentation is still wrong! Two more weeks developers can fall into this open pitfall...