Giter Club home page Giter Club logo

testopenvr's Introduction

TestOpenVR

Testing OpenVR extensions to Godot

This is a test Godot project for testing the OpenVR enhancements I've made to Godot.

Compiling

Note that you must build Godot from source using the enhancements in the OpenVR Branch in my Godot github fork. You also need to make sure you obtain the contents of the bin and lib folder of the OpenVR project from here: https://github.com/ValveSoftware/openvr As Godots ignore rules filter out some of the required files. OpenVR does not give access to the source unfortunately. For now just copy bin and lib to thirdparty/openvr/.

Currently compilation only works on Windows for 64bit and requires renaming openvr_api.lib to openvr_api.lib.windows.tools.64.lib. You also need to copy openvr_api.dll from openvr's bin directory into the folder that contains your godot exe (usually bin) for it to all work. In theory it should be easy to adjust the code to compile on Mac or Linux as support for both is included in OpenVR however I haven't had a chance to look into this.

The sample project

The VR solution is implemented through a new spatial node called SpatialTracker Each node can be linked to one of the tracked devices, the HMD, the VIVE controllers, even the base stations. As a result it is the OpenVR library that updates the rotation and translation properties of the node. You'll see they are even updated in the Godot editor if you've got your VIVE hardware attached.

At this point in time there is no rendering to the HMD yet and we've just got some testcubes to make the tracking visible.

Also note that the order in which you've turned on devices may effect what ID OpenVR has assigned to each controller. You may need to change these IDs. I will be adding code later on that does some detection for this.

There are a few important limitations to the (current) solution:

  • your VIVE must be attached before starting Godot or OpenVR will fail to initialize. I'm planning to add a restart/retry function in due time.
  • the HMD should be the first tracked node in your scene as it currently handles some of the processing. This will be moved to something more global.

Finally in VR units are much more important then in a non-stereoscopic environment. In normal 3D Godot projects it doesn't matter if you units are in centimeters, meters, fantasieworldunits, etc. In VR (or stereoscopic rendering in general) all of a sudden this is very important. If the distance between the two cameras, the distance between your two eyes, doesn't match up with the scale of the scene you are looking at, you'll be in for a very uncomfortable experience. For OpenVR the units are set to meters. So by default out 1.0 x 1.0 x 1.0 test cube is a 1 meter x 1 meter x 1 meter cube. You'll see that the cubes in the test project are scaled by 0.1 meaning they are 10cm x 10cm x 10cm in size. Keep this in mind as you design and import assets.

Abstraction

The implementation of SpatialTracker has been setup to have an abstraction class that is subclassed to communicate with the OpenVR SDK. In theory additional subclasses can be created for other SDKs like the Oculus SDK or the OSVR SDK. OpenVR being the first I'm implementing may result in the implementation being adjusted.

One of the things i haven't solved here is that different platforms may make different SDKs available. OpenVR should only be compiled in if you're compiling for Windows, Mac or Linux, while we may introduce say daydream or a more generic mobile VR option when targeting mobile.

The class that communicates with the OpenVR SDK is a singleton that is shared with all of the trackers. This singleton is only instantiated if you actually have trackers in your scene.

Roadmap

This is still very much up in the air but I'm planning to tackle the following enhancements over the coming few weeks:

  • implement a resource class that gives access to the render models interface in OpenVR. This allows you to render out controllers and base stations in your interface.
  • add button and joypad properties to the SpatialTracker class to give feedback on which buttons are pressed. While you could get to (or I could add) this information through Godots existing joystick input class I feel the SpatialTracker is a more natural implementation for VR
  • add signals for button presses on the controllers, detecting enabling/disabling controllers, etc.
  • create viewports for output to the HMD, unlike the early headsets we're not directly outputting to a 'monitor' (its possible with the Vive but not recommended) but we're outputting buffers to the SDK. The SDK does things like barrel adjustments.
  • enhance the existing camera or implement a new camera class that uses the projection matrices provided in OpenVR. Because the Vive allows you to adjust IPD on the device it is the SDK that provides us with projection matrices and positioning information that match with the person who's wearing the device.
  • look into parallel stereo rendering by allowing viewports to have separate left/right buffers, be linked to two instead of 1 cameras, culling based on a combined view frustum and duplicating draw class to render both eyes simultaniously.
  • look into both optimizing showing (or disabling) the output of one of the eyes to the monitor for spectators or allow for an alternative 3rd camera to render this. The main goal is to support tracked 3rd camera rendering for green screen composition but also for multiplayer games where one is using the HMD and another player is using the monitor to play.

testopenvr's People

Contributors

bastiaanolij avatar ssj71 avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Forkers

ssj71 boyquotes

testopenvr's Issues

Lagging Rotation

So I've been playing with this a little and noticed that the head tracking for position is very good, right on par with the other VR engine I used. But rotations lag, so if you turn your head side to side (like saying "no") it looks like the test cubes are moving back and forth rather than staying still. Is there something I can do to mitigate that? I'm only just looking into the godot src but if you could point me to a few modules to look at I can start trying some things.

Thanks!

Defunct for now

Hey All,

I just checked in a whole lot of changes here:
godotengine/godot#7968

This breaks the code in this project for now. Please check TestGodotVR for a new demo I'm working on that uses all the new code.

I may end up trashing this project in the long run...

I'd like to help out!

Hi Bastiaan:

Sorry I couldn't find any other way to contact you. My company is looking at making a game accessory and would like to develop a launch title that works on the htc vive and also on android/iOS mobile VR headsets. I'd really like to develop the game using Godot since I'm a big advocate of open source software.

I am hoping there are some tasks that I can assist in and we can get this working. I unfortunately have little experience in any game engines, only a prototyped game on the vive using the worldviz vizard 5 game engine, which is not portable to mobile (nor open source). Though I do have extensive c programming experience (embedded) and a fair bit of c++ too. I thought the easiest path would be to get a godot game working with the vive then try to move it over to the mobile targets. I have a vive for development. If you can just give me some direction while I'm doing my research into openVR what godot needs I hope it will be beneficial for everyone. I'm usually on IRC from around 4-12UTC. In the meantime I'll be looking through your code in this repo and your OpenVR branch of the godot codebase.

Thanks,
_Spencer

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.