• 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();
    }

  • 相关阅读:
    2015年第六届 蓝桥杯B组 C/C++决赛题解
    【每日一题】22.美味菜肴 ( 01背包变种问题 )
    【译】N 皇后问题 – 构造法原理与证明 时间复杂度O(1)
    服务商快速创建的小程序如何开通云开发?
    小程序●云开发感恩特惠震撼来袭,折扣力度历史最大
    云开发者专属盛会:邀你一起「重新定义开发」
    如何用 Cloudbase Framework 部署一个 Vue 项目
    Java 类型信息详解和反射机制
    Java7 新特性 —— java.nio.file 文件操作
    Java8 新特性 —— Stream 流式编程
  • 原文地址:https://www.cnblogs.com/herd/p/11107858.html
Copyright © 2020-2023  润新知