|
楼主 |
发表于 2013-4-2 13:47:30
|
显示全部楼层
array 发表于 2013-4-2 13:22
您不妨检查一下这个时候交点都是哪些,是否BoundBox本身就已经是无效的了
我跟过了,交点intersectPoints是有的,并且都在原点附近,BoundingBox是有效地,不知道原因。对了,还有一个奇怪的现象,曾经我用ComputeBoundsVisitor 检查模型中心的时候,画出所有的boundingBox的线框,用的是这个函数,- osg::ref_ptr<osg::Geode> getBox(osg::Node *node)
- {
- osg::ref_ptr<osg::Geode> geode = new osg::Geode;
- osg::ComputeBoundsVisitor cbbv;
- node->accept(cbbv);
- osg::BoundingBox box = cbbv.getBoundingBox();
-
- osg::Vec3 center = osg::Vec3(box.center().x(), box.center().y(), box.center().z());
- float dx = box.xMax()-box.xMin();
- float dy = box.yMax()-box.yMin();
- float dz = box.zMax()-box.zMin();
-
- osg::ref_ptr<osg::ShapeDrawable> pSelectionDrawble = new osg::ShapeDrawable(
- new osg::Box(center, dx, dy, dz));
- pSelectionDrawble->setColor(osg::Vec4(1.0f, 1.0f, 0.0f, 0.3f));
- geode->addDrawable(pSelectionDrawble.get());
- osg::PolygonMode* polymode = new osg::PolygonMode;
- polymode->setMode(osg::PolygonMode::FRONT_AND_BACK,osg::PolygonMode::LINE);
- geode->getOrCreateStateSet()->setAttributeAndModes(polymode,osg::StateAttribute::OVERRIDE|osg::StateAttribute::ON);
- geode->getOrCreateStateSet()->setMode(GL_BLEND,osg::StateAttribute::ON);
- geode->getOrCreateStateSet()->setRenderingHint(osg::StateSet::TRANSPARENT_BIN);
- return geode;
- }
复制代码 也会在某个地方(猜测是原点位置)出现多个点,请Array大师指导,谢谢 |
|