osg::ref_ptr<osg::Geode> OSG_Qt_::createBox()
{
osg::ref_ptr<osg::Geode> osg_geode = new osg::Geode;
osg::ref_ptr<osg::TessellationHints> osg_hints = new osg::TessellationHints;
osg::ref_ptr<osg::Box> osg_box = new osg::Box(osg::Vec3(0.0, 0.0, 0.0), 1.0, 0.5, 3.0);
osg::ref_ptr<osg::ShapeDrawable> osg_shapedrawable = new osg::ShapeDrawable(osg_box,osg_hints.get());

//设置颜色
osg::ref_ptr<osg::Material> osg_material = new osg::Material;
osg_material->setAmbient(osg::Material::FRONT_AND_BACK,osg::Vec4(1.0,1.0,1.0,1.0));
osg_material->setDiffuse(osg::Material::FRONT_AND_BACK, osg::Vec4(1.0, 1.0, 1.0, 1.0));
osg_material->setSpecular(osg::Material::FRONT_AND_BACK, osg::Vec4(1.0, 1.0, 1.0, 1.0));
osg_material->setShininess(osg::Material::FRONT_AND_BACK,60.0);

//应用材质
osg_geode->getOrCreateStateSet()->setAttributeAndModes(osg_material.get(),osg::StateAttribute::ON);
//设置透明度
osg_geode->getOrCreateStateSet()->setMode(GL_BLEND,osg::StateAttribute::ON);

//设置精度
osg_hints->setDetailRatio(0.5);
osg_geode->addDrawable(osg_shapedrawable.get());
return osg_geode;
}


 

osg 自定义图元_其他