To set up a first person weapon and animation you will already need a Mods folder that contains the necessary folders and files for exporting. This would be the Bin32 folder and Tools/Maxscript folder. This is critical in getting models to export and animations to export at all.
The rest of the documentation assumes you have the correct needed files and folder structure and crytools working in 3DS Max when loaded.
=Exporting Weapon Model & Animations=
==Setting Up The Basics==
*There are a few folders and files that need to be made, used or modified to get a weapon model exported correctly and to work properly ingame. In this tutorial I will go through the needed steps in setting up all the files and folders for a basic weapon export. Basic means no attachments or different modes. The tutorial will follow me preparing a new shotgun for the game. This will include creating a third person object for ingame weapon identification. In the end I will have quite a few files created, modified or used, and will consist of:
This is the folder I will create for the new shotgun (spas12) file that has been handed off to me by the weapons modeler.
This file is the finished model with textures done for it.
This will be the folder I keep all my textures for the weapon.
This will be the folder I keep my spas12.xml file so its usable ingame.
This file needs to be added and modified to export animations correctly.
This file will be used to help export the new weapon correctly for first person so I have arms that can be animated with the weapon for ingame.
==Before I Begin==
*Before I begin with exporting fp and tp models and animations what I will do is create or modify all the files that I won't be touching throughout the tutorial out of the way now so I don't have to worry about them later. This would include modifying the Animations.cba file, and creating the spas12.xml file.
*If I don't have a Animations.cba file in my animations folder I can grab the original from the Animation.pak file and put it in my mods Animation folder. The "Animation Definition" for the spas12_fp.chr file needs to be called also to export animations correctly. I can get the required code for it by opening the Animations.cba file with Notepad or Wordpad. I will grab the Animation Definition from the Shotgun and copy/paste it underneath itself and adjust it for my Spas12. This is just done for personal reasons, it can be listed anywhere among the rest without incident.
*The spas12.xml file I have is a simplified version of the Shotgun.xml file but slimmed down to only what I need it to do.
*Now that I have the files I need modified or created for exporting and using the spas12 ingame I can continue onto the weapon exporting.
In the XML file I stopped calling a few bone attachments, all the zoom modes, layers, accessories and also cut out quite a few animations I wouldn't need for a basic weapon. I also changed the animation path to exactly the CAF files I'm going to be calling instead of using some of the special prefixes used by default. Also note I'm already looking to call spas12_fp.chr for my first person piece of geometry and spas12_tp.cgf for my third person piece of geometry. Lastly, instead of the default firemode also looking for the param "fire" in its shotgun actions section it is only looking for "fire_cock". This doesn't have any affect later on, just done for organizations sake.
==Exporting Third Person Weapon Model==
*The first thing I'm going to do after getting a complete weapon model is have it set up into my file structure, spas12.max is saved in its respected folder location along with its textures. Next I'm going to open the file in 3ds Max, when I open the weapon model I can see its been broken up and also doesn't have a material assigned to it yet.
*What I need for the third person model is to have it textured and put together. First I'll move all the separate pieces to their respectful spots. I'll go to the Modify tab in the Command Panel, select the weapon, select editable poly, and choose element.
*Once the pieces are placed where they need to be I'll enter the Materials Editor by pressing shortcut "m". Once in I'll rename my material to spas12_tp, change the material type to Multi/Sub-Object, and set my number of sub materials to 1.
*Inside the sub material first I'll change the shader to a Crytek Shader, select my textures in the Maps section as a bitmap, and assign the material to the weapon.
*Once this is complete I'm going to save my file as spas12_tp.max since I won't be making any more changes. Next I'm going to create my MTL file with the Cryengine2 Exporter utility.
*Once I 'Create Material' I'll add a new multi material by right-clicking in the hierarchy window and save it as the same name I have my material for the weapon in the 3ds Max Material Editor, in this case spas12_tp. Once the material is added I'll right-click again on the material in the SB2 Material Editor and add 1 sub-material. Here I will choose my textures for the MTL file in the Texture Maps section and close the window.
*After that I will now make sure my weapon is selected for an object export, I'll check to make sure its exporting as a CGF file, and check that my export name is correct (spas12_tp). Once everything is checked I can safely export.
*I'll check ingame now to make sure everything exported correctly for my third person weapon. We can see I now have a CGF file in the Character Editor that is seen and textured, and I also have a Geom Entity ingame textured.
==Exporting First Person Weapon Model==
*The first thing I need to do is make sure I have the SCAR_L-C_fp.max file that came with the Example mod in my spas12 folder for my mod. Once thats secure I'll start my first person weapon model setup through that file.
*Once inside I need to get rid of everything I'm not going to be dealing with. This would consist of everything except the arms and the camera. First what I'll do is select everything in the scene and change the animation timeline to read from frame 1 to 10,000. This will allow me to select all the keys in the timeline and delete them.
*Once thats complete I'll hide my camera and select everything that deals with the weapon and delete them so all I'm left with is the arms.
*The next step is to hide the rootL and rootR nodes and switch the arms from the root node so that they are facing the positive Y axis to allow correct orientation when exporting the CHR file later on. To do this I'll 'select by name' in the main toolbar and choose rootL and rootR, click ok, and then right-click and Hide Selection.
*Now I can adjust the arms to where I need them. First I'll select the root node and with the transform handle chosen I'll use the x,y,z value boxes to change the y axis to its negative spot. I'll then choose the rotation handle and adjust the z axis 180 degrees so the arms face the positive Y.
*I am now ready to bring in the weapon. I'll select 'XRef Object' in the file menu and then click on 'Create XRef Record From File' button and select spas12.max and select spas12 as my object and click ok. I now have my weapon in the scene.
*Since the original file already had the object centered correctly and in the right proportions I don't have any modifying that needs to be done to the weapon. I will check the objects name (spas12) and rename it spas12_fp since it will used as my fp weapon. I'll also convert the weapon to a Editable Poly.
*At this time I will start setting up my dummy nodes as attachments so that I can link them together with physique in a little while to parent each piece of the weapon together.
If you look at the SCAR_L-C_fp.max weapon and how its set up you will notice the main stuff thats being animated like the trigger, magazine release, reload cock ect. are bones. Attachments used for modifying the weapon like scopes, silencers, flashlight ect are set up using dummy nodes. In this tutorial I will be making the animated pieces linked together with dummy nodes. This won't affect use ingame, exporting, or with animating. On a lighter note, first person animations never actually pull the trigger.
I need to have two dummy nodes per piece I'm going to be using as an "attachment", this is because the 'tip/front' node will be used to link the vertex points of the object, and the "base/back" node tells where the piece is located and allows the the user to transform/rotate the piece without affecting the actual geometry and cause stretching. Once I have all my dummy nodes in place I'll rename them to something more appropriate.
The dummy node at the tip of the weapon needs to be named "weapon_term" as this is the "Bone Attachment" that the XML file looks for so that I have muzzleflash and smoke when I fire the weapon.
In the picture you will notice that the piece to reload the shotgun and the shell ejection piece are one attachment. This was done on purpose as both are animated together, so those two pieces will become one attachment.
*The next step will be linking the dummy nodes together so that when the physique modifier is applied it will create a correct hierarchy. I will first select my weapon and freeze it so its not in the way of the linking process.
You can see the shoulder piece is being linked (dotted line) from the 'tip/front' node (white) back to the 'base/back' node of the shoulder piece (green)
The "weapon_term" node will be linked to the "collision" node at the butt of the weapon, that is then linked with the "weapon" node placed around the axis origin (0,0,0) which is then linked to the "root" node of the arms. All the other pieces are linked appropriately from the 'tip/front' node of the piece to the 'base/back' node of the piece which is then linked to my "weapon" node.
Remember to unfreeze it when you are done.
*Once that is complete I will now add a physique modifier to my weapon and click 'Add Node' in the Physique section and click on 'Select by Name' on the Main Toolbar and pick the root node. A Physique Initialization window will come up and I'll select rigid from the Vertex - Link Assignment section and click Initialize. I will now see a bunch of lines that stretch from my arms "root" node to all the appropriate pieces in the correct hierarchy.
*The next step will be assigning the vertex points to the right links. With my weapon selected I will select Physique in the Command Panel and select Vertex. I'll drag select all the vertex points of the weapon (which will turn green and look like a cross) and in Vertex Options of the Command Panel click on 'Remove from Link'. Next I will drag select the workspace area again (which will turn the yellow link lines turn red), select 'Rigid Vertices' (large green cross) and then again drag select all the vertex points in the workspace (this will turn all the vertex points blue).
*I haven't actually assigned anything to a link yet, This time I will click on 'Select' and click in the workspace to deselect everything I have (all my Vertex Type buttons are now all highlighted). Now I will select only the vertex points that are part of the main piece of the weapon. Next I'll click 'Assign to Link' and choose the link that goes between the "weapon_term" node and "collision" node (the main weapons vertex points turn green while all the rest of the weapons vertex points are white). The links will be colored appropriately also, the link that the vertex points have been assigned to will be red, while the others are yellow. Once this is complete I will click on 'Lock Assignments' which will turn the crosses the vertex points have been to boxes.
*I'll now repeat this process with my other weapon pieces by hitting 'Select' again and drag selecting each piece and assigning them to their links and locking them. This would be the ones that stretch across the piece I'm attempting to assign a link to, not the one that connects to the "weapon" node from the 'base/back' node were linking. In the end, all the pieces should now have boxes as vertex points instead of crosses.
*I now have one more thing I need to do before I can create my MTL file and CHR file. That would be assigning the textures to the weapon. I'll repeat the same steps I did earlier for setting up my material for the third person weapon inside 3DS Max and save the file as spas12_fp.max.
You'll have other materials that have been made because of the SCAR and its attachments, just leave them be, they won't be in your way. If you have texture issues after assigning the material to the weapon make sure you assigned the Diffuse map to Show Standard Map in Viewport because it might just show the last entered texture (bump).
*First I'll create my MTL file, I'll follow the same steps I did earlier when I used the 'Create Material' for the third person weapon.
Remember the MTL file needs to be named the same as your 3DS Max materials name. CryEngine2 Exporter does not save the MTL file with any uppercase letters.
*Once that is done I can export my weapon as a CHR file. I will now make sure my weapon is selected for an object export, check to make sure its exporting as a CHR file, and check that my export name is correct (spas12_fp). Once everything is checked I can safely export.
*I'll check inside the Editor now to make sure I have a visible weapon, with textures, and arms with the CHR file. The file has been exported correctly with textures applied and arms that can be able to be seen when I start animating.
To see arms with the CHR file all you need to do is create a new skin attachment and as your object use the objects/weapons/arms_global/arms_nanosuit_us.chr file without a MTL file. Click apply to have them appear.
*I now have a third person and first person model thats textured to be used ingame. At this time if I wanted I could place a spas_12 entity into my scene that I can pick up. What I would see though is nothing, as the object is behind the camera and facing the opposite way (remember I switched the orientation of the weapon and arms at the beginnig). What I need to do now is set up the weapon so it can be animated correctly.
==Exporting First Person Animations==
*Now that I have all the files I need I'm missing 2 more things, this would be the animations, and also the CAL file. First though I will clean up the 'Export File per Range' list that is looking for the old set of animations for the SCAR that I deleted when I first entered the file. I'll go to the Timing section in the CryEngine2 Exporter and click 'Edit Sub-Ranges', here I will see a list of animations that were being called for the SCAR to export. I will be remaking most of these, but for now, I'm going to clear the list as my keyframes will most likely differ in length and order.
*Next I can start setting up the weapon for animating. To do this I'll select Auto Key under the Timeline and repose my arms root node back to where it originally was, facing the negative Y axis. This would consist of setting the transform Y axis back to a positive number, and rotating the Z axis back 180 degrees.
*Once I do that I will select the weapon and right click and go to 'Object Properties' and uncheck 'Show Frozen in Gray'. Once that is complete I will freeze the weapon. From now on any time I need to move a part of the weapon I will use one of the 'base/back' nodes that corresponds with what I need to move.
*Finally before animating I will move all the separate pieces to the spots they need to be on the weapon.
At this time I now have a weapon completely ready to be animated. If your on a mod team the weapon can now be handed off by the Lead Animator to one of its animators to work on animations for the weapon, or if the modeler is setting up the weapon for the animators, this would be the point that the modeler should hand off the files to the animator for animation creation. From this point on all I would be doing is animating the weapon.
*The first thing I'm going to do is adjust the position of the weapon so that its in a spot that actually is useful for playing, and not in the middle of the screen. I'll select my weapon node and move it to the lower right corner of the camera. I'll also grab the Left arms "upperarm_NEW_L" and place it where I need the arm to be holding the weapons neck.
*With the initial pose now done I can start creating the 11 basic animations I need to make the weapon seem seamless ingame. As an example I will create 2 new animations "fire_hand_01" and "select_01". To do this is very easy. First I'm going to change the timeline to be from frame 1 to frame 20. Then to create the firing animation all I'm going to do is select the arms root attachment, and copy/paste frame 1 for frame 6 and 10. For frame 3 I'll translate the weapon back a little, and on key 7 I'll rotate the weapon down out of view.
*I now have 2 animations, One from frame 1 to 6 which will be the weapon firing, and one from frame 7 to 10 which will be selecting the weapon from inventory.
*I can now go back into the CryEngine2 Exporter and in the Timing section check 'Export File per Range'. Next I'll click 'Edit Sub-Ranges' and I'll add one animation from frame 1 to 6 named "fire_hand_01" and another from frame 7 to 10 named "select_01". The last thing to do is check that the Bone Export is exporting from the root, click 'Export Bones' and save the CAF files into my spas12 animation folder.
*The last thing I need to do is check to see if everything works fine in the editor. First though I need to create my CAL file so that they are loaded with my new first person weapon.
*Now i'll check ingame to see if everything is working. As we can see the weapon is in as a entity, the animations are seen in the character editor, and also its working as a fp weapon ingame.
*And thats its, I can focus on the rest of my animations. Hope you find this tutorial useful.
Issues will still be present, specialy for third person view. Look at this as a guide.