Exporting animated models from Maya to CrysisThis page gives instructions about the way to export animated models (.chr files) from Maya to Crysis. Before attempting to export an animated character, you should go to this page and try to export a simple s tatic mesh. It’s a good reading anyway, since the basic concepts are similar.Installation instructions for MayaCGF can be found on this page.GENERAL CONCEPT (Alternate Methods):1) The direct method:If you just want to do a simple animated model and you prefer to set keys directly on the skeleton that deforms the mesh, you can go ahead and do just that.Note that you should still select the root joint of your skeleton and click on “Prepare Joints For Export” before attempting to export a .chr file. This should be done prior to skinning or animating the joints.2) The master/slave method:This method offers the advantage of working well with your own pre-existing custom rigs. For this method, there should be in fact two skeletons for your model. One skeleton will be the skeleton you animate (the master skeleton), while the other skeleton (the slave skeleton) will actually deform the geometry. The master skeleton should be part of your animation rig.Again, the skeleton that deforms the geometry (on the left in the above picture) is a slave to the animation skeleton. The simple FK slave skeleton is the one that will be exported along with the character mesh.INSTRUCTIONS:You should work at film speed (24fps). At export time, your animation will automatically be converted to NTSC (29.97fps), which the CryEngine2 uses.The space unit can be set to anything (mine is on “centimeters”), but remember that one unit in Maya is equivalent to one meter in Crysis.The name of the exported file is derived from the name of the top node you select in Maya. So if you name the group containing your model “my_model”, the resulting exported files will be called “my_model.cgf”, “my_model.chr”, etc…The “exclude_GRP” is a group where you can put stuff you’d like to k eep within the main export group but that should not get exported.The mesh should be in the group bearing the name of the model you want to export (in the example below “ratTest”). You can also put the export skeleton and physics hierarchy within that group or choose to leave them parented to the world.The joints which are not an influence on the mesh (not part of the skincluster) will be automatically removed by MayaCGF at export time. So if the joint is part of your hierarchy, make sure it is also par t of the binding partition. You can then set its weights to 0 if it’s just a helper joint.IMPORTANT: Remember that all the joints that should appear in Sandbox 2 have to be an influence on the skin mesh. In other words, if you have a wrist joint which is parented to a forearm joint, but the forearm joint is not part of the skincluster, then the wrist (and all the joints which stem from it) will NOT be taken into account by the CryEngine2, even if THEY are part of the skincluster! This will likely wreak havoc on your model.After you freeze the rotations on the slave joints, the values from the jointOrient attributes have to be transferred onto the corresponding rotate channels. So by default the joints influencing the mesh should have values corresponding to their actual rotation and translation.To achieve this tedious task with just one click, select the root node of the slave skeleton (“bip01″) and click on “Prepare Joints For Export”(in the Tools section of MayaCGF).Then you can bind the mesh to the slave skeleton (set “Max Influence” to 4).Specific to master/slave method:The slave joints should bear the same name as the master joints, but be prefixed with “bip01_”. Then you just have to parent-constrain your “bip01″joints to the joints in your animation rig (the master skeleton). As a side note, you should probably hide t he slave skeleton, so you don’t select it by mistake. Remember th at you shouldn’t interact directly with the slave skeleton!The next step is to parent-constrain the slave skeleton to the master skeleton. To automatically do that, you can click on “Constrain Slave Skeleton”. All you have to do is select the bip01 joint andrun the script. It will look for the master joints based on the slave joints’ name minus “bip01_”. So it you have a joint named “bip01_L_shoulder_JNT”, the script will connect it to an existing “L_shoulder_JNT”.Finally, you should bind the mesh to t he slave skeleton (set “Max Influence” to 4).So to sum-up: the animation rig/skeleton drives the slave skeleton (“bip01″), which in turn drives the mesh.PHYSICS:If you do not want to be able to walk right through your animated model then you should also build a simplified physics skeleton for it. Create some very simple meshes that occupy roughly the same volume as your main joints and name them according to the joint they should represent plus “_Phys” at the end. For example, for a shoulder joint named “L_shoulder_JNT” you would build a mesh called “L_shoulder_JNT_Phys”.Note: The physics meshes won’t follow the joints movements in Maya. This is normal. If they get in the way visually, just put them in a layer and hide them. DO NOT turn their visibility off or they will not get exported!The physics hierarchy does not need to perfectly match the export skeleton one on one. In fact it is better if it doesn’t, as the skeleton for a classic biped can hold up to a hundred joints or more. The physics m esh should be few in number and fairly simple in topology (shperes, cubes, etc…). As long as the basic hierarchy makes sense and the name convention is respected, the physics will getexported correctly.Finally, to make the physics meshes solid in Crysis, assign a cryShader to proxy meshes (please refer to the static models instructions page). And make sure to do a “Freeze Transforms” and “Delete History” on all the “_Phys” meshes!BLENDSHAPES:You must first bind your base mesh to the skeleton and then apply all the blend shapes at once. The reason for this is that there can be only one blendShape node related to the skin cluster. So if you decide later on to add a blend shape to an already existing blend shapes set, you must first delete the existing blendShape node (not the blend shapes meshes themselves!) and then reapply all the blend shapes at once to your skinned base mesh.Also, you can move your blend shapes target meshes anywhere you want in space. Just make sure NOT to freeze their Translate channels, or else when you fire the target within Sandbox2, your whole mesh will jump in space as well!MODEL/RIG REQUIREMENTS:- To successfully export a model, the positive world X axis should point to the right of the model (to your left if you look at your model from the front). Usually, rigs and models are created with the world +X on your right and +Z towards you. So you’ll probably have to rotate your animation rig 180 degrees in Y. You’ll have to do the same for the geometry. Then don’t forget to freeze the transforms on the geometry!- The “bip01″joint (the root joint of your export skeleton) should have rotateX set to -90, rotateY to 0 and rotateZ to 90 (the other joints can be oriented any way you want, but try to avoid values neighboring 180 degrees). In addition, the “bip01″joint should lie at the origin of the world.- Make sure that the joints influencing the mesh do not have default values close to 180 in either rotation channel; this would result in weird flipping artifacts on those joints.- Always keep the default binding pose at frame 0 in your scene. It will be the reference frame upon which all your animations are based.- Your multiple meshes should be combined into one single mesh and its history deleted before you bind it.- The number of joints influencing one vertex in the CryEngine2 is limited to 4. In consequence, when binding your mesh to the joints, set “Max Influences” to 4 or less.- Each node (mesh, joint, etc…) in your model should have a unique name.- You should only use parentConstraints to drive the slave skeleton (do not use point or orientconstraints!).- There should be no instanced nodes in the model.- Scale attributes on the slave joints and geometry should be set to 1.- The “rotateOrder” of your deform skeleton’s joints should be “xyz“.- The “rotateAxis” and the “jointOrient” values of the slave skeleton’s joints should be 0 (and the “rotate” channels should inherit the “jointOrient” values).TROUBLESHOOTING:If you see joints twisting or popping out of place when you play your animation in Sandbox2, it probably means those joints have values in their “jointOrient” or “rotateAxis” attributes. Those should be set to 0; the only values should be in the “rotate” channels of the joints.Also double-check that the rotate values in your slave skeleton’s jo ints are nowhere near 180 degrees.If the default pose of your model looks wrong in Sandbox 2, turn on the joints label names and make sure all the joints have been exported (they most likely haven’t).EXPORTING ANIMATION:Again, you should always keep the default bind pose at frame 0 and set a key on all the joints. This is the reference frame upon which the animation export is based. If you don’t have this, your model will simply explode, both in Maya and Sandbox2.The path that appears in the Path tex t input only shows a partial result. Anything before “…/Crysis Wars/Game/Objects/…” will not appear. This is to keep the path short as to be able to see the export directory at a glance. If you hover your mouse over the text field, the complete path will appear. Choose the directory to which you want to export your model.Note that you can also click on the quick path menu line to access bookmarks that give you instant access to the last ten locations you used.To export animation, first click on “Add Animation Clip” to create… an animation clip! Give it a name and set the start and end frames for the animation. Finally, select your mesh group’s top node (in the first example above that would be “ratTest”) and click on “Export!”. When you export your animated model, several files will be created:.dae: Those are temporary Collada files; text files of your model which get compiled by the Crytek compiler to produce the actual files used by the CryEngine2..chr: Binary file containing the data for the mesh and joints (vertices, normals, weighting, etc…).caf: Binary file containing the animation data corresponding to a .chr file..cal: Text file listing the .caf animation files and the name under which they should appear in the Sandbox2 editor..cdf: Text file containing data regarding the character’s attachments and the way it should appear if the player picks it up in his hands, as well as attachments..mtl: Text file containing the material (shader information) related to a model.LOADING YOUR MODEL IN SANDBOX2:To see your model in Sandbox2, simply call the Character Editor window (View->Open View Panel->Character Editor) and load the .chr file. You’ll see the list of available animations on the right-han d side column. The “null” animation is created by default and is just a one-frame place-holder. Your animations should be neatly located within a folder with your model’s name.原网址/wordpress/?page_id=316。