当前位置: 首页>>代码示例>>C++>>正文


C++ idPlane类代码示例

本文整理汇总了C++中idPlane的典型用法代码示例。如果您正苦于以下问题:C++ idPlane类的具体用法?C++ idPlane怎么用?C++ idPlane使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了idPlane类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: Cull

/*
===================
Cull

cull points against given shadow frustum.
Return true of all points are outside the frustum.
===================
*/
bool shadowMapFrustum_t::Cull( const idVec3 points[8] ) const {

	bool outsidePlane[6];

	for (int i = 0; i < numPlanes; i++) {

		bool pointsCulled[8] = { true };
		const idPlane plane = planes[i];

		for (int j = 0; j < 8; j++) {
			const float distance = plane.Distance( points[j] );
			pointsCulled[j] = distance < 0;
		}

		outsidePlane[i] = true;
		for (int j = 0; j < 8; j++) {
			if (!pointsCulled[j]) {
				outsidePlane[i] = false;
			}
		}
	}

	for (int i = 0; i < numPlanes; i++) {
		if (outsidePlane[i])
			return true;
	}

	return false;
}
开发者ID:RobertBeckebans,项目名称:fhDOOM,代码行数:37,代码来源:tr_shadowmaps.cpp

示例2: R_CalcInteractionFacing

/*
================
R_CalcInteractionFacing

Determines which triangles of the surface are facing towards the light origin.

The facing array should be allocated with one extra index than
the number of surface triangles, which will be used to handle dangling
edge silhouettes.
================
*/
void R_CalcInteractionFacing( const idRenderEntityLocal *ent, const srfTriangles_t *tri, const idRenderLightLocal *light, srfCullInfo_t &cullInfo ) {
	SCOPED_PROFILE_EVENT( "R_CalcInteractionFacing" );

	if ( cullInfo.facing != NULL ) {
		return;
	}

	idVec3 localLightOrigin;
	R_GlobalPointToLocal( ent->modelMatrix, light->globalLightOrigin, localLightOrigin );

	const int numFaces = tri->numIndexes / 3;
	cullInfo.facing = (byte *) R_StaticAlloc( ( numFaces + 1 ) * sizeof( cullInfo.facing[0] ), TAG_RENDER_INTERACTION );

	// exact geometric cull against face
	for ( int i = 0, face = 0; i < tri->numIndexes; i += 3, face++ ) {
		const idDrawVert & v0 = tri->verts[tri->indexes[i + 0]];
		const idDrawVert & v1 = tri->verts[tri->indexes[i + 1]];
		const idDrawVert & v2 = tri->verts[tri->indexes[i + 2]];

		const idPlane plane( v0.xyz, v1.xyz, v2.xyz );
		const float d = plane.Distance( localLightOrigin );

		cullInfo.facing[face] = ( d >= 0.0f );
	}
	cullInfo.facing[numFaces] = 1;	// for dangling edges to reference
}
开发者ID:Deepfreeze32,项目名称:taken,代码行数:37,代码来源:Interaction.cpp

示例3: R_LocalPlaneToGlobal

void R_LocalPlaneToGlobal( const float modelMatrix[16], const idPlane &in, idPlane &out ) {
	float	offset;

	R_LocalVectorToGlobal( modelMatrix, in.Normal(), out.Normal() );

	offset = modelMatrix[12] * out[0] + modelMatrix[13] * out[1] + modelMatrix[14] * out[2];
	out[3] = in[3] - offset;
}
开发者ID:casey0102,项目名称:iodoom3,代码行数:8,代码来源:tr_main.cpp

示例4: FromWinding

/*
============
idBrush::FromWinding
============
*/
bool idBrush::FromWinding( const idWinding& w, const idPlane& windingPlane )
{
	int i, j, bestAxis;
	idPlane plane;
	idVec3 normal, axialNormal;
	
	sides.Append( new idBrushSide( windingPlane, -1 ) );
	sides.Append( new idBrushSide( -windingPlane, -1 ) );
	
	bestAxis = 0;
	for( i = 1; i < 3; i++ )
	{
		if( idMath::Fabs( windingPlane.Normal()[i] ) > idMath::Fabs( windingPlane.Normal()[bestAxis] ) )
		{
			bestAxis = i;
		}
	}
	axialNormal = vec3_origin;
	if( windingPlane.Normal()[bestAxis] > 0.0f )
	{
		axialNormal[bestAxis] = 1.0f;
	}
	else
	{
		axialNormal[bestAxis] = -1.0f;
	}
	
	for( i = 0; i < w.GetNumPoints(); i++ )
	{
		j = ( i + 1 ) % w.GetNumPoints();
		normal = ( w[j].ToVec3() - w[i].ToVec3() ).Cross( axialNormal );
		if( normal.Normalize() < 0.5f )
		{
			continue;
		}
		plane.SetNormal( normal );
		plane.FitThroughPoint( w[j].ToVec3() );
		sides.Append( new idBrushSide( plane, -1 ) );
	}
	
	if( sides.Num() < 4 )
	{
		for( i = 0; i < sides.Num(); i++ )
		{
			delete sides[i];
		}
		sides.Clear();
		return false;
	}
	
	sides[0]->winding = w.Copy();
	windingsValid = true;
	BoundBrush();
	
	return true;
}
开发者ID:Yetta1,项目名称:OpenTechBFG,代码行数:61,代码来源:Brush.cpp

示例5: EdgeSplitPoint

/*
============
idAASLocal::EdgeSplitPoint

  calculates split point of the edge with the plane
  returns true if the split point is between the edge vertices
============
*/
bool idAASLocal::EdgeSplitPoint( idVec3 &split, int edgeNum, const idPlane &plane ) const {
	const aasEdge_t *edge;
	idVec3 v1, v2;
	float d1, d2;
	edge = &file->GetEdge( edgeNum );
	v1 = file->GetVertex( edge->vertexNum[0] );
	v2 = file->GetVertex( edge->vertexNum[1] );
	d1 = v1 * plane.Normal() - plane.Dist();
	d2 = v2 * plane.Normal() - plane.Dist();
	//if ( (d1 < CM_CLIP_EPSILON && d2 < CM_CLIP_EPSILON) || (d1 > -CM_CLIP_EPSILON && d2 > -CM_CLIP_EPSILON) ) {
	if( FLOATSIGNBITSET( d1 ) == FLOATSIGNBITSET( d2 ) ) {
		return false;
	}
	split = v1 + ( d1 / ( d1 - d2 ) ) * ( v2 - v1 );
	return true;
}
开发者ID:nbohr1more,项目名称:Revelation,代码行数:24,代码来源:AAS_pathing.cpp

示例6: PlaneDistance

/*
================
idBox::PlaneDistance
================
*/
float idBox::PlaneDistance( const idPlane &plane ) const {
	float d1, d2;

	d1 = plane.Distance( center );
	d2 = idMath::Fabs( extents[0] * plane.Normal()[0] ) +
			idMath::Fabs( extents[1] * plane.Normal()[1] ) +
				idMath::Fabs( extents[2] * plane.Normal()[2] );

	if ( d1 - d2 > 0.0f ) {
		return d1 - d2;
	}
	if ( d1 + d2 < 0.0f ) {
		return d1 + d2;
	}
	return 0.0f;
}
开发者ID:Justasic,项目名称:DOOM-3,代码行数:21,代码来源:Box.cpp

示例7: PlaneSide

/*
================
idBox::PlaneSide
================
*/
int idBox::PlaneSide( const idPlane &plane, const float epsilon ) const {
	float d1, d2;

	d1 = plane.Distance( center );
	d2 = idMath::Fabs( extents[0] * plane.Normal()[0] ) +
			idMath::Fabs( extents[1] * plane.Normal()[1] ) +
				idMath::Fabs( extents[2] * plane.Normal()[2] );

	if ( d1 - d2 > epsilon ) {
		return PLANESIDE_FRONT;
	}
	if ( d1 + d2 < -epsilon ) {
		return PLANESIDE_BACK;
	}
	return PLANESIDE_CROSS;
}
开发者ID:Justasic,项目名称:DOOM-3,代码行数:21,代码来源:Box.cpp

示例8: BrushMostlyOnSide

