Oculus Rift Support In Blender Game Engine

Blender Logooculus-rift

Motivation

With Blender Game Engine we would have a Free Software alternative to Unity for virtual reality demos with the Oculus Rift. Existing BGE demos could be ported easily. With BGE you can easily create and import assets to your demo.

Status of the Rift in Free Software

Since it’s release in March, the Oculus Rift has seen a rather good adoption in proprietary Game Engines. Source, UDK3 and primarily Unity have embraced the new VR technolgy early. Sadly the community was only given Unity and C/C++ as tools, so most current demos are done with Unity. Free Software like Blender was rather sceptical about implementation due to the proprietary licensing of the Oculus SDK. The SDK license demonstrates that open source does not equal free software.
Only a few Oculus Demos were available for GNU/Linux, due to there not being a release of the official SDK. Because of that proprietary demos like Team Fortress 2 also do not include Rift support. Also the Unity Demos are not built for Linux, but OS X and Windows only.
Luckily we are in the github era, where you can find software for every need on the internet. The official Oculus SDK was ported to C and Linux by nsb, but has to keep it’s license. Another interesting project is libvr by thib, which has a BSD-2-clause license. Both libraries work in GNU/Linux without problems, but the first one is not a candidate of choice for Blender, since it lacks a free software license. The third available library is OpenHMD, it is Boost licensed. I made a minimalist Python wrapper for it, so we now have the Rift sensor in BGE. I achieved this in a similar approach to my Wii Balance Board wrapper for Python / BGE.

Including Rift input to your Blender Game Engine Demo

To build my github project, you need OpenHMD installed. For convenience, I created an Arch User Repository package, for us arch users 😉
For everyone else, install it in /usr/local or write a debian package, etc.
To build python-rift, you need to run “./setup.py build”. You need to symlink the .so file to your ~/.blender directory.


mkdir ~/.blender/2.67/scripts/addons/game_engine_rift/
ln -s /foo/python-rift/rift.cpython-33m.so ~/.blender/2.67/scripts/addons/game_engine_rift/

view raw

move.sh

hosted with ❤ by GitHub

Since it is in your Blender’s Python path now, you can initialize the PyRift object in BGE like this.


from game_engine_rift.rift import PyRift
def poll(rift):
rift.poll()
bge.logic.rotation = Quaternion((rift.rotation[0],
rift.rotation[1],
rift.rotation[2],
rift.rotation[3]))
try:
poll(bge.logic.rift)
except AttributeError:
bge.logic.rift = PyRift()

view raw

input.py

hosted with ❤ by GitHub

The rotation is acquired as an quaterion. Note that OpenHDM uses XYZW, but Blender WXYZ. I did get headaches not only from figuring that out, but also from the wrong rotation when I had the HMD on.
You can transform your camera like this.


try:
eu = bge.logic.rotation.to_euler()
except AttributeError:
eu = Euler((0, 0, 0), 'XYZ')
scene = bge.logic.getCurrentScene()
cam = scene.active_camera
fix = Euler((-1.5707963705062866, 0, 0), 'XYZ')
rot = Euler((-eu.z, eu.y, -eu.x), 'XYZ')
rot.rotate(fix)
cam.worldOrientation = rot

view raw

rotate.py

hosted with ❤ by GitHub

If you have a better way to do it, please tell me. This was rather a quick hack, but pretty functional.
Nice…! The camera moves, for me with a pretty amazing low latency. Unreal didn’t have this low latency on Windows.

Rendering for the Oculus Rift in BGE

As we know the BGE supports various types of stereoscopic rendering. One of them is the once required by the rift basically: Side-By-Side. The only thing we need to do know is the reverse lens distortion transformation we can achieve with a simple fragment shader.
Different versions of this fragment shader appeared on the net. A good explanation of the method can be found on the FireBox page. Another version is the one included in the OpenHMD examples.
Sounds good, huh? Yeah, but it didn’t not work. The fragment shader transformed the Side-By-Side rendering asymmetrically, so that the left eye was smaller than the right.
Image
The interesting thing is that the output of the shader is symmetrical when rendered with other stereo options, including Above-Below and without stereo. I asked for help in a Blender Stackexchange post and on the Blenderartists forum. Moguri from the forum came up with this patch that fixes the issue. Hooray, Rift support is complete.
As I noticed, people were trying to achieve this in Blender and had similar problems, due to this bug.
If you want Oculus Rift rendering support, try my example blend file and apply Moguri’s patch to Blender.
Screenshot from 2013-06-26 16:45:29

