
 /***************************************************************************
 *Rolf Schneider | Am Birkenwaeldchen 16/18 | 58 Hagen 7 | Tel.: 02331/45569*
 *                                                                          *
 *                      First Amiga Artists Program:                        *
 *                                                                          *
 *                          -- Artist's Copy I --                           *
 *AC3                                                                       *
 ***************************************************************************/


 /***************************************************************************
 *            IncludeFiles...                                               *
 ***************************************************************************/

#include "exec/types.h"
#include "exec/io.h"
#include "exec/memory.h"

#include "lattice/math.h"

#include "graphics/gfx.h"
#include "hardware/dmabits.h"
#include "hardware/custom.h"
#include "hardware/blit.h"
#include "graphics/gfxmacros.h"
#include "graphics/copper.h"
#include "graphics/view.h"
#include "graphics/gels.h"
#include "graphics/regions.h"
#include "graphics/clip.h"
#include "exec/exec.h"
#include "graphics/text.h"
#include "graphics/gfxbase.h"

#include "devices/console.h"
#include "devices/keymap.h"

#include "libraries/dos.h"
#include "graphics/text.h"
#include "libraries/diskfont.h"
#include "intuition/intuition.h"

extern struct Window *OpenWindow();

 /***************************************************************************
 *            Globals...                                                    *
 ***************************************************************************/

extern struct Window *Wini;
extern struct RastPort *RaPort;
extern struct IntuiMessage *meldung;
struct Window *TW;

struct NewWindow Taa = {
	80,25,480,150,
	1,2,
	MOUSEBUTTONS,
	ACTIVATE|GIMMEZEROZERO|RMBTRAP,
	NULL,
	NULL,
	NULL,
	NULL,
	NULL,
	0,0,0,0,
	WBENCHSCREEN  };

/*****     |       T       |      A      |     A         |   ********/

long X[] = {-50,-21,-36,-36,-14,0,14,-7,7,21,36,50,29,43};
long Y[] = {-18,-18,-18,18,18,-18,18,0,0,18,-18,18,0,0};
long Z[] = {50,50,50,50,50,50,50,50,50,50,50,50,50,50}; 

short index=0;

TAA ()
{
short i,j;
long x2[14],y2[14],dx,dy,dz,x[14],y[14],z[14],a11,a12,a13,a21,a22,a23,a31,a32,a33,M=3000,c=150;
double DM=3000,e=1,e1=0,e2=-1,e3=0,si,co,phi=10;

TW = OpenWindow (&Taa);
RaPort = TW -> BorderRPort;

SetAPen (RaPort,1);
RectFill (RaPort,0,0,479,149);
SetAPen (RaPort,2);
Box (0,0,479,149);
Box (1,1,478,148);
Box (2,0,477,149);

RaPort = TW -> RPort;

SetAPen (RaPort,1);
RectFill (RaPort,0,0,479,149);
SetAPen (RaPort,2);
SetBPen (RaPort,1);
SetDrMd (RaPort,JAM2);

Move (RaPort,181,101);
Text (RaPort,"Rolf Schneider",14);
Move (RaPort,141,109);
Text (RaPort,"Am Birkenwaeldchen 16/18",24);
Move (RaPort,197,117);
Text (RaPort,"58 Hagen 7",10);
Move (RaPort,169,125);
Text (RaPort,"Tel.: 02331/45569",17);

for (j=0;j<=13;++j)
	{
	x2[j]=239.5;
	y2[j]=49.5;
	if (index != 234) { Z[j]=Z[j]*M; Y[j]=Y[j]*M; X[j]=X[j]*M; }
	}
index = 234;

phi= phi * PI / 180;
si = sin (phi);
co = (1-cos (phi));

for (;;)
	{
	e=sqrt (e1*e1+e2*e2+e3*e3); e1=e1/e; e2=e2/e; e3=e3/e;
	for (j=0;j<=13;++j) { x[j]=X[j]; y[j]=Y[j]; z[j]=Z[j]; }
	a11=(long)((1-co*(e2*e2+e3*e3))*DM); a21=(long)((co*e1*e2+si*e3)*DM); a31=(long)((co*e1*e3-si*e2)*DM);
	a22=(long)((1-co*(e3*e3+e1*e1))*DM); a32=(long)((co*e2*e3+si*e1)*DM); a12=(long)((co*e2*e1-si*e3)*DM);
	a33=(long)((1-co*(e1*e1+e2*e2))*DM); a13=(long)((co*e3*e1+si*e2)*DM); a23=(long)((co*e3*e2-si*e1)*DM);
	for (i=0;i<=35;++i)
		{
		SetAPen (RaPort,1);
		RectFill (RaPort,130,0,350,92);
		SetAPen (RaPort,2);
		Line (x2[0],y2[0],x2[1],y2[1]);
		Line (x2[2],y2[2],x2[3],y2[3]);
		Move (RaPort,x2[4],y2[4]);
		Draw (RaPort,x2[5],y2[5]);
		Draw (RaPort,x2[6],y2[6]);
		Line (x2[7],y2[7],x2[8],y2[8]);
		Move (RaPort,x2[9],y2[9]);
		Draw (RaPort,x2[10],y2[10]);
		Draw (RaPort,x2[11],y2[11]);
		Line (x2[12],y2[12],x2[13],y2[13]);
		for (j=0;j<=13;++j)
			{
			dx=x[j]; dy=y[j]; dz=z[j]-50*M;
			x[j]=(dx*a11+dy*a12+dz*a13)/M;
			y[j]=(dx*a21+dy*a22+dz*a23)/M;
			z[j]=(dx*a31+dy*a32+dz*a33)/M+50*M;
			x2[j]=239.5+2*(x[j]/M)*c/((z[j]/M)+c);
			y2[j]=49.5+(y[j]/M)*c/((z[j]/M)+c);
			}
		meldung = (struct IntuiMessage *) GetMsg(TW -> UserPort);
		if ((meldung -> Class) == MOUSEBUTTONS)  break;
		}
	e1=(double)(9-RangeRand(18));
	e2=(double)(9-RangeRand(18));
	e3=(double)(9-RangeRand(18));
	if ((meldung -> Class) == MOUSEBUTTONS)  break;
	}

ReplyMsg (meldung);
CloseWindow (TW);
RaPort = Wini -> RPort;
}


