#include #include #include #include struct IntuitionBase *IntuitionBase; struct GfxBase *GfxBase; struct Window *Window; struct IntuiMessage *Massage; struct Screen *Screen1; struct Screen *Screen2; struct RastPort *RPort; struct NewScreen NewScreen = { 0,0,640,400,1, 0,0, HIRES | LACE, CUSTOMSCREEN | SCREENQUIET, (struct TextAttr *)NULL, (STRPTR)NULL, (struct Gadget *)NULL, (struct BitMap *)NULL }; struct NewWindow NewWindow = { 0,0, 640,400, 0,0, RAWKEY, ACTIVATE | RMBTRAP | BORDERLESS | BACKDROP, (struct Gadget *)NULL, (struct Image *)NULL, (STRPTR) NULL, (struct Screen *)NULL, (struct BitMap *)NULL, 0,0, 0,0, CUSTOMSCREEN }; long sinus(int w); #pragma regcall(sinus(d0)) #define cosinus(w) (sinus(w+256)) void CloseAll(LONG ExitCode) { if(Window) CloseWindow(Window); if(Screen1) CloseScreen(Screen1); if(Screen2) CloseScreen(Screen2); if(IntuitionBase) CloseLibrary(IntuitionBase); if(GfxBase) CloseLibrary(GfxBase); exit(ExitCode); } void OpenAll() { if(!(IntuitionBase = OpenLibrary("intuition.library",0))) CloseAll(20); if(!(GfxBase = OpenLibrary("graphics.library",0))) CloseAll(21); if(!(Screen1 = OpenScreen(&NewScreen))) CloseAll(22); if(!(Screen2 = OpenScreen(&NewScreen))) CloseAll(23); NewWindow . Screen = Screen1; if(!(Window = OpenWindow(&NewWindow))) CloseAll(24); SetAPen(&Screen1 -> RastPort,1); SetAPen(&Screen2 -> RastPort,1); SetDrMd(&Screen1 -> RastPort,JAM1); SetDrMd(&Screen2 -> RastPort,JAM1); } int points = 24, lines = 31, faces = 13; struct SCPNT { int x,y; } scpnt[255]; struct POINT { long x,y,z; } point[] = { -5,-10,-10, 10,-10,-10, 10, 10,-10, -10, 10,-10, -10,-10, 10, 10,-10, 10, 10, 10, 10, -10, 10, 10, 0, 0, 0, -6, -6, -9, -3, -6, -9, 0, -6, -9, -3, 6, -9, 6, -6, -9, 4, -6, -9, 2, -4, -9, 2, -2, -9, 6, 2, -9, 6, 4, -9, 4, 6, -9, 2, 6, -9, -10, -5,-10, -10,-10, -5, -5, -5, -5 }; struct POINT dp[24]; struct { int to_draw; int p1,p2; } line[] = { 1,0,1, /* 00 */ 1,1,2, 1,2,3, 1,3,21, 1,22,4, 1,1,5, /* 05 */ 1,2,6, 1,3,7, 1,4,5, 1,5,6, 1,6,7, /* 10 */ 1,7,4, 1,23,8, 1,1,8, 1,2,8, 1,3,8, /* 15 */ 1,9,11, 1,10,12, 1,13,14, 1,14,15, 1,15,16, /* 20 */ 1,16,17, 1,17,18, 1,18,19, 1,19,20, 1,0,21, /* 25 */ 1,21,22, 1,22,0, 1,0,23, 1,21,23, 1,22,23 /* 30 */ }; struct FACE { int solid; int lns; int Line[8]; } face[] = { 1,4, 8,11,10, 9, 0, 0, 0, 0, /* The cube itself */ 1,4, 1, 5, 9, 6, 0, 0, 0, 0, 1,4, 2, 6,10, 7, 0, 0, 0, 0, 1,5, 7,11, 4,26, 3, 0, 0, 0, 1,5, 5, 0,27, 4, 8, 0, 0, 0, 1,3, 14,13, 1, 0, 0, 0, 0, 0, /* CAVE unter TS */ 1,3, 15,14, 2, 0, 0, 0, 0, 0, 1,4, 0,13,12,28, 0, 0, 0, 0, 1,4, 12,15, 3,29, 0, 0, 0, 0, 1,3, 30,28,27, 0, 0, 0, 0, 0, /* Das kleine Eck */ 1,3, 25,28,29, 0, 0, 0, 0, 0, 1,3, 29,28,25, 0, 0, 0, 0, 0, /* wie oben, nur andersrum */ 1,3, 26,29,30, 0, 0, 0, 0, 0, }; long sintab[1024]; int wx = 0, wz = 0; int dz = -10; int xoff = 320, yoff = 200, zoff = 400; int wc; main() { for(wc=0; wc<1024; wc++) { sintab[wc] = (int)(sin(((double)wc) * ((double)3.14159265359) / ((double) 512)) * ((double)16384L)); } OpenAll(); for(;;) { ScreenToFront(Screen2); RPort = &Screen1 -> RastPort; SetRast(RPort,0); drehx(); drehz(); cube(); ScreenToFront(Screen1); RPort = &Screen2 -> RastPort; SetRast(RPort,0); drehx(); drehz(); cube(); if(Massage = GetMsg(Window -> UserPort)) { ReplyMsg(Massage); CloseAll(0); } } } cube() { long cnt,p1,p2,z,zf,lc; int l1,l2, l1p1,l1p2,l2p1,l2p2; int u1,u2,u3, v1,v2,v3/*, w1,w2,w3*/; /* die VEKTOREN */ for(cnt=0; cnt=400 || zoff<=0) dz = -dz; return 0; } drehx() { int cnt,sn,cs; long y,z; sn = sinus(wx); cs = cosinus(wx); wx += 2; if(wx > 1023) wx -= 1024; for(cnt=0; cnt 1023) wz -= 1024; for(cnt=0; cnt 1023) valid -= 1024; while(valid < 0) valid += 1024; return sintab[valid]; }