Forum Discussion

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

Wiki?

Was the Wiki taken offline? I'm trying to find that Minimal Oculus sample code that Cybereality wrote.

2 Replies

  • Sorry, the wiki is down now.

    Here is the code for the tutorial (you just have to setup project settings yourself).

    #include "OVR_CAPI.h"
    #include "Kernel\OVR_Math.h"
    #include <iostream>
    #include <conio.h>
    #include <windows.h>

    using namespace OVR;
    using namespace std;

    ovrHmd hmd;
    ovrFrameTiming frameTiming;

    void Init()
    {
    ovr_Initialize();

    hmd = ovrHmd_Create(0);

    if(!hmd) return;

    ovrHmd_ConfigureTracking(hmd, ovrTrackingCap_Orientation | ovrTrackingCap_MagYawCorrection | ovrTrackingCap_Position, 0);
    }

    void Clear()
    {
    ovrHmd_Destroy(hmd);

    ovr_Shutdown();
    }

    void Output()
    {
    // Optional: we can overwrite the previous console to more
    // easily see changes in values
    HANDLE h = GetStdHandle(STD_OUTPUT_HANDLE);
    CONSOLE_SCREEN_BUFFER_INFO bufferInfo;
    GetConsoleScreenBufferInfo(h, &bufferInfo);

    while(hmd){
    frameTiming = ovrHmd_BeginFrameTiming(hmd, 0);
    ovrTrackingState ts = ovrHmd_GetTrackingState(hmd, frameTiming.ScanoutMidpointSeconds);

    if (ts.StatusFlags & (ovrStatus_OrientationTracked | ovrStatus_PositionTracked)) {
    // The cpp compatibility layer is used to convert ovrPosef to Posef (see OVR_Math.h)
    Posef pose = ts.HeadPose.ThePose;
    float yaw, pitch, roll;
    pose.Rotation.GetEulerAngles<Axis_Y, Axis_X, Axis_Z>(&yaw, &pitch, &roll);

    // Optional: move cursor back to starting position and print values
    SetConsoleCursorPosition(h, bufferInfo.dwCursorPosition);
    cout << "yaw: " << RadToDegree(yaw) << endl;
    cout << "pitch: " << RadToDegree(pitch) << endl;
    cout << "roll: " << RadToDegree(roll) << endl;

    Sleep(50);
    }

    ovrHmd_EndFrameTiming(hmd);

    if (_kbhit()) exit(0);
    }
    }

    int main()
    {
    Init();

    Output();

    Clear();

    return 0;
    }
  • sbf0202's avatar
    sbf0202
    Honored Guest
    Thanks! It worked!

    Now to try and combine this with Irrlicht or Ogre3D