#include <QApplication>
#include <osg/Node>
#include <osg/Group>
#include <osg/Geode>
#include <osg/Geometry>
#include <osg/Texture2D>
#include <osg/StateSet>
#include <osg/PositionAttitudeTransform>
#include <osgViewer/Viewer>
#include <osgDB/ReadFile>
#include <osgParticle/PrecipitationEffect>
// 雨雪效果
#include <osg/MatrixTransform>
// 粒子效果
#include <osgParticle/PrecipitationEffect>
#include <osgParticle/Particle>
#include <osgParticle/LinearInterpolator>
#include <osgParticle/ParticleSystem>
#include <osgParticle/RandomRateCounter>
#include <osgParticle/PointPlacer>
#include <osgParticle/RadialShooter>
#include <osgParticle/ModularEmitter>
#include <osgParticle/ParticleSystemUpdater>
#include <osgParticle/ModularProgram>
#include <osgUtil/Optimizer>
#include <osgUtil/Simplifier>
#include <osgParticle/FireEffect>
// 雾
#include <osg/Fog>
#include <osgDB/ReadFile>
#include <osgViewer/Viewer>
#include <osg/StateSet>
#include <osg/StateAttribute>
#include <osgViewer/ViewerEventHandlers>
#include <osgWidget/ViewerEventHandlers>
//
#include <QDebug>
class MyDrawCallback : public osg::Drawable::DrawCallback
{
public:
void drawImplementation(osg::RenderInfo &renderInfo, const osg::Drawable *drawable) const
{
qDebug() <<"draw call back - pre drawImplementation"<<drawable ;
drawable->drawImplementation(renderInfo);
qDebug() <<"draw call back - post drawImplementation"<<drawable ;
static double dColor = 0;//颜色
glColor3f(dColor, 0, 0);
glBegin(GL_TRIANGLES);//在OSG中画一个opengl三角形
glVertex3f(0.0, 0.0, -2.0);
glVertex3f(0.2, 0.0, -2.0);
glVertex3f(0.0, 0.4, -2.0);
glEnd();
dColor += 0.01;//颜色渐变
if (dColor > 1.0)
{
dColor = 0.0;
}
}
};
int main(int argc, char *argv[])
{
osgViewer::Viewer viewer;
osg::ref_ptr<osg::Group> root=new osg::Group();
osg::ref_ptr<osg::Node> osgcool=osgDB::readNodeFile("D:\\Gitee\\data\\cow.osg");
osg::Group* ttt=osgcool->asGroup();
osg::Geometry* geom = ttt->getChild(0)->asGeode()->getChild(0)->asGeometry();
geom->setUseDisplayList(false);
geom->setDrawCallback(new MyDrawCallback());
osg::ref_ptr<osg::MatrixTransform> trans=new osg::MatrixTransform();
// osg::Matrix::scale(0.5,0.5,0.5)表示缩放的比例,也就是原来物体的一般大小
// *osg::Matrix::translate(0,-10,0)表示平移正前
trans->setMatrix(osg::Matrix::scale(0.5,0.5,0.5)*osg::Matrix::translate(0,-10,0));
trans->addChild(osgcool.get());
root->addChild(osgcool.get());
root->addChild(trans.get());
viewer.setUpViewInWindow(50,50,500,400);
viewer.setSceneData(root.get());
viewer.realize();
viewer.run();
}
没有合适的资源?快使用搜索试试~ 我知道了~
OSG利用DrawCallback实现模型重绘(Qt5.14.2+osgE3.6.5+win10)-No25-DrawCallb
共11个文件
user:2个
sln:1个
670a0aa:1个
需积分: 1 1 下载量 199 浏览量
2022-08-12
09:26:48
上传
评论
收藏 1.87MB RAR 举报
温馨提示
5.保证无毒 1.简单,方便,实用 3.实例可以自行改用 1.如有非法,本人无法律责任! 8.更多作品,查找标签“朱建强”7.下载,请杀毒! 4.如需联系我请看左边数字!1.如不知代表何物,那就放弃计算机吧! 0.还不懂?CSDN老板不让我上传联系方式。
资源详情
资源评论
资源推荐
收起资源包目录
No25-DrawCallback.rar (11个子文件)
No25-DrawCallback
TestOsgQt.vcxproj 14KB
TestOsgQt.pro.user.670a0aa 22KB
TestOsgQt.sln 937B
TestOsgQt.vcxproj.user 616B
TestOsgQt.pro.user.7651fee 22KB
TestOsgQt.pro.user 22KB
main.cpp 3KB
OSG利用DrawCallback实现模型重绘.gif 1.88MB
TestOsgQt.vcxproj.filters 2KB
TestOsgQt.pro.user.be22775 22KB
TestOsgQt.pro 1KB
共 11 条
- 1
zhujianqiangqq
- 粉丝: 30
- 资源: 388
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 基于matlab实现用有限元法计算电磁场的Matlab工具 .rar
- 基于matlab实现有限元算法 计算电磁场问题 边界条件包括第一类边界和第二类边界.rar
- 基于matlab实现用于计算不同车重下的电动汽车动力性和经济性.rar
- 基于matlab实现遗传算法求解多车场车辆路径问题 有多组算例可以用.rar
- 浏览器.apk
- 基于matlab实现是一个matlab中的power system 中搭建的一个模型
- 基于JSP毕业设计-教学管理系统(源代码+论文).zip
- 基于JSP毕业设计-家政管理系统-毕业设计.zip
- 基于Python实现淘宝商品评论采集(含逆向)源代码
- 基于matlab实现多目标进化算法NSGAⅡ&Matlab讲解.rar
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论0