本文整理汇总了C++中osg::Matrixd::postMult方法的典型用法代码示例。如果您正苦于以下问题:C++ Matrixd::postMult方法的具体用法?C++ Matrixd::postMult怎么用?C++ Matrixd::postMult使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类osg::Matrixd
的用法示例。
在下文中一共展示了Matrixd::postMult方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
void MinimalShadowMap::ViewData::trimProjection
( osg::Matrixd & projectionMatrix, osg::BoundingBox bb, unsigned int trimMask )
{
#if 1
if( !bb.valid() || !( trimMask & (1|2|4|8|16|32) ) ) return;
double l = -1, r = 1, b = -1, t = 1, n = 1, f = -1;
#if 0
// make sure bounding box does not extend beyond unit frustum clip range
for( int i = 0; i < 3; i ++ ) {
if( bb._min[i] < -1 ) bb._min[i] = -1;
if( bb._max[i] > 1 ) bb._max[i] = 1;
}
#endif
if( trimMask & 1 ) l = bb._min[0];
if( trimMask & 2 ) r = bb._max[0];
if( trimMask & 4 ) b = bb._min[1];
if( trimMask & 8 ) t = bb._max[1];
if( trimMask & 16 ) n = -bb._min[2];
if( trimMask & 32 ) f = -bb._max[2];
projectionMatrix.postMult( osg::Matrix::ortho( l,r,b,t,n,f ) );
#else
if( !bb.valid() || !( trimMask & (1|2|4|8|16|32) ) ) return;
double l, r, t, b, n, f;
bool ortho = projectionMatrix.getOrtho( l, r, b, t, n, f );
if( !ortho && !projectionMatrix.getFrustum( l, r, b, t, n, f ) )
return; // rotated or skewed or other crooked projection - give up
// make sure bounding box does not extend beyond unit frustum clip range
for( int i = 0; i < 3; i ++ ) {
if( bb._min[i] < -1 ) bb._min[i] = -1;
if( bb._max[i] > 1 ) bb._max[i] = 1;
}
osg::Matrix projectionToView = osg::Matrix::inverse( projectionMatrix );
osg::Vec3 min =
osg::Vec3( bb._min[0], bb._min[1], bb._min[2] ) * projectionToView;
osg::Vec3 max =
osg::Vec3( bb._max[0], bb._max[1], bb._max[2] ) * projectionToView;
if( trimMask & 16 ) { // trim near
if( !ortho ) { // recalc frustum corners on new near plane
l *= -min[2] / n;
r *= -min[2] / n;
b *= -min[2] / n;
t *= -min[2] / n;
}
n = -min[2];
}
if( trimMask & 32 ) // trim far
f = -max[2];
if( !ortho ) {
min[0] *= -n / min[2];
min[1] *= -n / min[2];
max[0] *= -n / max[2];
max[1] *= -n / max[2];
}
if( l < r ) { // check for inverted X range
if( l < min[0] && ( trimMask & 1 ) ) l = min[0];
if( r > max[0] && ( trimMask & 2 ) ) r = max[0];
} else {
if( l > min[0] && ( trimMask & 1 ) ) l = min[0];
if( r < max[0] && ( trimMask & 2 ) ) r = max[0];
}
if( b < t ) { // check for inverted Y range
if( b < min[1] && ( trimMask & 4 ) ) b = min[1];
if( t > max[1] && ( trimMask & 8 ) ) t = max[1];
} else {
if( b > min[1] && ( trimMask & 4 ) ) b = min[1];
if( t < max[1] && ( trimMask & 8 ) ) t = max[1];
}
if( ortho )
projectionMatrix.makeOrtho( l, r, b, t, n, f );
else
projectionMatrix.makeFrustum( l, r, b, t, n, f );
#endif
}