Torque render node

Exports the scene to the Torque DTS or DSQ format.

All Parameters Example files

Parameters

Export

Export root

The path to the root of the node hierarchy to export. Note that all geometry to be exported must be specified within a Detail Level. The export root node is only used to add bones and other node transforms to the exported shape.

Output file

The name of the exported DTS file. For DSQ export, this name is used as the base filename, with a .dsq extension, and optional sequence_name suffix (when Split DSQ is used).

Export scale

Global scale factor applied to the scene geometry during export. This setting is useful to quickly scale objects to be the right size in Torque without modifying the Houdini scene itself.

Replace underscores in bone names

Houdini does not allow certain characters (spaces, '-' etc) to be used in object names, instead replacing these with an underscore. This setting instructs the exporter to replace underscores in Bone and NULL node names with spaces. This is used to generate skeletons with node names compatible with the Torque Biped skeleton (used in player.dts).

Optimize geometry

When enabled, the exporter will attempt to optimize mesh geometry by collapsing duplicate points, and generating triangle strips from the resulting mesh. Optimized meshes will render much faster within Torque. Note that this setting can be overridden using a scene config file.

Save dump file

When enabled, an HTML dump file (dump.html) will be generated in the same directory as the exported DTS file. The dump file contains detailed information about the export process, and can be helpful when trying to track down export problems. It is recommended to generate and check this file if any problems with exporting are encountered.

Use .cfg file

When enabled, a DTS scene configuration file can be specified that allows fine tuning of the export process.

Config file

Filename of the DTS scene configuration file to use.

Export Animations

When generating a DTS shape, this flag controls whether animation sequence information is exported.

Copy textures

When this flag is enabled, the exporter automatically copies all textures used by the shape into the export directory. The Torque engine requires that all textures used by a shape are in the same directory as the DTS file itself.

Generate .cs file

When this flag is enabled, the exporter generates a TorqueScript file in the export directory containing the DTS shape and all animation sequences as required by the Torque engine.

Split DSQ export

When this flag is enabled, the exporter writes each animation sequence into a different DSQ file.

Bounds

Use custom bounds

For simple shapes that do not use ground transforms, the DTS exporter can determine the scene bounds automatically, and there is no need to add a separate 'bounds' object to the scene. However, for shapes that use ground transforms (such as walking/running characters), a separate bounds object should be created. When enabled, this setting instructs the exporter to use the custom bounds object instead of the (internal) automatic one.

Padding

Distance to extend the bounds mesh beyond the actual extents of the scene in the X,Y and Z directions.

Bounds node

Path to the object to use as a custom bounds node.

Create/Update Bounds

Creates (or updates the size/position of) the custom bounds node so that it contains all geometry in the scene (from Export Root down).

Details

Initialize Details From Scene

This button scans the scene (from Export Root down) adding detail levels (using the trailing numbers on geometry names) and linking the appropriate geometry. The exporter strips numbers from the end of geometry (but not bone) names, so beware of different geometry containers that differ only by the trailing number.

Also, the scan treats an underscore character '_' before the trailing number as a negative sign. eg. mesh_2 will initialize a detail level of size -2.

Detail Levels

Manages the list of detail levels to be exported. Level-of-detail (LOD) is an important concept to understand in order to get the desired result in the Torque engine. The LOD size of each detail level is used by the Torque engine to determine when to switch between the different geometry in the shape. This allows less detailed geometry to be drawn when the object is further away which can greatly improve rendering performance.

The Torque DTS exporter allows multiple detail levels to be defined, each linked to any number of geometry containers. The same geometry can be linked to multiple detail levels, and the exporter can automatically reduce the number of polygons if desired.

LOD size

The pixel size above which to display the linked geometry. For example, if a shape contained the following detail sizes: 100, 20, 5, when the size of the shape onscreen (in pixels) is 100 or more, the geometry associated with detail level 100 is used. Similarly, when the size of the shape is 20-99, detail 20 geometry is used, and when the size of the shape is 5-19, detail 5 geometry is used. When the size of the shape is less than 5, nothing is rendered. If the LOD size is negative, the Torque engine will not render any geometry associated with that detail level.

