|
osg::ref_ptr<osg::Geometry> geom=new osg::Geometry;
osg::ref_ptr<osg::Vec3Array> v=new osg::Vec3Array;
geom->setVertexArray( v.get() );
v->push_back( osg::Vec3( -1.f, 0.f, -1.f ) );
v->push_back( osg::Vec3( 1.f, 0.f, -1.f ) );
v->push_back( osg::Vec3( 1.f, 0.f, 1.f ) );
v->push_back( osg::Vec3( 1.f, 0.f, 1.f ) );
v->push_back( osg::Vec3( -1.f, 0.f, 1.f ) );
v->push_back( osg::Vec3( -1.f, 0.f, -1.f ) );
osg::ref_ptr<osg::Vec4Array> c = new osg::Vec4Array;
geom->setColorArray( c.get() );
geom->setColorBinding( osg::Geometry::BIND_PER_VERTEX );
c->push_back( osg::Vec4( 1.f, 0.f, 0.f, 1.f ) );
c->push_back( osg::Vec4( 0.f, 1.f, 0.f, 1.f ) );
c->push_back( osg::Vec4( 0.f, 0.f, 1.f, 1.f ) );
c->push_back( osg::Vec4( 1.f, 0.f, 0.f, 1.f ) );
c->push_back( osg::Vec4( 0.f, 1.f, 0.f, 1.f ) );
c->push_back( osg::Vec4( 0.f, 0.f, 1.f, 1.f ) );
osg::ref_ptr<osg::Vec3Array> n = new osg::Vec3Array;
geom->setNormalArray( n.get() );
geom->setNormalBinding( osg::Geometry::BIND_OVERALL );
n->push_back( osg::Vec3( 0.f, -1.f, 0.f ) );
geom->addPrimitiveSet(
new osg:rawArrays( osg:rimitiveSet::TRIANGLES,0,6 ) );
osg::ref_ptr<osg::KdTree> kd = new osg::KdTree();
osg::KdTree::BuildOptions op;
if (kd->build( op, geom.get() ))
{
cout<<"KdTree创建成功!!\n";
if(geode->addDrawable(new osg::ShapeDrawable(kd.get())))
{
cout<<"添加Drawable成功!!\n";
}
}
为什么没有绘制出来任何东西呢??
|
|