Next we will explain the camera concept. To paint in 3D in a video game we need to create a camera. In a game we have basically 2 kinds of camera: the orthogonal type projection cameras and the perspective projection cameras. The perspective projection camera is the one everyone understands, which is the one we see. This means that while an element gets away from the point of view it becomes smaller, changing its scale. So, the further we are from an element, the smaller we see it. But the orthographic is that camera that, no matter how much an element gets away from the point of view, its size doesn't variate in the point of view. So these are the two kinds of camera. In a 3D video game, as we are simulating reality, we use the perspective camera, which is the one we are going to use. If we go back to our code, we have one kind of camera, which is a base class, which will allow us to implement cameras. So we've got on one side the view matrix and the projection matrix. The view matrix will define us the camera point, the point where it is looking at and the vertical vector of the camera. And then we've got the projection matrix, which will define us the opening of the camera, as well as its aspect ratio, its near plane and its far plane. And then we have information which will define us those matrices which are the position, the look at, the vector at, the foat, the aspect ratio, the near and the far. From this code which has 16 CEPts, I will just talk on the CEP matrix methods. The CEP matrix method establishes the matrix. When we create the matrices, we use the methods XMMatrixLookatLH, which stands for look at left handed. We are using a Left handed coordinates system, where we put the positions from X,Y,Z, the LookAt and the VectorUp as we previously said, to create the view matrix, and to create the precision matrix we pass it the fill of view in radians in the camera angle, the camera opening, the AspectRatio, which in a current conventional screen should be 16/9, the ZNear, which is the minimum distance where the camera will start to see, and the ZFar, which is the maximum distance in which the camera will stop seeing. The next class we are going to explain is the Frustum. In aim to explain this class we need to explain what a camera Frustum is. In an XYZ coordinates system, as we said before, using X and Z, we will define a camera. The camera eye is the point where the camera is looking at, this will be the LookAt, and the Y. Then we've got the camera opening, FillOfView, which is an angle, and then we define the NearPlane and the FarPlane. All right. This is the NearPlane, and this is the FarPlane. Now, if we put this in 3 dimensions, it would be similar to this. NearPlane would come this way. And our camera would be defined this way. So, this would define a geometrical figure which would define our camera. All right. This geometrical figure is the camera Frustum. The camera Frustum defines 6 planes. The FarPlane in this case would be the LeftPlane, The TopLane, the Bottom and the RightPlane. Parting from these 6 planes we can define the elements which are inside the camera. So, in aim to be able to paint an element we will say that if the element is outside the Frustum we won't paint it, we will economize this painting, and if it is inside it we will paint it. It's what we define as Frustum Cooling. If I want to paint this sphere, I know that it is outside the Frustum so I won't paint it. And if it is touching the Frustum we will paint it as we know that there are some vertexes or pixels from this element which must be painted. To define whether an element is inside a plane, inside a Frustum, we need to define planes and calculate elements regarding this plane. So, we have the camera Frustum and we must define if, in this case, the sphere, is inside a Frustum. To do so, we will make some calculations. In aim to do that, we need to know the plane formula. The plane formula is the following: Nx multiplied by X plus NY multiplied by Y plus NZ multiplied by Z plus D equals to 0, where NX, NY and NZ are the normals of the plane, and D is a distance regarding the coordinates axis. So to calculate the formula to calculate a plane we need two elements: the normal of the plane and a point of the plane. So, we will define a coordinates system again and I will create a plane. This is my plane, and I will define the normal on it. The normal of this plane is 1, three dimensions 0,0 and a point of this plane, if it is in the X axis, 5 units from the axis, the coordinates center will be 5,0,0. It will be this point here. So, parting from those values, this will be the normal. Parting from these values, I will calculate the D, the Distance if we just said N is 1x plus 0y plus 0z plus D equals 0. And in aim to accomplish the formula, the 5,0,0 must be a point of the plane, so 1 multiplied by 5 plus 0 plus 0 plus D equals to 0, which means D equals to -5. This means our plane will be X minus 5 equals 0. This would be our plane's formula. All right. Once we've calculated our plane's formula, we will define if a point is inside our plane or if it would be seen. For example, if I set a point here, visually we can already see that it is inside the plane. So if this point is 8,2,0, we see that it is inside the plane. If I calculate this point regarding the plane it is 8 minus 5 equal 3. What does this mean? This means all the points higher or equal than 0, regarding the distance to the plane, are defined inside the plane. For example, if I put this point instead of this one, which is -2,2,0, and I calculate, we've got that -2-5=-7. This point, which is negative, is telling me it is outside the plane. If we go back to the frustum example, we've got to define the following: an element must be inside the plane in aim to be visible. So this point needs to be inside each of the frustum's 6 planes. If we now go back to our camera frustum, I'm going to create it again, eye, LookAt, Camera Stun, NearPlane, FarPlane. I redefine our plane, our camera frustum. If I define a point on the space, this point, regarding to the camera's right plan, is positive. in relation to the bottom, as well as to the near and to the far, but it is negative in relation to the left. So, this point shouldn't be painted. This point here is positive in relation to the 6 planes, so it should be painted. So what we do is, before painting an element we ask the camera frustum if an object is visible. How do we know if this object is visible? We can do it 2 ways: checking if its containing box is visible or checking if its containing sphere is visible. So, if a sphere is B it is seen by a frustum. Here we've calculated it in relation to a point. Before we said that if it was higher or equal than 0, it would be visible. Alright, now what we need to say is whether its radius, its distance is bigger or equal than the minus radium. So, if we had the plane before and the point was this one, this one was visible no matter its radium. But if the point was this one we said it wasn't visible. But if its radium was big enough to be inserted inside the plane, it would be visible, so if this was the plane's radius, as long as this radium was higher or equal than minus the distance, we would say it is inside the plane. This way we will check whether an object must be painted or not.