osg给节点染色

osg给节点染色

osg::ref_ptr<osg::ShapeDrawable> draw_h_bar_index = new osg::ShapeDrawable(new osg::Box(osg::Vec3(0.0, 0.0, 0.0), 1.0, 10.0, 10.0));
//设置材质
osg::ref_ptr<osg::Material> column_material = new osg::Material;
//设置环境光
column_material->setAmbient(osg::Material::FRONT_AND_BACK, osg::Vec4(1.0, 0.7, 0.0, 1.0));
//设置散射光
column_material->setDiffuse(osg::Material::FRONT_AND_BACK, osg::Vec4(1.0, 1.0, 1.0, 1.0));
//设置镜面光
column_material->setSpecular(osg::Material::FRONT_AND_BACK, osg::Vec4(1.0, 1.0, 1.0, 1.0));
//设置幅射光
column_material->setShininess(osg::Material::FRONT_AND_BACK, 60.0);

//设置材质
draw_h_bar_index->getOrCreateStateSet()->setAttributeAndModes(column_material, osg::StateAttribute::ON);

 

 

 

###################

posted @ 2021-10-07 16:19  西北逍遥  阅读(455)  评论(0编辑  收藏  举报