-
Notifications
You must be signed in to change notification settings - Fork 41
Using Meshes in Unity (Minecraft Version)
Cleaning the maps: In order to use the scans from Project Tango in Unity, the meshes need to be simple enough and small enough to be processed quickly. They also need to be smooth if you so choose to use the meshes as they are. Once you have the mesh files combined and cleaned in a MeshLab project (See: Mapping Hints and Tips), use Filters -> Point Set -> Surface Reconstruction: Poisson with both "Octree Depth" and "Solver Divide" settings in the low teens. This will create a smooth model that has some holes and obstacles for the Unity character to avoid. To make the model manageable for Unity and for the "voxelizer," use Filters -> Remeshing, Simplification and Reconstruction with target faces set at about 10000. Export this model as an OBJ file.
Minecraftifying (optional): Use this cool tool to make your models look as if they were made in Minecraft. Adjust the density slider to your own discretion, but be warned: the high density slider will increase your face count and model size. Use the size slider to determine the space between blocks: for the Minecraft look, set the slider all the way to the right then pull it back as little as possible. Use the options menu to select the "OBJ" file type, and click "Group voxels as single object." Lastly, after saving the file, you will need to import it into Meshlab and flip all of the faces. Use the "Select Connected Components in a Region" tool from the Edit menu and then Filter -> Normals, Curvatures and Orientation -> Invert Faces Orientation. Export this mesh as an OBJ file, and you're all set for Unity!
Creating the game: Follow the instructions from this tutorial to create a simple Unity game of a ball rolling in a plane.
Importing the map: In Unity's Asset menu, click "Import New Asset" and navigate to your OBJ file, either the Minecraft version or the smoothed one. Click on the file in the Projects window and in the Inspector uncheck "Import Materials." Drag the file from the Projects window into the Hierarchy window. Click the triangle next to the mesh name in the Hierarchy window and open "default." In the Inspector window, click "Add Component" and navigate to Physics -> Mesh Collider. If you look in the Scene window, you will see that the mesh is the wrong size - and in the wrong place - for the game. Use the scale tool and the translate tool to align the floor of your mesh with the plane in the game. Click on "Ground" in the Hierarchy window and uncheck the box by its name. Your game is all ready to go!
3 different ways to modify the mesh: