本文整理汇总了C++中idFixedWinding::GetBounds方法的典型用法代码示例。如果您正苦于以下问题:C++ idFixedWinding::GetBounds方法的具体用法?C++ idFixedWinding::GetBounds怎么用?C++ idFixedWinding::GetBounds使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类idFixedWinding
的用法示例。
在下文中一共展示了idFixedWinding::GetBounds方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CreateProjectionInfo
/*
=================
idRenderModelDecal::CreateProjectionInfo
=================
*/
bool idRenderModelDecal::CreateProjectionInfo( decalProjectionInfo_t &info, const idFixedWinding &winding, const idVec3 &projectionOrigin, const bool parallel, const float fadeDepth, const idMaterial *material, const int startTime ) {
if( winding.GetNumPoints() != NUM_DECAL_BOUNDING_PLANES - 2 ) {
common->Printf( "idRenderModelDecal::CreateProjectionInfo: winding must have %d points\n", NUM_DECAL_BOUNDING_PLANES - 2 );
return false;
}
assert( material != NULL );
info.projectionOrigin = projectionOrigin;
info.material = material;
info.parallel = parallel;
info.fadeDepth = fadeDepth;
info.startTime = startTime;
info.force = false;
// get the winding plane and the depth of the projection volume
idPlane windingPlane;
winding.GetPlane( windingPlane );
float depth = windingPlane.Distance( projectionOrigin );
// find the bounds for the projection
winding.GetBounds( info.projectionBounds );
if( parallel ) {
info.projectionBounds.ExpandSelf( depth );
} else {
info.projectionBounds.AddPoint( projectionOrigin );
}
// calculate the world space projection volume bounding planes, positive sides face outside the decal
if( parallel ) {
for( int i = 0; i < winding.GetNumPoints(); i++ ) {
idVec3 edge = winding[( i + 1 ) % winding.GetNumPoints()].ToVec3() - winding[i].ToVec3();
info.boundingPlanes[i].Normal().Cross( windingPlane.Normal(), edge );
info.boundingPlanes[i].Normalize();
info.boundingPlanes[i].FitThroughPoint( winding[i].ToVec3() );
}
} else {
for( int i = 0; i < winding.GetNumPoints(); i++ ) {
info.boundingPlanes[i].FromPoints( projectionOrigin, winding[i].ToVec3(), winding[( i + 1 ) % winding.GetNumPoints()].ToVec3() );
}
}
info.boundingPlanes[NUM_DECAL_BOUNDING_PLANES - 2] = windingPlane;
info.boundingPlanes[NUM_DECAL_BOUNDING_PLANES - 2][3] -= depth;
info.boundingPlanes[NUM_DECAL_BOUNDING_PLANES - 1] = -windingPlane;
// fades will be from these plane
info.fadePlanes[0] = windingPlane;
info.fadePlanes[0][3] -= fadeDepth;
info.fadePlanes[1] = -windingPlane;
info.fadePlanes[1][3] += depth - fadeDepth;
// calculate the texture vectors for the winding
float len, texArea, inva;
idVec3 temp;
idVec5 d0, d1;
const idVec5 &a = winding[0];
const idVec5 &b = winding[1];
const idVec5 &c = winding[2];
d0 = b.ToVec3() - a.ToVec3();
d0.s = b.s - a.s;
d0.t = b.t - a.t;
d1 = c.ToVec3() - a.ToVec3();
d1.s = c.s - a.s;
d1.t = c.t - a.t;
texArea = ( d0[3] * d1[4] ) - ( d0[4] * d1[3] );
inva = 1.0f / texArea;
temp[0] = ( d0[0] * d1[4] - d0[4] * d1[0] ) * inva;
temp[1] = ( d0[1] * d1[4] - d0[4] * d1[1] ) * inva;
temp[2] = ( d0[2] * d1[4] - d0[4] * d1[2] ) * inva;
len = temp.Normalize();
info.textureAxis[0].Normal() = temp * ( 1.0f / len );
info.textureAxis[0][3] = winding[0].s - ( winding[0].ToVec3() * info.textureAxis[0].Normal() );
temp[0] = ( d0[3] * d1[0] - d0[0] * d1[3] ) * inva;
temp[1] = ( d0[3] * d1[1] - d0[1] * d1[3] ) * inva;
temp[2] = ( d0[3] * d1[2] - d0[2] * d1[3] ) * inva;
len = temp.Normalize();
info.textureAxis[1].Normal() = temp * ( 1.0f / len );
info.textureAxis[1][3] = winding[0].t - ( winding[0].ToVec3() * info.textureAxis[1].Normal() );
return true;
}