RhinoVR - a sample plug-in for rendering Rhino viewports in virtual reality

Hello!

I decided to also post here in Rhino Developer, since this plug-in is very much intended to be for developers.

For the last couple of months I’ve been working on a virtual reality sample plug-in for Rhino which showcases how to render Rhino viewports in VR. This plug-in is intended to be a helpful example for developers of Rhino plug-ins with VR functionality.

It is now available from here: GitHub - mcneel/RhinoVR: RhinoVR - a virtual reality sample plug-in for Rhino 7

The first version of RhinoVR can be downloaded as an RHI from here: Releases · mcneel/RhinoVR · GitHub

System requirements :

  • HTC Vive or Oculus Rift
  • Steam with the SteamVR app installed.
  • Rhino 6 (Service Release 6, currently only available as a service release candidate) or Rhino WIP.

Installation :
Make sure you have at least Rhino 6 version 6.6.18156.11421 or Rhino WIP version 7.0.18156.04035. Rhino 6 SR 6 is currently available as a service release candidate. To enable the downloading of service release candidates, go to Tools → Options… → Updates and Statistics → Update frequency: Service Release Candidate. Then click “Check Now…”.

Technical information
There have been some SDK additions to make VR rendering easier. The main new function is the following method on CRhinoDisplayPipeline_OGL:

  //Description:
  //  Draws the viewport as seen from the left and the right eye viewports
  //  and returns the result as OpenGL texture handles.
  //
  //  dpa: The display pipeline attributes to use for drawing.
  //  vp_eye_left: The viewport representing the left eye location and look direction.
  //  vp_eye_right: The viewport representing the right eye location and look direction.
  //
  //Returns:
  //  handle_eye_left:  Will contain the OpenGL texture handle which references the left output color buffer.
  //  handle_eye_right: Will contain the OpenGL texture handle which references the right output color buffer.
  //
  //  true:  Drawing succeeded - 'handle_eye_left' and 'handle_eye_right' contain valid handles.
  //  false: Drawing failed    - 'handle_eye_left' and 'handle_eye_right' are both set to 0.
  bool DrawStereoFrameBuffer(
    CDisplayPipelineAttributes& dpa,
    const ON_Viewport& vp_eye_left,
    const ON_Viewport& vp_eye_right,
    unsigned long long& handle_eye_left,
    unsigned long long& handle_eye_right);

There is also a new enum StereoRenderContext which can be queried from CDisplayPipelineAttributes:

  enum class StereoRenderContext : unsigned int
  {
    NotApplicable = 0,
    RenderingLeftEye = 1,
    RenderingRightEye = 2,
    RenderingBothEyes = RenderingLeftEye | RenderingRightEye
  };

  StereoRenderContext GetStereoRenderContext() const;
  void SetStereoRenderContext(StereoRenderContext stereo_render_context);

The source code of RhinoVR itself should be pretty self-documenting. If you find any bugs or have any questions about the code then feel free to ask here, or to create an Issue or a Pull Request through github.

Usage :
Start Rhino and load the file you want to view in VR. Make sure a perspective viewport is selected and that it is set to the display mode you want to use. Type RhinoVR into the command line. This should automatically start Steam and SteamVR. If you’re using the Rift, it will also start the Oculus client. Rhino tells you when it is ready and asks you to put the VR headset on.

  • It is possible to navigate around in the Rhino scene using the VR controllers (Vive and Rift). Vive uses the touchpads for navigation and the Rift uses the analog sticks. The left controller controls translation (forward, backward, left, right) and the right controller controls horizontal rotation (turning left/right) and up/down movement.
  • Objects can be selected by pressing the touchpad button (Vive) or pressing the analog stick (Rift).
  • The Rhino Move-command can be initiated by pressing the Application Menu button (Vive) or the B-button (Rift). Remember, the move command works in steps: Select objects. Enter. Pick reference point. Pick new point.
  • A Rhino Enter key press can be mimicked using the VR controller by pressing the trigger button (Vive) or the A-button (Rift).
  • A Rhino Esc key press can be mimicked by squeezing the grip buttons (Vive) or by pressing the primary trigger button (Rift).

Type RhinoVR into the command line again to close down RhinoVR.

Finally, you can download a rather amateurish screen recording of me testing it out: Villa.gif - Google Drive

6 Likes

Thanks for sharing ! :slight_smile: