/*
 * HiddenSurface.c
 * This is a _simple_ little example of how to go about implementing a
 * hidden surface algorithm.  Define your faces in a clockwise manner and
 * the routine will do the rest.  This only works on _convex_ objects.
 * There is no sanity checking, so any gurus you generate are your own
 * fault...  BSI Thursday 13-May-93 04:35:55
 */


#include <proto/all.h>
#include <intuition/intuition.h>
#include <exec/types.h>
#include <exec/memory.h>
#include <graphics/gfx.h>
#include <graphics/gfxbase.h>
#include <graphics/gfxmacros.h>
#include <graphics/view.h>
#include <graphics/copper.h>


/*
 * #delightful #defines...
 */
#define PIXWIDTH  320				   /* Standard Low-Res width */
#define PIXHEIGHT 200		    /* Make the ViewPort NTSC # rasters high */
#define PIXDEPTH    3				 /* You may use 8 colours... */


/*
 * Those lovely prototypes...enough parameters here?
 */
void Rotate(short *,short *,short,short,short,short,short,short);
void DrawObject(struct RastPort *,struct Object *,
			    short,short,short,short,short,short);
int MakeViews(void);
void KillViews(void);
void SwapViews(void);


/*
 * A Unique Struct...
 */
struct Object {
	short *Faces;
	short *Points;
	};

/*
 * Face data:
 * NumPoints, Color, point1, point2, point3,...
 * Terminate list with zero for numpoints
 */
short connect[]={
	5,2,0,3,7,4,0,
	5,2,0,1,2,3,0,
	5,2,2,6,7,3,2,
	5,2,1,5,6,2,1,
	5,2,0,4,5,1,0,
	5,2,4,7,6,5,4,
	0 };	

/*
 * Obj Coords in x,y,z format...delineate end of list with MAXINT
 */
short coords[]={
	-256,-256,-256,
	-256,-256, 256,
	 256,-256, 256,
	 256,-256,-256,
	-256, 256,-256,
	-256, 256, 256,
	 256, 256, 256,
	 256, 256,-256,
	 32767 };

/*
 * Object definition for DrawObject()...
 */
struct Object myobject = { connect,coords };


/*
 * Multi-Purpose Sine/Cosine lookup table...
 * See implementation in Rotate()
 */
const signed short sincos[]={
	0x0000,0x0001,0x0003,0x0004,0x0006,0x0007,0x0009,0x000A,
	0x000C,0x000E,0x000F,0x0011,0x0012,0x0014,0x0015,0x0017,
	0x0019,0x001A,0x001C,0x001D,0x001F,0x0020,0x0022,0x0024,
	0x0025,0x0027,0x0028,0x002A,0x002B,0x002D,0x002E,0x0030,
	0x0031,0x0033,0x0035,0x0036,0x0038,0x0039,0x003B,0x003C,
	0x003E,0x003F,0x0041,0x0042,0x0044,0x0045,0x0047,0x0048,
	0x004A,0x004B,0x004D,0x004E,0x0050,0x0051,0x0053,0x0054,
	0x0056,0x0057,0x0059,0x005A,0x005C,0x005D,0x005F,0x0060,
	0x0061,0x0063,0x0064,0x0066,0x0067,0x0069,0x006A,0x006C,
	0x006D,0x006E,0x0070,0x0071,0x0073,0x0074,0x0075,0x0077,
	0x0078,0x007A,0x007B,0x007C,0x007E,0x007F,0x0080,0x0082,
	0x0083,0x0084,0x0086,0x0087,0x0088,0x008A,0x008B,0x008C,
	0x008E,0x008F,0x0090,0x0092,0x0093,0x0094,0x0095,0x0097,
	0x0098,0x0099,0x009B,0x009C,0x009D,0x009E,0x009F,0x00A1,
	0x00A2,0x00A3,0x00A4,0x00A6,0x00A7,0x00A8,0x00A9,0x00AA,
	0x00AB,0x00AD,0x00AE,0x00AF,0x00B0,0x00B1,0x00B2,0x00B3,
	0x00B5,0x00B6,0x00B7,0x00B8,0x00B9,0x00BA,0x00BB,0x00BC,
	0x00BD,0x00BE,0x00BF,0x00C0,0x00C1,0x00C2,0x00C3,0x00C4,
	0x00C5,0x00C6,0x00C7,0x00C8,0x00C9,0x00CA,0x00CB,0x00CC,
	0x00CD,0x00CE,0x00CF,0x00D0,0x00D1,0x00D2,0x00D3,0x00D3,
	0x00D4,0x00D5,0x00D6,0x00D7,0x00D8,0x00D9,0x00D9,0x00DA,
	0x00DB,0x00DC,0x00DD,0x00DD,0x00DE,0x00DF,0x00E0,0x00E1,
	0x00E1,0x00E2,0x00E3,0x00E3,0x00E4,0x00E5,0x00E6,0x00E6,
	0x00E7,0x00E8,0x00E8,0x00E9,0x00EA,0x00EA,0x00EB,0x00EB,
	0x00EC,0x00ED,0x00ED,0x00EE,0x00EE,0x00EF,0x00EF,0x00F0,
	0x00F1,0x00F1,0x00F2,0x00F2,0x00F3,0x00F3,0x00F4,0x00F4,
	0x00F4,0x00F5,0x00F5,0x00F6,0x00F6,0x00F7,0x00F7,0x00F7,
	0x00F8,0x00F8,0x00F9,0x00F9,0x00F9,0x00FA,0x00FA,0x00FA,
	0x00FB,0x00FB,0x00FB,0x00FB,0x00FC,0x00FC,0x00FC,0x00FC,
	0x00FD,0x00FD,0x00FD,0x00FD,0x00FE,0x00FE,0x00FE,0x00FE,
	0x00FE,0x00FE,0x00FF,0x00FF,0x00FF,0x00FF,0x00FF,0x00FF,
	0x00FF,0x00FF,0x00FF,0x00FF,0x00FF,0x00FF,0x00FF,0x00FF,
	0x0100,0x00FF,0x00FF,0x00FF,0x00FF,0x00FF,0x00FF,0x00FF,
	0x00FF,0x00FF,0x00FF,0x00FF,0x00FF,0x00FF,0x00FF,0x00FE,
	0x00FE,0x00FE,0x00FE,0x00FE,0x00FE,0x00FD,0x00FD,0x00FD,
	0x00FD,0x00FC,0x00FC,0x00FC,0x00FC,0x00FB,0x00FB,0x00FB,
	0x00FB,0x00FA,0x00FA,0x00FA,0x00F9,0x00F9,0x00F9,0x00F8,
	0x00F8,0x00F7,0x00F7,0x00F7,0x00F6,0x00F6,0x00F5,0x00F5,
	0x00F4,0x00F4,0x00F4,0x00F3,0x00F3,0x00F2,0x00F2,0x00F1,
	0x00F1,0x00F0,0x00EF,0x00EF,0x00EE,0x00EE,0x00ED,0x00ED,
	0x00EC,0x00EB,0x00EB,0x00EA,0x00EA,0x00E9,0x00E8,0x00E8,
	0x00E7,0x00E6,0x00E6,0x00E5,0x00E4,0x00E3,0x00E3,0x00E2,
	0x00E1,0x00E1,0x00E0,0x00DF,0x00DE,0x00DD,0x00DD,0x00DC,
	0x00DB,0x00DA,0x00D9,0x00D9,0x00D8,0x00D7,0x00D6,0x00D5,
	0x00D4,0x00D3,0x00D3,0x00D2,0x00D1,0x00D0,0x00CF,0x00CE,
	0x00CD,0x00CC,0x00CB,0x00CA,0x00C9,0x00C8,0x00C7,0x00C6,
	0x00C5,0x00C4,0x00C3,0x00C2,0x00C1,0x00C0,0x00BF,0x00BE,
	0x00BD,0x00BC,0x00BB,0x00BA,0x00B9,0x00B8,0x00B7,0x00B6,
	0x00B5,0x00B3,0x00B2,0x00B1,0x00B0,0x00AF,0x00AE,0x00AD,
	0x00AB,0x00AA,0x00A9,0x00A8,0x00A7,0x00A6,0x00A4,0x00A3,
	0x00A2,0x00A1,0x009F,0x009E,0x009D,0x009C,0x009B,0x0099,
	0x0098,0x0097,0x0095,0x0094,0x0093,0x0092,0x0090,0x008F,
	0x008E,0x008C,0x008B,0x008A,0x0088,0x0087,0x0086,0x0084,
	0x0083,0x0082,0x0080,0x007F,0x007E,0x007C,0x007B,0x007A,
	0x0078,0x0077,0x0075,0x0074,0x0073,0x0071,0x0070,0x006E,
	0x006D,0x006C,0x006A,0x0069,0x0067,0x0066,0x0064,0x0063,
	0x0061,0x0060,0x005F,0x005D,0x005C,0x005A,0x0059,0x0057,
	0x0056,0x0054,0x0053,0x0051,0x0050,0x004E,0x004D,0x004B,
	0x004A,0x0048,0x0047,0x0045,0x0044,0x0042,0x0041,0x003F,
	0x003E,0x003C,0x003B,0x0039,0x0038,0x0036,0x0035,0x0033,
	0x0031,0x0030,0x002E,0x002D,0x002B,0x002A,0x0028,0x0027,
	0x0025,0x0024,0x0022,0x0020,0x001F,0x001D,0x001C,0x001A,
	0x0019,0x0017,0x0015,0x0014,0x0012,0x0011,0x000F,0x000E,
	0x000C,0x000A,0x0009,0x0007,0x0006,0x0004,0x0003,0x0001,
	0xFFFF,0xFFFE,0xFFFC,0xFFFB,0xFFF9,0xFFF8,0xFFF6,0xFFF5,
	0xFFF3,0xFFF1,0xFFF0,0xFFEE,0xFFED,0xFFEB,0xFFEA,0xFFE8,
	0xFFE6,0xFFE5,0xFFE3,0xFFE2,0xFFE0,0xFFDF,0xFFDD,0xFFDB,
	0xFFDA,0xFFD8,0xFFD7,0xFFD5,0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xFF1C,0xFF1B,0xFF1A,0xFF19,0xFF19,
	0xFF18,0xFF17,0xFF17,0xFF16,0xFF15,0xFF15,0xFF14,0xFF14,
	0xFF13,0xFF12,0xFF12,0xFF11,0xFF11,0xFF10,0xFF10,0xFF0F,
	0xFF0E,0xFF0E,0xFF0D,0xFF0D,0xFF0C,0xFF0C,0xFF0B,0xFF0B,
	0xFF0B,0xFF0A,0xFF0A,0xFF09,0xFF09,0xFF08,0xFF08,0xFF08,
	0xFF07,0xFF07,0xFF06,0xFF06,0xFF06,0xFF05,0xFF05,0xFF05,
	0xFF04,0xFF04,0xFF04,0xFF04,0xFF03,0xFF03,0xFF03,0xFF03,
	0xFF02,0xFF02,0xFF02,0xFF02,0xFF01,0xFF01,0xFF01,0xFF01,
	0xFF01,0xFF01,0xFF00,0xFF00,0xFF00,0xFF00,0xFF00,0xFF00,
	0xFF00,0xFF00,0xFF00,0xFF00,0xFF00,0xFF00,0xFF00,0xFF00,
	0xFF00,0xFF00,0xFF00,0xFF00,0xFF00,0xFF00,0xFF00,0xFF00,
	0xFF00,0xFF00,0xFF00,0xFF00,0xFF00,0xFF00,0xFF00,0xFF01,
	0xFF01,0xFF01,0xFF01,0xFF01,0xFF01,0xFF02,0xFF02,0xFF02,
	0xFF02,0xFF03,0xFF03,0xFF03,0xFF03,0xFF04,0xFF04,0xFF04,
	0xFF04,0xFF05,0xFF05,0xFF05,0xFF06,0xFF06,0xFF06,0xFF07,
	0xFF07,0xFF08,0xFF08,0xFF08,0xFF09,0xFF09,0xFF0A,0xFF0A,
	0xFF0B,0xFF0B,0xFF0B,0xFF0C,0xFF0C,0xFF0D,0xFF0D,0xFF0E,
	0xFF0E,0xFF0F,0xFF10,0xFF10,0xFF11,0xFF11,0xFF12,0xFF12,
	0xFF13,0xFF14,0xFF14,0xFF15,0xFF15,0xFF16,0xFF17,0xFF17,
	0xFF18,0xFF19,0xFF19,0xFF1A,0xFF1B,0xFF1C,0xFF1C,0xFF1D,
	0xFF1E,0xFF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DA,0xFFDB,0xFFDD,0xFFDF,0xFFE0,0xFFE2,0xFFE3,0xFFE5,
	0xFFE6,0xFFE8,0xFFEA,0xFFEB,0xFFED,0xFFEE,0xFFF0,0xFFF1,
	0xFFF3,0xFFF5,0xFFF6,0xFFF8,0xFFF9,0xFFFB,0xFFFC,0xFFFE
};


