zoukankan      html  css  js  c++  java
  • osgText::Text osg字体

    #ifdef _WIN32
    #include <Windows.h>
    #endif // _WIN32
    #include<iostream>
    
    #include <osgViewer/Viewer>
    #include <osgViewer/ViewerEventHandlers> 
    #include <osgViewer/CompositeViewer> 
    
    #include <osgDB/ReadFile>
    
    #include <osg/Geode>
    #include <osg/Node>
    #include <osg/Geometry>
    #include <osg/GraphicsContext>
    #include <osg/ShapeDrawable>
    #include <osg/Material>
    #include <osg/Image>
    #include <osg/Texture2D>
    #include <osg/TexEnv>
    #include <osg/TexGen>
    #include <osg/NodeVisitor>
    #include <osg/MatrixTransform>
    #include <osg/PositionAttitudeTransform>
    #include <osg/AnimationPath>
    #include <osg/Matrixd>
    #include <osg/PagedLOD>
    #include <osg/Camera>
    #include <osgText/Text>
    
    #include <osgGA/TrackballManipulator>
    #include <osgGA/GUIEventHandler>
    #include <osgGA/CameraManipulator>
    #include <osgGA/StandardManipulator>
    #include <osgGA/OrbitManipulator>
    #include <osgGA/TrackballManipulator>
    
    #include <osgUtil/IntersectionVisitor>
    #include <osgUtil/LineSegmentIntersector>
    
    osg::Camera* createTextHUD()
    {
        osg::ref_ptr<osg::Geode> geode1 = new osg::Geode;
        osg::ref_ptr<osgText::Text> text1 = new osgText::Text;
        osg::ref_ptr<osg::Camera> camera1 = new osg::Camera;
    
        camera1->setViewMatrix(osg::Matrix::identity());
        camera1->setRenderOrder(osg::Camera::POST_RENDER);
        camera1->setClearMask(GL_DEPTH_BUFFER_BIT);
    
        camera1->setAllowEventFocus(false);
        camera1->setReferenceFrame(osg::Transform::ABSOLUTE_RF);
        camera1->setProjectionMatrixAsOrtho2D(-20, 600, -20, 400);
    
        text1->setFont("Fonts/simhei.ttf");
        text1->setCharacterSize(50);
        text1->setText(L"OSG 中文字体");
        text1->setPosition(osg::Vec3(0.0,0.0,0.0));
    
        geode1->getOrCreateStateSet()->setMode(GL_LIGHTING,osg::StateAttribute::OFF);
        geode1->addDrawable(text1);
    
        camera1->addChild(geode1.get());
        return camera1.release();
    }
    
    int main()
    {
        osg::ref_ptr<osgViewer::Viewer> viewer1 = new osgViewer::Viewer;
        osg::ref_ptr<osg::Group> group1 = new osg::Group;
        
        //osg::ref_ptr<osg::Node> node1 = osgDB::readNodeFile("D:\参考手册\BIM\osg\build20190628.osgb");
        osg::ref_ptr<osg::Node> node2 = osgDB::readNodeFile("D:\参考手册\BIM\osg\build1.osgb");
    
        group1->addChild(node2.get());
        group1->addChild(createTextHUD());
    
        viewer1->setSceneData(group1.get());
        viewer1->setUpViewInWindow(200,200,800,600,0);
    
        viewer1->run();
    }

  • 相关阅读:
    MySQL中数据类型介绍
    Linux rpm命令详解
    Cloudera Manager集群官方默认的各个组件开启默认顺序
    全网最全Python学习路线图+14张思维导图,让python初学者不走弯路!
    python插入Elasticsearch操作
    最全的常用正则表达式大全(校验数字,字符,号码等)
    django.db.utils.OperationalError: (1193, "Unknown system variable 'storage_engine'")
    MVC/MVT/装饰器
    ModuleNotFoundError: No module named 'tools.utils'
    request +lxml 天眼查爬虫
  • 原文地址:https://www.cnblogs.com/herd/p/11107858.html
Copyright © 2011-2022 走看看