User Tools

Site Tools


SWA Files

The SpeedTree World ASCII (SWA) file format is a text file that contains the names of base trees and the position, orientation, and scale of all instances of each tree in a scene. SWA files are intended to be easy to read and understand and are not necessarily for production (they are ASCII text files after all, not streamlined binary files).

Note: The SWA file format was introduced in version 6.0 to support arbitrary orientation for instances while keeping the STF format unchanged.

SWA File Format

SWA files are ASCII text files that contain a list of each unique tree instance in a given scene. The data stored for each tree are, in order, the SRT filename, and the number of instances of the tree. The position, rotation (in radians), scale, and other data for each instance follows. The following BNF describes the structure of an STF file.

<SWA File>     ::= { <Tree entry> }
<Tree entry>   ::= <Filename> <Instances>
<Filename>     ::= <double quote> { <char> } <double quote>
<Instances>    ::= <unsigned int> { <Placement> }
<Placement>    ::= <Pos> <Up Vector> <Right Vector> <Scale>
<Pos>          ::= <X> <Y> <Z>
<Up Vector>    ::= <X> <Y> <Z>
<Right Vector> ::= <X> <Y> <Z>
<X>            ::= <float>
<Y>            ::= <float>
<Z>            ::= <float>
<Scale>        ::= <float> [1.0 = no scale]

The listing below demonstrates a sample SWA file:

"Agarwood.srt"
1
-40.4579 33.0828 0 0 0 1 1 0 0 1

"Birches/WhiteBirch_RT.srt"
3
-1096.8 -1185.43 42.1044 0.000 0.000 1.000 -0.291 -0.957 0.000 1.50163
-1096.8 889.556 42.1044 0.000 0.000 1.000 -0.291 -0.957 0.000 1.50163
-1096.8 2964.54 42.1044 0.000 0.000 1.000 -0.291 -0.957 0.000 1.50163

Parsing SWA Files

The reference application contains a utility class, CMyPopulate, that provides utility functions for parsing SWA files.