示例#1
0
/* Transform body normals, draw front */
void drawbody(Matrix Rot)
{
    double bodyScale = 1.0/theBodyRadius;
    register int i, j, k, n;

    pushmatrix();
    scale(bodyScale, bodyScale, bodyScale);
    for (j=0; j<bodyNFaces; j++) {
        double dot = Rot[X][Z]*theFaceNormals[j][X]
                     +Rot[Y][Z]*theFaceNormals[j][Y]
                     +Rot[Z][Z]*theFaceNormals[j][Z];
        if (dot>0.0) {	  /* Front-facing polygon, so draw it */
            short shadedColor[3];
            dot += 0.4;
            if (dot>1.0) dot = 1.0;
            shadedColor[0] = dot*theFaceColors[j][0];
            shadedColor[1] = dot*theFaceColors[j][1];
            shadedColor[2] = dot*theFaceColors[j][2];
            n = theFaceVertices[j][0];
            RGBcolor(shadedColor[0], shadedColor[1], shadedColor[2]);
            bgnpolygon();
            for (k=1; k<=n; k++) {
                i = theFaceVertices[j][k];
                v4f(thePoints[i]);
            }
            endpolygon();
        }
    }
    popmatrix();
}
示例#2
0
/*
 * drawpoly
 *
 *	draw some polygons
 */
void
drawpoly()
{
	float	vec[3];
	short	val;

	color(YELLOW);

	/*
	 * Draw a polygon using poly, parray is our array of
	 * points and 4 is the number of points in it.
	 */
	poly(4L, parray);

	color(GREEN);

	/*
	 * Draw a 5 sided figure by using bgnpolygon, v3d, and endpolygon
	 */
	polymode(PYM_LINE);
	bgnpolygon();
		vec[0] = 0.0;
		vec[1] = 0.0;
		vec[2] = 0.0;
		v3f(vec);
		vec[0] = 3.0;
		vec[1] = 0.0;
		vec[2] = 0.0;
		v3f(vec);
		vec[0] = 3.0;
		vec[1] = 4.0;
		vec[2] = 0.0;
		v3f(vec);
		vec[0] = -1.0;
		vec[1] = 5.0;
		vec[2] = 0.0;
		v3f(vec);
		vec[0] = -2.0;
		vec[1] = 2.0;
		vec[2] = 0.0;
		v3f(vec);
	endpolygon();

	color(MAGENTA);

	/*
	 * draw a sector representing a 1/4 circle
	 */
	arc(1.5, -7.0, 3.0, 0, 900);

	move2(1.5, -7.0);
	draw2(1.5, -4.0);

	move2(1.5, -7.0);
	draw2(4.5, -7.0);

	qread(&val);
}
示例#3
0
void drawsegment(filter *f)
{
	float delx, dely; 
	float wid, *fptr;
	float px, py, nx, ny;

	wid = 0.04-f->vel;
	wid = wid*width;
	if(wid<0.00001)
		wid = 0.00001;
	delx = f->angx*wid;
	dely = f->angy*wid;

	color(0);
	px = f->lastx;
	py = f->lasty;
	nx = f->curx;
	ny = f->cury;

	fptr = polyverts+8*npolys;
	bgnpolygon();
	fptr[0] = px+odelx;
	fptr[1] = py+odely;
	v2f(fptr);
	fptr += 2;
	fptr[0] = px-odelx;
	fptr[1] = py-odely;
	v2f(fptr);
	fptr += 2;
	fptr[0] = nx-delx;
	fptr[1] = ny-dely;
	v2f(fptr);
	fptr += 2;
	fptr[0] = nx+delx;
	fptr[1] = ny+dely;
	v2f(fptr);
	fptr += 2;
	endpolygon();
	npolys++;
	if(npolys>=MAXPOLYS) {
		fprintf(stderr,"out of polys - increase the define MAXPOLYS\n");
		npolys--;
	}
	fptr -= 8;
	bgnclosedline();
	v2f(fptr);
	fptr += 2;
	v2f(fptr);
	fptr += 2;
	v2f(fptr);
	fptr += 2;
	v2f(fptr);
	fptr += 2;
	endclosedline();
	odelx = delx;
	odely = dely;
}
示例#4
0
static void triangle(
    float x1, float y1, float z1,
    float x2, float y2, float z2,
    float x3, float y3, float z3
) {
    bgnpolygon();
    vertex(x1, y1, z1);
    vertex(x2, y2, z2);
    vertex(x3, y3, z3);
    endpolygon();
}