• OsgOsg实例牛对象平移效果(Qt5.14.2+osgEarht3.6.5+win10)No7translation


    相关资料:

    https://www.cnblogs.com/ylwn817/articles/1973396.html     osg矩阵变换节点-----平移旋转缩放

    注意:

    osg方向如左图所示,x轴表示屏幕水平方向,y轴表示和屏幕垂直方向即屏幕里面方向,z轴表示屏幕垂直方向,每个箭头指向表示正方向 

    代码实例:

    .pro

     1 QT       += core gui widgets
     2 TARGET = TestOsgQt
     3 TEMPLATE = app
     4 DEFINES += QT_DEPRECATED_WARNINGS
     5 CONFIG += c++11
     6 
     7 SOURCES += \
     8         main.cpp
     9 
    10 HEADERS +=
    11 
    12 OsgDir = D:\\RuanJian\\osg365R
    13 CONFIG(release, debug|release) {
    14         LIBS += -L$${OsgDir}/lib/ -losgDB -losgViewer -lOpenThreads -losgAnimation -losg \
    15                                   -losgEarth -losgEarthAnnotation -losgEarthFeatures -losgEarthSymbology -losgEarthUtil \
    16                                   -losgQOpenGL -losgUtil -losgText -losgTerrain -losgSim \
    17                                   -losgShadow -losgParticle -losgManipulator -losgGA -losgFX \
    18                                   -losgWidget
    19 } else {
    20         LIBS += -L$${OsgDir}/debug/lib/ -losgDBd -losgViewerd -lOpenThreadsd -losgAnimationd -losgd \
    21                                   -losgEarthd -losgEarthAnnotationd -losgEarthFeaturesd -losgEarthSymbologyd -losgEarthUtild \
    22                                   -losgQOpenGLd -losgUtild -losgTextd -losgTerraind -losgSimd \
    23                                   -losgShadowd -losgParticled -losgManipulatord -losgGAd -losgFXd \
    24 }
    25 
    26 
    27 INCLUDEPATH += $${OsgDir}/include
    28 DEPENDPATH += $${OsgDir}/include
    View Code

    main.cpp

     1 #include <QApplication>
     2 
     3 #include <osg/Node>
     4 #include <osg/Group>
     5 #include <osg/Geode>
     6 #include <osg/Geometry>
     7 #include <osg/Texture2D>
     8 #include <osg/StateSet>
     9 #include <osg/PositionAttitudeTransform>
    10 #include <osgViewer/Viewer>
    11 #include <osgDB/ReadFile>
    12 #include <osgParticle/PrecipitationEffect>
    13 // 雨雪效果
    14 #include <osg/MatrixTransform>
    15 // 粒子效果
    16 #include <osgParticle/PrecipitationEffect>
    17 #include <osgParticle/Particle>
    18 #include <osgParticle/LinearInterpolator>
    19 #include <osgParticle/ParticleSystem>
    20 #include <osgParticle/RandomRateCounter>
    21 #include <osgParticle/PointPlacer>
    22 #include <osgParticle/RadialShooter>
    23 #include <osgParticle/ModularEmitter>
    24 #include <osgParticle/ParticleSystemUpdater>
    25 #include <osgParticle/ModularProgram>
    26 #include <osgUtil/Optimizer>
    27 #include <osgUtil/Simplifier>
    28 #include <osgParticle/FireEffect>
    29 //
    30 #include <osg/Fog>
    31 #include <osgDB/ReadFile>
    32 #include <osgViewer/Viewer>
    33 #include <osg/StateSet>
    34 #include <osg/StateAttribute>
    35 #include <osgViewer/ViewerEventHandlers>
    36 #include <osgWidget/ViewerEventHandlers>
    37 
    38 int main(int argc, char *argv[])
    39 {
    40     osgViewer::Viewer viewer;
    41     osg::ref_ptr<osg::Group> root=new osg::Group();
    42     osg::ref_ptr<osg::Node> osgcool=osgDB::readNodeFile("D:\\osgFiles\\cow.osg");
    43 
    44     osg::ref_ptr<osg::MatrixTransform> trans=new osg::MatrixTransform();
    45     // 就是用来平移物体,这个表示象Z轴正方向平移也就是屏幕正上方。
    46     trans->setMatrix(osg::Matrix::translate(0,0,20));
    47     trans->addChild(osgcool.get());
    48 
    49     root->addChild(osgcool.get());
    50     root->addChild(trans.get());
    51 
    52     viewer.setUpViewInWindow(50,50,500,400);
    53     viewer.setSceneData(root.get());
    54     viewer.realize();
    55     viewer.run();
    56 }
    View Code
  • 相关阅读:
    Memcached 笔记与总结(9)Memcached 与 Session
    python禁止函数修改列表的实现方法
    python禁止函数修改列表的实现方法
    大数据是工业的核心资源 企业入局需合理把握
    大数据是工业的核心资源 企业入局需合理把握
    Python执行时间的计算方法小结
    Python执行时间的计算方法小结
    大数据无处不在 企业实践指南有哪些?
    大数据无处不在 企业实践指南有哪些?
    python条件变量之生产者与消费者操作实例分析
  • 原文地址:https://www.cnblogs.com/FKdelphi/p/15879512.html
Copyright © 2020-2023  润新知