Project3: PIXEL VR


(Logo made by us)

Introduction & Youtube video & Code

For project 3 we decided to design a virtual reality application. Our group is composed of two members: Andrea Tricarico & Federico Sandrelli.
During project 2 we have stumbled upon and made great use of MagicaVoxel, a "voxel" (volumetric unit) art editor that allowed us to build creative environments for our game with a funky pixelated style we personally really like. Moreover, building models with that application was intuitive, easy and fun. We like the game Minecraft too, that uses the same voxels to build entire worlds and which is a very popular game.
So, we have decided to design a virtual reality work environment where it is possible for the user to create 3D models made of voxels.


Youtube video:
https://youtu.be/gcnrnk38C50

Link to the code: https://drive.google.com/open?id=1DTNXaicUkp1mz-91VohCPAFZDbFLfaJA

General features

-Editing of 3D models using voxels, adding and deleting voxels.
-Selecting various different colors and materials for the voxels.
-Undo of each actions.
-Redo of each actions.
-Copy and paste functionality.
-Teleporting around the editing area and move the area up and down in order to be always able to reach each part of the editing area.
-Save and load in the personal computer of the models of the user that will be saved in a file and reloaded after a restart of the application.
-The models created are saved in files that can be also shared with other people that will be able to load them in a different computer.
-Clear of the entire work area with a button.
-Load of two prefabricate models that are given with the application and that the user can use as starting point of his modelling work.
-Turn on/off the music in the virtual word, or change the current song, using the buttons on the radio.
-Change the virtual scene through virtual buttons. The user can choose between 4 very different settings which are closed rooms or open words.

Description

The application spawns the user in a virtual room which is the 3D version of the room seen in the old Pokémon games at the beginning of the adventure.
To make the user able to move around the environment freely without being limited by the physical environment where he is running the application, we used some teleporting stations that can be used to move around beyond the physical boundaries. We chose to disable the teleporting feature in the rest of the VR environment in order to prevent the user from going outside the work area.
The user can choose among different editing environments and has acmes to a ratio to put some music on if he/she wishes.

The user can interact with the radio using three buttons to turn the music on or off and to change the actual song. He can choose between 4 different songs: the 9th symphony of Beethoven played by the Chicago Symphony Orchestra, “The dark side of the moon” by Pink Floyd, a collection of piano music by Studio Ghibli, a soundtrack of the old Pokémon’s games.
The entire setting of the working area can be changed using the 4 buttons in the Room Selector Panel. There are 4 different scenes, each matched with a different button. As soon as the player clicks on one of the buttons the game object that contains the current scene is deactivated and the new one is activated. Switching between one scene to the other is achieved by deactivation and activation of game objects in order so save computational power because in this way the game engine has to elaborate not more than one scene at the same time. The first scene is the Pokémon’s room, this is the only scene that is a closed room to recreate a normal studio office. The other three are open spaces, this because we think that open spaces are more immersive, and they create a more relaxing environment to draw. The three open scenes are a city park, a medieval port and a futuristic Mars scene with explorer pods laying around.