/*
==================
BrushMostlyOnSide

==================
*/
int BrushMostlyOnSide( uBrush_t *brush, idPlane &plane )
{
	int			i, j;
	idWinding	*w;
	float		d, max = 0;
	int			side = PSIDE_FRONT;
	
	for( i = 0; i < brush->numsides; i++ )
	{
		w = brush->sides[i].winding;
		
		if( !w )
		{
			continue;
		}
		
		for( j = 0; j < w->GetNumPoints(); j++ )
		{
			d = plane.Distance( ( *w ) [j].ToVec3() );
			
			if( d > max )
			{
				max = d;
				side = PSIDE_FRONT;
			}
			
			if( -d > max )
			{
				max = -d;
				side = PSIDE_BACK;
			}
		}
	}
	return side;
}
开发者ID:revelator,项目名称:MHDoom,代码行数:41,代码来源:ubrush.cpp

示例9: R_PlaneForSurface

/*
=============
R_PlaneForSurface

Returns the plane for the first triangle in the surface
FIXME: check for degenerate triangle?
=============
*/
static void R_PlaneForSurface( const srfTriangles_t *tri, idPlane &plane ) {
	idDrawVert		*v1, *v2, *v3;
	v1 = tri->verts + tri->indexes[0];
	v2 = tri->verts + tri->indexes[1];
	v3 = tri->verts + tri->indexes[2];
	plane.FromPoints( v1->xyz, v2->xyz, v3->xyz );
}
开发者ID:revelator,项目名称:Revelation,代码行数:15,代码来源:tr_subview.cpp

示例10: R_LightProjectionMatrix

/*
====================
R_LightProjectionMatrix

====================
*/
void R_LightProjectionMatrix( const idVec3 &origin, const idPlane &rearPlane, idVec4 mat[4] ) {
	idVec4		lv;
	float		lg;

	// calculate the homogenious light vector
	lv.x = origin.x;
	lv.y = origin.y;
	lv.z = origin.z;
	lv.w = 1;

	lg = rearPlane.ToVec4() * lv;

	// outer product
	mat[0][0] = lg -rearPlane[0] * lv[0];
	mat[0][1] = -rearPlane[1] * lv[0];
	mat[0][2] = -rearPlane[2] * lv[0];
	mat[0][3] = -rearPlane[3] * lv[0];

	mat[1][0] = -rearPlane[0] * lv[1];
	mat[1][1] = lg -rearPlane[1] * lv[1];
	mat[1][2] = -rearPlane[2] * lv[1];
	mat[1][3] = -rearPlane[3] * lv[1];

	mat[2][0] = -rearPlane[0] * lv[2];
	mat[2][1] = -rearPlane[1] * lv[2];
	mat[2][2] = lg -rearPlane[2] * lv[2];
	mat[2][3] = -rearPlane[3] * lv[2];

	mat[3][0] = -rearPlane[0] * lv[3];
	mat[3][1] = -rearPlane[1] * lv[3];
	mat[3][2] = -rearPlane[2] * lv[3];
	mat[3][3] = lg -rearPlane[3] * lv[3];
}
开发者ID:wang35666,项目名称:doom3,代码行数:39,代码来源:tr_stencilshadow.cpp

示例11: PlaneSide

/*
================
idBounds::PlaneSide
================
*/
int idBounds::PlaneSide( const idPlane &plane, const float epsilon ) const {
	idVec3 center;
	float d1, d2;

	center = ( b[0] + b[1] ) * 0.5f;

	d1 = plane.Distance( center );
	d2 = idMath::Fabs( ( b[1][0] - center[0] ) * plane.Normal()[0] ) +
			idMath::Fabs( ( b[1][1] - center[1] ) * plane.Normal()[1] ) +
				idMath::Fabs( ( b[1][2] - center[2] ) * plane.Normal()[2] );

	if ( d1 - d2 > epsilon ) {
		return PLANESIDE_FRONT;
	}
	if ( d1 + d2 < -epsilon ) {
		return PLANESIDE_BACK;
	}
	return PLANESIDE_CROSS;
}
开发者ID:mrwonko,项目名称:preymotionmod,代码行数:24,代码来源:Bounds.cpp

示例12: PlaneDistance

