To import geometry inside our video game, we are going to use a file format called ASE file or ASE format. The ASE format comes with different 3D tools, such as 3D Studio MAX or other tools. It is a text format, coded in ASCII and we can read it in a human way, it's easy to understand and it can be read. So to do so we are going to create a cube inside 3D Studio MAX. We are going to export it in ASE format and we are going to see how this format works in aim to be able to import it inside our engine. To do so, the first thing we are going to do is starting 3D Studio MAX. 3D Studio MAX is a 3D tool to create and edit geometrical models. You will see it in the art course. I'm not going to specify how it works, because as a programmer I don't have much experience in it, I will simply create a box in 3D Studio MAX. The box's height and dept will be 1 meter and I will put it in the position 0,0. I will apply a material to it. To do so I will press M key, which will open the materials editor and I will put a texture on the diffuse channel. I will take a bitmap, which is a texture inside the 3D Studio Max folder. I will give it the Tiger texture. We've created the material and I apply it to the cube. I tell it that I want it to be seen on the viewer and here's our cube. I will turn this cube into an editable mesh. OK, so now our cube is in a geometrical format and with an editable mesh. So what I'm going to do next is exporting this object. To do so I go to the options button, Export, and I give it an ASE format, ASCII Scene Export. I will export it to my desktop and I will name it Box.ASE. Here I will give it the properties I want to export. Basically what I'm interested in is the mesh definition, the materials, the animation transformation keys aren't important right now. Animation mesh isn't important right now, neither is animated camera inverse kinematics nor normals, but texture coordinates are, as well as geometry. Shapes, cameras lights and helpers aren't either important right now and the rest is OK, I press OK and it generates the file in ASE format. If now I go to the desktop a Box.ASE file has appeared and if now I open it with a text editor, in my case Notepad++, we get this file. This file contains the following information: on one side we have the materials list where the first material contains a diffuse bitmap and this bitmap's texture is the name you can see next. Obviously this is a texture in the local path, which we need to use in the game path, so we need to adapt it to the game path. And then comes the geomobject part, which tells us we have an object called Box01, we have the object's transformation matrix as well as its scale, rotation, etc. and we also have the number of geometrical vertexes and the number of faces it has. So as we are speaking about a cube, it is telling us the cube has 8 vertexes and 12 faces. Each face has three vertexes, so we have 36 vertexes to paint those 12 triangles. 3D MAX uses an XZY coordinates system. So, the Z is the vertical, while in our game our Z is the depth and the Y is the vertical. So when we are using the coordinates system we will swap Y and Z's order. If we look at the geometry list, mesh vertex tells us that the first vertex's geometrical position is -0.5,-0.5,0. This will be X and Z in the MAX system which we will use as XZY. So what we need to do next is creating our vertex buffer system. To do so I'm going to create the vertexes system. So our first vertex will have the geometrical positions will be A = --0.5,0,-0.5. The second vertex will be 0.5,0,-0.5. The third one will be -0.5,0,0.5. The fourth will be 0.5,0,0.5 And this successively. The next structure tells us geometrical triangles are composed by the ABC vertex, which are indexes 0, 2 and 3. That is, the first vertex is formed by our 0 geometrical vertex which is -0.5,0,-0.5; and the second vertex of the first triangle will be the index 2. The index 2 will be 0,1,2,-0.5,0,0.5 and the third one will be 0.5,0,0.5. Don't forget the arrays are set starting at the 0 index. So, the first element of the array will be the 0 value, the second will be the 1, the third the 2, etc. It's telling us the geometry will be the vertex 0,2,3; then -0.5,0,-0.5,-0.5,0,0.5 and 0.5,0,0.5; these 3 vertexes will form the first triangle. But this will be at a geometrical level. Then below we have the textures information, the texture coordinates here in the tVertex. So, if before we had 8 geometrical vertexes now it's telling us we have 12 texture vertexes. Why do we have 12 if in a cube there are only 4? To do so I will make a little explanation. In a cube it would be something like this: We would have, at a geometric level, 1, 2, 3, 4, 5, 6, 7 and 8 vertexes, which are the vertexes geometry we have previously seen. However we have 12 texture vertexes. Why do we have 12 texture vertexes? The reason is simple, if we think of this face, this face and this other face. I will separate it and we will imagine how it is mounted. So, if we have the tiger drawing, which would be something like that, and the same on the other side, we get that our tiger's texture is something similar to this. We have the fact that the texture coordinates would be 0,0 in this vertex, 1,0 in this one, 1,1 in this one and 0,1 in this one. If we look at this vertex for the A face and the same one for the B face. This vertex's coordinates on the A face are 1,0. However, for the same vertex's side B texture coordinates we would have 0,0. So geometrically we only have one vertex, however in textures coordinates we have 2 vertexes. This is a problem when we need to mount our vertex buffer and mesh buffer system because in DirectX 11 we have to create a vertexes array with all the complete information, that is, both its geometry and its texture coordinates. So to do so we need to focus on the indexes. What does that mean? This means we can have 12 texture vertexes and 8 geometry vertexes but in both cases we have 36 indexes, which at its time would be 12 faces, both for textures and for geometry. What it is telling us here is that the first vertex, the first face's triangle, its geometry, is formed by the texture coordinates 9, 10 and 11. Which means that in the previous case we found that the first triangle's coordinates were -0.5,0, -0.5,-0.5,0,0.5 and 0.5,0,0,5 and if I'm not wrong it was 0, 2, 3. What does this mean? That the first vertex of the face we are going to build it again, this first vertex, this first triangle is composed by the vertexes 0, 2 and 3. So, at a geometrical level the first triangle is composed by the vertexes 0, 2 and 3, which means that geometrically the vertex 0 is -0.5,0,-0.5. This would be its geometry and, at a textures level, it is formed by the index 9 in coordinates texture, which means this vertex would be 1,0, that is, the vertex will have the texture coordinates 1,0. If we have previously made the transformation by swapping Z and Y, we will also have to modify in texture coordinates the V which would be the second couple of the second texture coordinate. So, its value would be 1 minus V, and in this case the V of the vertex 9 is 0, which would be 1-0=1. So, to make it clear, we are always talking on the vertex 9, with a 9 index. And here we can see the first face, which is formed by the vertexes 9, 11, 10. OK? So, what does all this mean? This means the first vertex of our first triangle will be the geometrical coordinate -0.5,0,-0.5 and the texture coordinates will be 1,1. For the second geometrical vertex it will be the index vertex 2, which has 2 as its index, so, it will be this vertex here, which will be -0.5,0,0.5 and at a textures level it will be the first face. The second vertex will be vertex 11, which means it will be 1, 1-1=0, And the third vertex, the C vertex, will be at a geometrical level the vertex with index 3, so the index 3 is this one. So it will be 0.5,0,0.5 and at a texture coordinates level it will be the texture 10 coordinates index will be 0, 1-1=0. As we can remember, V coordinates from the texture are 1-V', where V' is the value of the V on the first texture, which would be this value here in the index 10. OK, let's go on for the second triangle. This second triangle is formed by the vertexes 3, 1 and 0, OK? The next will be the vertexes formed by D, E and F. So as we said the vertex 3 with index 3 will be 0.5,0,0.5. The second vertex of the second triangle will be the vertex with the index 1. So it will be 0.5,0,-0.5, and the third vertex from the second triangle will be the vertex which has 0 as its index, which will be -0.5,0,-0.5. And its texture coordinates will be the second face of the indexes the vertexes which have 10, 8 and 9 as indexes have. So in this case, the vertex we have said, defined as D, will be the vertex which has 10 as its index. So it will be 0,1-1,0 The second vertex of the second triangle will be as index 8,0,1.0,1. And the third vertex of the second triangle will be the index 9 which is 1,1-0,1. And here we would have made the 2 first triangles of the cube we have generated. We should do this in all its faces, in all the vertexes in our geometry and with this we would have, on one side, our geometry's VertexBuffer. If we wanted to create an IndexBuffer setting off from here, we could do it this way: once we have all the vertexes we should look for a clean VertexBuffer, one whose vertexes aren't repeated. If we look carefully at it, in this VertexBuffer geometry with these 6 vertexes, the vertexes C,D, A and F are getting repeated. What does this mean? This means if we wanted to look for a clean VertexBuffer and IndexBuffer, our VertexBuffer would be our vertexes -0.5,0,-0.5,1,1. The next one would be -0.5,0,0.5,1,0. The next one would be 0.5,0,0.5,0,0. We wouldn't repeat the next vertex, D vertex, because it has been previously done. Instead we would do the E vertex which is 0.5,0,-0.5,0,1. And our IndexBuffer would be the next: the first triangle would be made by the vertexes 0, 1 and 2 and the third triangle would be made by the vertexes 2, 3 and again, 0. So, as we can see here, if we only used VertexBuffer the information or the size of the VertexBuffer would be bigger than if we were using VertexBuffer plus IndexBuffer. So the IndexBuffer is also used to lower the vertex arrays' size, and lower the video memory size of all the geometry.