本文整理汇总了C++中NodeRefPtr::getVolume方法的典型用法代码示例。如果您正苦于以下问题:C++ NodeRefPtr::getVolume方法的具体用法?C++ NodeRefPtr::getVolume怎么用?C++ NodeRefPtr::getVolume使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NodeRefPtr
的用法示例。
在下文中一共展示了NodeRefPtr::getVolume方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: showAll
void showAll(PerspectiveCameraRefPtr TheCamera, NodeRefPtr Scene, Vec3f Up)
{
//Make sure the volume is up to date for the Scene
Scene->updateVolume();
//Get the Minimum and Maximum bounds of the volume
Vec3f min,max;
Scene->getVolume().getBounds( min, max );
Vec3f d = max - min;
if(d.length() < Eps) //The volume is 0
{
//Default to a 1x1x1 box volume
min.setValues(-0.5f,-0.5f,-0.5f);
max.setValues( 0.5f, 0.5f, 0.5f);
d = max - min;
}
Real32 dist = osgMax(d[0],d[1]) / (2 * osgTan(TheCamera->getFov() / 2.f));
Pnt3f at((min[0] + max[0]) * .5f,(min[1] + max[1]) * .5f,(min[2] + max[2]) * .5f);
Pnt3f from=at;
from[2]+=(dist+fabs(max[2]-min[2])*0.5f);
//If the Camera Beacon is a node with a transfrom core
if(TheCamera->getBeacon() != NULL &&
TheCamera->getBeacon()->getCore() != NULL &&
TheCamera->getBeacon()->getCore()->getType().isDerivedFrom(Transform::getClassType()))
{
Matrix m;
if(!MatrixLookAt(m, from, at, Up))
{
dynamic_cast<Transform*>(TheCamera->getBeacon()->getCore())->setMatrix(m);
}
}
//Set the camera to go from 1% of the object to 10 times its size
Real32 diag = osgMax(osgMax(d[0], d[1]), d[2]);
TheCamera->setNear (diag / 100.f);
TheCamera->setFar (10 * diag);
}