Now we will go to 3D Studio Max to define the three classes we have created to encapsulate Cal3D. Let's open our project. Well, once our project is open. We go to the Actors folder and we see that we have six files, three in *.cpp format and three in *.h format which encapsulate three classes. The first class we are going to open is Cal3D Actor Manager, which is a manager, as we said, with Texture Manager, which encapsulates the different Cal3D Core Actor we have in our game, that is, what it is going to encapsulate is the different animated models we can integrate in our game. Just to help you understand it, if we are going to use only one model for all the characters, this model will be loaded only once in the memory, as we did in the Texture Manager, we have a map of the Cal 3D Core Actor identified by a string which will be the key, we have the builder-debuilder, the GetActor method and the CleanUp method. If we go to the code part, we see that in the builder it sets certain Cal3D load values, in this case, it tells it to load the rotated x axis, because we are working with the left mobile coordinates system, while internally Cal3D is working in right hand. Then we have the debuilder, which calls the CleanUp method, goes over all the map's cores and deletes each core; and the GetActor part, which basically will treat the cores and the instances, the use of which is, in case the Actor Name they are asking me for is in the dictionary, I will give back the element to the dictionary, giving back an instance. If not, I create Core Actor, I load it and I put it inside the map, so I create the Core and I put it inside the map and the instance to this Core, the first part, if you find it would be the one in lines 31 and 32, and the second one, if you don't find it on the map, would be from lines 33 to 39. Let's go to Cal3D Core Actor. Cal 3D Core Actor's function, as it encapsulates the Core model of the Core information on our Cal3D model, we find out this class comes from an XML Parser class, so you will have to read an XML file. As methods, we have Load Mesh, Load Skeleton and Load Animation which will load a mesh, a skeleton or an animation, in lines 20, 21 and 22. On Start Element method, which is an overwritten method from XML Parser class, will basically parse the XML file. Builder-debuilder, a Get method which takes you back to the Core Model, other Get methods for the textures and the Load method, to which we give the path where the XML and Cal3D files are. If we go to the Data folder inside Executable, we see that we have the XML. Then we go back to Bot folder, it's in Models, Bot, and we have an XML file called actor.xml. If we open it, this is the XML we will read when reading Cal3D Core Actor. Then, if we look at it, we see we have a root tag which is the Actor and then different tags inside our XML file, the first one we see is the skeleton, which is telling us our Cal3D model has a skeleton with the same name as the file where the skeleton's information is placed, called bot.csf. Then we have a geometry, which is the mesh. It is a file where the information is located, it is called Bot.CMF and it uses three textures: rocketl.jpg, ranger.jpg and rangerh.jpg and then in animations we have, where we give it on one side the animation's name as identifier, as key, and then on the other side the name of the file where the animation is placed. In the first case of the seventh row, we would have an animation called 'idle', which is the name of the file where the animation's information is placed. It is called idle.CAF, and the same with run, named run.CAF, hit as name and hit.CAF as a filename, die as name and die.CAF as filename, and the same with shoot and shoot.CAF. The animations inside Cal 3D can be identified both by their names and by their ID. So, in the idle animation, in this case it would be animation 0, run 1, hit 2, die 3 and shoot 4. Always setting off from index 0, if we go back to the code, we see that Cal3DCoreActor.cpp will be the responsible for reading this path, reading this XML file. We find out that in the same path where the XML file is, we have the CMF file, the CMF mesh and the different CAF point animations. We find the textures inside the Data Models folder, Textures, so we have them here, we go back to the code and we find the Cal 3D Core Actor builder where the member variables are initialized, the debuilder where the dynamic part we have built is deleted, and the Start Element method, which is the important part. In case it receives the actor-type tag, we give the name a value and we build the Cal Core Model we use from Cal 3D. Remember in this class and in the next we are going to explain, we are encapsulating the whole Cal3D code to simplify it, to make it more comfortable for us, to avoid constantly having to go to Cal3D base code to use animated elements. This is usually done when we use external libraries, simplifying and using only the part we are interested in, and then if we need any concrete element from the library, then we go straight to the library. So in case we get the mesh element, line 25, we call the Load Mesh method saving in the variable m_MeshFilename the number of the file we are going to load, so it will call the Load method to load the mesh. In case we get the skeleton, we do the same for the skeleton and we load the method Load Skeleton, lines 31 to 36. In case we get a texture, we add the filename to the texture, to the variable, to the textures list we have in m_TextureFilenameList. In case we receive an animation, we save the animation's name and the file name and we call the Load Animation method, giving it the animation's number and the file's number. The Load method will be all these classes' root, all these methods'. Basically we give it the name of the path where the XML and the Cal3D files are located and we parse the XML giving it the patch and the actor.xml, that is, our animated models will always have the same directory structure. A path, inside this path we will have the XML actor and inside this path we will also have the file, the mesh files our animated model contents, the files, the discrete file which has our animated model and the animation files our animated model has. Next we see the Load Mesh method. Load Mesh method adds the path from where the filename is to the mesh's filename, and it calls the Load Core Mesh from the Cal Core Model class. As we said, we are encapsulating Cal3D, so you are calling to the method Load Core Mesh from the Cal 3D class, giving it the complete filename where it has to go to find it. In case it loads correctly, give back true. In case it doesn't load correctly, give back false. Load Skeleton is basically the same as the previous method, but in this case, instead of calling the method Load Core Mesh, it calls the Load Core Skeleton method from Cal3D's library. Again we give it the complete path, that is, the path and the skeleton's XML filename. Next comes the Load Animation method, which also calls the Load Core Animation method giving it the full file's name with the path and the name of the animation we want to identify. And finally we have two Gets methods, which give us back Cal Core Model, lines 89 to 92 which is the Get Core Model method; and the Get Texture Name method, from 94 to 98, which gives us back the name of a texture in our Core Actor, depending on the textures list we have inside our m_TextureFilenameList list.