Creating Meshes

Getting Started
To create meshes for Delver, we're going to use Blender . Blender is a free 3D modelling program.

Once you get Blender installed you're ready to proceed.

Basics
First of all we need to be familiar with blender and what are the basics needed to make a mesh for Delver. If you don't have any practice with any 3D modelling software, I recommend you watch a basics tutorial, like this one.

Interface
Object Interation Mode - On the bottom you can change the object interaction mode. For this tutorial we're only going to need Object Mode and Edit Mode.

Mesh Select Mode - So you can select the vertexes, edges or faces of an object. This menu only appears in Edit Mode.

Transform - By default you have the 'outliner' on the right. Click the tiny cube button for the object properties. Here we can change its scale, rotation and position.

New Editor - On the top right of your current window, you can drag that little flap to create another editor window. Once the window is created, a similar flap on the bottom left can be used to close it (drag it left THEN right to have the option to close either)

Editor Type - On the bottom left of any editor window, you can change its type. For this tutorial we'll be using the 3D View and UV/Image Editor

Viewport Shading - Here we can change how we preview our object. We'll be using mostly Solid or Textured

Creating a Box
For this tutorial we'll be creating the most simple mesh: a box.

Luckly for us, Blender already gives us a cube to start with, which can be added manually by going to the Add menu > Meshes > Cube



Scale and Position
First of all, our cube is too big. The scale of the cube is double what it will be in-game, because it scales off the center of the cube. Our cube is currently 1 x 1 x 1, which would occupy the space of 2 tiles. Let's reduce it to 0.25 x 0.25 x 0.25 so our cube is half a tile.

Now let's center our cube in our 3D space so everything is as simple as possible. The cube is currently at the location of 0x0x0, but that will put it slight inside the floor (just look at the grid). Set the Z Location to 0.25

This is what out object should look like by now:



Unwrapping
In order to add a texture to our object, we need to create an UV projection of the mesh. To start, set the object interaction mode to Edit Mode and set our mesh selection mode to Edge Selection.

Holding Shilft, right click the edges that will open up. We want to form the classic open dice texture, so we select these edges:



Now press Ctrl+E and click mark seam. You can later mark more seams, or clear seams if you want to.

Once the seams are marked, press A once to clear the selection, and A once again to select everything. Now press U and click Unwrap.

Preparing the texture
Now that we unwrapped our cube, we will need a new window to edit it. Open it by dragging the flap on the top right of the current viewport, and set the Editor Type to UV/Image Editor. This is how our screen should look like now:



We should have everything ready to start texturing our object now. On the bottom of the UV/Image Editor window, click Image > Open Image and select the image you want. I'll be using the meshes.png file, located in the assets folder.

In order for us to preview the image into our cube, let's set it to display the texture. Change the viewport shading to '''Texture. '''You should now be seing the texture projected into the cube. But if you look around the cube, you'll notice some sides are completely black. This is because our scene isn't completely illuminated.



Since we are just creating a mesh, and not a scene, we don't need to worry about lightning. Instead, we are simply going to make our object completely bright.

On the right menu (with the cube still selected), click the Material button. Under the Shading submenu, you should find an option named "Shadeless". Click it. Now the cube is completely bright.



Editing the UV Map
Now we are ready to edit the UV Map.

First of all we need our UV map to snap to the image pixels. To do this, click UVs > Snap To Pixels.

Now let's roughly positionate our UV map where we need it.

On the bottom of the UV/Image Editor window you will find 4 buttons to select what to edit: Vertex, Edge, Face and Island.

For now, select Island and right click the UV map. You can press S to scale, and R to rotate the entire object's UV map.

Now select Face and place each face of the cube in the area of the image you want. We are texturing our box just like the default Crate in the game. Use the Edge and Vertex mode for positioning the UV map more precisely. Remember that to move the UV map, we drag it with Right Click and confirm the position by pressing Enter.



Exporting and Testing
We are ready to export our mesh! Go over to File > Export > Wavefront (.obj).

On the left you can see all the exporting options for the file format we selected. For Delver you'll want to uncheck everything, except Include UVs and Triangulate Faces.

Save it in the 'meshes' folder, inside the 'assets' folder of your mod.

Adding the object to DelvEdit
Open your entities.dat file, inside the 'data' folder. We have to configure some basic rules for our object so it works correctly in the game.

Add a new category of objects called "Custom" to the end of the file. It should look like this: "Ambient Sounds": { "Running water": { class: com.interrupt.dungeoneer.entities.AmbientSound, radius: 7, volume: 0.325, id: "", soundFile: "/ambient/env_waterfall.ogg" }, "Lava": { class: com.interrupt.dungeoneer.entities.AmbientSound, radius: 10, volume: 0.8, soundFile: "/ambient/env_lava.ogg", id: "" } }, 		"Custom":{ } 	} }

And add the box object inside it: "Custom":{ "Box": {class: com.interrupt.dungeoneer.entities.Model,meshFile: meshes/box.obj,textureFile:meshes.png,collision: {x: 0.25,y: 0.25,z: 0.5},isDynamic: false,isSolid:true} }

Now save and close.

Now the object is ready to be used in DelvEdit!

Troubleshooting
 In DelvEdit I can't open the entities menu 


 * You probably messed up the hierarchy of the entities.dat file. Pay attention to closing {} and how they need a comma after them, except the last one.

In DelvEdit my object disappears when I add it


 * Pay attention to the object and texture names in entities.dat, you may have a typo there.

The game/DelvEdit crashes because of my object


 * Make sure your object is correctly located in the meshes folder in the assets folder. Also make sure the path for the 'meshFile' and 'textureFile' in the entities.dat is correct.

The collision box is bigger than it should be


 * The collision box is calculated from the center of the object, so an object that is 1 tile wide only needs 0.5 wide collision box. This is only true for the X and Y sizes. Z is calculated from the base