2016-07-10 23:25:40 +00:00
|
|
|
LÖVR
|
2016-08-01 00:47:28 +00:00
|
|
|
===
|
2016-07-10 23:25:40 +00:00
|
|
|
|
2016-12-09 02:35:12 +00:00
|
|
|
LÖVR is a simple framework for creating virtual reality experiences with Lua. For more information,
|
2016-12-09 02:40:23 +00:00
|
|
|
visit the [website](http://bjornbyt.es/lovr).
|
2016-08-01 00:47:28 +00:00
|
|
|
|
2016-12-09 02:35:12 +00:00
|
|
|
Getting Started
|
2016-08-01 00:47:28 +00:00
|
|
|
---
|
|
|
|
|
2016-12-09 02:41:32 +00:00
|
|
|
You can download LÖVR from the [LÖVR website](http://bjornbyt.es/lovr). Once you have `lovr.exe`,
|
|
|
|
create a folder called `myGame` to hold the files for your game. Next, create a file called
|
|
|
|
`main.lua` in `myGame` and put this in it:
|
2016-08-01 00:47:28 +00:00
|
|
|
|
2016-08-01 00:48:08 +00:00
|
|
|
```lua
|
2016-09-30 07:17:35 +00:00
|
|
|
function lovr.draw(eye)
|
2016-10-03 01:13:58 +00:00
|
|
|
local x, y, z = 0, .25, -2
|
|
|
|
local size = 1
|
2016-12-05 09:17:32 +00:00
|
|
|
local angle = lovr.timer.getTime()
|
2016-08-01 00:47:28 +00:00
|
|
|
|
2016-10-03 01:13:58 +00:00
|
|
|
lovr.graphics.setColor(128, 0, 255)
|
2016-12-05 09:17:32 +00:00
|
|
|
lovr.graphics.cube('line', x, y, z, size, angle)
|
2016-10-03 01:13:58 +00:00
|
|
|
end
|
2016-08-01 00:47:28 +00:00
|
|
|
```
|
|
|
|
|
2016-12-09 02:39:46 +00:00
|
|
|
Finally, start SteamVR and drag the `myGame` folder onto `lovr.exe`. Put on your headset and you
|
|
|
|
should see a spinning purple cube!
|
2016-09-30 07:17:35 +00:00
|
|
|
|
2017-01-07 03:24:46 +00:00
|
|
|
#### Audio
|
|
|
|
|
|
|
|
Play an ogg file:
|
|
|
|
|
2017-01-07 03:25:06 +00:00
|
|
|
```lua
|
2017-01-07 03:24:46 +00:00
|
|
|
function lovr.load()
|
|
|
|
local sound = lovr.audio.newSource('darudeSandstorm.ogg')
|
|
|
|
sound:play()
|
|
|
|
end
|
|
|
|
```
|
|
|
|
|
|
|
|
Audio is spatialized using HRTFs, and the virtual audio listener is synchronized with the pose of
|
|
|
|
the HMD.
|
|
|
|
|
2016-10-31 20:56:27 +00:00
|
|
|
#### 3D Models
|
|
|
|
|
|
|
|
LÖVR supports most 3D model file formats:
|
|
|
|
|
|
|
|
```lua
|
|
|
|
function lovr.load()
|
|
|
|
model = lovr.graphics.newModel('teapot.fbx')
|
|
|
|
end
|
|
|
|
|
|
|
|
function lovr.draw()
|
|
|
|
model:draw()
|
|
|
|
end
|
|
|
|
```
|
|
|
|
|
2016-12-09 02:36:10 +00:00
|
|
|
For more examples, check out the [`examples`](examples) folder.
|
2016-12-09 02:35:12 +00:00
|
|
|
|
2016-12-09 02:42:22 +00:00
|
|
|
Hardware Support
|
2016-09-18 01:18:16 +00:00
|
|
|
---
|
|
|
|
|
2016-12-09 02:38:58 +00:00
|
|
|
- HTC Vive (full support via OpenVR)
|
|
|
|
- Oculus Touch (partial support via OpenVR)
|
2016-12-09 02:35:12 +00:00
|
|
|
- WebVR (partial support, see `emscripten` branch)
|
|
|
|
- Mobile VR (no support currently)
|
|
|
|
|
|
|
|
Documentation
|
|
|
|
---
|
2016-09-18 01:18:16 +00:00
|
|
|
|
2016-12-09 02:35:12 +00:00
|
|
|
See <http://bjornbyt.es/lovr/docs> for examples and API reference. The documentation is open source
|
2016-12-09 02:36:34 +00:00
|
|
|
and can be found [here](https://github.com/bjornbytes/lovr-docs).
|
2016-09-30 07:17:35 +00:00
|
|
|
|
2016-08-10 06:42:30 +00:00
|
|
|
Compiling
|
2016-08-01 00:47:28 +00:00
|
|
|
---
|
|
|
|
|
2016-12-09 02:38:58 +00:00
|
|
|
You might want to compile LÖVR from source so you can use LÖVR on other operating systems or create
|
|
|
|
a custom build.
|
2016-10-24 21:15:39 +00:00
|
|
|
|
|
|
|
### Dependencies
|
|
|
|
|
|
|
|
- LuaJIT
|
|
|
|
- GLFW (3.2+)
|
|
|
|
- OpenGL (Unix) or GLEW (Windows)
|
|
|
|
- assimp (for `lovr.model` and `lovr.graphics.newModel`)
|
2017-01-07 17:55:20 +00:00
|
|
|
- OpenVR (1.0.5, for `lovr.headset`)
|
2016-11-01 00:25:49 +00:00
|
|
|
- PhysicsFS
|
2017-01-07 03:24:46 +00:00
|
|
|
- OpenAL (1.17+ recommended for HRTF support)
|
2016-10-24 21:15:39 +00:00
|
|
|
|
|
|
|
#### Windows (CMake)
|
|
|
|
|
|
|
|
First, install [lovr-deps](https://github.com/bjornbytes/lovr-deps):
|
|
|
|
|
|
|
|
```sh
|
|
|
|
cd lovr
|
|
|
|
git clone --recursive https://github.com/bjornbytes/lovr-deps deps
|
|
|
|
```
|
|
|
|
|
|
|
|
Next, use CMake to generate the build files:
|
|
|
|
|
|
|
|
```sh
|
|
|
|
mkdir build
|
|
|
|
cd build
|
|
|
|
cmake ..
|
|
|
|
```
|
|
|
|
|
|
|
|
This should output a Visual Studio solution, which can be built using Visual Studio. Or you can
|
|
|
|
just build it with CMake:
|
|
|
|
|
|
|
|
```sh
|
|
|
|
cmake --build .
|
|
|
|
```
|
|
|
|
|
|
|
|
The executable will then exist at `/path/to/lovr/build/Debug/lovr.exe`. The recommended way to
|
|
|
|
create and run a game from this point is:
|
|
|
|
|
|
|
|
- Create a shortcut to the `lovr.exe` executable somewhere convenient.
|
|
|
|
- Create a folder for your game: `MySuperAwesomeGame`.
|
|
|
|
- Create a `main.lua` file in the folder and put your code in there.
|
|
|
|
- Drag the `MySuperAwesomeGame` folder onto the shortcut to `lovr.exe`.
|
|
|
|
|
|
|
|
#### Unix (CMake)
|
|
|
|
|
2017-01-07 17:55:20 +00:00
|
|
|
First, clone [OpenVR](https://github.com/ValveSoftware/openvr). For this example, we'll clone
|
2016-12-13 10:11:35 +00:00
|
|
|
`openvr` into the same directory that `lovr` was cloned into.
|
|
|
|
|
|
|
|
```sh
|
2017-01-07 17:55:20 +00:00
|
|
|
git clone --branch v1.0.5 https://github.com/ValveSoftware/openvr.git
|
2016-12-13 10:11:35 +00:00
|
|
|
```
|
|
|
|
|
|
|
|
Next, install the other dependencies above using your package manager of choice:
|
2016-10-24 21:15:39 +00:00
|
|
|
|
|
|
|
```sh
|
2016-11-01 00:25:49 +00:00
|
|
|
brew install assimp glfw3 luajit physfs
|
2016-10-24 21:15:39 +00:00
|
|
|
```
|
|
|
|
|
|
|
|
On OSX, you'll need to set the `DYLD_LIBRARY_PATH` environment variable to be
|
|
|
|
`/path/to/openvr/lib/osx32`.
|
|
|
|
|
|
|
|
Next, build using CMake:
|
|
|
|
|
|
|
|
```sh
|
|
|
|
mkdir build
|
|
|
|
cd build
|
2016-12-13 10:11:43 +00:00
|
|
|
cmake .. -DOPENVR_DIR=../../openvr
|
2016-10-24 21:15:39 +00:00
|
|
|
cmake --build .
|
|
|
|
```
|
|
|
|
|
|
|
|
The `lovr` executable should exist in `lovr/build` now. You can run a game like this:
|
|
|
|
|
|
|
|
```sh
|
|
|
|
./lovr /path/to/myGame
|
|
|
|
```
|
|
|
|
|
|
|
|
You can also copy or symlink LÖVR into a directory on your `PATH` environment variable (e.g.
|
|
|
|
`/usr/local/bin`) and run games from anywhere by just typing `lovr`.
|
2016-12-09 02:26:00 +00:00
|
|
|
|
|
|
|
License
|
|
|
|
---
|
|
|
|
|
|
|
|
MIT, see [`LICENSE`](LICENSE) for details.
|