Next we are going to explain the concepts of Bounding Box and Bounding Sphere. Bounding Box is the minimum controller box which contains a geometry, as we can see in the image on the left. How do we calculate a geometry's minimum Bounding Box? To calculate a geometry's minimum Bounding box we need to look at each of the vertexes and keep the minimum X component, the Y component and the Z component of each of those vertexes, so that we will get the minimum point of the containing box. We will also need the maximum point of the containing box. To do so, we will look at all the vertexes and we will keep the maximum X, Y and Z of all the geometry vertexes. These vertexes, both the minimum and the maximum of the containing box, don't need to coincide with a geometry vertex, in fact they usually won't. If we look carefully at the ship we see in the image, none of the box's geometrical vertexes coincides with any of the own geometry's vertex. The Bounding Sphere would be the same concept but with a sphere, that is, the minimum sphere which contains all our mesh's and geometry geometries. So to calculate the Bounding Sphere we need the center of the containing box and as we have previously calculated it, we calculate the radius or the distance of each of the vertexes regarding this center, and the maximum distance will match the Bounding Sphere ratio. This Bounding Sphere will be the minimum containing sphere which contains this geometry. To do so, to calculate this information if we go to the ASE Object class we see that in the low part we have, on one side, when we have calculated the isometric vertexes in the lines 116 to 128, it checks if the X position in the minimum box is bigger than the X position in the vertex, we keep the vertex position as the X position in the minimum box, and the same with Y and Z, that is, we take the minimum X,Y,Z positions of all the geometry vertexes and the same for the maximum box, for the maximum point of the containing box, in this case lines 123 to 128. That is, for the vertexes components, for each vertex we look at the maximum X, Y and Z and we keep it inside the maximum box's value. Once we've calculated this minimum and maximum points from the containing boxes, we calculate the center, which is basically the middle point. The middle point is the arithmetic mean of the two vertexes, the addition of the two vertexes divided by 2. And finally, again we look at all the vertexes and calculate the distance between the center of the containing box and the distance from the vertex of each of our Bounding Box's vertexes. The major radius or the major distance will be the radius of the minimum containing sphere. We are calculating this from lines 130 to 139. To finish, inside this class we have a method called IsInBoundingBox which tells us if a geometrical position is inside the containing box. To do so, the only thing it does is, in case the X position is bigger or equal to the minimum X of the containing box, if it's bigger or equal in Y and if it's bigger or equal than in Z and if the position in X is smaller or equal than the maximum of the containing box in X, Y and Z, then it will tell us if this geometrical point is inside the containing box. We will explain how to load and use textures inside the engine. To do so, we are going to use a textures manager called CTextureManager, a texture manager class and the CTexture class, which will store Y and Z's textures in C so that we can paint any element with them. So let's go back to the code and look at the TextureManager.h. We have two classes, the texture manager class and the CTexturer class. The texture manager will be accessible from the X application, so we can do it from any part of our game, of our ID engine. A basic method such as LoadTexture, which will load the texture we ask it to load. We don't want to load the textures many times in the memory, so if two elements need the same texture we will only load it once in the memory, and the two elements will use the same part of the memory. To do so, we use a textures dictionary or a map like the one on the line 24, which is the TextureMap. But if we look at the class, the LoadTexture method from the TextureManager class will look for this texture's filename inside the map and if it finds it, it will assign it to the variable, in this case the line 62 texture, and will give it back. In case it isn't found it will get the file name, it will create a texture, it will load it and it will add this new texture to the map and give back loaded this new texture. The code of this last part goes from line 65 to 72. The texture class, the CleanUp method called TextureManager class destroyer will erase from the memory all the textures we have loaded. And then we have the Texture class, which stores an ID3D11 texture and to do so we use a resource and a sample state, which we can see in lines 12 and 13 of the Texture class, so we have the Load method and the Activate method. The builder initializes the lines 6 and 7 member variables, we have the destroyer which deletes the lines 13 and 14 member variables from the memory and finally the Load method. The Load method creates a texture, a resource, a resource from the file name we give it and creates a sampler. What the sampler is saying is that this texture will be filtered into the magnified mapping in a linear way and then it has the U,V,W warp addresses and creates the sample state from this texture information. We can find the types of samplers or address in the IDX information. Basically we are going to use IDX11, if we go here we have the wrap, the mirror, the clamp, the border and the mirror_once. From those I will explain the wrap, the mirror, the clamp and the border. The mirror_once will be just as the mirror but only once. To do so I go to the IDX documentation. I will explain the address concepts. The kinds of address we have are wrap texture. It will cause that, if our reading coordinates go from 0 to 1, 0 will be the first vertex of the face, the texture up to 1,1 would be this vertex here. However, if it goes from 0 to 3, in this case, it will go from 0 and it will repeat the texture 3 times as we can see in the image. This would be the wrap type. If we apply the mirror instead of the wrap, what it will do is, every time we pass an unit, it will make a mirroring inside the Vs, that is, this would be the 0, this would be the coordinate 1 in Xu, and would be the coordinate 2, between 0 and 1 are looking towards one side and between 1 and 2 they are looking to the opposite side. This would be the address mirror but using it isn't very common. So, it's just knowledge. You must know it but you probably won't use it a lot. Then we have the clamp, which is another method, another kind of format used. What clamp does is, if the texture is the first one we see here, we go further than the texture coordinates, further than 0, further than 1, what it does is stretching out the last pixels towards the texture coordinates as we can see here, it repeats this pixel upward and this one to the right. This would be the address clamp. And finally the color, the border color, defines a color which in case we leave this textures coordinate, will use directly the color we told it in the format. So those will be the address, which we will use in the samplers. In this case we are loading the texture and we are using the samplers, the address format for U, V and W. Well, once we got to this point we will implement a bit of code, we will go to the X application class. and we have some things to do here, which tell us to do the ASE Object class forward declaration. Forward declaration will simply let us give the name of a class without having to implement or integrate the class club. In this case it's what U and V do. Well, we will do the to-do later, not now. So once this has been done, we create an ASE Object class-type object to paint a room. We will paint a room model, an ASE Object will create a class. We give it m_room. We give it m_room. OK? And then I go to the X application and I will do the include in the ASE Object.h, OK? I will go on with the part 1, OK? In the class destroyer it tells me to delete the m_TextureManager object, so I will delete it by the checked_delete in the checked_delete macro, then I go back to the first part to delete the object we've created to avoid the room, checked_delete_m_room, we create the object m_texturer_manager which equals to the object new_C_texturer manager, we create the object to paint the m_room like C_ASE_Object, and we load the object created by the geometry found in the X file. To do so we are going to use the Load method giving it the file name, the device and in this case no collisions, as we aren't going to use collisions at the moment. We call the Render method the object we have created to paint the room. We will call the render method of the room Render and we will use it with the DeviceContext. We will execute it, and we will see how the room we have loaded from our 3D Studio Max gets painted. OK, so here we have our room. Let's check the other camera. I can't get much closer at the moment, we will see it with more details later. OK? So now we have the first room, in this case, a room from the game Quake.