コード例 #1
0
	void addGeometry(SPGeometry geometry)
	{
		mBB.addPoint(geometry->getBB().min());
		mBB.addPoint(geometry->getBB().max());

		mGeometries.push_back(geometry);
	}
コード例 #2
0
ファイル: csgRegularPolygon.cpp プロジェクト: SnqKe/CPOA
BoundingBox CsgRegularPolygon::getBoundingBox()
{
	BoundingBox ret;
	Matrix33f mat = getMatrix();
	Vec3f v;

	v = mat * Vec3f(-0.5, -0.5, 1);
	ret.addPoint(v);
	v = mat * Vec3f(-0.5, +0.5, 1);
	ret.addPoint(v);
	v = mat * Vec3f(+0.5, -0.5, 1);
	ret.addPoint(v);
	v = mat * Vec3f(+0.5, +0.5, 1);
	ret.addPoint(v);

	return ret;
}
コード例 #3
0
    void buildCollision()
    {
        if (!mChanged)
            return;

        mChanged = false;

        mBoundingBoxes.clear();
        m_BB.reset();

        for (size_t div = 0; div < mVertices.size() / mDivCount; div++)
        {
            BoundingBox<Vector> bb;

            for (auto i = div*mDivCount; i < mVertices.size(); i++)
            {
                if (i > div*mDivCount + mDivCount)
                    break;

                bb.addPoint(mVertices[i]);
                m_BB.addPoint(mVertices[i]);
            }

            mBoundingBoxes.push_back(bb);
        }



        if (mVertices.size() % mDivCount != 0)
        {
            BoundingBox<Vector> bb;

            auto start = mVertices.size() - mVertices.size() % mDivCount;
            auto end = mVertices.size();

            for (auto i = start; i < end; i++)
            {
                bb.addPoint(mVertices[i]);
                m_BB.addPoint(mVertices[i]);
            }

            mBoundingBoxes.push_back(bb);
        }
    }
コード例 #4
0
ファイル: Mesh.cpp プロジェクト: Aantonb/gotham
void Mesh
  ::getBoundingBox(BoundingBox &b) const
{
  b.setEmpty();

  // iterate over positions
  for(PointList::const_iterator p = getPoints().begin();
      p != getPoints().end();
      ++p)
  {
    b.addPoint(*p);
  } // end for p
} // end Mesh::getBoundingBox()
コード例 #5
0
osg::Node* OSGVisualizationFactory::CreateBoundingBox(osg::Node *model, bool wireFrame)
{
	if (!model)
		return NULL;

	const osg::MatrixList& m = model->getWorldMatrices(); 
	osg::ComputeBoundsVisitor cbv; 
	model->accept( cbv ); 
	osg::BoundingBox bboxOSG = cbv.getBoundingBox(); 
	osg::Vec3 minV = bboxOSG._min * m.front(); 
	osg::Vec3 maxV = bboxOSG._max * m.front(); 

	BoundingBox bbox;
	Eigen::Vector3f minPoint(minV[0],minV[1],minV[2]);
	Eigen::Vector3f maxPoint(maxV[0],maxV[1],maxV[2]);
	bbox.addPoint(minPoint);
	bbox.addPoint(maxPoint);
	return CreateBoundingBoxVisualization(bbox,wireFrame);
}
コード例 #6
0
ファイル: PointSetNode.cpp プロジェクト: x414e54/CyberX3D4CC
void PointSetNode::recomputeBoundingBox() 
{
	CoordinateNode *coordinate = getCoordinateNodes();
	if (!coordinate) {
		setBoundingBoxCenter(0.0f, 0.0f, 0.0f);
		setBoundingBoxSize(-1.0f, -1.0f, -1.0f);
		return;
	}

	BoundingBox bbox;
	float		point[3];

	int nCoordinatePoints = coordinate->getNPoints();
	for (int n=0; n<nCoordinatePoints; n++) {
		coordinate->getPoint(n, point);
		bbox.addPoint(point);
	}

	setBoundingBox(&bbox);
}