Building a simple shape

The first tutorial is to assist developers in creating a simple crate shape, with collision information for use in the Torque Game Engine.


Getting Started

Ok, let's begin by building a simple crate.

Our goals for this tutorial are to:

Naming objects in the Shape

Care must be taken to model your shapes according to the guidelines detailed in the MAX2DTSExporter Documentation to ensure the exporter recognizes the various components and knows how to export them.

For the crate model the naming and hierarchical linkage we need to use is as follows; The same hierarchy would be used for other simple shapes (ie. Rocks, Trees, Vehicles).
  • "bounds" at the root of the scene (ROOT), encompasses the complete model and any animations performed by the model.
  • "shape" a dummy object at the ROOT used by the exporter to identify the model, and it various levels of detail (LOD).
    • "detail#" a dummy object, at least one must exist, however typically several exist to represent different LOD to be applied against a shape.
    • "start" a dummy object, which identified the start of our model. Any name can be used.
      • "models objects#" are the meshes that make up the model. In our crate's case, we have only one meshes the "crate". The "#" signifies the highest level of detail used. All meshes at this level would have the same number appended to there name.
Hierachy
NB: The names given to the objects in 3DS Max are not case sensitive to "MAX2DTSExporter".

Step-by-Step building the Shape

In 3DS MAX start a new scene. Follow each of the following steps to create a rough model of a pistol. You can use Max's "Command Panels -> Create -> Geometry -> Box -> Keyboard entry" facility to match the example exactly, otherwise use your own judgement on look, feel and sizes.

A copy of the "crate_box.max" is available under tge/tutorials/simpleshape/ directory.

Crate

Crate
6 Steps to build the shape
1.Create a dummy object and name it "shape".
2.Create another dummy object and name it "detail5", make it's parent the "shape" object. If you need help linking objects, refer to 3DS Max Online reference for help on the "Select and link" button or linking via the "Schematic View" option.
3.Create another dummy object and name it "start", make it's parent the "shape" object.
4.Create the Crate
  • create a box whose name is "crate5", position it at 0,0,0 and make it L=1.134, W=1.134, H=1.134 (approx 3' x 3' x 3')
  • make the crate's parent the "start" object.
5.Create collision information
  • create a box whose name is "col-1", position so it surround the entire "crate5" object. You could simply "clone" the crate5 and name it "col-1" to create a collision bounding box of same size, and location.
  • create a dummy object and name it "collision-1", make it's parent the "shape" object.
6.Create the Bounding box
  • create a box whose name is "bounds", position so it surround the entire shape. The box must encompasses fully the model you have created otherwise you may get any error when exporting.
  • set the pivot point of the bounding box (Command Panels -> Hierachy -> Pivot -> Affect Pivot Point) - blue axis points towards the top of the shape, the green axis towards the front of the shape, and the red axis towards the right of the shape. Although with a crate it's not that important, other shapes like vehicles would need to face the right way!

Exporting the Shape

Once your happy with the basic model, It's time to export it and see how it looks in the Torque Game Engine.

From the "Command Panels -> Utilities" select the "DTS Exporter Utility -> Utilities -> Whole Shape".

When prompted for a filename to export the .DTS shape to, enter one that represents the shape. ie CRATE.DTS

The exporter does not currently provide any "status" on the progress of the export, so you may think your computer has frozen, this is normal. If an error occurs it will be reported on screen via a message box (Basically: Be patient!).

Once the export has completed, try out your new model using the Torque Game Engine model viewer as described earlier in this guide.

Exporter

Adding Textures to the Shape

To add a simple wood texture to the crate, we will assign the tge/example/data/shapes/organic/woodtile1.png

Crate
7 Steps to texture the shape
1.Open the Material editor.
2.Select a sample slot.
3.In the Blinn Basic Parameters rollout of the shader, click the blank button next to the Diffuse colour swatch.
4. The Material/Map Browser appears, Double-click the Bitmap map type. Use the "Select Bitmap Image file" dialog to navigate to the woodtile1.png file in the tge/example/data/shapes/organic/ directory.
5.Click on the "Show Map in Viewport" button.
6.Click on the "Go to Parent" button.
7.Make sure the "crate5" box is selected, then click on the "Assign Material to Selection" to apply the texture.

Re-export the shape, and if everything been done in order, then the finished crate should look like

Crate Texture

To test the new crate in the Torque Game Engine, copy the CRATE.DTS file into the tge/example/data/shapes/organic/ directory, then add the following lines to the end of the TEST1.MIS script.

   new TSStatic() {
      position = "19.6218 -409.131 156.769";
      rotation = "1 0 0 0";
      scale = "1 1 1";
      shapeName = "~/shapes/organic/crate.dts";
   };

Well that's all folk!