[SESI logo]

Prisms Development Toolkit Documentation

Side Effects Software Inc. 1997

Prisms Internal Formats

1. Concepts

Prisms is a polygon-based product. There is no support for primitive object types such as spheres and cones, nor for procedural geometries such as NURBS.

Everything in Prisms is a polygon, and every polygon is a list of vertices. Vertices, in turn, reference points, and points may have attributes such as color, texture UV, and normals.

This data is organized as doubly-linked lists of various kinds of structures. At the top level is a thing called a Poly Detail. A Poly Detail is a collection of polygons into a group. This is not the same thing as an action object - there is no direct storage of Prisms objects as such.

Abstractly, the data structures look like the following:

Each Poly Detail points to a list of Polygons (which may be null). Each Polygon list is doubly linked.

Each Polygon points to a list of vertices, also doubly linked. Each vertex points to a point, which is a position in 3D space. Thus a point can be shared by more than one vertex.

Points vs. Vertices

A point is a 3D "place in space", and may be shared by many vertices. A vertex is a reference to a point, and is always unique. Vertices are used to enumerate the boundaries of polygons.

For example, if each of the 3 triangles above meets in the same place in 3D space (circled), then there would be only one point for that location. Then each triangle would have a vertex which references the same point.

It is also possible for each vertex to reference a unique version of the point, even though the points coincide in space. This would happen if the points were meant to be different colors, for example.

To sum up: the vertices of a primitive are always unique, while the points they reference may be shared between one or more polygons.

2. Programming Details

In programming terms, the structures look like this (this is include/poly.h):

typedef
struct p_point {
    int             flag;	/* Flag for defined bits	 */
    int             num;	/* Number in the linked list	 */
    Point	    pos;	/* Point coordinates		 */
    Txtr            txt;	/* Point texture coordinates	 */
    Color           clr;	/* Point color			 */
    Vector          nml;	/* Point normal			 */
    char           *sparePointer; /* Program dependent data	 */
    struct p_point *next;	/* Forward pointer to next point */
    struct p_point *prev;	/* Back pointer to last point	 */
} PolyPoint, *PolyPointPointer;
   
typedef
struct p_vertex {
    int              flag;	/* Flag for defined bits	  */
    PolyPoint       *ppt;	/* Pointer to the point data	  */
    char            *sparePointer; /* Program dependent data	  */
    struct p_vertex *next;	/* Forward pointer to next vertex */
    struct p_vertex *prev;	/* Back pointer to last vertex	  */
} PolyVertex, *PolyVertexPointer;

typedef
struct p_polygon {
    int               flag;	/* Flag for defined bits	   */
    int		      npts;     /* Number of points in polygon	   */
    PolyVertex       *pvtx;	/* Pointer to the vertex list	   */
    Vector            nml;	/* Polygon normal	  	   */
    Color             clr;	/* Polygon color		   */
    char             *sparePointer; /* Program dependent data	   */
    struct p_polygon *next;	/* Forward pointer to next polygon */
    struct p_polygon *prev;	/* Back pointer to last polygon	   */
} Polygon, *PolygonPointer;

typedef
struct p_detail {
    int               flag;	/* Flag for defined bits	*/
    int               fd;	/* Unix file descriptor		*/
    char             *sparePointer; /* Program dependent data	*/
    int               npts;	/* Number of points in object	*/
    PolyPoint        *ppt;	/* Pointer to points		*/
    int               npolys;	/* Number of polygons in object */
    Polygon          *ppoly;	/* Pointer to polygons		*/
    struct p_detail *next;	/* Fwd pointer to next object	*/
    struct p_detail *prev;	/* Back pointer to last object	*/
} PolyDetail, *PolyDetailPointer;

	Each point has at least an (x,y,z) value, stored in the pos
field. The flag field is used to signal whether the point has normal,
texture and/or color information also. The point number has no specific
meaning internally, and is for reference; but some routines do make use
of it.
	Similarly for polygons, the flag field determines whether the
nml and clr (normal and color) fields have any meaning.

	The definition of Vector, Color, etc are as follows:

typedef struct	{ 
    	float x;		/* 3-D x coordinate	  */
    	float y;		/* 3-D y coordinate	  */
    	float z;		/* 3-D z coordinate	  */
    	float w;		/* Homogeneous coordinate */
} Point, *PointPointer;

typedef	struct	{ 
    	float x;		/* 3-D x component	  */
    	float y;		/* 3-D y component	  */
    	float z;		/* 3-D z component	  */
} Vector, *VectorPointer;

typedef struct {
	float r;		/* Color red	*/
	float g;		/* Color green	*/
	float b;		/* Color blue	*/
	float t;		/* Transparency */
} Color, *ColorPointer;


The flags for polygons and points are set using these constants:
	VERTEX_CLRS 		point colors
	VERTEX_TXT    		texture
	VERTEX_NML 		normal
	POLY_CLRS        	polygon colors
	CLOSED         		polygon is closed


Tookit Overview
Expression Functions | User Functions | Custom SOPs
Prisms Internal Format | Programmer's Reference
Compiling SOPs | Using sopbuild | SOP Routine Reference
Dynamic SOPs | Prisms Types | Macros
Math Routines | Data Routines | Polygon Routines | Winged-edge Routines

Copyright © 1997 Side Effects Software Inc.
477 Richmond Street West, Toronto, Ontario, Canada M5V 3E7