If a shape defined three detail levels: 10, 50, 100, when the shape would be rendered with size 55, the geometry for detail level 50 would be used. When the rendered size is greater than 100, detail level 100 would be used. When the rendered size is less than 10, nothing would be rendered.

Detail type

Specifies the type of detail level to create:

  • Normal: normal mesh geometry

  • Auto Billboard: generates a billboard snapshot of the linked geometry which is displayed instead of the actual mesh.

  • Collision: linked geometry is used for collision checking (must be convex!)

  • LOS Collision: linked geometry is used for line-of-sight collision checking (must be convex!)

Equator Steps

This defines the number of snapshots to take around the equator. Imagine the object being rotated around the vertical axis, then a snapshot taken at regularly spaced intervals.

Size

Defines the size of the billboard images in pixels (must be a power of 2: eg. 2, 4, 8, 16….128). The larger the number, the more detailed the billboard will be.

Polar Steps

This defines the number of snapshots taken between the poles, at each equator step. eg. At each equator snapshot, the globe is tilted towards each pole, and a number of snapshots taken.

Index

Defines the detail level to use when generating the snapshots. Note that this is an array index rather than a detail size. So if an object has detail sizes of: 200, 150, 40, then setting Index to 1 will generate the snapshot using detail size 150.

Include Poles

If true, then object snapshots will be taken at the two poles. ie. with the camera looking directly down and directly up at the object.

Polar Angle

If pole snapshots are active ('Include Poles' is set), this parameter defines the camera angle within which to render the pole snapshot. eg. if 'Polar Angle' is set to 0.437 radians (25 degrees), then the snapshot taken at the pole (looking directly down or up at the object) will be rendered when the camera is within 25 degrees of the pole.

Linked Geometry

Manages the list of geometry nodes to be displayed at the current detail level.

Geometry Type

Specifies the type of geometry:

  • Normal: normal mesh geometry

  • Billboard: geometry always faces the camera

  • Z Billboard: geometry always faces the camera (Z axis only)

  • Sorted: geometry is sorted (may be useful for meshes using transparency)

% Polys

Defines the percentage of polygon reduction to apply to this geometry. If set to a value less than 1, the exporter will attempt to auto-generate a mesh with the following number of polygons: original_mesh_poly_count * reduction_percentage. This feature is useful for auto LOD. To make use of auto-LOD, simply define multiple detail levels, all linked to the same geometry, with different '% Polys' values.

Path

The path to the geometry node.

Auto Billboard Detail Levels

Detail levels marked as AutoBillboards are different from usual detail levels in that they take a 'snapshot' of the geometry which is rendered as a single image that always faces the camera, and can be very useful to speed up performance. To generate the billboards, the Torque engine renders the object at certain angles and stores the resulting image. In-game, the Torque engine determines which snapshot is closest to the camera’s current orientation, and renders the single image instead of the shape geometry.

Note that this is quite different to billboard geometry, where the actual geometry (not a snapshot) is automatically rotated such that it always faces the camera.

To understand how the snapshots are generated, it may be helpful to think of the shape as a globe, with the 'equator' running around the center in the horizontal plane, and the 'poles' at the top and bottom of the vertical axis. The image below shows some of the billboard snapshots when the shape is viewed from different angles.

Collision Details

Geometry used for collision and line-of-sight (LOS) collision checks must be convex. These two types of geometry are usually invisible, so the detail level should be negative to indicate to the Torque engine that the geometry should not be rendered. Collision meshes should use as few polygons as possible to reduce the CPU load when determining collisions with other objects.

For collision meshes, the exporter will generate a detail marker with name 'CollisionXXX' and geometry 'ColXXX', where XXX is the LOD size (normally -1 to -9).

