Skip to content

jorjic/vrmod-module

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

This module adds some Lua functions to provide basic OpenVR support to Garry's Mod.

To install or update the module, open the "install" folder and read "INSTALLATION.txt"

#######################################################################################
# Lua functions
#######################################################################################

Function: number vrmod.GetVersion()
Description: Returns the module version

Function: boolean vrmod.IsHMDPresent()
Description: Returns true if a VR headset is connected

Function: vrmod.Init()
Description: Starts OpenVR and performs some initialization.
This must be called successfully before using any of the functions listed below (apart
from vrmod.Shutdown which can be called at any time to ensure a clean state).
You must call vrmod.Shutdown() before calling this again.

Function: vrmod.Shutdown()
Description: Shuts down OpenVR and performs some clean up.
You must not call any of the functions listed below until you successfully run
vrmod.Init() again.

Function: vrmod.SetActionManifest( string fileName )
Description: Sets the specified file as the action manifest.
Path is relative to garrysmod/data/.
This should be called only once between init/shutdown.

Function: vrmod.SetActiveActionSets( string actionSetName, ... )
Description: Makes the given action sets currently active.

Function: table vrmod.GetDisplayInfo( number nearZ, number farZ )
Description: Returns the following table of information:
{
  table ProjectionLeft, --Left eye projection matrix as 2D table [row][col]
  table ProjectionRight,
  table TransformLeft, --Left eye transform matrix
  table TransformRight,
  number RecommendedWidth, --Recommended render target resolution (per eye)
  number RecommendedHeight,
}

Function: vrmod.ShareTextureBegin()
Description: After calling this function, the next texture that is created in the game
will be shared with the module. You should create a new texture (using GetRenderTarget
for example) immediately after calling this function. This should be called only once
between init/shutdown.

Function: vrmod.ShareTextureFinish()
Description: This must be called after creating a texture to finish the texture sharing
process. This should be called only once between init/shutdown.

Function: vrmod.UpdatePosesAndActions()
Description: This should be called once per frame to update the poses and actions
which you can then use to render with.
This function is also responsible for syncing the fps to the headsets refresh rate.

Function: table vrmod.GetPoses()
Description: Returns a table of poses. The hmd pose is automatically included, the
rest are defined by the action manifest.
{
  hmd = {
    vector pos,
    vector vel,
    angle ang,
    angle angvel,
  },
  ...
}

Function: table, table vrmod.GetActions()
Description: Returns a table of actions (defined by the action manifest) and their states.
The second table only includes boolean actions that changed state from the previous call.
It could look something like this:
{
  boolean boolean_example,
  number vector1_example,
  vector2_example = {
    number x,
    number y,
  }
  skeleton_example {
    table fingerCurls = {
      number 1
      number 2
      number 3
      number 4
      number 5
    }
  }
}

Function: vrmod.SetSubmitTextureBounds( uMinLeft, vMinLeft, uMaxLeft, vMaxLeft, 
  uMinRight, vMinRight, uMaxRight, vMaxRight )
Description: Sets UV coordinates to use for the left/right eye areas of the shared
texture

Function: vrmod.SubmitSharedTexture()
Description: Submits the shared texture to the VR Compositor. This should be called
once per frame, after you have rendered to / updated the shared texture.

Function: vrmod.TriggerHaptic( string actionName, number delay, number duration,
  number frequency, number amplitude )
Description: Triggers the specified vibration action (defined by the action manifest)
using the given parameters.

Function: table vrmod.GetTrackedDeviceNames()
Description: returns a sequential numerical indexed table with names of all connected
tracked devices. For example:
{
  1 = "indexhmd"
  2 = "knuckles"
  3 = "knuckles"
}

#######################################################################################
# Compiling
#######################################################################################

Windows:
step 1: have Visual Studio installed
step 2: make sure the path to vcvarsall is correct inside build.bat
step 3: run build.bat

Linux:
step 1: have the terminal open with the current working directory set to the folder
where build.sh is located
step 2: run build.sh

#######################################################################################
# Credits / Special Thanks
#######################################################################################

-UselessGhost (https://steamcommunity.com/id/UselessGhost)
For sharing tips and the their gmod vr project
(https://bitbucket.org/uselessghost/gmcl_openvr)
-willox (https://github.com/willox)
For updating gmod which has made VR work better, as well as providing solutions for
some other issues

About

openvr module for garry's mod

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages

  • C++ 76.9%
  • Batchfile 18.9%
  • Shell 4.2%