/* 
 * Wicket.h - vertex, ray and transfer function abstract data type include file.
 * 
 * Author:	L. Van Warren
 * Date:	April 1984
 * Copyright (c) 1984 L. Van Warren * All Rights Reserved
 */

/*
 * Wickets have three roles.
 * A Wicket can be a vertex, a ray, or a transfer function used to maps in rays to out new rays.
 * When a Wicket is a vertex:
 *     the pos  field holds the position        of the vertex,
 *     the cmp  filed holds the  normal         to the vertex,
 *     the clr  field holds the  color          of the vertex,
 *     the kind field holds the   type          of the vertex,
 *     the noni field holds the  transparency   of the vertex.
 *
 * When a Wicket is ray:
 *     the pos  field holds the point of origination of the ray,
 *     the cmp  field holds the direction cosines of the ray,
 *     the clr  field holds the spectral information associated with the ray,
 *     the kind field holds state information about the ray such as:
 *         did it   bounce    from the front or back side,
 *         did it transmit through the front or back side,
 *         did it miss, etc.
 *     the noni field holds attenuation or perturbation constants associated with the ray.
 *
 * When a Wicket is transfer function:
 *     the pos  field holds the point of intersection of the ray and the material surface,
 *     the cmp  field holds the normal to the material surface,
 *     the clr  field holds the spectral transfer information associated with the material surface.
 *     the kind field indicates the type of material.
 *     the noni field holds the ratio of the indices of refraction associated with the material.
 *
 * When a Wicket is a ray-object intersection:
 *     the pos  field holds the point of intersection of the ray and the material surface,
 *     the cmp  field holds the normal to the material surface,
 *     the clr  field holds the spectral transfer information associated with the material surface.
 *     the kind field indicates the material type id if the ray hit, zero if the ray missed.
 *     the noni field holds the ratio of the indices of refraction associated with the material.
 */

/* General Wicket definition. */
typedef struct
{
    int kind;
    Vec pos;
    Vec cmp;
    Vec clr;
    Vec ntuv;
} Wicket;

/* Wicket I/O */
void   fprintWicket(FILE*, Wicket);
Wicket  fscanWicket(FILE*);
void   fwriteWicket(FILE*, Wicket);
Wicket  freadWicket(FILE*);

/* When Wicket is a Ray */

#define RAY_MISS	0
#define RAY_KIND    1
#define  INTL_REFL  2
#define  FRNT_REFL  3
#define  BACK_REFL  4
#define  FRNT_REFR  5
#define  BACK_REFR  6
#define VRT_KIND    7
#define XFR_KIND    8
#define ITR_KIND    9
/* material kind id's must begin at 10 */

#define ORIGIN_OFFSET 0.005 /* LVW: BUG: GET RID OF THIS ASAP ; DEBUG TAG */

typedef Wicket Xfr;
typedef Wicket Ray;
typedef Wicket Vrt;
typedef Wicket Itr;

/* Wicket instantiation */
extern Wicket asnWicket(int, Vec, Vec, Vec, Vec);
extern Ray		 formRay();
extern Vec		pntOfItr();
extern Ray	reflected(Ray, Wicket);
extern Ray	refracted(Ray, Wicket);


typedef struct
{
    Itr *itrList;
    int numItr;
} ItrList;

extern ItrList addToItrList();
extern ItrList asnItrList();
extern ItrList freeItrList();

extern ItrList itrRayPlane();
extern ItrList itrRayPoly();
extern ItrList itrRaySphere();
extern ItrList itrRayPrimitive();
extern ItrList itrRayBooleanOp();
extern ItrList itrRayFunction();

/* When Wicket is a Vrt */
extern Vrt lrpVrt2(Vrt, Vrt, double);
extern Vrt lrpVrt3(Vrt, Vrt, Vrt, Vec);


/* Functions returning values other than integers.                         */
extern Itr asnItr();
extern Itr itrRayObj();
extern Itr comp_Obj_Itr();