/*
 * Rotate in 3D then convert 3-D to 2-D projection...
 */
void Rotate(short *points3d,short *points2d,short xrot,short yrot,short zrot,
	short distance,short centerx,short centery){
	    
short sinx,siny,cosx,cosy,sinz,cosz;
short x,y,z;
long  t,u;

sinx=sincos[xrot&0x3ff];			  /* Get sincos of 3 axes... */
cosx=sincos[(xrot+0x100)&0x3ff];

siny=sincos[yrot&0x3ff];		/* Table is 1024 entries so MOD 1023 */
cosy=sincos[(yrot+0x100)&0x3ff];	/* Cos 0 = Sin PI/4 so 1024/4 = 256! */

sinz=sincos[zrot&0x3ff];
cosz=sincos[(zrot+0x100)&0x3ff];

for(;;) {
	if((x=*(points3d++))==0x7fff) break; 	/* See if end of sequence... */
	    y=*(points3d++);			/* otherwise, fetch + go!    */
	    z=*(points3d++);

	t =((x*cosz)-(y*sinz))>>8;		      /* Rotate X - Y thru Z */
	u =((y*cosz)+(x*sinz))>>8;
	x =(short)t;
	y =(short)u;

	t =((y*cosx)-(z*sinx))>>8;		      /* Rotate Y - Z thru X */
	u =((z*cosx)+(y*sinx))>>8;
	y =(short)t;
	z =(short)u;

	t =((x*cosy)-(z*siny))>>8;		      /* Rotate X - Z thru Y */
	u =((z*cosy)+(x*siny))>>8;
	x =(short)t;
	z =(short)u;

	*(points2d++)=((long)x<<8)/(z+distance)+centerx;       /* 3-D to 2-D */
	*(points2d++)=((long)y<<8)/(z+distance)+centery;       /* conversion */
	}
*(points2d++)=0x7fff;	             /* Mark the end of table with MAXINT... */
}


