Links

Creating‎ > ‎

Models

NOTE: The latest version of these docs is in the source code, in docs/models.markdown.

The Cube 2 models reference is useful (note that we use .js config files, not .cfg, and we use JavaScript syntax in those files. See the example models). The Cube Wiki also has several useful pages on the exporting process (like this one).

Some clarifications to those docs:
  • MD5 models:
    • Each mesh in the md5mesh file must be 'marked' as follows:

      mesh {
      // meshes: MESHNAME

      where MESHNAME is the name of the mesh, that you will use in the config file.
    • MD5 models are meant, by default, for characters (basically human-type figures). One implication of that is that such models will not pitch, by default. The typical usage is to tell the model (using md5Pitch) to pitch a particular bone. Then that bone will pitch, but everything else by default wont - which lets you pitch the upper half of the model, keeping the lower half fixed (how characters normally work). If you want, instead, for an entire MD5 model to pitch (like an OBJ model would), do

      Model.md5Pitch('', 1.0, 0, -90, 90);


  • OBJ models: After the last 'vt' line for a mesh, you should have:

    g MESHNAME

  • Unit sizes: The units for meshes - and everything else in the world - is in 'cube units'. 7 cube units are about equal to a meter (3.28 feet). So, typical character models are usually around 10-12 cube units or so.
    • If you are importing from Blender, then generally 1 Blender unit is equal to one meter. So, your model config file should have something like Model.scale(500); - which scales the model 500% (or 5 times), so 2 units in meters in the model file will be 10 units in the game (a reasonable value).

Differences with Cube 2/Sauerbraten

  • You can have up to 128 animations per model. 0-39 are defined by Cube 2, which leaves 40-127 free to be used as custom animations by you.
    • To define a custom animation in the model script, use e.g. "50" to define animation 50 (use that where you would have used a Cube 2 animation identifier like "jump", "forward", etc.).
    • To run a custom animation on a model, use the integer value, like 50, where you would have used a Cube 2 constant like ANIM_JUMP or ANIM_FORWARD (of course, you can define constants for your own use, so you don't type 50 everywhere).

Tips on Importing and Setting Up

  • /clearmodel will remove a loaded model, which will then be reloaded, so that is a way to refresh it as you are testing changes to your md5.js. It might be convenient to do something like /bind F5 [clearmodel MYMODEL] so that you can quickly iterate and test.

Sign in  |  Recent Site Activity  |  Terms  |  Report Abuse  |  Print page  |  Powered by Google Sites