This is a project that I worked on for around a week during April's Intersession while taking the VR Arts and Design class. Though the focus for this class was on using already existing tools to create 3D models and other visual pieces, I took interest in using my experience with coding to create a tool myself as my final project for this class.
What I settled on was a physics editor/playground for experimenting with how to create interactive physics-based environments in VR. I’ve noticed other engines that have accomplished this before, by allowing you to interact with objects using their supported interface, such as Boneworks, and Rec Room, and I figured that experimenting with my own implementation of a VR game for physics would be interesting. Regarding how VR games often have detailed physics interactions, this could become an issue as there being few programs for exploring how to test and handle these physical interactions is a limitation. Though editors do exist for creating physics interactions, there’s so much that could be done using a VR physics editor. This doesn’t only influence how a VR game could be made, but also could help with time constraints.
I wanted to explore how players could create their own physical environments by not only creating objects, but also constraints and joints, such as hinges and ropes. Regarding this, allowing users to actually build out these simulations and objects in a VR program allows them to better visualize how these interactions might play out in the real world or in a video game. A real-world example for where this program could be used is also in simulating events, such as how to design a wrecking ball to demolish a building, or the effects of an earthquake on a structure.
In order to do this, I wanted players to have the ability to create different colliders of different shapes based on their own input, as well as the option to create joints, which can also be linked between different objects of any shape, such as cylinders, boxes, spheres, and capsules.
In the first few days of coming up with the idea for the project and designing what features I would need, I decided to take a look at a few engines that I could use to create this project. I eventually settled on LOVR, which is an open-source framework used for creating VR games. Like Love2D, this program didn't use a visual editor to create games, but instead was all code-based and in Lua.
LOVR also natively supports audio, an implementation for rigid-body physics, joints/constraints, and simple lighting, which was exactly what I needed for this project. It's documentation also ended up being really useful, as they have extensive examples for different features and mini-projects that you can use that the engine provides.
Rigid-bodies in videogames are solid objects of any shape that can collide and respond to those collisions, but don't deform from any impacts. Most games use rigid-bodies to simulate physics, and this project isn't any different. I'll refer to rigid-bodies as colliders throughout the rest of this page.
What I wanted players to have the ability to do with rigid-bodies is to be able to grab, rotate, and position them from any point. In response to grabbing a rigid-body, I also wanted to simulate how it's mass would influence the amount of force and movement the player would have to exert in order to keep this rigid-body stable.
In implementation, I ended up creating a library that includes functions for creating colliders for boxes, cylinders, spheres, and capsules. This library also includes a function for generating colliders for the player's controllers relative to their position and orientation.
During each frame, the physics are then updated and all collisions are calculated between objects. Your controller colliders, also being physical objects, have their velocity and angular velocity set relative to the player's actual controllers. Grabbing objects is done by creating a joint between the controller collider and the other collider. This ensures that the weight of each collider is respected, and also means that depending on the angle and weight of the collider you’re grabbing, your hands will bend and rotate depending on their distance from it’s center of mass.
Finally, all of these colliders are rendered to the screen during each frame based on their color, size, rotation, and position.