/*
	name:	typedef.h

	Type-defenitions
	----------------

	These defenitions are convenient for handling rays, objects etc.


    This source-code is part of the RayLab 1.1 package, and it is provided
    for your compiling pleasure.  You may use it, change it, re-compile it
    etc., as long as nobody else but you receive the changes/compilations
    that you have made!

    You may not use any part(s) of this source-code for your own productions
    without the permission from the author of RayLab. Please read the legal
    information found in the users documentation for RayLab for more details.

*/


typedef struct Point_Struct POINT;
typedef struct UVCoord_Struct UVCOORD;
typedef struct Vector_Struct VECTOR;
typedef struct TransformEntry_Struct TRANSFENTRY;
typedef struct Transform_Struct TRANSFORM;
typedef struct Texture_Struct TEXTURE;
typedef struct Color_Struct COLOR;
typedef struct ColorMap_Struct COLORMAP;
typedef struct Line_Struct LINE;
typedef struct Plane_Struct PLANE;
typedef struct Sphere_Struct SPHERE;
typedef struct Ellipsoid_Struct ELLIPSOID;
typedef struct Triangle_Struct TRIANGLE;
typedef struct TriangleList_Struct TRIANGLELIST;
typedef struct Box_Struct BOX;
typedef struct Disc_Struct DISC;
typedef struct Cylinder_Struct CYLINDER;
typedef struct Cone_Struct CONE;
typedef struct CSG_Struct CSG;
typedef struct Torus_Struct TORUS;
typedef struct Peak_Struct PEAK;
typedef struct Deoflaska_Struct DEOFLASKA;
typedef struct Light_Struct LIGHT;
typedef struct Camera_Struct CAMERA;
typedef struct Object_Struct OBJECT;
typedef struct Intersection_Struct INTERSECTION;
typedef struct Color12_Struct COLOR12;
typedef struct Color24_Struct COLOR24;
typedef struct Image24_Struct IMAGE24;
typedef struct Image8_Struct IMAGE8;


struct Point_Struct
{
	double	x, y, z;
};

struct UVCoord_Struct
{
	double	u, v;
};

struct Vector_Struct
{
	double	x, y, z;
};

struct TransformEntry_Struct
{
	short	Type;
	VECTOR	Values;
};

struct Transform_Struct
{
	short	NumTransforms;
	TRANSFENTRY Entry[10];
};

struct Color_Struct
{
	double	r, g, b;
};

struct ColorMap_Struct
{
	short	LastBound;
	double	Bounds[10];	/* Note: MUST BE SORTED IN ASCENDING ORDER! */
	COLOR	Colors[10];
};

struct Texture_Struct
{
	COLORMAP CMap;
	short	Pattern;
	short	ImageType;
	int	ImageNum;	/* Image number (in global image array) */
	double	Turbulence;
	COLOR	Reflect;
	COLOR	Filter;
	double	Ior;
	double	Ambient;
	double	Diffuse;
	double	Phong;
	double	PhongSize;
	TRANSFORM Transform;
};

struct Line_Struct
{
	POINT	Origin;
	VECTOR	Direction;
};

struct Plane_Struct
{
	VECTOR	Normal;
	double	a;
};

struct Sphere_Struct
{
	POINT	Centre;
	double	r;
};

struct Ellipsoid_Struct
{
	POINT	Centre;
	VECTOR	Radius;
};

struct Triangle_Struct
{
	UVCOORD	Corners[3];
	short	Projection;
	VECTOR	Normal;
	double	Offset;
};

struct TriangleList_Struct
{
	UVCOORD	Corners[3];
	short	Projection;
	VECTOR	Normal;
	double	Offset;
	TRIANGLELIST *NextTriangle;
};

struct Box_Struct
{
	POINT	Corners[2];
};

struct Disc_Struct
{
	POINT	Centre;
	double	r;
	PLANE	Plane;
};

struct Cylinder_Struct
{
	double	h,r;
};

struct Cone_Struct
{
	double	h,r1,r2;
};

struct CSG_Struct
{
	OBJECT	*Object1,*Object2;
	short	Operator;
};

struct Torus_Struct
{
	double	r0,r1;
};

struct Peak_Struct
{
	double	dummy;
};

struct Deoflaska_Struct
{
	double	h,r0,dr;
};

struct Light_Struct
{
	POINT	Location;
	COLOR	Color;
	double	Size;
	short	SoftRec;
	double	Jitter;
};

struct Camera_Struct
{
	POINT	Location;
	POINT	ViewPoint;
	VECTOR	Direction;
	VECTOR	Up;
	VECTOR	Right;
	VECTOR	Aspect;
};

struct Object_Struct
{
	short	ShapeType;
	void	*Shape;		/* Pointer to the acual shape description (Box, Sphere or whatever) */
	TEXTURE	Texture;	/* Object texture */
	TRANSFORM Transform;	/* Object transformation */
	short	Invert;		/* Tells wether the object should be inverted (inside->outside, and vice versa) */
	short	Shadow;		/* Tells wether the object will cast shadows or not */
	short	BoundType;	/* Bunding type (none, box or sphere) */
	void	*Bound;		/* Shape-description */
};

struct Intersection_Struct
{
	POINT	IPoint;		/* Intersection point */
	VECTOR	Normal;		/* Surface normal */
	TEXTURE	*Texture;	/* Pointer to texture for intersected object */
	short	Shadow;		/* Cast shadows or not cast shadows, that is the question */ 
};

struct Color12_Struct
{
	unsigned char r,g,b;
};

struct Color24_Struct
{
	unsigned char r,g,b;
};

struct Image24_Struct		/* 24-bit image (16M colors) */
{
	int	XSize,YSize;
	short	Interpolate,Maptype,Tile;
	unsigned char	*Body;
	TRANSFORM Transform;
};

struct Image8_Struct		/* 8-bit color-mapped image (256 colors, 'infinite' amount of colors in palette) */
{
	int	XSize,YSize;
	short	Interpolate,Maptype,Tile;
	COLOR	Colormap[256];
	unsigned char	*Body;
	TRANSFORM Transform;
};



/* Declaration of entries in the anti-aliasing table(s) */

typedef struct AAEntry_Struct {
	COLOR	Color;
	unsigned char	Done;
} AAENTRY;
