Geom Format

Written by Paul Bourke
July 1999


The "geom" format contains low level geometric primitives, points, lines, facets, etc. The "geom" file consists of a number of lines of printable ascii characters, the first string in each line is the primitive ID. The rest of the line (or lines) contain the data that is different for each primitive. The arguments on each line are separated by any "white" space (fscanf() is my parser). After the last of the required arguments the rest of the current line is considered a comment. At the time of writing the primitives ID's and their required arguments are a follows.

ID Description Arguments Comments
# Comment   Comments must start with a '#' in the first columns, they extend to the end of the line.
s Sphere
center(x,y,z),
radius,
colour(r,g,b)
Spheres should be used sparingly unless the rendering engine explicitly supports them. For example, OpenGL does not and so each sphere becomes a large number of polygons.
st Textured Sphere
center(x,y,z),
radius,
colour(r,g,b),
texturefilename (tga)
 
d Disk vertex(x,y,z),
normal(x,y,z),
inner radius,
outer radius,
colour(r,g,b)
disk
c Cone vertex1(x,y,z),
vertex2(x,y,z),
radius1,
radius2,
colour(r,g,b)
cone
t Text position(x,y,z),
right(x,y,z),
up(x,y,z),
colour(r,g,b),
textstring
The text is drawn from a start position, along the right vector, and in the plane of the right-up vector. The size is determined by the right and up vector lengths.
p Point
vertex(x,y,z),
colour(r,g,b)
 
P Thick Point
vertex(x,y,z),
colour(r,g,b),
size
The size is in pixel coordinates, not world coordinates.
i Illumination
(Point light source)
vertex(x,y,z),
colour(r,g,b)
There may be limitations on the number of light sources allowed, for example, a maximum of 8 for OpenGL based systems.
l Line
vertex1(x,y,z),
vertex2(x,y,z),
colour(r,g,b)
 
L Thick Line
vertex1(x,y,z),
vertex2(x,y,z),
colour(r,g,b),
width
 
lc Coolour Line
vertex1(x,y,z),
vertex2(x,y,z),
colour1(r,g,b)
colour2(r,g,b)
Colour at each end of the line, blended along the line.
f3 3 vertex facet
vertices[3],
colour(r,g,b)
The normal for each vertex is created from the cross product of the three given vertices.
f3
f3n 3 vertex facet
With normals
vertices[3],
normals[3],
colour(r,g,b)
f3n
f3c 3 vertex facet
With and colours
vertices[3],
colour[3]
 
f3nc 3 vertex facet
With normals and colours
vertices[3],
normals[3],
colour[3]
Each vertex has a normal and colour, this is the general primitive for representing "smooth" objects.
f4 4 vertex facet
vertices[4],
colour(r,g,b)
The normal for each vertex is calculated from the cross product of the first 3 vertices. Note that the vertices need not be coplanar but the effects that might occur in such circumstances is undefined. Non planar 4 vertex facets are not recommended.
f4
f4n 4 vertex facet
With normals
vertices[4],
normals[4],
colour(r,g,b)
f4n
f4c 4 vertex facet
With colours
vertices[4],
colour[4]
 
f4nc 4 vertex facet
With normals and colours
vertices[4],
normals[4],
colour[4]
This is the most general 4 vertex facet for representing smooth objects.
f4t 4 vertex facet
With texture
vertices[4],
colour,
texturefilename (tga),
scale,
transparency [o,t]
The colour is only used when the object is displayed in a draft or non texture mode (or if the viewer doesn't support texture). The texture scale is between 0 and 1. 1 is for a clamped textures over the whole plane, otherwise the texture will be scaled and tiled over the polygon. The last argument is a flag for transparent or opaque in which case the colour is used internally to create an opaque mask.
m Marker type
size
vertex
colour
A non oriented symbol. The size is in world coordinates. The current types are:
0 - tetrahedron
1 - 3D plus
2 - cube
3 - octahedron


Example

The objects below are not supposed to look like anything sensible but rather just give an example of a "geom" file.
# Example geom file, this is a comment
l 0 0 0 1 0 0 1 0 0 red x axis
l 0 0 0 0 1 0 0 0.5 0 green y axis
l 0 0 0 0 0 1 0 0 1 blue z axis
s 0 0 0 0.5 1.0 0.5 0.5 ball
f4 -1 -1 -1   1 -1 -1   1 -1  1   -1 -1  1   0.5 0.5 0.5  bottom face of cube
f4 -1  1 -1   1  1 -1   1  1  1   -1  1  1   0.5 0.5 0.5  top face
f4 -1 -1  1  -1 -1 -1  -1  1 -1   -1  1  1   0.5 0.5 0.5  left face
f4  1 -1  1   1 -1 -1   1  1 -1    1  1  1   0.5 0.5 0.5  right face
f4 -1 -1  1   1 -1  1   1  1  1   -1  1  1   0.5 0.5 0.5  front face
f4 -1 -1 -1   1 -1 -1   1  1 -1   -1  1 -1   0.5 0.5 0.5  back face
f4nc -0 -1.3 1.3 -0 -1.2 1.4 0 -1.3 1.3 0 -1.4 1.2 -1 0 0 -1 0 0 -1 -0.03 0.04 -1 -0.03 0.03 1 0 0 1 0.11 0 1 0.11 0 1 0 0 
f3 -67 27 -53 -67 27 -53 -67 27 -53 1 0 0
f3n -67 27 -53 -67 27 -53 -67 27 -53 0.02 -0.9 -0.2 0.9 -0.3 -0.3 0.5 -0.3 -0.8 1 0 0
p 0 0 0 1 0 0