For LOS meshes, the exporter will generate a detail marker with name 'LOSXXX' and geometry 'LOScolXXX', where XXX is the LOD size (normally -9 to -15).

Billboard Geometry

Parts of a shape can be billboard objects (i.e., they always face the camera). So, for example, you could have an explosion in which shrapnel flies out from the center and also have little explosion balls fly out that are just flat polygons that always face you.

Linked geometry can be made a billboard by selecting the Billboard or Z Billboard types from the dropdown menu. Note that not all detail levels of the object need to be billboard objects, so the highest detail level of a shape could be a complicated 3d shape, whereas the lowest detail could just be a billboard. Z billboards are the same as regular billboards except that they only rotate about the z (vertical) axis.

Note

Billboard objects tend to have strange sorting properties if transparent materials are used.

Sorted Geometry

Objects with transparent textures often times appear to sort improperly in the engine. On modern graphics hardware, drawing on the screen amounts to storing values on the graphics card for the red, green, and blue channel, and also storing values for the distance of the fragment from the camera. The later value is often referred to as the “depth-value” or “z-value”. The depth value is important for determining what should be drawn in front of what.

To understand how this works, you have to understand one basic point: polygons are always drawn in an order. One is drawn first, another second, etc. So when the second is being drawn, the value of the first polygon is sitting in the frame buffer (the place on the graphics card that holds what you are drawing on the screen). This means that the graphics hardware can simply compare the depth value of the incoming pixel against the depth value of the stored pixel, and only update the frame buffer if the incoming pixel is in front of the stored pixel. That is exactly what happens.

Drawing transparent fragments also requires a combination of what is in the frame buffer already and the incoming fragment. With transparency, the incoming fragment has an “alpha-value” in addition to red, green, and blue, and the alpha value is used to blend the fragment with the framebuffer. An alpha of 1 means to over-write what’s in the buffer, an alpha of 0 means not to touch the frame buffer, and an alpha of 0.5 means to mix them equally.

Transparent drawing with depth tests gets very tricky. If polygons are drawn back to front, depth tests and transparency behave well together. But when some polygons in the front are drawn first, things start to get very messy. Imagine what would happen if you had a fully transparent texture (alpha of 0) drawn first, and that it fully covered the camera and was in front of everything else. Since the alpha value is zero everywhere, it would not draw to the RGB channels. But the depth value would still be updated for the entire screen. Now everything that was drawn would fail the depth test. The result is that you would see a blank screen no matter what you draw behind the phantom polygon.

Because of this issue, transparent polygons are normally drawn with special care: the depth value is not saved but the depth test is still used. Transparent polygons are drawn after non-transparent polygons, and transparent polygons are drawn from back to front. The result is that transparent polygons behave when they overlap each other because they are drawn back to front. Transparent polygons behave when overlapping non-transparent polygons because they only drawn when they are in front of the non-transparent polygons (remember, the depth test is still carried out, the depth value just isn’t stored). The phantom polygon issue is avoided because the depth value isn’t stored.

One consequence of all this is that any object that draws transparent polygons must do so with special care. Furthermore, the engine itself must take special care to draw everything in the right order. In particular, the most accurate way for the game to draw the scene is to first draw the non-transparent polygons of all objects, then draw the transparent polygons of each object from furthest to closest to the camera. Each object, then, is only responsible for drawing it’s own polygons so that they can sort amongst themselves.

Three space has several mechanisms built in to handle the sorting of polygons. First, parts with only non-transparent polygons are drawn first, then parts with a mixture of transparent and non-transparent polygons, and then transparent parts. Note that if you have several parts with mixed polygon types, you will likely get some inappropriate sorting, so don’t do this. These are all the measures 3space takes by default. However, there are special objects that do a little more sorting on their own. These are the sort objects described below. What these objects do is order the polygons so that they will always draw back to front. Believe it or not, it is often possible to do this for all camera angles. This however, it is not always possible. In those cases, the object has different orderings for different angles (usually only a few are needed) and in really bad cases, polygons have to be split. The latter can sometimes lead to large file size. If you see this happening, you should redesign the shape.

