void DebugLineDouble(vec3_t start, vec3_t end, int color) {
	vec3_t points[4], morepoints[4], dir, cross, up = {0, 0, 1};
	float dot;

	VectorCopy(start, points[0]);
	VectorCopy(start, points[1]);
	//points[1][2] -= 2;
	VectorCopy(end, points[2]);
	//points[2][2] -= 2;
	VectorCopy(end, points[3]);


	VectorSubtract(end, start, dir);
	VectorNormalize(dir);
	dot = DotProduct(dir, up);
	if (dot > 0.99 || dot < -0.99) VectorSet(cross, 1, 0, 0);
	else CrossProduct(dir, up, cross);

	VectorNormalize(cross);

	VectorMA(points[0], 2, up, morepoints[0]);
	VectorMA(points[1], -2, up, morepoints[1]);
	VectorMA(points[2], -2, up, morepoints[2]);
	VectorMA(points[3], 2, up, morepoints[3]);

	VectorMA(points[0], 2, cross, points[0]);
	VectorMA(points[1], -2, cross, points[1]);
	VectorMA(points[2], -2, cross, points[2]);
	VectorMA(points[3], 2, cross, points[3]);

	trap_DebugPolygonCreate(color, 4, points);
	trap_DebugPolygonCreate(color, 4, morepoints);
}
示例#2
0
/*
================
DebugLine

debug polygons only work when running a local game
with r_debugSurface set to 2
================
*/
int DebugLine( vec3_t start, vec3_t end, int color ) {
	vec3_t points[4], dir, cross, up = {0, 0, 1};
	float dot;

	VectorCopy( start, points[0] );
	VectorCopy( start, points[1] );
	VectorCopy( end, points[2] );
	VectorCopy( end, points[3] );

	VectorSubtract( end, start, dir );
	VectorNormalize( dir );
	dot = DotProduct( dir, up );
	if ( dot > 0.99 || dot < -0.99 ) {
		VectorSet( cross, 1, 0, 0 );
	} else { CrossProduct( dir, up, cross ); }

	VectorNormalize( cross );

	VectorMA( points[0], 2, cross, points[0] );
	VectorMA( points[1], -2, cross, points[1] );
	VectorMA( points[2], -2, cross, points[2] );
	VectorMA( points[3], 2, cross, points[3] );

	return trap_DebugPolygonCreate( color, 4, points );
}