/* $Id$ */ #include #include #include #include #include void Calc3D(void); void DrawObject(void); void InitProgram(void); void MainLoop(void); void Rotation(void); int key(void); void Legende(void); #define COPYRIGHT "Dark Alliance (c) 1996-2000 DreamDemon" #define DATUM "13.02.2000" #define PI 3.14 #define Lines 72 static int World[Lines][3] = { 90, 0, 0, 10, 10, 10, 90, 0, 0, 10, 10,-10, 90, 0, 0, 10,-10,-10, 90, 0, 0, 10,-10, 10, -90, 0, 0, -10, 10, 10, -90, 0, 0, -10, 10,-10, -90, 0, 0, -10,-10,-10, -90, 0, 0, -10,-10, 10, 0, 90, 0, 10, 10, 10, 0, 90, 0, -10, 10, 10, 0, 90, 0, -10, 10,-10, 0, 90, 0, 10, 10,-10, 0,-90, 0, 10,-10, 10, 0,-90, 0, -10,-10, 10, 0,-90, 0, -10,-10,-10, 0,-90, 0, 10,-10,-10, 0, 0, 90, 10, 10, 10, 0, 0, 90, 10,-10, 10, 0, 0, 90, -10,-10, 10, 0, 0, 90, -10, 10, 10, 0, 0,-90, 10, 10,-10, 0, 0,-90, 10,-10,-10, 0, 0,-90, -10,-10,-10, 0, 0,-90, -10, 10,-10, 10, 10, 10, -10, 10, 10, 10,-10, 10, -10,-10, 10, 10, 10,-10, -10, 10,-10, 10,-10,-10, -10,-10,-10, 10, 10, 10, 10,-10, 10, -10, 10, 10, -10,-10, 10, 10, 10,-10, 10,-10,-10, -10, 10,-10, -10,-10,-10, 10, 10, 10, 10, 10,-10, 10,-10, 10, 10,-10,-10, -10,-10, 10, -10,-10,-10, -10, 10, 10, -10, 10,-10}; float X, Y, Z, sX, sY, Xa, Ya, Za, sXs, sYs, D, G, Page, Xmid, Ymid; float R, R1, R2, R3, Sr1, Sr2, Sr3, Cr1, Cr2, Cr3, mX, mY, mZ; void main(void) { InitProgram(); MainLoop(); closegraph(); printf("%s\n",COPYRIGHT); // getch(); } void Calc3D(void) { X = -1 * X; Xa = Cr1 * X - Sr1 * Z; Za = Sr1 * X + Cr1 * Z; X = Cr2 * Xa + Sr2 * Y; Ya = Cr2 * Y - Sr2 * Xa; Z = Cr3 * Za - Sr3 * Ya; Y = Sr3 * Za + Cr3 * Ya; X = X + mX; Y = Y + mY; Z = Z + mZ; sX = Xmid + D * X / Z; sY = Ymid + D * Y / Z; } void DrawObject(void) { int i; Rotation(); for(i=0; i (2 * PI)) R1 = 0; break; case 101: case 69: // E R2 += G; if(R2 > (2 * PI)) R2 = 0; break; case 113: case 81: // Q R3 += G; if(R3 > (2 * PI)) R3 = 0; break; case 119: case 87: // W R1 -= G; if(R1 < 0) R1 = 2 * PI; break; case 100: case 68: // D R2 -= G; if(R2 < 0) R2 = 2 * PI; break; case 97: case 65: // A R3 -= G; if(R3 < 0) R3 = 2 * PI; break; case 43: // + if(D < 30000) D += 1000; break; case 45: // - if(D > 1000) D -= 1000; break; case 13: // Enter R1 = 0.3; R2 = 0.0; R3 = 0.3; D = 10000; break; case 32: // Space Demo = 1 - Demo; break; default: break; } if(Demo == 1) { R += 0.1; if(R > (2 * PI)) R = 0; R1 = R2 = R3 = R; } clearviewport(); DrawObject(); Legende(); setvisualpage(Page); Page = 1 - Page; setactivepage(Page); } } void Rotation(void) { Sr1 = sin(R1); Sr2 = sin(R2); Sr3 = sin(R3); Cr1 = cos(R1); Cr2 = cos(R2); Cr3 = cos(R3); } extern int key(void) { int k=0; if(kbhit()) { k = getch(); if (k == 0) k = key(); } return k; } void Legende(void) { outtextxy( 10, 10,"Space: Run/Stop Demo"); outtextxy( 10, 20,"Enter: Set to Zero"); outtextxy( 10, 30,"+/- : Zoom"); outtextxy( 10, 40,"Esc : Quit"); outtextxy(470, 10,"Rotation:"); outtextxy(550, 10,"Q W E"); outtextxy(550, 20,"A S D"); outtextxy( 10,330,COPYRIGHT); outtextxy(540,330,DATUM); }