RTG and AnimRTG are portable (ASCII) file formats for 3D models and animation, suitable for game authoring. These formats allow the different game platforms and non-standardized PC development environments to share 3D data.
Although the RTG formats are not standards (governed by a committee), it is designed to be very easy to parse and translate, allowing easy creation of new translators on any platform.
Alias|Wavefront now supplies RTG 2.0, based on the Direct Translator (Dt) API (based on the OpenModel API). RTG 2.0 gives you the following benefits:
Up to version 1.8, Alias|Wavefront RTG and AnimRTG converters were based on the OpenModel API. Alias|Wavefront still supplies this product as a converter for OpenModel. |
RTG 1.8 and RTG 2.0 are very similar. Some of the new features are:
Alias|Wavefront plans to update the RTG applications periodically. All future development of RTG will be based on RTG 2.0. Alias|Wavefront still supplies this product as a converter for OpenModel.
The source code for the Dt API and translators is included in /usr/aw/alias/ODS/Games/source/.
This section describes how to use the interface of the RTG2.0-specific Direct Translator. For information on how to run the translator, see Using the MakeGame Plug-in on page 9 and Using Translators from the Command Line on page 15. |
The Direct3D translator does not require any special installation.
When you run the translator from MakeGame, the RTG window appears. Use this window to set the options described below, then click OK to start converting.
Use these options to control what parts of the scene are converted.
Output pivot information for each node in the hierarchy.
ON -output descriptions of transformations.
OFF - output static geometry in world space.
Output transformation matrix for each node in the hierarchy.
Output animation information. The translator converts the frames specified in the MakeGame window.
For details on the .rtg and .bin file formats see RTG File Format Details on page 108.
To convert scenes to RTG 2.0, use the MakeGame and the RTG2.0 Direct Translator. See Installing the MakeGame Plug-in on page 6 and RTG 2.0 Translator on page 98. |
To install the RTG 1.8 converter as an external application in Alias:
$ALIAS_LOCATION/ODS/Games/bin/rtg %i
rtg_output_wire.temp
The converter window will open. Click Cancel to close it if you don't want to convert geometry now.
To convert a scene to a RTG 1.8 format file:
"Active" objects means picked objects and all objects below them in the hierarchy graph.
The Wire to RTG v1.8 window appears.
A terminal window will display any updates or error messages.
directory where output files are created.
the base name for the output files, to which the converter will add frame numbers and suffixes for different file types (such as ".rtg" and ".bin").
determines what level of organization in the Alias wire file corresponds to an "object" (which has a vertex list and polygon list) in the RTG file. The Polyset w/Hierarchy option uses object space coordinates. All other options use world space coordinates. Choose from:
All Processed = the entire wire file is treated as one object with one vertex list and one polygon list.
Top Level DAG = each top-level node is treated as an object.
Polyset = each polyset is treated as an object.
Polyset w/Hierarchy = each polyset is treated as an object, and hierarchy information is included. This is the only way to include hierarchy information in an RTG 1.8 file.
ON = output transformation matrices from the hierarchy.
scaling factor for vertex coordinates (use to fit model inside game box).
Scaling is only applied when no hierarchy is being output, since scaling would disrupt transforms applied to vertices in object space.
Tris Only = only output triangles. Quadrangles are converted to triangles, other polygons are not output.
Quads Only = only output quadrangles. Triangles are converted to degenerate quadrangles (quadrangle with two points at the same location), other polygons are not output.
Tris & Quads = output triangles and quadrangles. Other polygons are not output.
Tri/Quad Degen = output triangles and quadrangles. Degenerate quadrangles (quadrangle with two points at the same location) are converted to triangles, other polygons are not output.
N-sided = output all polygons. Note that textures on polygons with fewer than 3 or more than 4 sides are not useful.
Clockwise = use clockwise (left-handed) orientation to decide which side of a polygon is the front.
Counter-Clockwise = use counter-clockwise (right-handed) orientation to decide which side of a polygon is the front.
output quadrangle vertices in triangle strip format.
Triangle strips can fix problems arising from non-planar quadrangles. This option can be useful to bring geometry into a GL/OpenGL program that uses triangle strips.
This option is not used when the Geometry Mode is Tris Only or N-sided.
output a list of vertex normals for each object, with indexes for each polygon in the object.
output a list of texture coordinates for each object, with indexes for each polygon in the object.
output normals for each polygon.
output a list of vertex colors for each object, with indexes for each polygon in the object.
do not output redundant vertices or normals.
output graphics files containing the texture images.
standard format to save texture information in.
default resolution for all textures. Maximum value is 256 in both directions.
Texture per Shader = output a texture for each shader. A texture is generated for each shader that is assigned to polygons and has a texture or other mapping.
Texture per Polygon = output a texture for each polygon. A texture is generated for each polygon with a shader that has a texture or other mapping. Textures are automatically distorted for irregular quadrangles and triangles.
Color Only = use flat color only (do not output textures).
If Texture per Shader or Texture per Polygon are selected, but a shader does not use textures or mapping (a simple color shader), the translator will output a color value instead of a texture.
Use Shader Name = encode a texture's resolution information as part of the shader name.
Use Polyset Name = encode a texture's resolution information as part of the polyset name.
NONE = use the default X and Y resolutions (above) for all textures.
See Encoding Texture Resolutions on page 104.
modify the colors of objects to simulate a simple light model (parallel light with some ambient).
output index counters at the beginning of each list entry. Index counters start at 0 for the first entry of a list and increase with each entry in that list.
number of decimal places to include for numbers. (maximum of 10).
DOS = use DOS/Windows standard character marker (carriage return + linefeed) for end-of-line.
UNIX = use UNIX standard character marker (linefeed) for end-of-line.
output the conversion settings (since RTG output is so flexible, it is extremely helpful when decoding to know the settings a file was converted with).
per Polygon = print a progress message for each polygon during conversion.
per Polyset = print a progress message for each polyset during conversion.
Almost None = do not print progress messages during conversion.
start/end frame of animation (output separate files for each frame of animation).
RTG uses a hack to include the resolution of textures in the file:
To encode a texture resolution in a shader name:
x<xres>y<yres><shadername>
For example, for a shader named GoblinNose, and a texture with resolution 64 by 128, type x64y128goblinNose in the name text box.
To encode a texture resolution in a polyset name:
x<xres>y<yres><polysetname>
For example, for a polyset named GoblinNose, and a texture with resolution 64 by 128, type x64y128goblinNose in the name text box.
For details on the .rtg and .bin file formats see RTG File Format Details on page 108.
To convert scenes to RTG 2.0 (which integrates animation information into the main format), use MakeGame and the RTG2.0 Direct Translator. |
See Installing the MakeGame Plug-in on page 6 and RTG 2.0 Translator on page 98. |
The rtgAnim utility and file format were created to supplement the RTG 1.8 format with animation information.
rtgAnim outputs an ASCII representation of the animation for each animated transformation, vertex group, and polyset. The utility outputs the following information:
rtgAnim is in $ALIAS_LOCATION/ODS/Games/bin/. It supports the following command line options:
rtgAnim -i <inputfile> -o <outputfile> [-l] [-s <startframe>] [-e <endframe>] [-b <byframe>] [-y] [-z]
These files contain the animation data for objects in the scene:
The contents of an rtgAnim node file look like this:
0001.0: X_Rotate 1.58 Y_Rotate 0.928 Z_Rotate 0.972
0003.0: X_Rotate 4.74 Y_Rotate 2.784 Z_Rotate 2.916
0005.0: X_Rotate 7.9 Y_Rotate 4.64 Z_Rotate 4.86
0007.0: X_Rotate 11.06 Y_Rotate 6.496 Z_Rotate 6.804
0009.0: X_Rotate 14.22 Y_Rotate 8.352 Z_Rotate 8.748
This is a sample of frames 1 through 9, by two. Only the rotations were animated in the model, so they are the only transformations output.
For cluster animation, the fields are in world coodinates. For all other types of animation (including keyframed vertices), the coordinates are in object space. |
The contents of an rtgAnim vertex file might like this:
0001.0: X_Translate -0.806515 Y_Translate 0
0002.0: X_Translate -0.457943 Y_Translate 1
0003.0: X_Translate -0.10937 Y_Translate 2
This is a sample of frames 1 through 3.
For polysets animated with clusters, the world positions per vertex per frame are output, since it is difficult to work in object space with clusters. |
The following describes the Alias|Wavefront Real Time Games Format (v1.0). Running the wire2rtg converter generates an ASCII text .rtg file, and possibly a .bin file (if textures have been assigned to polygonal geometry in PowerAnimator). The .rtg file contains polygonal data with possible hierarchy information and possible texture table data. The .bin file contains a byte oriented RGBA pixel dump of all textures generated for its corresponding .rtg file.
The .rtg file contains various tags including title tags, to denote sections of data, and descriptor tags, which are used for visual reference and can be ignored when parsing the file.
The polygonal data (hereafter referred to as P-data) file begins with a number of header lines (currently there are 3 header lines).
These header lines contain general information for the file. So far, only the title, version, and date information header lines are generated.
All header lines begin with tags starting with HEADER_. The following is an example of these lines:
HEADER_TITLE Alias|Wavefront Real Time Games Output
HEADER_VERSION v1.0
HEADER_DATE Tue Aug 15 21:58:15 1995 (RTG 1.8 only)
Counters for the P-data file appear after the header lines. Currently there is only one counter. This is for the number of objects that exist in the file. All counter info lines will begin with tags starting with NUMBER_OF_. For example:
NUMBER_OF_OBJECTS 4
If there are any flags for the P-data file, they appear after the counter information. These indicate whether or not a particular item(s) will be found in the file.
For example, the flag info line OUTPUT_HIERARCHY on indicates that a hierarchy tree will be found in the file. This version contains flags for:
Indicates if a NORMAL list for vertex normals is included in this file or not.
Indicates if a COLOR list for vertex colors is included in the file or not.
Indicates if a TEXCOORD list for vertex texture coordinates is included in this file or not.
Indicates if Normals for each polygon will be output on a polygon data line or not.
Indicates if a hierarchy tree is included in this file or not.
Indicates if materials are included in this file.
Indicates if animation data is included in this file.
Indicates whether or not index counters (sort of like line numbers for each list - starting at 0) are included in this file.
This is an example of a Flags info section:
OUTPUT_VERT_NORMS on
OUTPUT_VERT_COLORS on
OUTPUT_TEX_COORDS on
OUTPUT_POLY_NORMS on
OUTPUT_HIERARCHY on
SHOW_INDEX_COUNTERS on
OUTPUT_MATERIALS on
OUTPUT_ANIMATION on
The Selections Info section follows the Flag info section. It contains various modes that had been selected when this file was generated.
Currently there is only one selection line:TEXTURE_MODE. Valid modes (modes that are currently supported) are color, per_shader, or per_polygon.
If color mode is indicated, only RGB color assignments are made to polygons and no textures are generated for this file.
If per_shader is indicated, a texture for each used shader is assigned to polygons, with texture coordinates needed for proper texture mapping.
If per_polygon is indicated, a correctly pre-distorted texture swatch is generated for each polygon, with texture coordinates being pretty much meaningless as these textures effectively map directly to the corners of each polygon.
The material list contains a list of all materials used in the model. The MATERIAL_LIST line contains a count of the number of materials. Each material is named and has an index which is used in the OBJECTS section to reference the materials. The following is an example:
MATERIAL_LIST 2
MATERIAL 0
NAME Shader
AMBIENT 0.000000 0.585938 0.996094
DIFFUSE 0.000000 0.468750 0.796875
SPECULAR 0.000000 0.000000 0.000000
EMMISION 0.000000 0.000000 0.000000
SHININESS 0.000000
TRANSPARENCY 0.000000
TEXTURE_NAME File#10
FILENAME color file /usr/u/psantan/user_data/demo/pix/small.rgb
MATERIAL 1
NAME DefaultShader
AMBIENT 0.000000 0.585938 0.996094
DIFFUSE 0.000000 0.468750 0.796875
SPECULAR 0.000000 0.000000 0.000000
EMMISION 0.000000 0.000000 0.000000
SHININESS 0.000000
TRANSPARENCY 0.000000
END_MATERIAL_LIST
This is the location in RTG 2.0 that enables you to find texture maps. |
A Hierarchy list only exists in the file if the OUTPUT_HIERARCHY flag is set ON. Otherwise, parsing should continue with the OBJECT Data as described in the following.
The first line of a hierarchy list begins with the tag HIERARCHY_LIST. There are three tags that follow this on the first line.
The first of these is the Info Level Tag. This tag can be H (Hierarchy only), HX (Hierarchy with Xforms), or HXP (Hierarchy with Xforms and Pivots.
A count for the number of top level dag nodes in the hierarchy list, and a descriptor tag top_level that can be read and ignored follows the Info Level Tag.
After the first line, the hierarchy is output with node lines, and possibly transform lines and pivot lines.
[level] [node_type] [node_name]
where level is an integer number indicating hierarchy level. A top dag node is at level 0.
The node_type is either G (Group) or P (polygonal) Data.
The node_name is a string name used to individually identify a node.
If Hierarchy List is selected, transforms with or without pivots can be output for each node line of the hierarchy. Transform lines are (x,y,z) triplets, one for each of translate, rotate and scale. Pivot lines are (x,y,z) triplets, one for each of scale and rotate.
An example of hierarchy list output without transforms or pivots:
HIERARCHY_LIST H 2 top_level
0 G node#27
1 G node#26
2 G node#25
3 P x16y16end
3 P x24y32box
0 G node#28
1 P x8y8sphere3
1 P x22y18sphere2
END_HIERARCHY_LIST
The same example of hierarchy list output but with transforms and no pivots:
HIERARCHY_LIST HX 2 top_level
0 G node#27
tran: 0.0000 0.0000 0.0000
rot: 0.0000 0.0000 0.0000
scal: 1.0000 1.0000 1.0000
1 G node#26
tran: 0.0000 0.0000 0.0000
rot: 0.0000 0.0000 0.0000
scal: 1.0000 1.0000 1.0000
2 G node#25
tran: 0.0000 0.0000 0.0000
rot: 0.0000 0.0000 0.0000
scal: 1.0000 1.0000 1.0000
3 P x16y16end
tran: 0.0000 0.0000 0.0000
rot: 0.0000 0.0000 0.0000
scal: 1.0000 1.0000 1.0000
3 P x24y32box
tran: 0.0000 0.0000 0.0000
rot: 0.0000 0.0000 0.0000
scal: 1.0000 1.0000 1.0000
0 G node#4
tran: -5.9248 -0.2723 0.0000
rot: 0.0000 0.0000 0.0000
scal: 1.0000 1.0000 1.0000
1 P x8y8sphere3
tran: 9.6807 0.0000 0.0000
rot: 0.0000 0.0000 0.0000
scal: 0.6858 0.6858 0.6858
1 P x22y18sphere2
tran: 0.0000 0.0000 0.0000
rot: 0.0000 0.0000 0.0000
scal: 1.0000 1.0000 1.0000
END_HIERARCHY_LIST
The same example of hierarchy list output but with both transforms and pivots:
HIERARCHY_LIST HXP 2 top_level
0 G node#27
tran: 0.0000 0.0000 0.0000
rot: 0.0000 0.0000 0.0000
scal: 1.0000 1.0000 1.0000
sPiv: 0.0000 0.0000 0.0000
rPiv: 0.0000 0.0000 0.0000
1 G node#26
tran: 0.0000 0.0000 0.0000
rot: 0.0000 0.0000 0.0000
scal: 1.0000 1.0000 1.0000
sPiv: 0.0000 0.0000 0.0000
rPiv: 0.0000 0.0000 0.0000
2 G node#25
tran: 0.0000 0.0000 0.0000
rot: 0.0000 0.0000 0.0000
scal: 1.0000 1.0000 1.0000
sPiv: 0.0000 0.0000 0.0000
rPiv: 0.0000 0.0000 0.0000
3 P x16y16end
tran: 0.0000 0.0000 0.0000
rot: 0.0000 0.0000 0.0000
scal: 1.0000 1.0000 1.0000
sPiv: 0.0000 0.0000 0.0000
rPiv: 0.0000 0.0000 0.0000
3 P x24y32box
tran: 0.0000 0.0000 0.0000
rot: 0.0000 0.0000 0.0000
scal: 1.0000 1.0000 1.0000
sPiv: 0.0000 0.0000 0.0000
rPiv: 0.0000 0.0000 0.0000
0 G node#4
tran: -5.9248 -0.2723 0.0000
rot: 0.0000 0.0000 0.0000
scal: 1.0000 1.0000 1.0000
sPiv: -5.9248 -0.2723 0.0000
rPiv: -5.9248 -0.2723 0.0000
1 P x8y8sphere3
tran: 9.6807 0.0000 0.0000
rot: 0.0000 0.0000 0.0000
scal: 0.6858 0.6858 0.6858
sPiv: 3.7558 -0.2723 0.0000
rPiv: 3.7558 -0.2723 0.0000
1 P x22y18sphere2
tran: 0.0000 0.0000 0.0000
rot: 0.0000 0.0000 0.0000
scal: 1.0000 1.0000 1.0000
sPiv: -5.9248 -0.2723 0.0000
rPiv: -5.9248 -0.2723 0.0000
END_HIERARCHY_LIST
The hierarchy list ends with the tag END_HIERARCHY_LIST to indicate the end of hierarchy processing.
There are a number of Object sections, one for each object in the file, as indicated by the NUMBER_OF_OBJECTS info line.
An Object section begins with an object start line. This line starts with an OBJECT_START tag and is followed by the name of the object and counter tags. Each counter tag has a letter prefix (to denote what the counter is for) with a number (how many items of that type there are) appended to it.
The letter v is for vertices, n for vertex normals, t for texture coordinates, and p for polygons. These counters are in the order of:
regardless of whether or not some the counters are omitted.
OBJECT_START sphere v26 n45 t45 p32
indicates that the object sphere contains a VERTEX list of 26 vertex positions, a NORMAL list of 45 vertex normal values, a TEXCOORD list of 45 texture (u,v) coordinate values, and a POLYGON list of 32 polygon data entries.
If the OUTPUT_VERT_NORMS flag is off (meaning the output of vertex normals has been omitted) then the n counter, (n45 in the above example), is omitted from the object start line. |
Also, if the OUTPUT_TEX_COORDS flag is off (meaning the output of texture coordinates has been omitted) then the t counter, (t45 in the above example), is omitted from the object start line. |
The USES_MATERIAL tag indicates which material (if materials are being output) is used for this object. It is followed by the index of the material and the name:
USES_MATERIAL 0 Shader
The VERTEX list follows the OBJECT_START line. It begins with a line containing the VERTEX tag along with a coordinate space tag. This second tag is either local or world to indicate whether the position of the vertex is output in local (object) space or in world space. A list of vertex positions specified in X Y Z order (one vertex position per line) follows. If the SHOW_INDEX_COUNTERS flag is on, each vertex line is prefixed with an index number starting at 0 and incrementing by one for each vertex line in the list.
The vertex COLOR list follows the VERTEX list. It begins with a line containing the COLOR tag. A list of the vertex color values then follows.
The vertex NORMAL list follows the VERTEX list. It begins with a line containing the NORMAL tag. A list of vertex normal values specified in X Y Z order (one vertex normal per line) then follows.
If the SHOW_INDEX_COUNTERS flag is on, each vertex normal line is prefixed with an index number starting at 0 and incrementing by one for each vertex normal in the list.
If the OUTPUT_VERT_NORMS flag is off (meaning the output of vertex normals has been omitted), a NORMAL list will not be found after the VERTEX list. |
The following list is the texture coordinate (TEXCOORD) list. It begins with a line containing the TEXCOORD tag. A list of vertex texture coordinate (u,v) values specified in U V order (one texture coordinate pair per line) then follows. If the SHOW_INDEX_COUNTERS flag is on, each line is prefixed with an index number starting at 0 and incrementing by one for each line in the list.
If the OUTPUT_TEX_COORDS flag is off (meaning the output of vertex texture coordinates has been omitted) then a TEXCOORD list will not be found here. |
The next list within an object section is the polygon list for that object. This begins with a line containing only the POLYGON list tag. A list of polygon data lines (one line/entry for each polygon in the object) then follows containing the following data:
(RTG 1.8 only) A polygon will only have either the texture_index OR an rgb_color assignment. The tags v, n, t, N, T, and C exist to identify the data that follows them. These are omitted from the output if their corresponding data is also omitted. |
The object data ends with a line containing the OBJECT_END and the name of the object as it appeared on the object start line.
The texture table starts with a line containing the TEXTURE_TABLE tag along with the name of the associated texture file (.bin), an entry count, the entries descriptor tag, the header descriptor tag, the number of bytes in the header of the .bin file, and finally the bytes descriptor tag.
Following the first line are the texture entries. Each texture entry line is of the format:
[index] [pixel_format] [X_res] [Y_res] [source_shader] [byte_size]
The texture table ends with a line containing the END_TEXTURE_TABLE and the name of the associated texture file (.bin) as it appeared on the texture table start line.
The index counter on each entry is omitted if the SHOW_INDEX_COUNTERS flag is off. |
The following is an example of the TEXTURE_TABLE format:
TEXTURE_TABLE wackyB1.bin 3 entries (header: 82 bytes) 0 RGBA 32 32 Shader#2 4096 1 RGBA 32 32 Shader 4096 2 RGBA 32 32 Shader#4 4096 END_TEXTURE_TABLE wackyB1.bin
The following is an example of the TEXTURE_TABLE format using the encoded texture resolutions option on shader names:
TEXTURE_TABLE wackyB1.bin 3 entries (header: 82 bytes)
0 RGBA 32 32 Shader#2 4096
1 RGBA 32 32 Shader 4096
2 RGBA 32 32 Shader#4 4096
END_TEXTURE_TABLE wackyB1.bin
The header of the texture file contains a text title, a version tag, and time and date creation information. This header string is NOT null terminated.
Use the header byte count found in the texture table start line to determine how many bytes to read to clear the header. The version tag is preceded by a ver descriptor tag and the time and date info is preceded by a date descriptor tag.
The header should be parsed to get the version tag and the date in order to verify the texture file against the P-data file. |
After the header, any textures generated for the corresponding polygonal data file is dumped pixel by pixel into this file. Each pixel is separated into 4 bytes one for each of R, G, B and A, and written out to this file in that order. Values for each of RGB and A range from 0 to 255. Pixel values are output starting from the bottom-left (texture coord 0,0) and are output moving left to right and bottom to top.
RTG 2.0 differs from previous versions of RTG in that it is capable of creating a single file that contains both model and animation data. The RTG 2.0 animation data starts with the tag ANIMATION_LIST, and ends with END_ANIMATION_LIST. Between those two are a sequence of FRAME records and within each frame record is a list of all of the objects that are animated and what their transforms are.
The format of the transformation data is as per the hierarchy section. The following is an example of a three frame animation of two objects.
ANIMATION_LIST
FRAME 1
OBJECT sphere#2
tran: -2.000000 6.000000 0.000000
rot: 0.000000 0.000000 0.000000
scal: 1.000000 1.000000 1.000000
sPiv: -2.000000 6.000000 0.000000
rPiv: -2.000000 6.000000 0.000000
OBJECT sphere
tran: -2.000000 -4.000000 0.000000
rot: 0.000000 0.000000 0.000000
scal: 1.125168 1.125168 1.125168
sPiv: -2.000000 -4.000000 0.000000
rPiv: -2.000000 -4.000000 0.000000
FRAME 2
OBJECT sphere#2
tran: -2.000000 6.000000 0.000000
rot: 3.827586 0.000000 0.000000
scal: 1.000000 1.000000 1.000000
sPiv: -2.000000 6.000000 0.000000
rPiv: -2.000000 6.000000 0.000000
OBJECT sphere
tran: -2.000000 -4.000000 0.000000
rot: 0.000000 0.000000 0.000000
scal: 1.250335 1.250335 1.250335
sPiv: -2.000000 -4.000000 0.000000
rPiv: -2.000000 -4.000000 0.000000
FRAME 3
OBJECT sphere#2
tran: -2.000000 6.000000 0.000000
rot: 7.655172 0.000000 0.000000
scal: 1.000000 1.000000 1.000000
sPiv: -2.000000 6.000000 0.000000
rPiv: -2.000000 6.000000 0.000000
OBJECT sphere
tran: -2.000000 -4.000000 0.000000
rot: 0.000000 0.000000 0.000000
scal: 1.375503 1.375503 1.375503
sPiv: -2.000000 -4.000000 0.000000
rPiv: -2.000000 -4.000000 0.000000
END_ANIMATION_LIST