The faces of these objects are presorted so that faces are drawn from back to front. This is used to force the sorting order of transparent objects (which are not z-buffered) This sometimes involves splitting faces and sometimes involves different orders depending on where the camera is.

To make linked geometry a sort object, select the Sorted type from the dropdown menu. Other detail levels of this object do not have to be sort objects.

Sequences

Start Frame

First frame (inclusive) in the sequence. This number should match the frame number in the Houdini animation timeline.

End Frame

Last frame (inclusive) in the sequence. This number should match the frame number in the Houdini animation timeline.

FPS

Frames per second for this animation. This does not affect the number of keyframes, only how fast they will be played back.

Override Duration

If you override the sequence duration, it will change the duration of the sequence when it plays in the game at time scale 1, but it won’t otherwise change the animation data (same keyframes will be used, they’ll just play at different times). This is useful for altering the speed of the ground transform of an object without scaling the animation. Most of the time, this is not used, and should be set to -1.

Priority

Controls what sequence will affect a node when two sequences want to control the same node. The sequence with higher priority will control the node.

Cyclic

If turned on, the sequence will loop (e.g. walk and run animations). If turned off, the sequence will play once then stop (e.g. death animations).

Ignore Ground Transform

Don’t export a ground transform for this sequence. This should be false for animations that move the shape.

Blend Sequence

Makes the sequence a blend animation.

Reference Frame

The reference frame number for the blend animation. Only valid if the blend flag is set.

Enable Morph

This will force the exporter to export all mesh animations as a series of mesh snapshots.

Enable TVert

Enables animated texture coordinates.

Enable Visibility

Enables use of the DTS Material visibility channel.

Enable Transform

Enables transform (eg translation and rotation) animation.

Enable IFL

Enables IFL animation.

Number of Triggers

Manages the list of trigger frames and states for this sequence.

Trigger X Frame

The frame number (in the Houdini animation timeline) on which a trigger event occurs.

Trigger X State

The state of the trigger. The meaning of the states are up to the programmer.

Morph Animation

This type of animation captures the mesh geometry as a series of snapshots. ie. the position of every single point in the mesh is stored for each frame of the animation. This is useful for certain types of animations (e.g. flags or facial movements), but it will produce large files and does not contain animated nodes.

One way of animating the points in a mesh is to add a Point SOP to the output of the geometry, then animate the TX, TY, TZ parameters.

TVert Animation

This type of animation allows the texture UV coordinates to change over time, and is useful for things where the texture itself must animate. Scrolling computer monitors, waterfalls, and tank treads are just a few of the applications for animated texture coordinates. To animate the UV coordinates, simply add a Point SOP to the output of the geometry, and animate the MAPU and MAPV parameters (MAPW is not used during DTS export).

Visibility Animation

A DTS Material has a 'Visibility' parameter that can be animated to control the transparency of the object using the material over time. This is useful for parts of the model that you may only wish to show during certain animations.

Note that environment mapping (the DTS Material 'Env. Mapping' parameter) should be set to 0 for DTS materials that animate the 'Visibility' parameter, as otherwise the visibility will be either on (1) or off (0), without values in between.

IFL Animation

IFL (image file list, or image file library) animation allows the texture applied to an object to be switched automatically over time. The IFL file defines a list of textures, and optionally the number of frames to display each texture for.

Note

If using Houdini to edit the IFL (using the DTS Material SHOP), make sure to save the latest changes to file, as this is not done during export.

Note

IFL animations are not affected by the frame rate of the sequence in which they are played. The durations specified in the file are assumed to be at a frame rate of 30 fps.

Blended Animations

