Exporting static models from Maya to Crysis.

This page gives instructions about the way to export static models (.cgf files) from Maya to Crysis. For animated characters, please refer to this page.

Installation instructions for MayaCGF can be found on this page.

The Geometry:

When working in Maya, you should make sure to turn off two-sided lighting in the viewport (Lighting->Two Sided Lighting). That way, if some faces turn black, you’ll know the normals are flipped the wrong way.

The model can be constituted of any number of separated meshes. You do not have to combine them. All the meshes making up your model should be located in a group. That group’s name is going to be the name of your exported model.

You don’t have to delete the history when exporting a static model, although sometimes there’s no way around it (see Troubleshooting section). But always make sure you freeze the transformations (especially Scale)! Also, there should be no instanced nodes anywhere in the model. And each name should be unique.

Physics Proxy:

Before you export your model, you should make it solid by creating a collision mesh, also called a “physics proxy”. This is not strictly necessary in the sense that if you simply assign a “Physics” shader (in MayaCGF’s Tools section) the Cryengine2 will automatically physicalyze the model (even if it doesn’t find a physics proxy mesh). But it is better to create a simple mesh that roughly encompasses your render mesh. The Cryengine2 could get confused if the physics mesh is too complex, and it will contribute to slow things down anyway.

IMPORTANT: Do not turn the visibility of the physics meshes (or their parents) off. If you do the physics will not get exported! If you want to hide the physics meshes, just put them in a layer and turn the layer’s visibility off.

Also, be aware that Sandbox2 does not reflect the changes you make on a physics mesh when you re-export models during the same session. So you may have to close and restart Sandbox2 to update the collision proxy.

For a mesh called “myMesh”, you should name the proxy mesh “myMesh_Phys” and make sure it is parented to the top node along with the mesh itself. In the picture above you can see the render mesh selected (a beveled cube), and around it (in Xray mode) the physics proxy.

LODs (Level Of Detail objects):

This paragraph deals with static model LODs. Animated model LODs follow a different method. To include a LOD in your model, just make a copy of your mesh, then rename it to “_lod1” and parent it to the original mesh itself (not the general export group). Finally, reduce the polygon number by 50% and delete the history. Some rules about LODs:

  • You can add a suffix after the “_lod1” part (eg: “_lod1_mySphere”) but the name must start with “_lod1” (or “_lod2”, “_lod3”, etc…).
  • The maximum number of LODs allowed per exported file is 6 (usually 3 is amply sufficient).
  • Each LOD should have a poly number reduced by at least 50 percents compared to the previous LOD.
  • You can use fewer shaders on the LOD objects than on the original mesh.
  • The last LOD object should be at least 300 polygons. If it’s less, it won’t be recognized by the cryEngine.

Materials:

You can use any kind of Maya material you like (Lambert, Phong, Blinn, etc…).

Select every mesh making up your model. Then select the proper physics setting (in the Tools section) and click on “Assign cryShader”. This will make sure that the currently assigned Maya material gets an extra attribute related to the physics in Crysis (if you select the shader itself and scroll down to the bottom of the channelBox you’ll see the new “CryShader” attribute).

NoPhysics: The mesh will be visible but not solid – this is the default.
Physics: The mesh will be solid and visible.
Physics(NoDraw): The mesh will be solid but invisible.
NoCollide: The mesh will catch bullets but the player can walk through it.
Obstruct: The mesh will block the AI.

NoPhysics is the default for the render meshes; you should use this for the meshes you want to see in game but that don’t need to be solid (for example if you also use a simplified physics mesh).

Physics(NoDraw) is typically used for the proxy physics mesh: you want those meshes to be solid, but you don’t want to actually see them in game.

If you do not want to create a physics proxy mesh (in case your model is not very heavy), then choose Physics; The mesh will then be both visible and solid.

So to summarize: each mesh in Maya has to have one (and one only) Maya shader applied to it. But you can apply the same shader to any number of meshes. And you can name the shader anything you like (preferably something you will recognize from within Sandbox2). When you export a file (CGF or CHR), one (and only one) material file (.mtl) is created. This material file holds the list of Maya shaders that were applied to your meshes. So if you export a CGF file made of several meshes but all using the same Maya shader, one .mtl file will be created, containing only one material.

Also, please note that the materials within Sandbox 2 will always appear as a set of “submaterials”. So the top name is “NameOfYourObject”, and within that, you get a numbered list of the all the Maya shaders.

Hair (wind turbulence):

The hair turbulence is really easy to setup. It doesn’t use vertex colour but instead uses vertex alpha channel (very similar). But since it’s a bit of a pain in the butt to paint, I added a tool for that in the Tools section of MayaCGF. In a few words:

1) Select a row of vertices on the bottom of the hair strip (where the “wind” will be more noticeable).

2) In the hair section of MayaCGF, click on “2”, “3” or “4” (“5” will move a lot).

3) Repeat with the vertices further up, until you select the upper part of the hair strip and click on “0”, so that the hair that hangs along the skull doesn’t move at all.

4) Then you have to setup the hair material’s parameters within Sandbox2 (cf screenshot).

Exporting The Model:

First, choose the directory to which you want to import your static model. Remember that this directory must absolutely be located in …Crysis Wars/Game/Objects. Again, you cannot export a file to anywhere else on your hard drive!

The path that appears in the Path text 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. Note that you can also right-click on the Path line to access a quick bookmarks menu that gives you instant access to the last five locations you used.

Choose “.CGF” in the “File Type” pulldown menu. Then select the top node of the model and click on “Export!”. By default, if a .mtl file already exists for the model, MayaCGF will not overwrite it, unless you check the “Overwrite .mtl File” option. But beware, if you spend time tweaking the material file within Sandbox2, you wouldn’t want to overwrite it with the default “bland” one!

When you export a static model, the following files are 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.
.cgf: Binary file containing the data for the mesh (vertices, normals, etc…)
.mtl: Text file containing the material (shader information) related to a model.

Troubleshooting:

Some meshes look all stretched and warped in Maya just after I export them: This is likely because you haven’t deleted the history on that mesh prior to exporting. In some cases you can let the history be on a mesh, in some others you have to delete it. It seems to be a case-by-case situation, really.

I’m trying to export my humongous spaceship with tons of details but the .cgf file is not created: The Crytek compiler (which MayaCGF uses) is limited to 65,535 vertices (number taken from the BlueMars doc page). So try to simplify your model before exporting it again.

After I successfully export a static model composed of several different meshes, some of the meshes in Maya jumped away from their position: This is because the names of those shapes are not unique. Make sure you give a unique name to those meshes.

Some meshes are invisible in Sandbox 2 although I assigned a proper shader to them: Some meshes are probably still connected to Maya’s “initialShadingGroup”. Break the connection in the Hypergraph and remove the useless material in the .mtl file (most likely called “lambert1”).

  1. No comments yet.