We need to implement what we have just done on a paper into our engine. To do so, we have created an ASE Object class which will allow us to read ASE Object format files and render geometry inside our game, inside our engine. And then we have as support this ASE Object class, a Text class which allows us to read or skip to a text mode file in text mode, either in values, names, or searches inside the file. So to do so we will go to the visual studio project again, and we will see how it works. On one side, we have the text class which is a standard class we will find in many internet sites, and which allow us to read a file or text in text format and, setting off this file reading we can look for elements inside the text or get our values in full mode or float. If we go to the ASE Object class we have the class builder. Let's type .h to see its features. The ASE Object class has on one side the position effect which we will need in aim to be able to paint our geometry, a RenderableVertexs vector. We have seen how RenderableVertex was either a vertex buffer or a vertex case buffer and, in this case, we have a RenderableVertex vector which will allow us to vectorize different geometry blocks. Depending on the number of materials our mesh has we will need to create a RenderableVertex for each material. To do so, it is necessary a RenderableVertex vector. Also, we have a textures vector. The texture class we will now see will allow us to use textures or images in aim to be able to paint over the geometry we are going to paint using the ASE Object class. Then we have an information which is the BBMin and BBMax position, which I will explain later, 4 values, 4 variables which save the geometrical vertexes number information, the number of geometrical faces in our ASE Object, the number of texture vertexes, the number of geometry faces. And then another member variable, which is m_Radius, which tells us the radius. We will talk on it later. We've got the Radius method, which we will explain next, the load method which will load the file in an ASE format, 3 get methods for the possible BBMin and BBMax which I will explain later, and the Rendel method which will allow us to paint IsInBoundingBox which I will also explain later. So if we go to ASEObject.cpp we see that in the builder we simply initialize the member variables and we have the load method. The load method gets the name of the ASE file we need to load, the device and a boolean parameter which will tell us whether we have to create a collision mesh for the geometry we have loaded. The first thing Load method does is creating many variables we are going to use later. If we look carefully at the line 41 it looks for the tag *BITMAP inside the format ASE file. We use *BITMAP as a material creator, that is, we set off the base each of our geometry's material is a diffuse texture and this material has only one diffuse texture. So we look for the Bitmap and we load it through the LoadTexturer method on the TextureManager, which we will explain now, and we put it inside our textures vector. We can see this in the rows 64 and 65, so we will load a texture for each material. Next we look for the geometry's initial point, searching the GEOMOBJECT we look for the node name. We aren't going to use it, but we can keep it if we want to. And so we start looking for information in aim to generate our geometry's Vertex Buffer. In this case we look for the number of vertexes, we save it in the variable m_NumVertexs located in lines 85 and 86, then we look for the number of faces and we keep it in the m_NumFaces variable which is in the lines 90 and 91. Next for each one of the geometrical vertexes the ASE file told us we have we get the vertex's X and Z geometrical positions and we save them in the vertexes vector called l_VertexBuffer. Well, once we have all the geometries we load all the geometrical indexes. To do so, we make a loop for each one of the faces indexes and we pick up the face index, the index of the face that has the index, the A vertex of the face, its index, the B vertex of the face, its index, the C vertex of the face and we put it inside the indexes vector called l_Index. Then we also put the material applied to this face, as we can see in lines 153, 154, 155 and 156. Once we've formed all this we have the geometry part and the geometrical indexes part. Let's go now to the number of themes part, to the texture coordinates part. We do this step just like the previous one, we gather all the texture vertexes, looking for the number of texture vertexes and looking for each one of those vertexes through the tag Mesh_tvert, as you can see in line 160 and then we pick up the value and we introduce it in the vector l_texturerVertexBuffer which is placed in line 174. We do the same we did before for the geometrical faces but in this case for the texture crowns faces. We look for the number of texture manuals indexes, we read each of those texture manual indexes and we put all this information in the l_texturerIndex variables for each of the face indexes, the face index 0, the face index 1 and the face index 2. And the other thing we are going to do here is preparing our VertexIndexBuffer or creating as many Vertex, IndexBuffer and CurrentFaceIds as vertexes and faces these elements have. Finally, from the line 203, where there is a loop from line 203 to line 227 we create the full vertex based on, on one side, the geometrical vertex, and on the other side the geometrical coordinate, the texture coordinate. Once we have created this complete vertex information we introduce it inside the RenderableVertex based on the material index, this means, we don't mix different materials' vertexes and we must create it this way, OK? And finally, for each of the materials we create a RenderableVertex. That is, for each material we will create a RenderableVertex based on its VertexBuffer. So to do so we use the TrianglesListsRenderableVertex class we see in the line 231, we give it the vertex-type device, which in this case has position, color and texture and the vertexes array which is the variable l_VertexBuffers based on the material index, the number of indexes multiplied by 3, that is, the number of vertexes this VertexsBuffer has and the number of primitives we are going to use, l_IndexCount of the material, which is the number of primitives we are going to paint. And once we've created the RenderableVertex we add it to the m_EnableObjects variable in aim to obtain it inside the vector. In case we have to free the collision mesh we use the code from lines 236 to 243, which I will explain when we get to the physics part. Finally, we delete the local variables we aren't going to use anymore and to finish the load method, we load the sender depending on the kind of vertex we are using, in this case the kind of vertex is called kg_position_color_texture_vertex, that is, it is a vertex which has geometrical coordinates, color and texture. Next we see the Render method, which basically sets the color parameters we are going to use inside he sender. It turns on for each RenderableObject its texture and uses the Draw method which will have RenderableObject for each material using the effect and the parameters and the device which will be very clean. And then we have the class destroyer which simple goes through all the RenderableObjects, removing them from memory.