46 thoughts on “Oculus Rift Support In Blender Game Engine

  1. Hey! I did the FireBox project 🙂

    Cool work, and glad you got that shader figured out haha 🙂 The GLSL shaders I made work fine (and I can see yours are based on mine!) – it’s just a matter of composing the final Rift rendering the right way (I use two quads, one for each eye, which can translate horizontally – I mention this because it looks like the centres of projection in your example images may be spaced out too far apart).

    Anyway great stuff, have yet to check out OpenHMD myself – great to hear about low latency using it – is that for a Linux build of blender as well?

    1. Thank you for your work! You demo was actually the first thing I got working with the Rift in Linux and also the first demo with code available.
      The GLSL shader works the same as yours but has to be drawn on one quad, because it uses only one framebuffer. It’s a Filter2D in Blender.
      Everything from my article is run on Archlinux.

  2. Hi there, I am trying to install openHMD on OSX and while its tedious (because of my ignorance) I think I am getting there (still cannot ‘make install’, but ./configure is compiling).
    Have you had much problem installing OpenHMD?

      1. the OpenHMD team got back to me and I think I managed to get some of it working (the ‘simple’ example was dumping the rift’s values). But when I tried to build your python wrapper I got this:

        sh-3.2# ./setup.py build
        running build
        running build_ext
        skipping ‘rift.cpp’ Cython extension (up-to-date)
        building ‘rift’ extension
        llvm-gcc-4.2 -fno-strict-aliasing -fno-common -dynamic -g -Os -pipe -fno-common -fno-strict-aliasing -fwrapv -mno-fused-madd -DENABLE_DTRACE -DMACOSX -DNDEBUG -Wall -Wstrict-prototypes -Wshorten-64-to-32 -DNDEBUG -g -fwrapv -Os -Wall -Wstrict-prototypes -DENABLE_DTRACE -arch i386 -arch x86_64 -pipe -I/usr/local/openhmd/include -I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c rift.cpp -o build/temp.macosx-10.7-intel-2.7/rift.o
        cc1plus: warning: command line option “-Wstrict-prototypes” is valid for Ada/C/ObjC but not for C++
        cc1plus: warning: command line option “-Wstrict-prototypes” is valid for Ada/C/ObjC but not for C++
        llvm-gcc-4.2 -fno-strict-aliasing -fno-common -dynamic -g -Os -pipe -fno-common -fno-strict-aliasing -fwrapv -mno-fused-madd -DENABLE_DTRACE -DMACOSX -DNDEBUG -Wall -Wstrict-prototypes -Wshorten-64-to-32 -DNDEBUG -g -fwrapv -Os -Wall -Wstrict-prototypes -DENABLE_DTRACE -arch i386 -arch x86_64 -pipe -I/usr/local/openhmd/include -I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c Rift.cpp -o build/temp.macosx-10.7-intel-2.7/Rift.o
        cc1plus: warning: command line option “-Wstrict-prototypes” is valid for Ada/C/ObjC but not for C++
        cc1plus: warning: command line option “-Wstrict-prototypes” is valid for Ada/C/ObjC but not for C++
        llvm-g++-4.2 -Wl,-F. -bundle -undefined dynamic_lookup -Wl,-F. -arch i386 -arch x86_64 build/temp.macosx-10.7-intel-2.7/rift.o build/temp.macosx-10.7-intel-2.7/Rift.o -lopenhmd -o build/lib.macosx-10.7-intel-2.7/rift.so
        ld: warning: ignoring file /usr/local/lib/libopenhmd.dylib, file was built for unsupported file format which is not the architecture being linked (i386)
        ld: duplicate symbol Rift::Rift() in build/temp.macosx-10.7-intel-2.7/Rift.o and build/temp.macosx-10.7-intel-2.7/rift.o for architecture i386
        collect2: ld returned 1 exit status
        ld: duplicate symbol Rift::Rift() in build/temp.macosx-10.7-intel-2.7/Rift.o and build/temp.macosx-10.7-intel-2.7/rift.o for architecture x86_64
        collect2: ld returned 1 exit status
        lipo: can’t open input file: /var/tmp//cc1BVFmp.out (No such file or directory)
        error: command ‘llvm-g++-4.2’ failed with exit status 1

        and I don’t really know what is happening (mismatch architecture i386 and x86_64?), other the fact that I cannot see the rift.cpython-33m.so file!

      2. You get a linker error, /usr/local/lib/libopenhmd.dylib seems to be 32bit, but Cython seems to build 64bit. I am not sure what the other error with the duplicate means, maybe you are building both architectures?

        Maybe setting arch flags could help http://stackoverflow.com/questions/6325607/error-compiling-cython-on-mac-10-6

        I am not experienced with Cython on OS X, but you need to set flags or edit the setup.py. I would be glad when you posted this in the bug tracker on github.
        https://github.com/lubosz/python-rift/issues

      3. been looking for a way to integrate OR dev into blender. looking forward to utilizing your solution. i too am having some link issues on OSX. any suggestions?

        running build
        running build_ext
        skipping ‘rift.cpp’ Cython extension (up-to-date)
        building ‘rift’ extension
        clang -fno-strict-aliasing -fno-common -dynamic -g -Os -pipe -fno-common -fno-strict-aliasing -fwrapv -mno-fused-madd -DENABLE_DTRACE -DMACOSX -DNDEBUG -Wall -Wstrict-prototypes -Wshorten-64-to-32 -DNDEBUG -g -Os -Wall -Wstrict-prototypes -DENABLE_DTRACE -arch i386 -arch x86_64 -pipe -I/usr/include/openhmd -I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c rift.cpp -o build/temp.macosx-10.8-intel-2.7/rift.o
        clang: warning: argument unused during compilation: ‘-mno-fused-madd’
        clang -fno-strict-aliasing -fno-common -dynamic -g -Os -pipe -fno-common -fno-strict-aliasing -fwrapv -mno-fused-madd -DENABLE_DTRACE -DMACOSX -DNDEBUG -Wall -Wstrict-prototypes -Wshorten-64-to-32 -DNDEBUG -g -Os -Wall -Wstrict-prototypes -DENABLE_DTRACE -arch i386 -arch x86_64 -pipe -I/usr/include/openhmd -I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c Rift.cpp -o build/temp.macosx-10.8-intel-2.7/Rift.o
        clang: warning: argument unused during compilation: ‘-mno-fused-madd’
        clang++ -bundle -undefined dynamic_lookup -Wl,-F. -arch i386 -arch x86_64 build/temp.macosx-10.8-intel-2.7/rift.o build/temp.macosx-10.8-intel-2.7/Rift.o -lopenhmd -o build/lib.macosx-10.8-intel-2.7/rift.so
        ld: warning: ignoring file /usr/local/lib/libopenhmd.dylib, file was built for unsupported file format ( 0xcf 0xfa 0xed 0xfe 0x 7 0x 0 0x 0 0x 1 0x 3 0x 0 0x 0 0x 0 0x 6 0x 0 0x 0 0x 0 ) which is not the architecture being linked (i386): /usr/local/lib/libopenhmd.dylib
        duplicate symbol __ZN4RiftC1Ev in:
        build/temp.macosx-10.8-intel-2.7/rift.o
        build/temp.macosx-10.8-intel-2.7/Rift.o
        duplicate symbol __ZN4RiftC2Ev in:
        build/temp.macosx-10.8-intel-2.7/rift.o
        build/temp.macosx-10.8-intel-2.7/Rift.o
        duplicate symbol __ZN4RiftD1Ev in:
        build/temp.macosx-10.8-intel-2.7/rift.o
        build/temp.macosx-10.8-intel-2.7/Rift.o
        duplicate symbol __ZN4RiftD2Ev in:
        build/temp.macosx-10.8-intel-2.7/rift.o
        build/temp.macosx-10.8-intel-2.7/Rift.o
        duplicate symbol __ZN4Rift15printDeviceInfoEv in:
        build/temp.macosx-10.8-intel-2.7/rift.o
        build/temp.macosx-10.8-intel-2.7/Rift.o
        duplicate symbol __ZN4Rift5printESsi16ohmd_float_value in:
        build/temp.macosx-10.8-intel-2.7/rift.o
        build/temp.macosx-10.8-intel-2.7/Rift.o
        duplicate symbol __ZN4Rift9inputLoopEv in:
        build/temp.macosx-10.8-intel-2.7/rift.o
        build/temp.macosx-10.8-intel-2.7/Rift.o
        duplicate symbol __ZN4Rift4pollEv in:
        build/temp.macosx-10.8-intel-2.7/rift.o
        build/temp.macosx-10.8-intel-2.7/Rift.o
        duplicate symbol __ZN4Rift12printSensorsEv in:
        build/temp.macosx-10.8-intel-2.7/rift.o
        build/temp.macosx-10.8-intel-2.7/Rift.o
        duplicate symbol __ZN4Rift5sleepEd in:
        build/temp.macosx-10.8-intel-2.7/rift.o
        build/temp.macosx-10.8-intel-2.7/Rift.o
        ld: 10 duplicate symbols for architecture i386
        clang: error: linker command failed with exit code 1 (use -v to see invocation)
        error: command ‘clang++’ failed with exit status 1

        thanks!

  3. I’m thinking about starting to look into integrating some Rift/HMD support into the BGE. Would you mind if I used your shader? Do you have a license in mind for the shader?

    1. I will release my BGE Oculus Demo soon. I would license the shader and the demo as GPL3. This will be done with the release of the whole demo.

  4. Hello
    I’m very interested in working with oculus in Blender. I’ve tryied to compile openHMD under windows, but without success…. does it work only on linux?
    thx

      1. Thanks for reply… I got compiled dll of openHMD, made a lib… now I got stuck in compiling your stuff. There are couple things, that are not possible within windows system (nanosleep) and syntax differences… But somehow I got it compiled through VC++ 2010, so I had dll and lib file. But I realized, that I don’t have a py file to connect it with blender, only that pyx. So I’ve tried to compile it through cython, but error appeared:

        d:\users\DavidSvoboda\Documents\prace\oculus\tools\python-rift2>setup.py build
        running build
        running build_ext
        skipping ‘rift.cpp’ Cython extension (up-to-date)
        building ‘rift’ extension
        creating build
        creating build\temp.win32-2.7
        creating build\temp.win32-2.7\Release
        d:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\BIN\cl.exe /c /nologo /Ox /MD /W3 /GS- /DNDEBUG -ID:\Python27\include -ID:\Python27\PC /Tprift.cpp /Fobuild\temp.win32-2.7\Release\rift.obj /EHsc
        rift.cpp
        d:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\BIN\cl.exe /c /nologo /Ox /MD /W3 /GS- /DNDEBUG -ID:\Python27\include -ID:\Python27\PC /TpRift.cpp /Fobuild\temp.win32-2.7\Release\Rift.obj /EHsc
        Rift.cpp
        creating build\lib.win32-2.7
        “d:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\BIN\link.exe” /DLL /nologo /INCREMENTAL:NO /LIBPATH:D:\Python27\libs /LIBPATH:D:\Python27\PCbuild openhmd.lib /EXPORT:initrift build\temp.win32-2.7\Release\rift.obj build\temp.win32-2.7\Release\Rift.obj /OUT:build\lib.win32-2.7\rift.pyd /IMPLIB:build\temp.win32-2.7\Release\rift.lib /MANIFESTFILE:build\temp.win32-2.7\Release\rift.pyd.manifest
        build\temp.win32-2.7\Release\Rift.obj : warning LNK4042: object specified more than once; extras ignored
        LINK : error LNK2001: unresolved external symbol initrift
        build\temp.win32-2.7\Release\rift.lib : fatal error LNK1120: 1 unresolved externals
        error: command ‘”d:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\BIN\link.exe”‘ failed with exit status 1120

        Do you know, what can help me now? I’m feeling like step before finish….

  5. Hi, I’m ThibG, LibVR’s author, and I’m quite confused about what you wrote… why do you think it is not free software? It is licensed under the BSD-2-clause.

  6. Hi, I’m trying to build your python-rift project on Ubuntu 12.04 64bit.

    after getting openHMD to play along I stumbled upon the following error when running ./setup.py build:

    — snipp —
    cythoning rift.pyx to rift.cpp

    Error compiling Cython file:
    ————————————————————

    def printDeviceInfo(self):
    self.thisptr.printDeviceInfo()

    property rotation:
    def __get__(self): return self.thisptr.rotation
    ^
    ————————————————————

    rift.pyx:35:44: Cannot convert ‘vector’ to Python object

    — snipp —

    any idea what’s the problem?

    1. Hi!
      I’m on Ubuntu 13.10 and even if I installed the last version of Cython as you suggested for your problem, I’ve got problem running the script as for me.
      If I do : inside blender :

      “from game_engine_rift.rift import PyRift”

      and in the console I get :
      “ImportError: libopenhmd.so.0: cannot open shared object file: No such file or directory”

      I’ve found that “libopenhmd.so.0” is in fact in “/usr/local/lib/”. Why is it not found by the module??

  7. Nice post, I’m sure you’ve saved loads of people days of head scratching. Just FYI I’ve had some trouble getting the filter working with blender player in the latest builds. However, it would seem if you set up the viewports for each eye manually instead of using stereo view the shaders work just fine.

  8. Hello,
    I’m trying to get the Oculus Rift working with the BGE and I stumbled into your method. Everything builds without a problem, but when running the input.py script, I keep getting this output:

    Blender Game Engine Started
    523 294
    Python script error – object ‘Camera’, controller ‘Python1’:
    Traceback (most recent call last):
    File “input.py”, line 1, in
    ImportError: /usr/local/blender/2.67/2.67/scripts/addons/game_engine_rift/rift.so: undefined symbol: PyString_InternFromString
    Blender Game Engine Finished

    As you can see by the second line from the console, I’m using your rendering example for the Oculus Rift. I have the input.py script attached to the camera and run with an always sensor.

      1. I think I found the fix to the problem. When running “python setup.py build” make sure you’re using python version 3.3. If you have it installed is should be “python3.3 setup.py build”.

  9. Hi, thanks for the great work. I would love to get the Oculus Rift to work with Blender. I have built hidapi and openhmd, but now I try to build your python-rift on OSX 10.8.5 and get the following error:

    running build
    running build_ext
    skipping ‘rift.cpp’ Cython extension (up-to-date)
    building ‘rift’ extension
    /usr/bin/clang -Wno-unused-result -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -pipe -O2 -I/usr/local/include/openhmd -I/opt/local/Library/Frameworks/Python.framework/Versions/3.3/include/python3.3m -c rift.cpp -o build/temp.macosx-10.8-x86_64-3.3/rift.o
    /usr/bin/clang -Wno-unused-result -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -pipe -O2 -I/usr/local/include/openhmd -I/opt/local/Library/Frameworks/Python.framework/Versions/3.3/include/python3.3m -c Rift.cpp -o build/temp.macosx-10.8-x86_64-3.3/Rift.o
    creating build/lib.macosx-10.8-x86_64-3.3
    /usr/bin/clang++ -bundle -undefined dynamic_lookup -L/opt/local/lib build/temp.macosx-10.8-x86_64-3.3/rift.o build/temp.macosx-10.8-x86_64-3.3/Rift.o -lopenhmd -o build/lib.macosx-10.8-x86_64-3.3/rift.so
    duplicate symbol __ZN4RiftC1Ev in:
    build/temp.macosx-10.8-x86_64-3.3/rift.o
    build/temp.macosx-10.8-x86_64-3.3/Rift.o
    duplicate symbol __ZN4RiftC2Ev in:
    build/temp.macosx-10.8-x86_64-3.3/rift.o
    build/temp.macosx-10.8-x86_64-3.3/Rift.o
    duplicate symbol __ZN4RiftD1Ev in:
    build/temp.macosx-10.8-x86_64-3.3/rift.o
    build/temp.macosx-10.8-x86_64-3.3/Rift.o
    duplicate symbol __ZN4RiftD2Ev in:
    build/temp.macosx-10.8-x86_64-3.3/rift.o
    build/temp.macosx-10.8-x86_64-3.3/Rift.o
    duplicate symbol __ZN4Rift15printDeviceInfoEv in:
    build/temp.macosx-10.8-x86_64-3.3/rift.o
    build/temp.macosx-10.8-x86_64-3.3/Rift.o
    duplicate symbol __ZN4Rift5printESsi16ohmd_float_value in:
    build/temp.macosx-10.8-x86_64-3.3/rift.o
    build/temp.macosx-10.8-x86_64-3.3/Rift.o
    duplicate symbol __ZN4Rift9inputLoopEv in:
    build/temp.macosx-10.8-x86_64-3.3/rift.o
    build/temp.macosx-10.8-x86_64-3.3/Rift.o
    duplicate symbol __ZN4Rift4pollEv in:
    build/temp.macosx-10.8-x86_64-3.3/rift.o
    build/temp.macosx-10.8-x86_64-3.3/Rift.o
    duplicate symbol __ZN4Rift12printSensorsEv in:
    build/temp.macosx-10.8-x86_64-3.3/rift.o
    build/temp.macosx-10.8-x86_64-3.3/Rift.o
    duplicate symbol __ZN4Rift5sleepEd in:
    build/temp.macosx-10.8-x86_64-3.3/rift.o
    build/temp.macosx-10.8-x86_64-3.3/Rift.o
    ld: 10 duplicate symbols for architecture x86_64
    clang: error: linker command failed with exit code 1 (use -v to see invocation)
    error: command ‘/usr/bin/clang++’ failed with exit status 1

    Any idea what’s the problem and how to fix it?

      1. Because I don’t know much about compiling and cython, it took me a long time to figure out. In the end the solution is rather simple: because the standard mac filesystem is NOT case sensitive, there was no difference between rift.o and Rift.o. After changing rift.pyx to pyrift.pyx and changing the setup.py accordingly I was able to build correctly and I got a proper rift.so. The import in Blender also worked. Tomorrow I will test with my Oculus Rift, which is still at work.

  10. hello! great work. I can have the render correctly side-by-side inside blender with 2.69 (the patch you propose seems to have been included), but when I try to export to standalone application I see the side-by-side rendered on one side and empty grey on the other.
    Did you try to export to standalone?

  11. Hi,
    I’m trying to use the oculus rift for running a 3d (yet visually simple experiments) on matlab. I’ve been using blender to create side-by-side image files of cones approaching the viewer (I’m a blender noob btw).
    I would like to add barrel distortion to the final rendered image. For this, I find your function very useful and would like to use it, if I may.
    Also, I’m unable to export the blender game engine output as single image files. Is there a work around for this that you know of in blender? (This question might be a bit off-topic, but any input would be welcome.)
    Thanks!

  12. Hey,
    Great work with integrating the Oculus Rift into Blender! I would like to get this set up, but I am unfortunately very new to git and everything associated with it. I’ve been trying to get hidapi and OpenHMD installed for a while and finally managed to get the .dll files (I’m a Windows user btw). However, I’ve now come to a wall of sorts. I really don’t know how to get your portion of the project working. Any help would be greatly appreciated!
    Thanks!

  13. This is really awesome, i love Blender and using the Game Engine would be very cool.
    So far i’ve compiled and installed openHMD and got the rift.so (cmake , make then ./setup.py build).The “Test” File also shows me device:0 Oculus and device 1: Dummy from OpenHMD.
    i’ve put the rift.so in my Blender addons/game_engine_rift folder.(tried linkng as discribed)
    But when i run in Blender python console the command : from game_engine_rift.rift import PyRift i get an an import error saying: …scripts/addons/game_engine_rift/rift.so: undefined symbol: PyString_InternFromString

    any help very welcome 🙂

    thanks again for the authors work!

  14. Mac users should note that the commands given in the section entitled “Including Rift input to your Blender Game Engine Demo” are Linux-specific. On Mac OS, the equivalent of ~/.blender is ~/Library/Application\ Support/Blender. Though I haven’t tried it, on Windows it should be %APPDATA%\Blender.

  15. Very cool post, thanks for sharing! I’m just now learning Python as my first programming language and have been brainstorming possible future projects. Do you think that it is realistic to be able to develop functional applications using only Python for the Rift?

    1. IMO, I don’t see no problem for that. I’m doing exactly that! And you will not find a Game Engine so flexible, and Open Source better than Blender.
      Check the forum http://blenderartists.org/forum/index.php to have advice for your education, it’s a very friendly place and with lot of people to answer any questions!

  16. Hello! I’m looking for how to use Oculus Rift for Blender GE, and this is the only thing I find, but I do not understand 😦 how do I even install the OpenHMD?? Really need this for a school project, cheers!

    1. I had a similar problem (I was on Windows). The programs and libraries required are difficult for a newb (like me) to install. Tried for a month. I would suggest trying Unity engine? It takes Blender files as assets, so you can still do all your modeling in Blender and use Unity for the rift integration. There is a free 30 day trial available for Pro (which you need for the Rift). If you bought the dev version, the rift also comes with a 4 month trial. If you don’t know how to build programs and applications (like me), this is probably the easiest solution.

      1. The method to install OpenHMD presented here by Lubosz IS really working. Maybe you’d better try to install it on linux, since it’s way easier. Especially if you are a newb.

  17. Hey! love the read.
    Just a quick question, as per the extra installs in order to make the Oculus work inside blender. When you compact and export the game as a final .exe, will the receiving user need to install said packages? or would they be exported into the folder of the .exe for the executable to use on play?

  18. Hello,
    I’m working now with your python binding with OpenHMD,
    thanks for the work, it’s very usefull.

    I finally decided to do an external application to send the oculus orientation with OSC, so compiling the python-rift is not dependant of the version of python of blender …
    I had troubles setting up the orientation like you do in your exemple, and found that my OpenHMD export of the Orientation Quaternion is of the format Y-WXZ, so then when simply putting the object.localOrientation to Quaternion(( -arg[1], arg[2], arg[0], arg[3] )) get me the right setup… (no need for euler transformation… )
    I got this by literaly looking at the stream of numbers while rotating the Oculus, as the format is not documented in the OpenHMD source code (simply say “quaterion with absolute orientation”… hum … )
    so maybe I’m wrong somewhere but … try it, it might work 😉
    (I’ll publish things later on http://f-lat.org website )
    Ol.

  19. Thank you! I tried it with Blender 2.72b (Ubuntu 12.04, DK2) and it works great! By the way, I did some experiments to set up the orientation without the euler transformation, as suggested by Olme. This is my script. Not sure it’s perfect (sure it’s not 😉 but I hope it can help someone.

    import mathutils
    from game_engine_rift.rift import PyRift

    scene = bge.logic.getCurrentScene()
    cam = scene.active_camera

    def poll(rift):
    rift.poll()
    bge.logic.rotation = mathutils.Quaternion((rift.rotation[0],
    -rift.rotation[3],
    rift.rotation[2],
    -rift.rotation[1]))
    try:
    poll(bge.logic.rift)
    except AttributeError:
    bge.logic.rift = PyRift()

    fix = mathutils.Quaternion((-0.7071, 0.7071, 0, 0))
    bge.logic.rotation.rotate(fix)

    cam.worldOrientation = bge.logic.rotation

  20. I think that is among the such a lot significant information for me. And i’m happy reading your article. However should statement on few common things, The website style is perfect, the articles is actually nice : D. Good process, cheers

Leave a reply to mars Cancel reply