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

  • 相关阅读:
    笨办法学Python——学习笔记4
    意识、语言、文字和程序感想
    笨办法学Python——学习笔记3
    把vim作为shell ide
    HDUYuna's confusion 树状数组 Or Multiset
    POJ3252 Round Numbers 组合数学
    HDU3874 Necklace 树状数组+离线处理
    UVA10212 The Last Nonzero Digit. 分解质因子+容斥定理
    HDU1041 Computer Transformation 大数
    HDUFish买电脑 二分查找
  • 原文地址:https://www.cnblogs.com/herd/p/11107858.html
Copyright © 2011-2022 走看看