コード例 #1
0
ファイル: cm_trisoup.c プロジェクト: a1batross/Xash3D_ancient
/*
=====================
CM_GenerateFacetFor4Points
=====================
*/
bool CM_GenerateFacetFor4Points( cfacet_t *facet, const vec3_t p1, const vec3_t p2, const vec3_t p3, const vec3_t p4 )
{
	float	dist;
	vec4_t	plane;

	// if we can't generate a valid plane for the points, ignore the facet
	if( facet->surfacePlane == -1 )
	{
		facet->numBorders = 0;
		return false;
	}

	Vector4Copy( planes[facet->surfacePlane].plane, plane );

	// if the fourth point is also on the plane, we can make a quad facet
	dist = DotProduct( p4, plane ) - plane[3];
	if( fabs( dist ) > ON_EPSILON )
	{
		facet->numBorders = 0;
		return false;
	}

	facet->numBorders = 4;
	facet->borderNoAdjust[0] = false;
	facet->borderNoAdjust[1] = false;
	facet->borderNoAdjust[2] = false;
	facet->borderNoAdjust[3] = false;
	facet->borderPlanes[0] = CM_GenerateBoundaryForPoints( plane, p1, p2 );
	facet->borderPlanes[1] = CM_GenerateBoundaryForPoints( plane, p2, p3 );
	facet->borderPlanes[2] = CM_GenerateBoundaryForPoints( plane, p3, p4 );
	facet->borderPlanes[3] = CM_GenerateBoundaryForPoints( plane, p4, p1 );

	return true;
}
コード例 #2
0
/*
=====================
CM_GenerateFacetFor3Points
=====================
*/
bool CM_GenerateFacetFor3Points( cFacet_t *facet, const vec3_t p1, const vec3_t p2, const vec3_t p3 )
{
	vec4_t          plane;

	// if we can't generate a valid plane for the points, ignore the facet
	//if(!PlaneFromPoints(f->surface, a, b, c, true))
	if ( facet->surfacePlane == -1 )
	{
		facet->numBorders = 0;
		return false;
	}

	Vector4Copy( planes[ facet->surfacePlane ].plane, plane );

	facet->numBorders = 3;

	facet->borderNoAdjust[ 0 ] = false;
	facet->borderNoAdjust[ 1 ] = false;
	facet->borderNoAdjust[ 2 ] = false;

	facet->borderPlanes[ 0 ] = CM_GenerateBoundaryForPoints( plane, p1, p2 );
	facet->borderPlanes[ 1 ] = CM_GenerateBoundaryForPoints( plane, p2, p3 );
	facet->borderPlanes[ 2 ] = CM_GenerateBoundaryForPoints( plane, p3, p1 );

	//VectorCopy(a->xyz, f->points[0]);
	//VectorCopy(b->xyz, f->points[1]);
	//VectorCopy(c->xyz, f->points[2]);

	return true;
}
コード例 #3
0
qboolean CM_GenerateFacetFor4Points( cFacet_t *f, drawVert_t *a, drawVert_t *b, drawVert_t *c, drawVert_t *d ) {
	float	dist;
	int		i;
	vec4_t	plane;

	// if we can't generate a valid plane for the points, ignore the facet
	if ( !PlaneFromPoints( f->surface, a->xyz, b->xyz, c->xyz ) ) {
		f->numBoundaries = 0;
		return qfalse;
	}

	// if the fourth point is also on the plane, we can make a quad facet
	dist = DotProduct( d->xyz, f->surface ) - f->surface[3];
	if ( fabs( dist ) > PLANAR_EPSILON ) {
		f->numBoundaries = 0;
		return qfalse;
	}

	// make boundaries
	f->numBoundaries = 4;

	CM_GenerateBoundaryForPoints( f->boundaries[0], f->surface, a->xyz, b->xyz );
	CM_GenerateBoundaryForPoints( f->boundaries[1], f->surface, b->xyz, c->xyz );
	CM_GenerateBoundaryForPoints( f->boundaries[2], f->surface, c->xyz, d->xyz );
	CM_GenerateBoundaryForPoints( f->boundaries[3], f->surface, d->xyz, a->xyz );

	VectorCopy( a->xyz, f->points[0] );
	VectorCopy( b->xyz, f->points[1] );
	VectorCopy( c->xyz, f->points[2] );
	VectorCopy( d->xyz, f->points[3] );

	for (i = 1; i < 4; i++)
	{
		if ( !PlaneFromPoints( plane, f->points[i], f->points[(i+1) % 4], f->points[(i+2) % 4]) ) {
			f->numBoundaries = 0;
			return qfalse;
		}

		if (DotProduct(f->surface, plane) < 0.9) {
			f->numBoundaries = 0;
			return qfalse;
		}
	}

	TextureMatrixFromPoints( f, a, b, c );

	return qtrue;
}
コード例 #4
0
/*
=====================
CM_GenerateFacetFor3Points
=====================
*/
qboolean CM_GenerateFacetFor3Points( cFacet_t *f, drawVert_t *a, drawVert_t *b, drawVert_t *c ) {
	// if we can't generate a valid plane for the points, ignore the facet
	if ( !PlaneFromPoints( f->surface, a->xyz, b->xyz, c->xyz ) ) {
		f->numBoundaries = 0;
		return qfalse;
	}

	// make boundaries
	f->numBoundaries = 3;

	CM_GenerateBoundaryForPoints( f->boundaries[0], f->surface, a->xyz, b->xyz );
	CM_GenerateBoundaryForPoints( f->boundaries[1], f->surface, b->xyz, c->xyz );
	CM_GenerateBoundaryForPoints( f->boundaries[2], f->surface, c->xyz, a->xyz );

	VectorCopy( a->xyz, f->points[0] );
	VectorCopy( b->xyz, f->points[1] );
	VectorCopy( c->xyz, f->points[2] );

	TextureMatrixFromPoints( f, a, b, c );

	return qtrue;
}