wlm24 (at) drexel (dot) edu |
 
Lesson: Modeling Structures with Torque Constructor

Introduction

In Torque, structures such as buildings and bridges follow a slightly different pipeline then other 3D models, such as weapons, items, and characters. These large structures are typically built as DIF objects.

Keep in mind: there is a bit of strange nomenclature when it comes to DIF objects. In Torque, DIF objects are called interiors, but this is misleading, because you could use DIF objects to create outdoor objects as well.

Why use DIF objects for large, collidable structures instead of DTS?

  • Automatic creation of collision meshes
  • Efficient collision calculations
  • Inherent understanding of lighting and shadow

CSG

DIF models are built using CSG or Constructive Solid Geometry. CSG models are built using smaller, closed, convex primitives. What is meant by convex? A convex shape does not bend in upon itself; such an object would be concave.

Essentially, if you can draw a vector from one point to another within the shape and still intersect a side, you have a concave object. This is important for the creation of BSP trees, which will be discussed in another lecture (if you want to get a jump on understanding BSP trees, an excellent FAQ can be found here).

This seems very limiting, but CSG has a very simple and elegant solution. Brush editors can easily divide concave objects into multiple convex objects. This is where boolean operations come in. Boolean operations perform what many who are familiar with other modeling packages refer to as mathematical operations. There are three main boolean operations: intersection, subtraction, and union.

Wait, what about the restriction of shapes being concave? Don't worry, the CSG brush editor will break up your geometry into smaller, convex pieces automatically (or will throw an error if it isn't possible).

By using these simple operations, we can create surprisingly complex models.

Brush Editors

The CSG modeling package (brush editor) we are going to be using is GarageGames' Constructor. If you want to play along at home, a demo can be picked up from GarageGames product page (free GG account required).

There are many other brush editors available. QuArK (Quake Army Knife) has been the brush editor of choice for many Torque developers until Constructor was released. It is an open-source tool, and a version configured specially for Torque can be picked up here. Valve's Hammer can also be used to create Torque DIFs. Instructions to set up Hammer for Torque can be found here. (free GG account required)

Be forewarned! These other packages take a bit of finagling to get working!

Constructor is really sweet because the workflow is fantastically streamlined; simply export the DIF map to your Torque interiors folder.

Getting Familiar

Once you have Torque Game Engine (TGE) and Torque Constructor installed, we can begin modeling. Open up Constructor. This is what you will see:

If you have used other 3D packages before, you may feel at home.

Navigating 3D Space

If you are starting Constructor for the first time, you are greeted by four viewports (top, perspective, back, and right). Each of these viewports can be called to fullscreen by pressing 0 on the numerical keypad. You can quickly switch views by moving your mouse into the appropriate viewport and pressing the following keys:

  • Top: Keypad 1
  • Bottom: Keypad 2
  • Front: Keypad 3
  • Back: Keypad 4
  • Left: Keypad 5
  • Right: Keypad 6
  • Perspective: Keypad 7
  • Texture (UV): Keypad 8
You can navigate the 3D worldspace simply using the mouse:
  • Translate: Click + Hold scrollwheel
  • Rotate: Click + Hold LMB
  • Zoom: Spin scrollwheel

Palettes

Your viewports are surrounded on both sides by palettes.

  • Tools: This palette contains brushes for creating 3D primitives, creating entities (lights, path waypoints, etc.), and importing DTS shapes. This palette also contains the boolean modifiers, user-created macros, prefabs, and workspace management.
  • Properties: The currently selected object's properties appear here.
  • Scene: An scene outline exists here. This is very useful when your scene gets large.
  • Materials: Your material application tools.

At the bottom of workspace are selection modes. These tools are extremely useful; they allow you to modify the base primitives by editing verts and faces, a feature lacking from QuArK. Now, you can use familiar poly-modeling techniques when building your scene. You can quickly switch between these modes by pressing 1, 2, and 3 on the number row.

Modeling

[To be added]

Exporting from Constructor and Importing into Torque

To export your object, select "Export as DIF" from the file menu. The DIF should be exported to the folder:

C:\%TORQUEINSTALLFOLDER%\example\%DEMO%\data\interiors

where
%TORQUEINSTALLFOLDER%
is your default Torque Game Engine install (C:\Torque\TGE_1_5_2 by default) and
%DEMO%
is your game folder (starter.fps, starter.racing, tutorial.base, etc.)

Once the export is complete, start up the demo which you exported to. Press F11 to enter edit mode, then press F4 to enter World Editor Creator.

On the lower right hand quarter of the screen, click on the [+] next to Interiors to expand the menu. Continue to drill down until you open the "interiors" folder. Your exported file should be visible in the hierarchy.

Select it to drop it into the scene.

Once your DIF has been added to the scene, you can move it using the translate gizmo (hold ALT to rotate the object, and hold ALT+CTRL to scale).

Before you exit out of edit mode, be sure to relight the scene (hotkey: ALT+L). This ensures that shadows are being cast from your structure, and that the structure's light map is combined with world lighting.

Your new structure is ready! Be sure to save your mission (hotkey: CTRL+S)!

It's not working!

Common mistakes: be sure that your DIF file has an extension (.dif); otherwise TGE will not see it. Also, make sure that your texture file is copied to the same folder that your DIF is located. (To avoid mess, create your own sub-folder within interiors, and place your DIF and textures inside.