|
楼主 |
发表于 2012-5-22 10:38:10
|
显示全部楼层
array 发表于 2012-5-22 09:38
您需要给出更多的信息,自己写的Drawable是不能求交的,不过如果您是用了Geometry并继承它的话,倒是没有问 ...
osg::ref_ptr<osg:rawable> createRectangle()
{
osg::ref_ptr<osg::Geometry> geom = new osg::Geometry();
osg::ref_ptr<osg::Vec3Array> coords = new osg::Vec3Array();
coords->push_back(osg::Vec3(-6.5f,0.0f,6.5f));
coords->push_back(osg::Vec3(-6.5f,0.0f,5.5f));
coords->push_back(osg::Vec3(-6.0f,0.0f,5.5f));
coords->push_back(osg::Vec3(-6.0f,0.0f,6.5f));
geom->setVertexArray(coords.get());
geom->addPrimitiveSet(new osg::DrawArrays(osg:rimitiveSet:UADS,0,4));
osg::ref_ptr<osg::Vec3Array> nc = new osg::Vec3Array();
nc->push_back(osg::Vec3(0.0f,-1.0f,0.0f));
geom->setNormalArray(nc.get());
geom->setNormalBinding(osg::Geometry::BIND_OVERALL);
osg::ref_ptr<osg::Vec4Array> vc = new osg::Vec4Array();
vc->push_back(osg::Vec4(1.0f,1.0f,1.0f,1.0f));
vc->push_back(osg::Vec4(1.0f,1.0f,1.0f,1.0f));
vc->push_back(osg::Vec4(1.0f,1.0f,1.0f,1.0f));
vc->push_back(osg::Vec4(1.0f,1.0f,1.0f,1.0f));
geom->setColorArray(vc.get());
geom->setColorBinding(osg::Geometry::BIND_OVERALL);
osg::StateSet* stateset = geom->getOrCreateStateSet();
stateset->setMode(GL_LIGHTING,osg::StateAttribute::OFF);
stateset->setMode(GL_DEPTH_TEST,osg::StateAttribute::ON);
return geom.get();
}
我是定义的一个Drawable,把它加给BillBoard就不能拾取,加给geode就可以拾取 |
|