/*
================
idBounds::PlaneDistance
================
*/
float idBounds::PlaneDistance( const idPlane &plane ) const {
	idVec3 center;
	float d1, d2;

	center = ( b[0] + b[1] ) * 0.5f;

	d1 = plane.Distance( center );
	d2 = idMath::Fabs( ( b[1][0] - center[0] ) * plane.Normal()[0] ) +
			idMath::Fabs( ( b[1][1] - center[1] ) * plane.Normal()[1] ) +
				idMath::Fabs( ( b[1][2] - center[2] ) * plane.Normal()[2] );

	if ( d1 - d2 > 0.0f ) {
		return d1 - d2;
	}
	if ( d1 + d2 < 0.0f ) {
		return d1 + d2;
	}
	return 0.0f;
}
开发者ID:mrwonko,项目名称:preymotionmod,代码行数:24,代码来源:Bounds.cpp

示例13: IsLedgeSide_r

/*
============
idAASBuild::IsLedgeSide_r
============
*/
bool idAASBuild::IsLedgeSide_r( idBrushBSPNode *node, idFixedWinding *w, const idPlane &plane, const idVec3 &normal, const idVec3 &origin, const float radius ) {
	int res, i;
	idFixedWinding back;
	float dist;

	if ( !node ) {
		return false;
	}

	while ( node->GetChild(0) && node->GetChild(1) ) {
		dist = node->GetPlane().Distance( origin );
		if ( dist > radius ) {
			res = SIDE_FRONT;
		}
		else if ( dist < -radius ) {
			res = SIDE_BACK;
		}
		else {
			res = w->Split( &back, node->GetPlane(), LEDGE_EPSILON );
		}
		if ( res == SIDE_FRONT ) {
			node = node->GetChild(0);
		}
		else if ( res == SIDE_BACK ) {
			node = node->GetChild(1);
		}
		else if ( res == SIDE_ON ) {
			// continue with the side the winding faces
			if ( node->GetPlane().Normal() * normal > 0.0f ) {
				node = node->GetChild(0);
			}
			else {
				node = node->GetChild(1);
			}
		}
		else {
			if ( IsLedgeSide_r( node->GetChild(1), &back, plane, normal, origin, radius ) ) {
				return true;
			}
			node = node->GetChild(0);
		}
	}

	if ( node->GetContents() & AREACONTENTS_SOLID ) {
		return false;
	}

	for ( i = 0; i < w->GetNumPoints(); i++ ) {
		if ( plane.Distance( (*w)[i].ToVec3() ) > 0.0f ) {
			return true;
		}
	}

	return false;
}
开发者ID:tankorsmash,项目名称:quadcow,代码行数:60,代码来源:AASBuild_ledge.cpp

示例14: PlaneIntersection

/*
================
idPlane::PlaneIntersection
================
*/
bool idPlane::PlaneIntersection( const idPlane &plane, idVec3 &start, idVec3 &dir ) const {
	double n00, n01, n11, det, invDet, f0, f1;

	n00 = Normal().LengthSqr();
	n01 = Normal() * plane.Normal();
	n11 = plane.Normal().LengthSqr();
	det = n00 * n11 - n01 * n01;

	if ( idMath::Fabs(det) < 1e-6f ) {
		return false;
	}

	invDet = 1.0f / det;
	f0 = ( n01 * plane.d - n11 * d ) * invDet;
	f1 = ( n01 * d - n00 * plane.d ) * invDet;

	dir = Normal().Cross( plane.Normal() );
	start = f0 * Normal() + f1 * plane.Normal();
	return true;
}
开发者ID:krunt,项目名称:projects,代码行数:25,代码来源:Plane.cpp

示例15: PlaneDistance

/*
================
idSphere::PlaneDistance
================
*/
float idSphere::PlaneDistance( const idPlane &plane ) const {
	float d;

	d = plane.Distance( origin );
	if ( d > radius ) {
		return d - radius;
	}
	if ( d < -radius ) {
		return d + radius;
	}
	return 0.0f;
}
开发者ID:AndreiBarsan,项目名称:doom3.gpl,代码行数:17,代码来源:Sphere.cpp


注:本文中的idPlane类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。