/****
 *
 * Copyright (c) 1988 by Sun Microsystems, Inc.
 * @(#)sh_LIGHTS.h 22.1 89/08/10 Copyright 1988 Sun Micro
 *
 * LIGHT.H - LIGHT object information
 *
 ****/
#ifndef	_SH_CLASS_LIGHT

#define	LIGHT_MAX_SOURCES 10

/****
 *
 * LIGHT_SOURCE
 * Structure describing a single light source (argument to
 * Add_Light and Set_Light call
 *
 ****/
typedef enum
  {
   LIGHT_INF,	/* infinite light source */
   LIGHT_POINT,	/* point light source */
   LIGHT_SPOT,	/* spot light source */
  } LIGHT_Type;

typedef struct
  {
   LIGHT_Type	type;	/* light source type */
   COLOR	col;	/* light source color */
   POINT_F3D	pos;	/* light source position */
   POINT_F3D	dir;	/* light source direction */
   float	angle;	/* spotlight angle */
   float	exp;	/* spotlight power */
  } LIGHT_SOURCE;

#define	LIGHT_OP_Destroy	0
#define	LIGHT_OP_Init		1
#define	LIGHT_OP_Get		2
#define	LIGHT_OP_Set		3
#define	LIGHT_OP_Print		4
#define	LIGHT_OP_Clear		5
#define	LIGHT_OP_Add		6
#define	LIGHT_OP_Copy		7
#define	LIGHT_OP_Attach		8
#define	LIGHT_OP_Install	9
#define	LIGHT_OPERS		10

/*
 * Device specific LIGHT operators.
 * The following operations on light groups are device specific.
 * They have different implementations for different devices.
 *
 * LIGHT Create_Light(n)	create LIGHT object
 * Destroy_Light(lg)		destroy light group
 * Clear_Light(lg)		clear light group
 * Add_Light(lg, ls)	  	add new light source
 * Get_Light(lg, i	  	get Ith light source
 * Set_Light(lg, i, ls)  	set Ith light source
 * Copy_Light(slg, dlg)		copy light sources
 *
 * Print_Light(lg)		print lights
 * Apply_Light(lg, p)		apply light sources
 * Attach_Light(lg, ctx)	attach light sources to context
 * Install_Light(lg, cm)	install light sources
 */
#define	Create_Light(n)	 ((LIGHT) Create_Obj(CLASS_LIGHT, n))
#define	Temp_Light(n)	 ((LIGHT) Temp_Obj(CLASS_LIGHT, n))
#define	Destroy_Light(l) Destroy_Obj(l)
#define	Clear_Light(l)	 ((void) GetOper_Obj(l, LIGHT_OP_Clear)(l))
#define	Copy_Light(s,d)  ((LIGHT) GetOper_Obj(s, LIGHT_OP_Copy)(s,d))
#define	Add_Light(l,s)	 ((LIGHT_SOURCE *) GetOper_Obj(l, LIGHT_OP_Add)(l,s))
#define	Get_Light(l,i)	 ((LIGHT_SOURCE *) GetOper_Obj(l, LIGHT_OP_Get)(l,i))
#define	Set_Light(l,i,s) ((LIGHT_SOURCE *) GetOper_Obj(l, LIGHT_OP_Set)(l,i,s))
#define	Print_Light(l) ((void) GetOper_Obj(l, LIGHT_OP_Print)(l))
#define Attach_Light(l,c) ((LIGHT) GetOper_Obj(l, LIGHT_OP_Attach)(l,c))
#define Install_Light(l,c) ((LIGHT) GetOper_Obj(l, LIGHT_OP_Install)(l,c))

#define Apply_Light(l,p)  ((fract) (*(l->lg_apply_func))(l, p))

/*
 * Internal format for light source information
 */
typedef struct ls_data
  {
   LIGHT_Type   ls_type;        /* light source type */
   COLOR        ls_col;         /* light source color */
   POINT_F3D    ls_pos;         /* light source position */
   POINT_F3D    ls_dir;         /* light source direction */
   float        ls_angle;       /* spotlight angle */
   float        ls_exp;         /* spotlight power */
   POINT_F3D    ls_mpos;	/* light source position (model space) */
   float        ls_red;		/* red component */
   float        ls_green;	/* green component */
   float        ls_blue;	/* blue component */
  };

/*
 * LIGHT (light group) Object Data Structure
 */
typedef struct class_LIGHT
  {
#include "sh_LIGHTS.ah"
  };

#define	_SH_CLASS_LIGHT
#endif	/* _SH_CLASS_LIGHT */
