/* pattern.h  (Steve Hill)  1.1  3/9/90$ */

/* pattern.h
 *
 * Header for pattern.c.
 *
 * Contains the definition of pattern type.
 */

/* pattern_t
 *
 * Patterns give solids varying surface properties, so they encompass
 * both texture and colour.
 *
 * The structure contains information used by the function to
 * control the pattern.
 *
 * The transform matrix is the inverse of the composition of any
 * transformations that have been applied to the solid.  It is used
 * to transform the supplied point so that it is relative to the origin.
 * All patterns are specified relative to the origin.
 */

typedef enum
{
	CHEQUERED,
	LAYERED,
	BITMAP
}
description_sort_t;

typedef struct chequered_s
{
	real_t		x_res, y_res, z_res;
	surface_t	*surface1, *surface2;
}
chequered_t;

#define ChequeredNull	((chequered_t *) NULL)

typedef struct layered_s
{
	real_t		res;
	axis_t		axis;
	surface_t	*surface1, *surface2;
}
layered_t;

#define LayeredNull	((layered_t *) NULL)

typedef union description_union_u
{
	chequered_t	*chequered;
	layered_t	*layered;
	bitmap_t	*bitmap;
}
description_union_t;

typedef struct description_s
{
	description_sort_t	sort;
	description_union_t	body;
}
description_t;

#define DescriptionNull	((description_t *) NULL)

typedef struct pattern_s
{
	description_t	*description;
	void		(*function)();
	matrix_t	*matrix;
	point_t		*point;
}
pattern_t;

#define PatternNull	((pattern_t *) NULL)

pattern_t	*Pattern PROTO((description_t *, void (*)())),
		*PatternCopy PROTO((pattern_t *)),
		*PatternTransform PROTO((pattern_t *, matrix_t *));

description_t	*Description PROTO((description_sort_t, address_t)),
		*DescriptionCopy PROTO((description_t *));


chequered_t	*Chequered PROTO((real_t, real_t, real_t, surface_t *, surface_t *)),
		*ChequeredCopy PROTO((chequered_t *));

layered_t	*Layered PROTO((real_t, axis_t, surface_t *, surface_t *)),
		*LayeredCopy PROTO((layered_t *));

void		PatternFree PROTO((pattern_t *)),
		PatternPrint PROTO((FILE *, pattern_t *)),
		DescriptionFree PROTO((description_t *)),
		DescriptionPrint PROTO((FILE *, description_t *)),
		ChequeredFree PROTO((chequered_t *)),
		LayeredFree PROTO((layered_t *));
