Creating the Weapon Model

So…
This first step comes in three parts. First, we do our research. Then we build the model. Finally we create a texture map. For this tutorial, and the sake of simplicity, I will be creating a baseball bat. A very simple bashing instrument. But it’s no surprise to anyone who knows me, that a personal motto of mine is simply to KISS. (Keep it stupid simple.)

This is the mesh for the weapon I created while writing the tutorial.

Here’s my model, it’s a simple thing. Couple hundred tris, max. Anyway, once we have a model. We’ll need to texture map it. This could be as simple as normalizing every polygon face to a 1:1 uv-space, or as complex as actually creating a decent texture map. I went with the former. And once I had UVs, I cooked out an ambient occlusion. (NOTE: As CryEngine uses realtime shadows… if you use Ambient Occlusion, do not bake shadows into the occlusion map.) Little image editing later and ta-da!

And again, this time with a quickly created texture.

Now that we have a model, we need to scale it to approximately the right size. This is pretty easy. To do this, we import a copy of the third-person character. Now we’ll grab the model, and indiscriminately move, and rotate it to approximately where the character will be holding it. And scale it to the appropriate size. Now rather than try to explain how this works, here’s what I’m talking about:

This part is tricky.

Now you’ll want to snap the pivot to the joint which is meant to anchor our weapon. (On the standard SDK rig, this is the “item_attachment” joint.) Once we have established our scale, and repositioned the pivot, we will snap the weapon back to the origin, and zero out the rotation information. (CryEngine will take care of the actual placement, we just needed the scale.) Oh, and delete the imported skeleton (and any junk he brought with him. (The materials, for instance.))

We need to create two (or more materials.) One (or more) for the render mesh, and one for the physics mesh. Once this is done we’ll need to add the CryTek attributes. (By opening the CryTek UI and hitting the “Add Attributes” button.) Then we select our materials, and set the Physicalize values. The Render Material has a value of “None” (the default), while the Physics Material gets set to “ProxyNoDraw.” Oh, it’s useful, but unnecessary, to give these materials unique and identifiable names. (render_mat and phys_mat for example.)

Finally, with all of this done; we’ll want to create a material group (so the engine will later know what to export.) We do this now, so the model will use the same material files regardless of first or third person. (Note: This is sub-optimal for performance. In a production environment you will likely want to use a lower res version of each material and model for the third-person mesh (as well as using multiple LODs). But for the sake of simplicity, we do it now.)

Scaled to the model and aligned at the origin. This is what we want.
Anyway, now you need to set up the Material export data. If you’re using Max or XSI… I can’t really help you. But if you’re using Maya then you are in luck!
The Maya to CryEngine 3 Material Export Process

  1. Select all target geometry with material.
    (Alternative: Select desired materials in HyperGraph.)
  2. Open CryTek Material editor.
  3. Click on “Create Group From Selection”
  4. Name the group. (For instance, I named mined baseball_bat)
    Note: Whatever is input into box is the filename used for export.
  5. Material should be ready to export.
  6. Open CryTek UI and click on Generate Material Files.
  7. You should have a *.mtl file in with the source scene asset. You will relocate this to the engine.