Blend animations allow additive animation on the node structure of the shape. These will not conflict with other threads, and can be played on top of the node animation contained in other threads. Such animations are relative. Blends only read the changes that occur over the course of the animation and not the absolute position of the nodes. This means that if a node is transformed by a blend animation, it includes only the transform information for that node, and it will add that transformation on top of the existing position in the base shape (the DTS).

Bear in mind that a blend can be played as a normal sequence, or it can be played on top of other sequences. When another sequence is playing, it will alter the root position, and the blend will be applied on top of that.

If you try to do a blend sequence where the root position is different than the 'normal' root (in the default root animation), you might expect that the blend will blend it to the new root (the position the character is positioned in during the blend animation). However, it does not work this way. Since nothing would actually be animating, it doesn’t move the bones to the new position. What is contained in the blend sequence is only transform offsets from the blend sequence root position.

It is not a good idea to have a different root position in your 'normal' animations and your blends, as they can easily get out of sync.

You can determine the position that the blend animation uses for the animation offset by using the blend reference frame.

The values added from the blend animation are based on the root position in the DTS/DSQ file. This root position does not have to be the beginning of the animation. You can pick any position for the blend animation to reference.

This is useful, because you can have a blend animation that can have a reference position that is the 'root' position. For animation like hip twists and arm movements (as in the 'look' animation), the character can be in a natural default state. In this way, you can have one animation control the character through the base pose to an extreme in either direction while referencing the default 'base' state, which will exist somewhere in the middle of the blend animation.

Ground Transforms

Animation sequences that move the character must export a ground transform. The engine knows that the character has a specific velocity in all directions (this is set in script). When the animations are being played, the engine is aware of what the distance covered is and plays the appropriate animation. If, for instance, the forward velocity of the character increases past the point of a walk animation to the speed of a run, the engine will automatically transition to the run animation.

The Torque exporter figures out the ground transform (meters per second over a given distance) by determining how much the bounding box has moved over the course of the animation. The bounding box is a box at the scene root level (/obj) called 'bounds', which can be automatically created by the Torque output node.

If you have no ground transform, the animation will not play properly when the character moves. In the Torque engine with the default character, the forward ground transform is approx=4m/sec.

Triggers

Triggers are arbitrary markers that can be used to call events on specific frames in a sequence. An example of a triggered event is calling footstep sounds and footprints during walk and run animations. You may define up to 32 triggers per sequence.

There can be up to 32 trigger states each with their respective on (1 to 32) and off (-1 to -32) values. What each of those trigger states means is up to you. You should work with your programmer to define what the trigger states mean and how you should use them.

For example, you could have one trigger for each foot of a character that creates a footprint when the foot is down on the ground. Let’s say that a triggerState of 1 is the left foot down and a triggerState of 2 is the right foot down. When the sequence plays the frame during which the left foot touches the ground, you could have a trigger on that frame that has a triggerState of 1 to create a footprint. You would then create another trigger with a triggerState of 2 for the right foot. You don’t necessarily need to turn off the footprints (let’s assume that the programmer will turn them off when it is necessary), but you could by creating two more triggers with triggerStates -1 and -2.

There is one Frame and State per trigger. Trigger numbering starts at 0. For example, Frame0 and State0 are the first trigger, Frame1 and State1 are the second trigger, etc. Note that when you delete triggers from the list, all of the remaining triggers are renumbered starting from 0. Their frame and state attributes are retained.

Preparing Scene for Export

  1. Geometry must be converted to triangles before exporting. Add Convert and/or Divide SOP nodes to the output of geometry nodes as required.

  2. The exporter attempts to export what you see in Houdini, so it is important to set the 'Render/Display' flag correctly within each geometry container. The SOP nodes within a geometry container generally form a chain (the output of one node connects to the input of another), and the 'Render/Display' flag determines which node output is both rendered in the Houdini viewport and used for DTS export. Generally, the best practice is to set the 'Render/Display' flag on the last node in the chain, indicating that the accumulated output of the entire SOP chain is to be used (see image below). Note that Houdini does not do this automatically!

  3. Add a new 'Torque' node to the /out network (TAB->More->Torque).

  4. The Torque DTS exporter does not require any special node hierarchy, but it is important to set the 'Export Root' parameter to point at the root node of the scene to be exported. The default ('/obj') is usually correct.

  5. Create the detail levels manually, or use the Init Details From Scene button to generate them automatically.

  6. Create animation sequences as desired

  7. Set the name of the shape to be exported, and select whether to export a DTS (geometry and animation) or DSQ (animation only)

  8. Export the scene using the menu bar (Render->Start Render) or directly from the Torque node parameter view (using the Render button).

