Example #1
0
File: misc.c Project: arvidfm/fiend
void draw_fiend_beam(BITMAP *dest, BITMAP *img, int x1, int y1,int x2, int y2)
{
	int i;

	V3D_f point[4];
	V3D_f temp_point[2];

	VERTEX the_point[4];
	
	float angle;

	angle = compute_angle(x2,y2,x1,y1);

	// set points of a point...
	temp_point[0].y = 0;
	temp_point[0].x = -img->w/2;
	temp_point[1].y = 0;
	temp_point[1].x = img->w/2;

	//rotate the points
	for(i=0;i<2;i++)
	{
		point[i].x = (temp_point[i].x*COS(angle)-temp_point[i].y*SIN(angle));
		point[i].y = (temp_point[i].y*COS(angle)+temp_point[i].x*SIN(angle));
	}

	//give the other point thses cords...
	point[2].x = point[0].x;
	point[2].y = point[0].y;
	point[3].x = point[1].x;
	point[3].y = point[1].y;

	//transform to world space..
	point[0].x += x1;
	point[0].y += y1;
	point[1].x += x1;
	point[1].y += y1;
	point[2].x += x2;
	point[2].y += y2;
	point[3].x += x2;
	point[3].y += y2;

	//set the u,v cords (texture cords)
	for(i=0;i<4;i++)
		point[i].c = makecol(255,0,0);

	point[0].u = 0;
	point[0].v = 0;
	point[1].u = img->w;
	point[1].v = 0;
	point[2].u = 0;
	point[2].v = distance(point[0].x,point[0].y,point[2].x,point[2].y );
	point[3].u = img->w;
	point[3].v = distance(point[1].x,point[1].y,point[3].x,point[3].y );

	for(i=0;i<4;i++)
	{
		the_point[i].x = point[i].x;
		the_point[i].y = point[i].y;
		the_point[i].u = point[i].u;
		the_point[i].v = point[i].v;
	}


	quad3d_f(dest,POLYTYPE_ATEX_MASK,img, &point[0], &point[1], &point[3],&point[2] );

	//fiend_quad3d(dest,img, &the_point[0], &the_point[1], &the_point[3],&the_point[2] );

	
	//for(i=0;i<4;i++)
		//circlefill(dest,point[i].x,point[i].y,3,makecol(255,0,255));
}