Building a simple weapon
The second tutorial is to assist developers in creating a simple weapon shape for use
in the Torque Game Engine.
Getting Started
Ok, let's begin by building a simple hand gun (pistol).
Our goals for this tutorial are to:
- Get an understanding of the naming and object hierarchy used by the Exporter for simple shapes.
- Create a basic gun shape (handgrip, barrel, chamber)
- Export it!
- Add a texture
- Animate it!
Naming objects in the Shape
Care must be taken to model your shapes according to the guidelines detailed in theMAX2DTSExporter Documentationto ensure the exporter recognizes the various components and knows how to export them.
For the pistol 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.
- animation dummy Sequence II objects
- "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.
- "pistol" a dummy object, which identified the start of our model. Any name can be used, often "start" or "branch" is used.
- "models objects#" are the meshes that make up the model. In our pistol's
case, we have three meshes the "barrel", "grip" and the "chamber". The "#"
signifies the highest level of detail used. All meshes at this level would
have the same number appended to there name.
- various other dummy objects to handle mount point
|
|
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 "pistol_box.max" is available under "tge/tutorials/simpleweapon/" directory.

|
| 8 Steps to build the shape
|
| 1.
|
Create a dummy object and name it "shape".
|
| 2.
|
Create another dummy object
and name it "detail64", 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 "pistol", make it's parent the "shape" object.
|
| 4.
|
Create the Barrel
- create a box whose name is "barrel64", position it in the bounding box and make it are L=0.324, W=0.032, H=0.032
- make the barrel's parent the "pistol" object.
|
| 5.
|
Create the Chamber
- create a box whose name is "chamber64", position at one end of the barrel where the Grip will be and make it L=0.16, W=0.048, H=0.048
- make the Chamber's parent the "pistol" object.
|
| 6.
|
Create the Handle Grip
- create a box whose name is "grip64", position it below the chamber and make it L=0.08, W=0.048, H=0.128
- make the Grip's parent the "pistol" object.
|
| 7.
|
Add the Weapon Mount Point
- create a dummy object and name it "mountpoint".
- position the mountpoint at the center point of the Handle Grip
- make the mountpoint's parent the "pistol" object.
- set the pivot point of the mountpoint dummy object - 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.
|
| 8.
|
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 - 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.
|
|
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 PISTOL.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 theTorque Game Engine model vieweras described earlier in this guide.
|
|
Adding Textures to the Shape
...Todo: Still working on it! Creating a simple animation
To create a simple animation, we will simulate the recoil of the chamber,
so each time the pistol is fired the chamber will slide back down the barrel,
then return to it's starting position.


|
| 10 Steps to create a simple animation
|
| 1.
|
Select the chamber64 box.
|
| 2.
|
Set the time slider to 0/100.
|
| 3.
|
From the "Command Panels -> Motion Tab" select the "PRS Parameters -> Create Key -> Position".
|
| 4.
|
Create the draw back effect of the Chamber on firing
- move the Time slider to 9/100
- select "PRS Parameters -> Create Key -> Position".
- change the chamber64 position in the "Key Info (Basic)" to reflect a backward movement of about 0.040 from its starting position
|
| 5.
|
Create a delay
- move the Time slider to 15/100
- select "PRS Parameters -> Create Key -> Position".
|
| 6.
|
Create the forward movement effect of the Chamber on firing
- move the Time slider to 24/100
- select "PRS Parameters -> Create Key -> Position".
- change the chamber64 position in the "Key Info (Basic)" to reflecting a forward
movement of about 0.090 from its current position
|
| 7.
|
Create a delay
- move the Time slider to 30/100
- select "PRS Parameters -> Create Key -> Position".
|
| 8.
|
Return the Chamber to it's starting position at the end of the firing sequence
- move the Time slider to 38/100
- select "PRS Parameters -> Create Key -> Position".
- change the chamber64 position in the "Key Info (Basic)" to reflect the chamber64 original position.
|
| 9.
|
From the "Command Panels -> Create" select the "Helpers -> Pulldown -> General DTS Objects".
- create sequence object and name it "Fire".
- uncheck the "Cyclic sequence" option.
|
| 10.
|
From the "Track View" menu select "Open Track View"
- Expand the Objects list
- Expand the Fire list
- Expand the Object (Sequence II) list
- Select the "Add Keys" option and click on the "Sequence Begin/End" line at
time 0, followed by a further click at time 38. This will provide the exporter
with details as to where the animation starts and ends for the sequence "Fire".
|
|
|
Done! If you've followed each step, you should have a basic weapon, with
an attached animation for when it fires. Export it, and try in theTorque Game Engine model viewer
|
|
Well that's all folk!
|