/** ** PALTEST.C ** ** Copyright (C) 1992, Csaba Biegl ** 820 Stirrup Dr, Nashville, TN, 37221 ** csaba@vuse.vanderbilt.edu ** ** This file is distributed under the terms listed in the document ** "copying.cb", available from the author at the address above. ** A copy of "copying.cb" should accompany this file; if not, a copy ** should be available from where this file was obtained. This file ** may not be distributed without a verbatim copy of "copying.cb". ** You should also have received a copy of the GNU General Public ** License along with this program (it is in the file "copying"); ** if not, write to the Free Software Foundation, Inc., 675 Mass Ave, ** Cambridge, MA 02139, USA. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. **/ #include "test1.h" #include #include #include int zbuf[256][256]; extern brot(int c[3], int b[3], int x , int y, int z); clear3d() { int x,y; int pol[][2] = {{0,0}, {255,0}, {255,255}, {0,255} }; for (x=0; x<256; x++) for (y=0; y<256; y++) zbuf[x][y] = -32000; GrFilledPolygon(4,pol,0); } #define setflatnr(x,y,z,c) if (zbuf[x][y]0 && t2[1]>0 && t2[2]>0 && zbuf[t2[0]][t2[1]]= 0) { switch(Argv[0][0]) { case 'r': case 'R': r = ((Argv[0][1] - '0') & 3) << 6; if(cp == &r) cp = &g; break; case 'g': case 'G': g = ((Argv[0][1] - '0') & 3) << 6; if(cp == &g) cp = &b; break; case 'b': case 'B': b = ((Argv[0][1] - '0') & 3) << 6; if(cp == &b) cp = &r; break; } Argv++; } /* for(ii = 0; ii < 4; ii++) { *cp = ii << 6; GrFilledBox(50*ii,20,50*ii+49,80,GrAllocColor(r,g,b)); } r = g = b = 0; for(ii = 0; ii < 4; ii++) { *cp = ii << 6; GrFilledBox(50*ii,120,50*ii+49,180,GrAllocColor(r,g,b)); } */ /* GrNumColors ; GrSetColor */ for(ii = 0; ii < 256; ii+=1) { GrFreeColor(ii/1); GrSetColor(ii/1,ii,ii,ii); } for(ii = 0; ii < 512; ii++) { GrLine(50+ii,100,50+2*ii+1,300,(ii/1)%256); } for (ii=0; ii<256; ii++) GrLine(0,470-1*ii,500+ii,470,ii); col = 191; GrFilledPolygon(4,pol,col); getkey(); clear3d(); for (ii=0; ii<2*256; ii++) si[ii]=(int) (256.0*sin(ii*2*PI/256)); /* t2[0]=100; t2[1] = 1; t2[2] = 2; printvec(t2); brot(t3,t2,0,0,0); printvec(t3); */ for (w=0; w<20; w+=6) { clear3d(); for (u=0; u<13; u+=3) { for (x=0; x<60; x++) for (y=0; y<50; y++) setflat(x,y,y,210); for (x=0; x<60; x++) for (y=0; y<50; y++) setflat(x+10,y+20,3*(25-y),75); } } for (w=0; w<20; w+=6) { u=w; v=w; clear3d(); for (z=0+64; z<128+64; z++) { zz=SI(z); rr=CO(z); for (x=32; x<33; x++) for (y=0; y<256; y++) setflat(rr*SI(y)/(3*256)+128, rr*CO(y)/(3*256)+128, zz/3, zz>0? zz/2+32 :0 ); } for (z=0; z<256; z++) { zz=SI(z); rr=CO(z); for (x=32; x<33; x++) for (y=0; y<256; y++) setflat(rr*SI(y)/(4*256)+100, rr*CO(y)/(6*256)+64, zz/4, zz>0? zz : 0 ); } getkey(); for (x=40; x<190; x+=23) { vec[0] = x; vec[1]= x + 30; vec[2] = 40-x; r = 30; sphere(vec,r); } getkey(); } } sphere(x,r) int x[],r; { int xx,y,z, zz, rr; /* printf("%d %d %d %d\n",x[0],x[1],x[2],r); fflush(stdout); getkey(); */ for (z=0; z<256; z++) { zz=SI(z); rr=CO(z); rr *= r; rr/=256; for (xx=32; xx<33; xx++) for (y=0; y<256; y++) setflat(rr*SI(y)/(256)+x[0], rr*CO(y)/(256)+x[1], r*zz/256+x[2], zz>0? zz : 0 ); } }