本文整理汇总了C++中idFixedWinding::Split方法的典型用法代码示例。如果您正苦于以下问题:C++ idFixedWinding::Split方法的具体用法?C++ idFixedWinding::Split怎么用?C++ idFixedWinding::Split使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类idFixedWinding
的用法示例。
在下文中一共展示了idFixedWinding::Split方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Fracture_r
/*
================
idBrittleFracture::Fracture_r
================
*/
void idBrittleFracture::Fracture_r( idFixedWinding &w ) {
int i, j, bestPlane;
float a, c, s, dist, bestDist;
idVec3 origin;
idPlane windingPlane, splitPlanes[2];
idMat3 axis, axistemp;
idFixedWinding back;
idTraceModel trm;
idClipModel *clipModel;
while( 1 ) {
origin = w.GetCenter();
w.GetPlane( windingPlane );
if( w.GetArea() < maxShardArea ) {
break;
}
// randomly create a split plane
a = gameLocal.random.RandomFloat() * idMath::TWO_PI;
c = cos( a );
s = -sin( a );
axis[2] = windingPlane.Normal();
axis[2].NormalVectors( axistemp[0], axistemp[1] );
axis[0] = axistemp[ 0 ] * c + axistemp[ 1 ] * s;
axis[1] = axistemp[ 0 ] * s + axistemp[ 1 ] * -c;
// get the best split plane
bestDist = 0.0f;
bestPlane = 0;
for( i = 0; i < 2; i++ ) {
splitPlanes[i].SetNormal( axis[i] );
splitPlanes[i].FitThroughPoint( origin );
for( j = 0; j < w.GetNumPoints(); j++ ) {
dist = splitPlanes[i].Distance( w[j].ToVec3() );
if( dist > bestDist ) {
bestDist = dist;
bestPlane = i;
}
}
}
// split the winding
if( !w.Split( &back, splitPlanes[bestPlane] ) ) {
break;
}
// recursively create shards for the back winding
Fracture_r( back );
}
// translate the winding to it's center
origin = w.GetCenter();
for( j = 0; j < w.GetNumPoints(); j++ ) {
w[j].ToVec3() -= origin;
}
w.RemoveEqualPoints();
trm.SetupPolygon( w );
trm.Shrink( CM_CLIP_EPSILON );
clipModel = new idClipModel( trm );
physicsObj.SetClipModel( clipModel, 1.0f, shards.Num() );
physicsObj.SetOrigin( GetPhysics()->GetOrigin() + origin, shards.Num() );
physicsObj.SetAxis( GetPhysics()->GetAxis(), shards.Num() );
AddShard( clipModel, w );
}