Question Oculus Issues

maym86

New Member
Contributor
Hello,

I have been trying to run the latest build with Oculus support on a Windows 7 64-bit machine.

I followed the instructions underneath this video


The wrapper for the Oculus lib isn't working. I have tried both the precompile TeraOVR and compiled the dll myself. Neither work. When I run the game with the tera-ovr64.dll in the natives/windows folder the program logs the following error

[main] WARN o.terasology.engine.TerasologyEngine - Could not load optional TeraOVR native libraries - Oculus support disabled

After editing the source code to print the actual error I get this:

[main] WARN o.terasology.engine.TerasologyEngine - C:\Users\hsvl\Documents\Terasology\natives\windows\tera-ovr64.dll: Invalid access to memory location

It means that the dll is not being loaded to support the Oculus input. The same issue occurs when I run the TeraOVR.java class which comes with the Oculus wrapper. Has anyone had this problem?

I am using the latest 64-bit version of the JRE and JDK: 7.45

Thanks,

Mike
 

Cervator

Org Co-Founder & Project Lead
Contributor
Design
Logistics
SpecOps
Hi maym86 !

The Oculus support was implemented back before we went through our major "Great Convergence" project that brought multiplayer and a new codebase structure back into the develop branch. Chances are something broke in the process and the only one of us with an Oculus Rift (that I know of) is begla

What you might want to try is see if you can get it working with the legacy branch ? If it works there and not in develop then we definitely broke it :)

A lot of stuff is getting loaded differently now and a lot of paths have changed.

I'll try to badger begla a bit to see if he can test on his setup sometime :D
 

maym86

New Member
Contributor
Think the issue is with Java loading the dll not the Terasology side of things. Java fails on the System.loadLibrary("tera-ovr64"); before any of the code is actually used. This happens with a bare bones test java class which is just trying to load the native Oculus libaray. I even had the same error when I compiled and ran a different Oculus Java library. https://github.com/38leinaD/JRift. Same Invalid access to memory location when I ran that so I'm thinking it's something to do with my machine or how I'm building the library. Any thoughts?

Would definitely appreciate some help from @begla.

Thanks

Mike
 

Cervator

Org Co-Founder & Project Lead
Contributor
Design
Logistics
SpecOps
I heard back from begla and he'll try to pop on IRC sometime over the weekend :)

I'm not sure we've ever had it tested off his machine, maybe there was some local magic present there that never made it on to GitHub.

Immortius also has some experience with using native code from Java - but dunno if that error would ring a bell.
 

Immortius

Lead Software Architect
Contributor
Architecture
GUI
I suspect tera-ovr64.dll uses an oculus rift dll, so the issue may be that you need to put that dll in natives/windows as well, or the oculus rift dll may have broken compatibility? The invalid access to memory location error indicates an issue within the dll at any rate.
 

begla

Project Founder and Lead Developer
Contributor
Architecture
Logistics
Yey, someone who at least tried to get the Oculus Rift support in Terasology up and running. Welcome maym86! :)

Guess it is as Immortius pointed out. The native C++ library/wrapper I wrote back then based on a certain version of the Oculus SDK - which has been updated multiple of times since then. So to get it working with the latest version of the SDK the following steps might be necessary...
  • Use an older version of the SDK (I used version 0.2.2 if I recall correctly)
  • ... alternatively the native C++ library has to be recompiled using the latest version of the Oculus SDK
  • ...the library has to be adjusted due to changes to the Oculus SDK's API and there might be some changes necessary in Terasology's core (might be optional)
I'll try to fix this whenever I find the time - but I can't make any promises when. Maybe next weekend, maybe the weekend after, ... Let me know if you have any success using an older version of the SDK!
 

maym86

New Member
Contributor
Ok. It got it working with the latest build of Terasology by adding the following legacy code into LocalPlayerSystem.java at line 130 right after:

Code:
 processInput(entity, characterComp, characterMovementComponent);
        updateCamera(characterComp, characterMovementComponent, characterComp, location);

This is from the legacy version with a few variable changes:

Code:
if (CoreRegistry.get(Config.class).getRendering().isOculusVrSupport()
                && OculusVrHelper.isNativeLibraryLoaded()){
 
            lookYaw += OculusVrHelper.getYawRelativeToLastCall() * (180.0f / (float) Math.PI);
            lookPitch += -1.0f * OculusVrHelper.getPitchRelativeToLastCall() * (180.0f / (float) Math.PI);
            lookRoll += -1.0f * OculusVrHelper.getRollRelativeToLastCall() * (180.0f / (float) Math.PI);
 
            LocationComponent loc = entity.getComponent(LocationComponent.class);
            if (loc != null) {
                QuaternionUtil.setEuler(loc.getLocalRotation(), TeraMath.DEG_TO_RAD * lookYaw,  TeraMath.DEG_TO_RAD * lookPitch, TeraMath.DEG_TO_RAD * lookRoll);
            }
        }
        /

I built the dll with the old oculus lib (0.2.2) and that works now.

Will look into updating it to the new Oculus lib but if you can take a look that wold be great as I am new to the library.

Thanks for the feedback. Was very useful.

Mike
 

Cervator

Org Co-Founder & Project Lead
Contributor
Design
Logistics
SpecOps
Ah-hah! Nice catch. Contributor badge for you, many thanks :)
 

maym86

New Member
Contributor
Ok fixed the dll for the new 0.2.5 oculus sdk

The SensorFusion object needs to be a pointer now.

Code below:

Code:
Ptr<DeviceManager> g_Manager = 0;
Ptr<HMDDevice> g_HMD = 0;
Ptr<SensorDevice>    g_Sensor = 0;
SensorFusion* g_FusionResult;
HMDInfo g_Info;
bool g_InfoLoaded;
 
JNIEXPORT void JNICALL Java_org_terasology_TeraOVR_initSDK
  (JNIEnv * p_Env, jclass p_Class)
{
 
    OVR::System::Init();
 
    g_FusionResult = new SensorFusion();
 
 
    g_Manager = *DeviceManager::Create();
    g_HMD = *g_Manager->EnumerateDevices<HMDDevice>().CreateDevice();
 
    if (g_HMD)
    {
        g_Sensor = *g_HMD->GetSensor();
        g_InfoLoaded = g_HMD->GetDeviceInfo(&g_Info);
 
 
    }
    else
    {
        g_Sensor = *g_Manager->EnumerateDevices<SensorDevice>().CreateDevice();
    }
 
    if (g_Sensor)
    {
    g_FusionResult->AttachToSensor(g_Sensor);
    }
}
 
JNIEXPORT void JNICALL Java_org_terasology_TeraOVR_clear
  (JNIEnv * p_Env, jclass p_Class)
{
    g_Sensor.Clear();
    g_Manager.Clear();
    g_HMD.Clear();
 
    delete g_FusionResult;
 
    OVR::System::Destroy();
}
 
Top