P3D File Format Summary

Also Known As: Pittsburgh Supercomputer Center 3D Metafile


Type 3D scene description
Colors NA
Compression Uncompressed
Maximum Image Size NA
Multiple Images Per File NA
Numerical Format NA
Originator Carnegie Mellon University
Platform All
Supporting Applications P3D
See Also None

Usage
Description and storage of 3D objects.

Comments
A powerful format that implements its own language and provides support for a number of common and useful renderers.

Vendor specifications are available for this format.


P3D is a system that originated at Carnegie Mellon University's Pittsburgh Supercomputing Center, which retains the copyright for the system. The P3D format used by the P3D system was intended for the storage of 3D models and was designed to be portable, flexible, compact, and extensible. The authors wished to create a format that would be compatible with applications, renderers in particular, on a number of platforms.

Contents:
File Organization
File Details
For Further Information

The P3D format implements a sophisticated description language, which consists of a set of extensions to Common Lisp. Perhaps to avoid implementation dependencies, only a subset of Common Lisp, called Alisp, is used. While this can be a boon to developers who already know a Lisp dialect, it provides a barrier to entry to those who don't. As a consequence, the P3D format has not been used much outside academic circles, which is a shame, because it is otherwise a powerful model and a well-thought-out specification.

File Organization

A P3D file consists of a number of ASCII lines that are usually Common Lisp statements. Extensions to the language are mainly in an idiosyncratic terminology that is unfortunately at odds with most of the rest of the computer graphics world.

File Details

A P3D file stores a model, which is a set of objects; these may be geometrical structures or things more like architectural primitives, such as directed acyclic graphs. P3D normally supports the specification of spheres, cylinders, tori, polygons, polylines, polymarkers, lists of triangles, meshes, spline surfaces, font objects, and lighting objects. Various attributes may be associated with objects.

There are also procedural features designed to trigger actions in the application processing a P3D file. An example is the snap function, which can be used to trigger rendering.

A P3D file contains descriptions of one or more graphical objects, called gobs in the documentation. These may be primitive objects, like spheres or triangle lists, or they may consist of numbers of primitive objects. A gob is generally a directed acyclic graph, the nodes of which may be other gobs.

The P3D documentation describes gobs as follows:

Gobs are defined either by invoking a function which returns a primitive gob, or by listing the "children" and possibly the attributes the new gob is to have. A gob can be saved either by binding it to a name (for example, via a Lisp setq function) or by including it directly into the list of children of another gob. Color, material type, and backface cullability are examples of attributes that might be associated with a gob.

There is intrinsic support in P3D for mathematical entities such as vectors, points, and lines, which may be manipulated in an arbitrary fashion. After the initial definition, a gob may be referenced repeatedly. Each reference instance may be associated with attributes and transformations independent of the those inherent in the original definition. It is the programmer's responsibility to make sure that no gob is its own descendant.

Coordinate System

The P3D system assumes a right-hand coordinate system. Coordinate transformations are effected by manipulation with 4x4 matrices as follows:

Rotation:

[ R11 R12 R13 0 ]
[ R21 R22 R23 0 ]
[ R31 R32 R33 0 ]
[  0   0   0  1 ]

Translation:

[  1   0   0  Tx ]
[  0   1   0  Ty ]
[  0   0   1  Tz ]
[  0   0   0  1  ]

Scale:

[ Sx   0   0  0 ]
[  0  Sy   0  0 ]
[  0   0  Sz  0 ]
[  0   0   0  1 ]

Points are defined in the following manner:

(defstruct point
  (x 0.0)    ;x coordinate
  (y 0.0)    ;y coordinate
  (z 0.0))   ;z coordinate

They can also be made with the function make-point, which takes three floating-point arguments (x,y,z) that default to zero.

(setq origin (make-point))

is the definition of the standard symbol "origin."

Vectors are defined as follows:

(defstruct vector
  (x 0.0)    ;x coordinate
  (y 0.0)    ;y coordinate
  (z 0.0))   ;z coordinate

Vectors can also be created through the function make-vector. Thus:

