|
GLASS object file specificationIndex
GLASS objects are stored in plaintext files, using the following format.
GLASS would read this as three words, `foo', followed by `bar', and `foo bar'. Comments are started by the hash character (#), and a terminated by the next newline. Comments are completely ignored by GLASS. For example:
GLASS would read this as:
nameThe name of this GLASS object. Followed by a string. Default is "". Optional.versionThe version of GLASS this object is designed for. Followed by a string. Example "1.0.0". If the version of GLASS that is loading the object differs from this, a warning is emitted. Optional.beginBegins a component of a GLASS object. Followed by a string that can be (case sensitive):endEnds the last GLASS component. (see above). Each begin must be followed by an end.Components of a GLASS objectThere are 7 component types in a GLASS object, which are defined between a begin/end pair. These are:TexturesTextures are used to load RGB image files and use them as (openGL) textures. The texture component has two fields, these are:nameThe name of the texture, must be unique. Required.imageThis field is the path of a RGB image file relative to the GLASS object file. Required.An example of a texture component is:
This defines a new texture with the name "marble texture", that uses the image file
"marble.rgb" which is found in the the subdirectory "textures/" which is in the directory
the GLASS object is in.
nameDefines the name of the material. Must be unique. Required.textureThe name of a texture component. If the material has this field, then a texture will be used by triangles that use this material. Optional.ambientThe ambient reflectance of the material. Followed by four floating point values that define the ambient RGBA reflectance. If unused, the material has an ambient reflectance of (0.2, 0.2, 0.2, 1.0). Optional.diffuseThe diffuse reflectance of the material. Followed by four floating point values that define the diffuse RGBA reflectance. If unused, the material has an diffuse reflectance of (0.8, 0.8, 0.8, 1.0). OptionalspecularThe specular reflectance of the material. Followed by four floating point values that define the specular RGBA reflectance. If unused, the material has an specular reflectance of (0.0, 0.0, 0.0, 1.0). OptionalemissionThe emitted light intensity of the material. Followed by four floating point values that define the RGBA emitted intensity. If unused, the material has an emission of (0.0, 0.0, 0.0, 1.0). OptionalshininessFollowed by a singe floating point value that defines the RGBA specular exponent of the material. If unused, material has a shininess of 0.0. OptionalAn example of a material is:
Triangle ListsA triangle list defines a solid piece of the GLASS object. It has one field, its name, and a list of triangles.nameThe name of the triangle list. Must be unique. Required.TrianglesTriangles are defined between braces ({, }). A triangle has six fields. These are:materialThe name of a material component used by this triangle. OptionalposThe position of a vertex in the triangle. It is followed by an integer value that defines which vertex this is changing (0-2), and three floating point values that define the position of that vertex. The default position is (0.0, 0.0, 0.0). Optional (but highly recommended!).colThe colour of a vertex in the triangle. It is followed by an integer value that defines which vertex this is changing (0-2), and three floating point values that define the RGB colour of that vertex. The colour field is only used when lighting is disabled. The default colour is (1.0, 1.0, 1.0). OptionalalphaThe alpha colour component of a vertex in the triangle. It is followed by an integer value that defines which vertex this is changing (0-2), and a floating point value that define the alpha colour of that vertex. The alpha field is only used when lighting is disabled. The default alpha component is 0.0. Optional.norThe normal of a vertex in the triangle. It is followed by an integer value that defines which vertex this is changing (0-2), and three floating point values that define the normal of that vertex. The normal field is only used when lighting is enabled. The default value is (0.0, 0.0, 1.0). OptionaltexThe texture co-ordinate of a vertex in the triangle. It is followed by an integer value that defines which vertex this is changing (0-2), and two floating point values that define the 2D texture co-ordinate of that vertex. The texture co-ordinate field is only useful if the triangles material has a texture, and texturing is enabled. The default value is (0.0, 0.0). Optional.An example of a triangle list is:
This defines a multi-coloured tetrahedron, that when lit has the material "blue marble".
nameThe name of the variable. Must be unique. Required.valueThe current value of the variable. Followed by a floating point value that defines this value. Default value is 0.0. Optional.minThe minimum value the variable can take. Followed by a floating point value that defines this minimum. Default value is 0.0. Optional.maxThe maximum value the variable can take. Followed by a floating point value that defines this maximum. Default value is 1.0. Optional.An example of a variable is:
Active PointsActive points give feedback from the current shape of the GLASS object. They have two fields.nameThe name of the active point. Must be unique. Required.initial_dirThe initial direction that the active point points to. Followed by three floating point values that define the initial direction of the active point. Default value is (1.0, 0.0, 0.0). Optional.An example of an active point is:
ComponentsThe components in a GLASS object make up the way the triangle lists connect together. Components have six fields.indexEach component needs a unique integer to link them together. Followed by one integer value. The component with the index of zero is the root component (unless a structure is defined), and the others are attached to it. Required.next_indexThe index of a sibling component of the current component. Followed by a single integer that is a valid index of a component. A sibling component will inherit nothing from the current component, but shares the same parent as the current component. Only required if a structure is not used. Optional.child_indexThe index of a child component of the current component. Followed by a single integer that is a valid index of a component. A child component inherits any transforms that are performed by the current component. Only required if a structure is not used. Optional.transformThis defines the type, and parameters of an openGL basic transform. Followed by n parameters, that can be either constants, or variables. The first word after transform is the transform type (case sensitive). It can be one of:The type is followed by n parameters, which can be a floating point constant, or a variable. Variables are used by adding "V::" to the front of the variables name. Examples of transforms are:
listThe name of a triangle list. Followed by a valid name of a triangle list. When this component is drawn, that triangle list will be drawn. Optional.active_pointThe name of an active point. Followed by a valid name of an active point. This active point will calculate the current position and direction of the (initial) vector (0.0, 0.0, 0.0), after the transform in this component has been completed. Optional.An example of two components are:
StructureThe structure makes a convenient way of defining how components link together by hand. While the next_index, and child_index fields can be used with components, a structure allows you to draw the shape of the tree so you can see what you're doing.To draw the structure, convert the indices of the components to three character numbers, for example the index 21 would go to 021. Start by writing the index of the root component. If the root has a child, its index would go directly below it. If the root has a sibling, its index would be written to the right of the root index, with 8n-3 dashes (-), between them. (n is the number of rows across you want this index). Continue to do this for each component, building up the tree of how the components link together. This is perhaps hard to explain, but easy to do in practice (see the below examples). An example of a structure is:
This shows that component 000 (index=0), is the root component, and component 001 (index=1), is a child of this component. An example of a more complicated structure is:
As you can see, this way is easier to do by hand, as you can see the "big picture" as
you link the components together. If you had used the next_index, and
child_index fields, you would be more likely to make a mistake.
The finished object:
About this documentIf you think that parts of this document could be explained better, and you are able to do so, then please email me with improvements. If you make a GLASS object, consider adding it to an archive of them (under a suitable free license), by mailing it to me. All (and any) feedback is welcome.Robert Cleaver Ancell Last modified: Fri Jun 29 17:44:47 NZST 2001 |