Skip to content

lxkast/vr-voxel-game

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

VR Voxel Game with Headset and Controller Integration

Overview

A repository for our first-year C group project at Imperial College London containing:

  • A VR voxel game written in C with OpenGL.
  • A custom VR headset design (Raspberry Pi 4) along with code to track headset orientation, integrated into the game.
  • A custom bluetooth controller design (Raspberry Pi Pico) with code.

The game runs at about 30-35 FPS on the headset (Raspberry Pi 4).

We placed 2nd out of 58 teams and won the "Most Interesting Extension" prize.

IMG_1789.mov

Features

  • Procedural terrain generation (infinite world).
  • 3D hotbar user-interface.
  • Multiple biomes.
  • Trees, cacti and igloo structures.
  • Vertex lighting.
  • Breaking and placing blocks.
  • Physics system.
  • 3D Audio with miniaudio.
  • Render distance-based fog.
  • Extremely optimised (frustum culling, meshing algorithms, multi-threading etc).

Installation

PC Installation (Windows, Mac, Linux)

Note: Linux users will need to install the GLFW dependencies separately in order to build, see https://www.glfw.org/docs/3.3/compile.html.

  1. Clone this repository and its submodules.

    git clone --recursive https://github.com/lxkast/vr-voxel-game.git
    
  2. Build with CMake (use GCC/Clang/MinGW).

    cd vr-voxel-game/
    
    cmake -B build
    
    cmake --build build
    
  3. The game executable is found in ./build/game/src.

Building the VR Headset

Our headset is powered by a Raspberry Pi 4. Below is an overview of the headset's setup.

image

The ICM-42688 is connected like so:

headset electronics drawio

Raspberry Pi 4 Setup

  1. Install the GLFW dependencies, see https://www.glfw.org/docs/3.3/compile.html.

  2. Clone this repository:

    git clone --recursive https://github.com/lxkast/vr-voxel-game.git
    
  3. Build:

    cd vr-voxel-game/
    
    cmake -DBUILD_FOR_RPI=ON -B build
    
    cmake --build build
    
  4. Run:

    cd build/game/src
    
    ./game
    

Controls

Controls on PC:

  • WASD - movement
  • Left Click - mine a block
  • Right Click - place a block
  • Space - Jump
  • Number Keys - select an item in your hotbar
  • B - opens 3D hotbar
  • P - switches between normal view (one image without distortion) and headset view (two distorted images)
  • O - shows the wireframe view of the world
  • ESC - quit

Controls with Headset and Controller:

Head movement controls where you look and the controller handles everything else.

Below shows what we decided on for our controller:

image

Should you decide to use your own controller, our program uses 5 buttons from the controller, which are taken as part of an array, as well as an axis input from a joystick. This is how each button is assigned:

  • Button 0 - Opens the 3D hotbar
  • Button 1 - Mines a block
  • Button 2 - Place a block
  • Button 3 - Sprinting
  • Button 4 - Jump

Screenshots

image image image image

Credits/Copyright

All code outside of game/external is our own, with the exception of gl.c.

All textures are our own.

Audio files are sources from pixabay.com and are used in accordance with their content license.

Final Words

This repository was migrated from the original GitLab repository owned by the university. Commit messages are prepended with our personal shortcodes for marking purposes.

This project had a 4-week deadline, so we did not have time to make major refactors for any poor architectural decisions. There have been no major changes to the project post-submission.

About

VR Voxel Game + Custom VR Headset & Controller

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •