Game Development Community

Oculus Rift DK2

by Steve Lamperti · in Torque 3D Professional · 01/08/2015 (10:38 am) · 57 replies

I guess this post is a bit of an appeal for help. I work for a company that has a 3D window in our product that is based on T3D. We're always working on a new version, and when a customer said something about the Oculus Rift, I got excited, and told them that we might be able to support the rift in our next release, because I had seen information on this site about the engine supporting the rift.

I ordered the DK2, and was having a great time setting it up and playing with it, until I actually started trying to work with the code.

The DK2 interface is quite different then the DK1, and the current code in the engine is seriously out of date. The process of updating it is out of the scope of what I can do with the time I have available to work on it.

There is information on the OculusVR website about using T3D with the rift, and it's currently the case that anyone from there who tries will encounter the same problem.

After playing with the Rift for a while, it does seem like a powerful device, and it's sad if the T3D support is completely dropped.

I'm hoping that someone can update the code in the engine to support the DK2.
#21
03/16/2015 (5:21 pm)
Updated the branch. Rendering now works correctly, though the view is currently offset incorrectly. Also need to sort out the render target size more correctly as currently its a bit of a hack.
#22
03/17/2015 (4:16 pm)
Just an update, I've fixed the projection matrix so its pointing the right way. I'm currently changing GameTSCtrl so it renders to an offscreen render target instead of directly to the window, as required by the newer oculus APIs. It'll also make it a little easier to have a dynamic pixel density option.
#23
03/20/2015 (11:40 am)
Time for another update...

After realizing torque already supports off-center projection matrices, I scrapped the old hack which generates a projecton matrix using the oculus code and instead generated one with torque using the available fovport information provided by the sdk. This seems to have fixed all the weird issues I was having with the display, and upon eyeballing wearing the rift... appears to be more or less correct.

Remaining issues:

- Expose some more config options
- Fix the memory leak
- Resolve a few problems with initialization (sometimes it barfs out for unknown reasons)

Might be doing this later:
- Add some support for rendering 2d elements in the canvas
- Add support for rendering to two render targets

And a screenshot for the curious...

i.imgur.com/ZH4Czbh.jpg
Current changes are in the previously mentioned repository.
#24
03/25/2015 (1:43 pm)
Very cool!
#25
03/25/2015 (5:04 pm)
@James,
Just tried to build the source in your repository, and I'm getting a link error on gLastStereoTexture. I probably should leave it alone until you're further along, but I just thought you might want to know.


Edit: My bad, sorry. Dumb post. I hadn't included some files.
#26
03/28/2015 (1:04 pm)
@Steve

Might not have committed everything, I'll check it out tomorrow. Hopefully should get everything outstanding wrapped up by the end of the weekend.
#27
03/28/2015 (3:04 pm)
Great stuff! Awesome to see this coming along.
#28
04/02/2015 (2:44 am)
Pushed an update to the repository which smooths out the movement by using the latest pose data from the rift when rendering.

Currently working on an offscreen canvas implementation so I can have some sort of menu system in-game as currently the rift overrides all current rendering in torque, meaning you can't easily quit the game. I'm somewhat surprised there is still no solution for this in the T3D MIT repo.

I'm also going to update the repository to the latest development branch since there are a few peculiarities with the console code which were fixed.
#29
04/04/2015 (1:20 pm)
Another update....

I've added support for rendering an offscreen canvas in the centre of the display - a screenshot has been added below. It's by no means perfect, but I can now quit back to the menu as normal using some rather poor in-game mouse controls.

i.imgur.com/8UPderG.jpg
Current issues remaining:

- There's still some jitter with the camera in general. Not too sure where it's originating from at the moment, might need to go through the code with a fine toothcomb again.
- No callbacks for losing tracking state.
- Need more metrics to print.
- Need to update to the 0.5 sdk.
- Need some support for setting the world scale.
- OpenGL support (should be reasonably trivial provided I can get it loaded in windows or OSX or whatever)

If anyone has any issues with this code, please let me know.
#30
04/24/2015 (2:10 pm)
@James,

Feel like a noob asking this, but any hints about getting to rift library files up and running? When I tried to get this stuff running a little while ago, I found that I had trouble figuring out how to, and which files to, incorporate from the oculus rift SDK.
Any suggestions you could provide would be appreciated.
#31
04/25/2015 (5:03 am)
@Steve

Apologies, I have yet to write install instructions.

Basically in order for it to work you need to follow the instructions at http://wiki.torque3d.org/coder:oculus-rift-setup . The important things are:

- TORQUE_EXTENDED_MOVE needs to be defined
- The Extended move manager needs to be compiled in
- Oculus VR code needs to be compiled in
- You need to point your include paths to the relevant oculus sdk folder
- You need to link with the relevant oculus libs

I'll be updating the stuff to the 0.5 sdk today. Also going to write some more comprehensive instructions so anyone can check it out properly.
#32
04/26/2015 (9:44 am)
I consistently get these errors when building the exe
Error	56	error C2039: 'getCenterOffset' : is not a member of 'OculusVRHMDDevice'

Error	54	error C2039: 'getChromaticAbCorrection' : is not a member of 'OculusVRHMDDevice'

Error	55	error C2039: 'getDistortionScale' : is not a member of 'OculusVRHMDDevice'

Error	53	error C2039: 'getKDistortion' : is not a member of 'OculusVRHMDDevice'

All of these originate from barrelDistortionPostEffect.cpp at lines 118 130 124 143

Am I setting something up wrong, or is there an unmerged change to that file?
#33
04/26/2015 (11:53 am)
@alfalfa

barrelDistortionPostEffect.cpp should not be compiled in. I will remove this file from the repository to avoid further confusion.
#34
04/26/2015 (12:48 pm)
@James Thanks for clearing that up
#35
04/27/2015 (2:08 pm)
@James,

Trying to sync your code with my project, but I am running into the changes in the console code that you mentioned in a post above. The newer version of console.h from the development branch does not seem to be playing well with your code. Just to let you know. I will try reverting my console.h to see if I can work around this.
#36
04/27/2015 (2:40 pm)
@Steve

I\ll see about merging this with the latest development branch. Was holding off for a while due to aforementioned issues.
#37
05/01/2015 (6:07 am)
@James,

From the T3D community here is a big THANKS! for all your work on this. I have been busy with other projects and my DK2 is on loan to another group at the moment, but in a month or so when I get back to it I look forward to being able to use the DK2 with T3D.

Woooo Haaaa!
#38
05/05/2015 (3:00 pm)
I've updated the code so it is based on the latest development branch, which should resolve a few issues with the console code.

@Ken

Thanks!
#39
05/06/2015 (3:17 pm)
I've submitted a pull request with the current code, i.e. https://github.com/GarageGames/Torque3D/pull/1297

Differences since the last time:

- Tidied a few things up
- Added basic GL support on non-win32 platforms (not tested)
- Updated to latest development & oculus 0.5 SDK
- Added callback for tracking state
- Added world scale parameter for position tracking

Needs a little bit of feedback but this is probably the best state its been in for a few months so might as well see about merging it in. :)
#40
05/15/2015 (9:52 am)
Just noticed Oculus have released the 0.6 SDK. Will see about updating the current branch to that release provided its not too complicated. Based on the changelist I don't expect it to be.