The following image shows the chain of SOPs within a geometry container:

Note that the last SOP in the chain has the 'Display/Render' flag set (the double circles around it). This means that the output of this node will be used both for rendering in the Houdini viewport and for DTS export. If the 'Display/Render' flag was moved to the 2nd node in the chain (texture1), we would still have the geometry (from the grid1 node) and the UV coordinates (from the texture1 node), but we would no longer render or export the material assignment (material1) or the point animation (point1).

Materials

Because the DTS format supports only a subset of the Houdini shader functionality, it is best to use the DTS Material provided in the OP_dts.otl library. The DTS Material node must be added to a SHOP Network, and a Material SOP added to the object node which points towards the DTS_Material path as shown below.

You can add multiple DTS Material nodes to the SHOP Network, and assign each to a different group (or groups) of geometry primitives using the Material SOP.

TroubleShooting

  • If you are having trouble with UI elements flashing or not being drawn correctly (common with older or less capable video cards), set the following environment variable and restart Houdini: HOUDINI_OGL_SOFTWARE = 1

  • Warning message in dump file: This object contains unsupported geometry.: The DTS format supports only triangular primitives, so any geometry that is to be exported must first be converted into this form. There are two SOPs that can help with this:

    1. Convert: Used to convert from NURB/Mesh etc to polygons (and can also output triangles, removing the need for the separate Divide node).

    2. Divide: Used to split polygons into triangles.

  • Houdin crash on export: First check the dump.html file for errors or warnings. If the export process crashes during the “Optimising geometry” stage, the problem could be that the geometry has too many polygons for the tri-stripper. Try reducing the polygon count, breaking the geometry into separate pieces, or turning off geometry optimization.

  • Missing textures in exported shape:

  • check that the Houdini geometry container has the Display/Render flag set for the correct node

  • check dump file to confirm that materials were found during export

  • the Torque engine requires the texture files to be in the same directory as the .dts file

  • textures do not need to be square, but the width and height must be powers of 2 (eg. 2, 4, 8, 16, 32 etc)

Example files

TorqueDetailMap

$HFS/houdini/help/examples/nodes/out/torque/TorqueDetailMap.otl

Load | Launch

This example illustrates using a detail map with the Torque exporter.

TorqueIFL

$HFS/houdini/help/examples/nodes/out/torque/TorqueIFL.otl

Load | Launch

This example illustrates using an IFL file with the Torque exporter.

TorqueLOD

$HFS/houdini/help/examples/nodes/out/torque/TorqueLOD.otl

Load | Launch

This example illustrates using level of detail with the Torque exporter.

TorqueMorph

$HFS/houdini/help/examples/nodes/out/torque/TorqueMorph.otl

Load | Launch

This example illustrates using level of deforming geometry with the Torque exporter.

TorqueReflectanceMap

$HFS/houdini/help/examples/nodes/out/torque/TorqueReflectanceMap.otl

Load | Launch

This example illustrates using reflectance maps with the Torque exporter.

TorqueUV

$HFS/houdini/help/examples/nodes/out/torque/TorqueUV.otl

Load | Launch

This example illustrates using texture coordinates with the Torque exporter.

TorqueVisAnim

$HFS/houdini/help/examples/nodes/out/torque/TorqueVisAnim.otl

Load | Launch

This example illustrates using animated visibility with the Torque exporter.

Usages in other examples

Example name Example for