(setq x-vec (make-vector :x 1.0 :y 0.0 :z 0.0))

is the definition of the standard symbol "x-vec."

The structure holding a color is as follows:

(defstruct color
  (r 0.8)    ;red intensity
  (g 0.8)    ;green intensity
  (b 0.8)    ;blue intensity
  (a 1.0))   ;opacity

The color "red," for instance, can be made as follows:

(setq red (make-color :r 1.0 :g 0.0 :b 0.0))

A vertex may be formed in a similar manner:

(defstruct vertex
  (x 0.0)        ;x coordinate
  (y 0.0)        ;y coordinate
  (z 0.0)        ;z coordinate
  (clr nil)      ;local color
  (normal nil))  ;local surface normal

For example:

(setq red-origin (make-vertex :clr red))

creates vertex "red-origin."

Structured Fields

This discussion of structured fields in a P3D file is extracted from the P3D documentation.

The structure used to hold a material (a set of properties used with attributes like color to determine the appearance of an object) is represented as a structure with at least the following fields:

Field

Type

Meaning

:ka

float

Ambient light weighting factor

:kd

float

Diffuse light weighting factor

:ks

float

Specular light weighting factor

:exp

float

Specular exponent

:reflect

float

Reflection coefficient

:refract

float

Index of refraction

:energy

color

Energy density (for radiosity)

Other structure fields may exist, but they are maintained by P3D and should not be modified by the programmer. A material should always be created with the "def-material" function:

( def-material :ka ka-value :kd kd-value :ks ks-value
  :exp exp-value :reflect reflect-value
  :refract refract-value :energy energy-color )

Parameters are listed below:

:ka ka-value optional Ambient light weighting factor
:kd kd-value optional Diffuse light weighting factor
:ks ks-value optional Specular light weighting factor
:exp exp-value optional Specular exponent
:reflect reflect-value optional Reflection coefficient
:refract refract-value optional Index of refraction
:energy energy-color optional Energy density for radiosity

This function returns material with the given characteristics.

All of the keyword-field pairs are optional. Fields that are not specified are assigned specific default values; see the specification for the "default-material" predefined symbol at the end of this document for the default values of each field.

Cameras

Cameras are defined as follows:

(defstruct camera
  (lookfrom origin)       ;eye point
  (lookat origin)         ;point to look at
  (up y-vec)              ;view's 'up' direction
  (fovea 56.0)            ;view included angle
  (hither -0.01)          ;hither clipping distance
  (yon -100.0)            ;yon clipping distance
  (background black))     ;background color

Gob Structures

A gob is represented as a structure with at least the following options:

Option

Type

Meaning

:attr

assoc-list

Attribute-value pairs for this gob

:transform

transformation

Coordinate transformation

:children

list

List of gobs to be children

Other structure slots may exist, but they are maintained by P3D and should not be modified by the programmer. All of the fields default to nil.

A gob should always be created with "def-gob," or with one of the geometrical primitive generators (see below). If "def-gob" is used, the definition should include a ":children" option or the gob will have no descendants in the DAG and thus be useless.

( def-gob :attr attrlist
  :transform transformation
  :children childlist )

Parameters are the following:

:children childlist

required

List of children of this gob

:transform transformation

optional

Coordinate transformation for this gob

:attr attrlist

optional

Association list of attribute and value pairs for this gob

This function returns a gob with the given children, coordinate transformation, and attributes.

For Further Information

For further information about the P3D format, see the P3D specification on the CD-ROM. For up-to-date P3D documentation, see:

http://pscinfo.psc.edu/general/software/packages/p3d/p3d.html
http://pscinfo.psc.edu/general/software/categories/graphics.html

You can obtain P3D generators and translators via FTP from:

ftp://ftp.psc.edu/pub/p3d/

You can also contact:

Joel Welling
Pittsburgh Supercomputer Center
4400 Fifth Avenue
Pittsburgh, PA 15213
Email: [email protected]


This page is taken from the Encyclopedia of Graphics File Formats and is licensed by O'Reilly under the Creative Common/Attribution license.

More Resources