Wednesday, June 19, 2013

Creating a custom weapon for Cryengine3 using Maya


                               In this tutorial I'm going to talk about how to export a custom weapon to cryengine3 using Maya. To do this you will need a arm with joints which matching with cryengine3 skeleton structure. Simply download my custom arm or you can create your own by looking at my previous post.
                              First you have to texture your weapon with correct uvs. If not you cannot export your weapon using cryexporter. In here I have used Zbrush polypaint.
                              Open the arm scene.(in cryengine 3.4.5 you have to move root bone to world center and  upper arms, l/r roots...... to little bit downward). You need to rename your arm group because we don't need to export the arm model. we only need to export weapon and the "root" joint structure. Import the weapon. Center the pivot. Place the weapon at 0,0,0. Select the weapon and press ctrl+g to group. Then move it near the hand. After that move the pivot to 0,0,0 by pressing d+v. Select the weapon group and create a parent group. Rename it as cryexportnode_weaponname.

                             Place the whole weapon group near right hand. Now you have to create the joints for the weapon. Start with the weapon bone.

                                 Link the weapon joint to root joint.

                        Make the Zero Joints Rotations for the joints. Bind each joint to each suitable part. Bind the remaining parts to weapon joint. In here I have used the binding settings which I used for custom arms(look at my previous post). Then add a material and export. Copy the .CHRPARAMS and .CDF file to the weapon directory. Rename the files and open them. Rename the directories. This is my MP5.CDF.

<CharacterDefinition>
 <Model File="objects/weapons/MP5/MP5.chr" Material="Objects/weapons/MP5/MP5Material"/>
 <AttachmentList>
  <Attachment AName="arms" Type="CA_SKIN" Rotation="1,0,0,0" Position="0,0,0" BoneName="" Binding="objects/weapons/Myarms/Myarms.chr" Flags="0"/>
 </AttachmentList>
 <ShapeDeformation COL0="0" COL1="0" COL2="0" COL3="0" COL4="0" COL5="0" COL6="0" COL7="0"/>
</CharacterDefinition>

                              Make a copy of default scar.xml file and rename it. Change item name and geometry path. Now open the cryengine and edit the equipment pack. Play the game.

                               Download the final part>>>>>.
                               You will see your right hand and the weapon are not in the correct position. Because you have not created the animations for the weapon yet. After you created the animations everything will be fine.
                               First you have to look at .CHRPARAMS file for animation definitions. There is a animation called "idle_right_01". You have to create this caf file.
<Animation name="idle_right_01" path="idle_right_01.caf"/>

              Move joints(weapon, hand etc) to proper place.

                             Create a simple(player in idle mode) animation with several keyframes. Go to animation manager and create a new animation called "idle_right_01".

                          Export the animation. Now you will see the idle animation is working in the gameplay. Likewise you have to create all other animations which are defined in the .CHRPRAMS file. Enjoy.
Download the idle animation.
                          If you have any questions please post it as a comment. Thanks.

1 comment:

  1. Hey dude

    I would like to experiment with replacing the fps model and changing its swimming animations into what I need. Are swimming animations also in the agent_fp_Global.chrparams script? It seems like its not.

    ReplyDelete