It is possible to add Virtual Reality to a Panda3d project with a smartphone and about ten lines of code using a program called Trinus VR. This can be tried free of charge using demo versions of the software needed. It also requires a dll which is installed by installing a separate program called FreePIE. I have this running with Windows 7 and a Samsung Galaxy S2.
Trinus VR is a pair of programs: the server runs on a PC and the client runs on a smartphone. It works best when the phone is inside a Google Cardboard head mount. The client uses sensors in the phone to monitor the head position and feeds them back to the server. The server writes this data into a .dll file and Python code in your Panda3d project can then read these values in real time using the ctypes library which is part of the python installed alongside Panda3d. The Trinus server also transmits the currently active window’s contents to the phone where it is displayed on screen. It can fake a 3d effect by duplicating the window contents side by side although your Panda3d code could create two cameras which would give realistic 3d.
The code required in your project is as follows but you do need to amend the path to the freepie_io.dll
from ctypes import *
fields = [
in the init section of your code add
self.lib = CDLL(“C:/Program Files/FreePIE/freepie_io.dll”)
self.dat = head()
in the main game loop add
self.test = self.lib.freepie_io_6dof_read(0, 1, byref(self.dat))
Trinus server needs to communicate with the phone. This can be accomplished without wires but I use a USB lead to increase the bandwidth.
And you need FreePIE from andersmalmgren.github.io/FreePIE/
but note that you do not need to run FreePIE, just have it installed.
To make Trinus send the data through correctly open the configuration options and go to Advanced View. Then in the Main section set Sensor Output to FreePieIO.