osg Box透明度

 

复制代码
#include <osg/Node>
#include <osgViewer/Viewer>
#include <osgDB/ReadFile>
#include <osg/ShapeDrawable>

int main()
{
    // 创建Box对象
    osg::ref_ptr<osg::Box> box = new osg::Box(osg::Vec3(0, 0, 0), 15, 2, 14);
    box->setHalfLengths(osg::Vec3(7.5, 1, 7)); // 设置Box的尺寸和位置

    // 创建Geode对象
    osg::ref_ptr<osg::Geode> geode = new osg::Geode();
    geode->addDrawable(box.get()); // 将Box添加到Geode中

    // 创建材质对象
    osg::ref_ptr<osg::Material> material = new osg::Material;
    material->setAmbient(osg::Vec4(0.5, 0.5, 0.5, 0.5)); // 设置混合光颜色为灰色,并设置透明度为0.5
    material->setDiffuse(osg::Vec4(0.5, 0.5, 0.5, 0.5)); // 设置漫反射光颜色为灰色,并设置透明度为0.5
    material->setSpecular(osg::Vec4(1, 1, 1, 1)); // 设置镜面光颜色为白色,并设置透明度为1
    material->setShininess(128.0); // 设置镜面光强度为128

    // 将材质添加到Geode的状态集
    geode->getOrCreateStateSet()->setAttributeAndModes(material.get(), osg::StateAttribute::ON);

    // 创建视图器并显示场景图
    osgViewer::Viewer viewer;
    viewer.setSceneData(geode);
    viewer.run();

    return 0;
}
复制代码

 

 

 

 

 

========

posted @   西北逍遥  阅读(41)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义
· 提示词工程——AI应用必不可少的技术
· 地球OL攻略 —— 某应届生求职总结
· 字符编码:从基础到乱码解决
· SpringCloud带你走进微服务的世界
历史上的今天:
2023-01-01 matlab数据处理函数
2023-01-01 IfcOwnerHistory
2022-01-01 Qto_WindowBaseQuantities
2021-01-01 IfcPixelTexture
2021-01-01 IfcIndexedColourMap ——Example
2021-01-01 IfcIndexedColourMap
2021-01-01 IfcImageTexture
点击右上角即可分享
微信分享提示