osg 自定义图元

复制代码
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;
}
复制代码

 

 

posted @   西北逍遥  阅读(303)  评论(0编辑  收藏  举报
编辑推荐:
· AI与.NET技术实操系列:基于图像分类模型对图像进行分类
· go语言实现终端里的倒计时
· 如何编写易于单元测试的代码
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
阅读排行:
· 25岁的心里话
· 闲置电脑爆改个人服务器(超详细) #公网映射 #Vmware虚拟网络编辑器
· 零经验选手,Compose 一天开发一款小游戏!
· 因为Apifox不支持离线,我果断选择了Apipost!
· 通过 API 将Deepseek响应流式内容输出到前端
历史上的今天:
2018-06-22 Java3D-对象基本变换
2017-06-22 git在eclipse中的配置 完整版 转载
2017-06-22 在阿里云上搭建自己的git服务器
2017-06-22 阿里云 linux搭建git服务器
点击右上角即可分享
微信分享提示