2017-04-21 04:11:24 +00:00
|
|
|
<p align="center"><a href="http://lovr.org"><img src="src/data/logo.png" width="160"></a></p>
|
2017-04-02 13:32:07 +00:00
|
|
|
|
|
|
|
<h1 align="center">LÖVR</h1>
|
2016-07-10 23:25:40 +00:00
|
|
|
|
2017-03-24 00:52:38 +00:00
|
|
|
LÖVR is a simple framework for creating virtual reality experiences with Lua.
|
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
|
|
|
---
|
|
|
|
|
2017-04-21 04:11:24 +00:00
|
|
|
You can download precompiled binaries from the [LÖVR website](http://lovr.org). There, you
|
2017-03-24 00:52:38 +00:00
|
|
|
can also find documentation and a set of tutorials and examples. Here are a few short snippets so
|
|
|
|
you can get an idea of what it looks like to use LÖVR:
|
2016-08-01 00:47:28 +00:00
|
|
|
|
2017-02-17 02:31:13 +00:00
|
|
|
#### Hello World
|
|
|
|
|
|
|
|
Create a folder called `myProject`. In that folder, create a file called `main.lua` with the
|
|
|
|
following in it:
|
2016-08-01 00:47:28 +00:00
|
|
|
|
2017-02-17 02:31:13 +00:00
|
|
|
```lua
|
|
|
|
function lovr.draw()
|
2017-02-17 08:48:43 +00:00
|
|
|
lovr.graphics.print('Hello World!', 0, 1, -1)
|
2016-10-03 01:13:58 +00:00
|
|
|
end
|
2016-08-01 00:47:28 +00:00
|
|
|
```
|
|
|
|
|
2017-02-17 02:31:13 +00:00
|
|
|
Finally, start SteamVR and drag the `myProject` folder onto `lovr.exe`. Put on your headset and you
|
|
|
|
should see the hello world text at the front of the play area.
|
|
|
|
|
|
|
|
#### Cube
|
|
|
|
|
|
|
|
You can draw a spinning cube using
|
|
|
|
[`lovr.graphics.cube`](http://bjornbyt.es/lovr/docs/lovr.graphics.cube):
|
|
|
|
|
|
|
|
```lua
|
|
|
|
function lovr.draw()
|
|
|
|
lovr.graphics.cube('line', 0, 1, 0, .5, lovr.timer.getTime())
|
|
|
|
end
|
|
|
|
```
|
2016-09-30 07:17:35 +00:00
|
|
|
|
2017-04-21 04:11:24 +00:00
|
|
|
#### Detecting Hardware
|
2017-01-07 03:24:46 +00:00
|
|
|
|
2017-01-07 03:25:06 +00:00
|
|
|
```lua
|
2017-01-07 03:24:46 +00:00
|
|
|
function lovr.load()
|
2017-04-21 04:11:24 +00:00
|
|
|
if lovr.headset.isPresent() then
|
|
|
|
print('Woo! We have a headset: ' .. lovr.headset.getType())
|
|
|
|
else
|
|
|
|
print('Boo! No VR for us :(')
|
|
|
|
end
|
2017-01-07 03:24:46 +00:00
|
|
|
end
|
|
|
|
```
|
|
|
|
|
2016-10-31 20:56:27 +00:00
|
|
|
#### 3D Models
|
|
|
|
|
|
|
|
LÖVR supports most 3D model file formats:
|
|
|
|
|
|
|
|
```lua
|
|
|
|
function lovr.load()
|
2017-02-17 02:31:13 +00:00
|
|
|
model = lovr.graphics.newModel('teapot.fbx', 'teapot.png')
|
2016-10-31 20:56:27 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
function lovr.draw()
|
|
|
|
model:draw()
|
|
|
|
end
|
|
|
|
```
|
|
|
|
|
2017-04-21 04:11:24 +00:00
|
|
|
#### Audio
|
|
|
|
|
|
|
|
Play an ogg file:
|
|
|
|
|
|
|
|
```lua
|
|
|
|
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.
|
|
|
|
|
2017-05-07 06:23:50 +00:00
|
|
|
For more examples, see <http://lovr.org/examples>.
|
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
|
|
|
---
|
|
|
|
|
2017-05-07 06:23:50 +00:00
|
|
|
LÖVR supports headsets compatible with OpenVR or WebVR. Notably, the HTC Vive is well tested.
|
2016-12-09 02:35:12 +00:00
|
|
|
|
|
|
|
Documentation
|
|
|
|
---
|
2016-09-18 01:18:16 +00:00
|
|
|
|
2017-05-07 06:23:50 +00:00
|
|
|
See <http://lovr.org/docs> for guides 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+)
|
2017-03-07 23:23:06 +00:00
|
|
|
- OpenGL (3+)
|
|
|
|
- assimp
|
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)
|
2017-03-07 23:24:19 +00:00
|
|
|
- FreeType
|
2017-05-07 06:23:50 +00:00
|
|
|
- Emscripten (optional, for compiling for web)
|
2016-10-24 21:15:39 +00:00
|
|
|
|
2017-03-08 00:01:43 +00:00
|
|
|
See [lovr-deps](https://github.com/bjornbytes/lovr-deps) for a GitHub repo containing all of these
|
|
|
|
as submodules.
|
|
|
|
|
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
|
2017-02-19 21:21:27 +00:00
|
|
|
brew install assimp glfw3 luajit physfs freetype openal-soft
|
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
|
|
|
|
2017-05-07 06:23:50 +00:00
|
|
|
#### WebVR
|
|
|
|
|
|
|
|
First, install the Emscripten SDK. Make sure you're running [this
|
|
|
|
branch](https://github.com/bjornbytes/emscripten/tree/lovr) of Emscripten.
|
|
|
|
|
|
|
|
```sh
|
|
|
|
mkdir build
|
|
|
|
cd build
|
|
|
|
emcmake cmake -DCMAKE_BUILD_TYPE=Release ..
|
|
|
|
emmake make -j2
|
|
|
|
```
|
|
|
|
|
|
|
|
The above commands will output `lovr.html`, `lovr.js`, and `lovr.js.mem`. To package a game, run:
|
|
|
|
|
|
|
|
```
|
|
|
|
python /path/to/emscripten/tools/file_packager.py game.data --preload /path/to/game@/ --js-output=game.js
|
|
|
|
```
|
|
|
|
|
|
|
|
Which will output `game.js` and `game.data`. The `lovr.html` file will need to be modified to
|
|
|
|
include `game.js` in a script tag.
|
|
|
|
|
2016-12-09 02:26:00 +00:00
|
|
|
License
|
|
|
|
---
|
|
|
|
|
|
|
|
MIT, see [`LICENSE`](LICENSE) for details.
|