示例#1
0
void  TXPArchive::getExtents(osg::BoundingBox& extents)
{
    TileInfo sw, ne;
    trpg2iPoint tileExtents;

    this->GetHeader()->GetLodSize(0, tileExtents);
    this->getTileInfo(0, 0, 0, sw);
    this->getTileInfo(tileExtents.x-1, tileExtents.y-1, 0, ne);
    extents.set(sw.bbox._min, sw.bbox._max);
    extents.expandBy(ne.bbox);
}
void ComputeBoundingBoxByRotation(osg::BoundingBox & InOut,osg::Vec3 BBCenter,float BBSize,osg::Matrixd Rotation)
{
	osg::BoundingBox bb;
	bb.set(BBCenter.x()-BBSize,BBCenter.y()-BBSize,BBCenter.z()-BBSize,BBCenter.x()+BBSize,BBCenter.y()+BBSize,BBCenter.z()+BBSize);
    osg::BoundingBox Tbb;
	for(unsigned int i=0;i<8;i++)
    {
        Tbb.expandBy(Rotation.preMult(bb.corner(i)));
    }
	InOut.set(Tbb.xMin(),Tbb.yMin(),Tbb.zMin(),Tbb.xMax(),Tbb.yMax(),Tbb.zMax());
}
示例#3
0
bool GetBoundingBox(osg::BoundingBox & BB, dtCore::DeltaDrawable & drawable)
{
    osg::Node* node = drawable.GetOSGNode();
    if (node != 0)
    {
        dtUtil::BoundingBoxVisitor bbv;
		node->accept(bbv);

		// no copy constructor for osg::BB...
		BB.set(bbv.mBoundingBox._min, bbv.mBoundingBox._max);
		return true;
    }

    LOG_WARNING("No valid osg node of drawable when asking for bounding box.");
    return false;
}