BTG file format: Difference between revisions

Jump to navigation Jump to search
table style, simgear file template
(added SF links. simgear.org down ?)
(table style, simgear file template)
Line 2: Line 2:
These files contain geometry in the form of points, individual triangles, triangle strips and triangle fans.
These files contain geometry in the form of points, individual triangles, triangle strips and triangle fans.


The authoritative source for the format definition is the class <code>[http://www.simgear.org/doxygen/classSGBinObject.html SGBinObject]</code>, which is defined in <code>simgear/io/sg_binobj.{[http://www.simgear.org/doxygen/sg__binobj_8hxx-source.html hxx],[http://www.simgear.org/doxygen/sg__binobj_8cxx-source.html cxx]}</code>.
The authoritative source for the format definition is the class <code>[http://www.simgear.org/doxygen/classSGBinObject.html SGBinObject]</code>, which is defined in:
 
* {{simgear file|simgear/io/sg_binobj.cxx}}
http://sourceforge.net/p/flightgear/simgear/ci/next/tree/simgear/io/sg_binobj.cxx
* {{simgear file|simgear/io/sg_binobj.hxx}}
 
http://sourceforge.net/p/flightgear/simgear/ci/next/tree/simgear/io/sg_binobj.hxx


== General Structure ==
== General Structure ==
Each BTG-File contains a header followed by a variable number of objects.
Each BTG-File contains a header followed by a variable number of objects.
Each object is introduced by a header indicating the type of object, the number of associated properties and the number of elements contained in the object.
Each object is introduced by a header indicating the type of object, the number of associated properties and the number of elements contained in the object.


=== Coordinates ===
=== Coordinates ===
All coordinates in the file (except for texture coordinates) are [[Geographic Coordinate Systems#Cartesian Geocentric Coordinates|cartesian geocentric coordinates]].
All coordinates in the file (except for texture coordinates) are [[Geographic Coordinate Systems#Cartesian Geocentric Coordinates|cartesian geocentric coordinates]].


Line 21: Line 17:
All measurements are in meters.
All measurements are in meters.


=== Texture Coordinates ===
=== Texture Coordinates ==
 
Texture coordinates are used to map textures onto 3D faces.
Texture coordinates are used to map textures onto 3D faces.
For this each corner vertex of a face is associated with the location of the texture pixel to be shown at this corner.
For this each corner vertex of a face is associated with the location of the texture pixel to be shown at this corner.
Line 34: Line 29:


=== Endianness ===
=== Endianness ===
The files are stored in Little Endian, i.e. the least-significant byte is stored first.
The files are stored in Little Endian, i.e. the least-significant byte is stored first.


=== Alignment ===
=== Alignment ===
Some of the structures used in this file format are not properly aligned, i.e. not all fields start at an offset which is a multiple of their size.
Some of the structures used in this file format are not properly aligned, i.e. not all fields start at an offset which is a multiple of their size.
Therefore special care is to be taken when translating these definitions into record types, e.g. C or C++ <code>struct</code>, as the compiler must be instructed not to enforce proper alignment.
Therefore special care is to be taken when translating these definitions into record types, e.g. C or C++ <code>struct</code>, as the compiler must be instructed not to enforce proper alignment.
Line 44: Line 37:
== Header ==
== Header ==


{| border="1"
{| class="wikitable"
|-
|-
! Byte offset
! Byte offset
Line 73: Line 66:
Each object starts by an object header.
Each object starts by an object header.


{| border="1"
{| class="wikitable"
|-
|-
! Byte offset
! Byte offset
Line 94: Line 87:
The object type can be one of the following:
The object type can be one of the following:


{| border="1"
{| class="wikitable"
|-
|-
! Code
! Code
Line 130: Line 123:
The number of properties in this list is given by the '''Number of Object Properties''' field.
The number of properties in this list is given by the '''Number of Object Properties''' field.


{| border="1"
{| class="wikitable"
|-
|-
! Byte offset
! Byte offset
Line 151: Line 144:
The property type can be one of the following (see the object type descriptions for more details):
The property type can be one of the following (see the object type descriptions for more details):


{| border="1"
{| class="wikitable"
|-
|-
! Code
! Code
Line 174: Line 167:
Even though more than one bounding sphere may be stored in such an object, all except for the last one found in the file are ignored.
Even though more than one bounding sphere may be stored in such an object, all except for the last one found in the file are ignored.


{| border="1"
{| class="wikitable"
|-
|-
! Byte offset
! Byte offset
Line 204: Line 197:


=== Vertex List ===
=== Vertex List ===
The Vertex List object contains a list of vertices to be referenced by other geometry primitives.
The Vertex List object contains a list of vertices to be referenced by other geometry primitives.


Line 212: Line 204:
Each of the vertices gets a unique index, starting with 0 for the first vertex found in the file and incrementing by 1 for each further vertex.
Each of the vertices gets a unique index, starting with 0 for the first vertex found in the file and incrementing by 1 for each further vertex.


{| border="1"
{| class="wikitable"
|-
|-
! Byte offset
! Byte offset
Line 229: Line 221:
Each vertex is a triple of single precision floating point values:
Each vertex is a triple of single precision floating point values:


{| border="1"
{| class="wikitable"
|-
|-
! Byte offset
! Byte offset
Line 259: Line 251:
Each of the normals gets a unique index, starting with 0 for the first normal found in the file and incrementing by 1 for each further normal.
Each of the normals gets a unique index, starting with 0 for the first normal found in the file and incrementing by 1 for each further normal.


{| border="1"
{| class="wikitable"
|-
|-
! Byte offset
! Byte offset
Line 276: Line 268:
Each normal is a triple of signed bytes, interpreted as fixed point values:
Each normal is a triple of signed bytes, interpreted as fixed point values:


{| border="1"
{| class="wikitable"
|-
|-
! Byte offset
! Byte offset
Line 306: Line 298:
Each of the coordinates gets a unique index, starting with 0 for the first coordinate found in the file and incrementing by 1 for each further coordinate.
Each of the coordinates gets a unique index, starting with 0 for the first coordinate found in the file and incrementing by 1 for each further coordinate.


{| border="1"
{| class="wikitable"
|-
|-
! Byte offset
! Byte offset
Line 323: Line 315:
Each texture coordinate is a pair of single precision floating point values:
Each texture coordinate is a pair of single precision floating point values:


{| border="1"
{| class="wikitable"
|-
|-
! Byte offset
! Byte offset
Line 349: Line 341:
Each of the colors gets a unique index, starting with 0 for the first color found in the file and incrementing by 1 for each further color.
Each of the colors gets a unique index, starting with 0 for the first color found in the file and incrementing by 1 for each further color.


{| border="1"
{| class="wikitable"
|-
|-
! Byte offset
! Byte offset
Line 366: Line 358:
Each color definition is a 4-tuple of single precision floating point values:
Each color definition is a 4-tuple of single precision floating point values:


{| border="1"
{| class="wikitable"
|-
|-
! Byte offset
! Byte offset
Line 392: Line 384:


=== Geometry Objects ===
=== Geometry Objects ===
All geometry objects are structured the same way, with each element consisting of a list of index-tuples referencing vertex, normal, color and texture coordinate lists.
All geometry objects are structured the same way, with each element consisting of a list of index-tuples referencing vertex, normal, color and texture coordinate lists.


Line 403: Line 394:
The meaning of the bits is given in the following table:
The meaning of the bits is given in the following table:


{| border="1"
{| class="wikitable"
|-
|-
! Bit Number
! Bit Number
Line 439: Line 430:


==== Points ====
==== Points ====
In case of the Points object type, each of the elements represents a single point, e.g. a point lightsource.
In case of the Points object type, each of the elements represents a single point, e.g. a point lightsource.


==== Individual Triangles ====
==== Individual Triangles ====
In case of the Triangle object type, three succeeding elements are combined to form the vertices of a single triangle.
In case of the Triangle object type, three succeeding elements are combined to form the vertices of a single triangle.
The vertices of triangle <code>i</code> (starting with 0 for the first triangle) are given by elements <code>3*i</code>, <code>3*i+1</code> and <code>3*i+2</code>.
The vertices of triangle <code>i</code> (starting with 0 for the first triangle) are given by elements <code>3*i</code>, <code>3*i+1</code> and <code>3*i+2</code>.
Line 455: Line 444:


==== Triangle Fans ====
==== Triangle Fans ====
Triangle Fans are similar to Triangle Strips.
Triangle Fans are similar to Triangle Strips.
However, in case of triangle fans, all triangles share the first element and the other two triangle vertices are provided in pairs of elements, representing a fan of triangles around a single vertex.
However, in case of triangle fans, all triangles share the first element and the other two triangle vertices are provided in pairs of elements, representing a fan of triangles around a single vertex.

Navigation menu