Tutorial (Component Exporting)

Export Component

Tips, basic knowledge

  • I suggest you download the sample pack and just try exporting one of the existing components or arenas. Then slowly try tweaking various things to get an understanding of how it works. Try moving the start points around, try changing the collision geometry, etc. It's much easier to modify an existing file than it is to create a new one from scratch.
  • The GMF viewer must be in a simple path, such as C:\gmfviewer. The gmf file you are viewing must be in that same folder. Drag the gmf file onto the viewer exe. There must be a folder called maps, where the textures can be found. This version of the viewer does not work properly with lighting. If your scene has lights, they will appear too bright in the scene. Best option is to export without lights for this preview tool.
  • Most objects have two sets of geometry: one is the display mesh, which can be fairly high-poly and has textures, etc; the other is the collision geometry, which is invisible and should be low-poly since Havok uses this for detecting when objects collide with one another. So, for example, a weapon might look very detailed with intricate parts and pieces, but that's just the display mesh; the collision mesh could be a simple box. Display and collision meshes must align properly, so when they have the same transform (position, rotation, never use scale) they appear in the same location and orientation. Set their pivot points to be identical.
  • The GMF exporter is a max plugin found in the utility panel, not on the file-export menu. Only export what is needed for the component or arena. The easiest way to do this is to create selection-sets in Max, then use the "Export Selected" button.
  • If a component appears at an unexpected orientation, you probably forgot to reset it's transformation. There's a handy max utility called "Reset XForm" which adds a modifier to the stack that will reset the transform. I personally prefer to explicitly manage pivot point positions and rotations rather than use modifiers.
  • Textures must always be square, in powers of 2 (64x64, 128x128, 256x256, etc). 3D Studio Max has a million great features, most of which have nothing to do with a realtime game and will never work. Don't get excited about a cool Max effect. You can assign colors to objects, or solid textures (.bmp file) or alpha textures (.tga file with alpha channel, put it in both diffuse and opacity maps). You can also use reflection maps for special effects, but it's a bit tricky. Alpha can be additive effect instead of normal alpha by checking the additive blending radio button in the material editor.
  • Arenas use Python to script hazards and other events. With a little work, you could script some really neat stuff.
  • Remember that Havok is a rigid body simulation and the geometry of objects never changes. You cannot "crush" an object, for example in a giant hydraulic press. When the chassis of the robot gets battered and bashed, this is a visual effect that we did to fool you into thinking the bot is getting dented. The collision geometry never changes, only the display mesh changes in response to physics events.
  • The AI bots need A* pathfinding maps to find their way around the arenas. This is the .map file in the arena folders.
  • Cameras don't export from the scene. In my example arena, I create them simply to get their positions and orientation. They are written into the arena script.

How to create and export a component from Max

File requirements

Bot components are loaded dynamically into the game. So you need only place the required files into the components folder, and the game will automatically load it.

The general structure for files is:

Components\myfolder\maps\...bmp...tga    -> associated textures for this component

The text file is the key required file that causes the game to try to load a component. It contains path information to find the gmf as well as other important data. See the Component File Format page for details on this data.

Max Requirements

Rigid Bodies
Must have a rigid body collection with the necessary rigid bodies for your component. Some components have only one rigid body. Others have one rigid body with several primitives. Others have two rigid bodies constrained together.

The master rigid body must be positioned and oriented with NO transform. This means at the origin with no rotations.

Attachment points
There must be at least one point helper object with user data in it defining an attachment point. See the Component Attaching page for details on this format. You can have more than one attachment point if your component can be attached in multiple orientations or can have other objects attach to it.

The orientation of this helper point is critical. The positive local Y axis must point away from the object. Think of it as a plug that will fit into the receiving socket of whatever the object is attaching to.

Additionally, if the component can be attached to the baseplate of the chassis, the attach point must be outside of the collision body so that, when attached, there is no intersection with the chassis.

You can export multiple styles of a single component (variable lengths, sizes, orientations, etc). The most fundamental way to do this is to export separate gmf's, one for each style. Then define the styles in the text file. There is also a Max script plugin with a new helper object that can facilitate this. The plugin is also helpful for storing component data in Max so you don't need to create the text file by hand, unless there are unique items required in it.

RA2 Component Helper Plugin
This is a scripted plugin that extends the Dummy helper. It stores data about this component (name, description, filenames, other data) and automatically exports both the text file(s) and gmf(s) for one or more styles.

To use it, create an instance of this dummy in the scene anywhere, and modify the properties shown in the rollout panels. It is best to set up a default export directory (C:\RA2Components for example) and then always export your components here. Many of the rollout controls correspond to the data needed in the text file.

You will need a selection set defining your exported objects (do not include the helper dummy in this selection set). The first rollout in the helper panel is the export rollout which has a dropdown to choose your export selection set and a button to do the exporting. Click it and your text file, gmf, and maps will all be placed in your export directory. You then just copy these things to the RA2 components folder.

AI bot components won't really need styles since the player won't use these components. But some AI components might be worth using as player components, too. If you want to create styles, the helper object can have style names added to a list. It then will export corresponding frames for each style: frame 0 is the first style, frame 1 is the second style, etc. So you can animate vertices of an object to create several sizes of it. The helper can't export different meshes for each style, so if your objects change per style, you'll need to set up the text file by hand.

Note that the whole process is rather fragile and it is rare that you export a component perfectly the first time. Always test your component after exporting.