(Image of the buttons of the VIVE controller, from https://www.vive.com/us/support/vive/category_howto/about-the-controllers.html)
After setting up the environment the user can start modeling in the 3D canvas. The space in the middle of the room is the working area where the user can create the models. As soon as he enters in the area a voxel will appear in the slot of the grid which is closest to the tip of the controller. The current implementation only makes use of the controller recognised by the system as the “right controller”. Since the controllers are identical it can be held in any hand and is suitable both for left and right handed. This voxel will move in the grid following the movements of the controller and it helps the user showing in real time where (and how) the cube will be created with the user trigger in that moment.
Clicking on the Trigger button it is possible to make the cube be permanently instantiated in the current position of the right controller, or it is possible to keep the button pressed and make cubes appear as the controller is moving.
It is possible to delete voxels moving the right controller in the position of the voxel that we want to delete and clicking the Grip button.
The user has access to other editing functionalities using the two tables in the scene.

One table is a reinvented version of a color table. The colors and materials are not showed with names or images like in the common version of editing tools but with voxels that are a preview of what the material will look like in the model giving to the user a 3D preview of the material (which is very important for materials like “water” or “glass”. To select a material, it is sufficient to take one object (Grip button) and put it in the highlighted zone on the table. The cubes used for selected the material have no gravity and physics in order to make possible for the user to reorganize them in the positions that he prefers in a very easy way (and without the risk that he loses some material throwing the corresponding cube away in the open world scenes.
Moreover, for a developer that wants to extends the materials in the applications, this is a very easy operation because the code is made in a way that permits it to be made only with the Unity3D graphic interface and without entering in the scripts: he will have only to copy one on the cubes (both in the table and in the list of colors), change the material, and add the one from the list of colors in the array that is present in the attribute of the GridCube object.

On the other table the user has ten buttons and a level that give him the access to the remaining editing functionalities. The lever is useful to change the height of the model, this is very useful to model in a comfortable way objects without having to stretch or lean too much.
The are the buttons to undo and redo the actions of the user, these give to the user an unlimited number of undo / redoes. The button to clear the entire work area is present too, to give an easy and quick way to erase all the cubes created.
The button “Copy” gives the access to the “copy and paste” functionality. Clicking on this button the selecting function is activated, the user will be able to select an area with the shape of rectangular parallelepiped clicking and holding the Trigger button on the controller (the script will use the points of click and release of the button to calculate the selected area). After the selection the voxel that is always present on the right controller will became red, indicating that the next click of the trigger button will paste” the copied area. After the paste click the area will be pasted starting from the current position of the controller, keeping the original materials and orientations of the cubes.
The last buttons give the user the possibility to save persistently his work in an external file and to load previous saved models or one of the two models (made by use using directly our application) that we have inserted in the project and that are given to the user to have a some prefabs which can be used as starting point of his work.


Therefore, there are two buttons to load the prefabs models (these are saved in binary files the project folder) and 4 buttons to save and load models made by the user himself. The user has two slots of memory where he can save the models. The created files are binary files and can be found in the path C:/Users/USER_NAME/AppData/LocalLow/DefaultCompany/PixelVR, these files can be shared with other people on different computers where our VR application is run.
It is important to note that the editing grid can be scaled at preference and placed anywhere in the scene. The logic of the grid can be fount in the script called “GridScript”. All scripts we have created or edited can be found in the folder called “MyScripts” in the project assets.




How to run the project

To run the application it is necessary to download the code from the link on this site, open the project with the Unity3D Editor and starting the environment with the “play” button. We have decided to avoid to build the application and use the editor in order to give an uniform code to run, otherwise we have needed to write some pieces of code differently for each platform (Windows, Mac or Linux) because of the different instructions to retrieve the path where we have saved the predefined models that the user can load during his experience.

Hardware & Software Platforms

Hardware: HTC VIVE
Our project uses virtual reality so for the hardware we decide to use the HTC VIVE that we already used in the second project. This hardware can give us the precision that we need for the application, since this is a modelling app it needs an high precision during the movement and the positioning of the cubes.
Software: Unity3D & VRTK library with the SteamVR plugin.

Credits

Music:
https://youtu.be/rOjHhS5MtvA
https://www.youtube.com/watch?v=gmHrHQEmp2Q
https://www.youtube.com/watch?v=YjohMzHkBqI&t=1823s
https://www.youtube.com/watch?v=DVT_ycaNZqI
Scenes:
PokemonRoom:
https://sketchfab.com/models/b23b6b253207463c97db2a7092adff74
Port:
https://assetstore.unity.com/packages/3d/environments/historic/polylised-medieval-desert-city-94557
Park:
https://assetstore.unity.com/packages/3d/environments/urban/low-poly-park-61922
Planet Mars:
https://assetstore.unity.com/packages/3d/vehicles/space/mars-pod-121710
Inspiration for initial stages of our code: https://pastebin.com/nd70x7Gx