/*
 * Draw an object with hidden faces...
 */
short xypoints[512];	   /* Buffer for pts converted to 2-D... 512's enuff */

void DrawObject(struct RastPort *rp,struct Object *obj,short xrot,short yrot,
		short zrot,short distance,short centerx,short centery){

short i,j,x1,y1,x2,y2,x3,y3,*cptr;

Rotate(obj->Points,xypoints,xrot,yrot,zrot,distance,centerx,centery);
cptr=obj->Faces;

for(;;){ 
	if(!(j=*(cptr++)))break;		  /* Check if end of list... */

	SetAPen(rp,*(cptr++));	   		     /* Set color of face... */

	x1=xypoints[(*cptr)<<1];	y1=xypoints[((*(cptr++))<<1)+1];
	x2=xypoints[(*cptr)<<1];	y2=xypoints[((*(cptr++))<<1)+1];
	x3=xypoints[(*cptr)<<1];	y3=xypoints[((*(cptr++))<<1)+1];

	if(((y3-y1)*(x2-x1)-(x3-x1)*(y2-y1))>0)        /* See if face viz... */
		{ 				   
		Move(rp,(long)x1,(long)y1);		 /* Yeah, draw it... */
		Draw(rp,(long)x2,(long)y2);
		Draw(rp,(long)x3,(long)y3);

		for(i=0;i<(j-3);i++)
		Draw(rp,(long)xypoints[(*cptr)<<1],
				(long)xypoints[((*(cptr++))<<1)+1]);
		}
	else cptr+=(j-3);
	}
}


/*
 * Double-Buffering Globals...
 */
struct View view[2],*actiview;

struct ViewPort viewport[2];
struct BitMap bitmap[2];
struct RasInfo rasinfo[2];
struct RastPort rastport[2],*rp;

short colors[]={0x0000,0x000f,0x00f0,0x0f00,0x00ff,0x0ff0,0x0f0f,0x0fff};

short currview=0;
PLANEPTR *plane1=NULL;


/*
 * Construct the Views...
 */
int MakeViews(void) {
short i,j;

if(plane1=AllocMem(((PIXWIDTH>>3)*PIXHEIGHT*PIXDEPTH)*2,MEMF_CHIP|MEMF_CLEAR))
	{
	actiview=GfxBase->ActiView;

              /*--------------- Make VPORTS ---------------*/

	for(j=0;j<2;j++) {
		InitView(&view[j]);
		InitVPort(&viewport[j]);
		view[j].ViewPort=&viewport[j];

		InitBitMap(&bitmap[j],PIXDEPTH,PIXWIDTH,PIXHEIGHT);
		for(i=0;i<PIXDEPTH;i++)
			bitmap[j].Planes[i]=(PLANEPTR)plane1+
				(PIXWIDTH>>3)*PIXHEIGHT*i+
				(PIXWIDTH>>3)*PIXHEIGHT*PIXDEPTH*j;
		InitRastPort(&rastport[j]);
		rastport[j].BitMap=&bitmap[j];
		SetDrMd(&rastport[j],JAM1);

		rasinfo[j].BitMap=&bitmap[j];
		rasinfo[j].RxOffset=rasinfo[j].RyOffset=0;
		rasinfo[j].Next=NULL;

		viewport[j].RasInfo=&rasinfo[j];
		viewport[j].DWidth=PIXWIDTH;
		viewport[j].DHeight=PIXHEIGHT;

		if(viewport[j].ColorMap=GetColorMap(8L))
			{
			LoadRGB4(&viewport[j],colors,8);
			MakeVPort(&view[j],&viewport[j]);
			MrgCop(&view[j]);
			}
		}

        /*--------------- Make VPORT FINI (whew!) ---------------*/

	SwapViews();
	}
return((int)plane1);
}


/*
 * Kill da Views...
 */
void KillViews(void) {
short i;

LoadView(actiview);
WaitTOF();

if(plane1)FreeMem(plane1,(PIXWIDTH>>3)*PIXHEIGHT*PIXDEPTH*2);

for(i=0;i<2;i++)
	{
	if(viewport[i].ColorMap)FreeColorMap(viewport[i].ColorMap);
	FreeVPortCopLists(&viewport[i]);
	if(view[i].LOFCprList)FreeCprList(view[i].LOFCprList);
	}
}


/*
 * Double-buffered screen swapper...
 */
void SwapViews(void) {

LoadView(&view[currview]);
WaitTOF();
currview^=1;
rp=&rastport[currview];
Move(rp,0,0);
ClearScreen(rp);
}


/*
 * Now what you've been waiting for...
 * The weird values in the DrawObject() function simulate an orbit-like
 * motion with variable distancing, that's all...
 */
struct IntuitionBase *IntuitionBase;
struct GfxBase *GfxBase;

void main(void) {
short i,distance;

if(IntuitionBase=(struct IntuitionBase *)OpenLibrary("intuition.library",33)){
if(GfxBase=(struct GfxBase *)OpenLibrary("graphics.library",33)){
if(MakeViews()){

for(i=0;i!=2000;i+=2)
	{
	distance=(sincos[((i<<2)+0x100)&0x3ff]<<3)+3800;
	DrawObject(rp,&myobject,i,i<<1,i<<2,distance,
	(PIXWIDTH>>1)+((sincos[(i<<2)&0x3ff])>>1),
	(PIXHEIGHT>>1)+((sincos[((i<<2)+0x100)&0x3ff])>>3));
	SwapViews();
	}
}

KillViews();
CloseLibrary((struct Library *)GfxBase);}
CloseLibrary((struct Library *)IntuitionBase);}
}
