osgkeyboardMouse例子分析

osgkeyboardmouse例子 本例子演示了拾取的功能。 PickHandler继承GUIEventHandler ‘s’键通过CreateModelToSaveVisitor把选中的节点写出。 virtual void apply(osg::Node& node)     {         osgFX::Scribe* scribe =  dynamic_cast(&node);         if (scr 阅读详情

(1)Scribe

(2)NodeVisitor

 

class CreateModelToSaveVisitor : public osg::NodeVisitor
{
public:

    CreateModelToSaveVisitor():
        osg::NodeVisitor(osg::NodeVisitor::TRAVERSE_ALL_CHILDREN)       
    {
        _group = new osg::Group;
        _addToModel = false;
    }
   
    virtual void apply(osg::Node& node)
    {
        osgFX::Scribe* scribe = dynamic_cast<osgFX::Scribe*>(&node);
        if (scribe)
        {
            for(unsigned int i=0; i<scribe->getNumChildren(); ++i)
            {
                _group->addChild(scribe->getChild(i));
            }
        }
        else
        {
            traverse(node);
        }
    }
   
    osg::ref_ptr<osg::Group> _group;
    bool _addToModel;
};

// class to handle events with a pick
class PickHandler : public osgGA::GUIEventHandler
{
public: 
    bool handle(const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& aa)
    {
        osgViewer::Viewer* viewer = dynamic_cast<osgViewer::Viewer*>(&aa);
        if (!viewer) return false;

        switch(ea.getEventType())
        {
            case(osgGA::GUIEventAdapter::KEYUP):
            {
                if (ea.getKey()=='s')
                {
                    saveSelectedModel(viewer->getSceneData());
                }               
    ......
            }
            case(osgGA::GUIEventAdapter::RELEASE):
            {
                if (_mx == ea.getX() && _my == ea.getY())
                {
                    // only do a pick if the mouse hasn't moved
                    pick(ea,viewer);
                }
                return true;
            }   
        }
    }

    void pick(const osgGA::GUIEventAdapter& ea, osgViewer::Viewer* viewer)
    {
    ......
                osg::NodePath& nodePath = intersection.nodePath;
                node = (nodePath.size()>=1)?nodePath[nodePath.size()-1]:0;//最后一个节点(如geode)
                parent = (nodePath.size()>=2)?dynamic_cast<osg::Group*>(nodePath[nodePath.size()-2]):0;//上一个节点(如Scribe)
    ......
                toggleScribe(parent, node);//添加或去掉Scribe线框
     
    }

    void toggleScribe(osg::Group* parent, osg::Node* node) {
       ......
        osgFX::Scribe* parentAsScribe = dynamic_cast<osgFX::Scribe*>(parent);
        if (!parentAsScribe)//如果无Scribe,则加上
        {
            // node not already picked, so highlight it with an osgFX::Scribe
            osgFX::Scribe* scribe = new osgFX::Scribe();
            scribe->addChild(node);
            parent->replaceChild(node,scribe);
        }
        else
        {
            // node already picked so we want to remove scribe to unpick it.
            osg::Node::ParentList parentList = parentAsScribe->getParents();
            for(osg::Node::ParentList::iterator itr=parentList.begin();
                itr!=parentList.end();
                ++itr)
            {
                (*itr)->replaceChild(parentAsScribe,node);//还原为非Scribe节点
            }
        }

    }

    void saveSelectedModel(osg::Node* scene)
    {
        CreateModelToSaveVisitor cmtsv;
        scene->accept(cmtsv);
      
    }

 

int main( int argc, char **argv )
{
    ......
    viewer.addEventHandler(new PickHandler());
 
}

==============

  CreateModelToSaveVisitor cmtsv;
        scene->accept(cmtsv);

详细过程如下:

void Node::accept(NodeVisitor& nv)

{

    if (nv.validNodeMask(*this))

    {

        nv.pushOntoNodePath(this);

        nv.apply(*this);

        nv.popFromNodePath();

    }

}

 

void NodeVisitor::apply(Node& node)

{

    traverse(node);

}

 

NodeVisitor:

inline void traverse(Node& node)

        {

            if (_traversalMode==TRAVERSE_PARENTS) node.ascend(*this);

            else if (_traversalMode!=TRAVERSE_NONE) node.traverse(*this);

        }

 

void Group::traverse(NodeVisitor& nv)

{

    for(NodeList::iterator itr=_children.begin();

        itr!=_children.end();

        ++itr)

    {

        (*itr)->accept(nv);

    }

}

=============================

完整源代码如下:

/* OpenSceneGraph example, osgkeyboardmouse.
*
*  Permission is hereby granted, free of charge, to any person obtaining a copy
*  of this software and associated documentation files (the "Software"), to deal
*  in the Software without restriction, including without limitation the rights
*  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
*  copies of the Software, and to permit persons to whom the Software is
*  furnished to do so, subject to the following conditions:
*
*  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
*  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
*  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
*  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
*  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
*  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
*  THE SOFTWARE.
*/

// Simple example of use of osgViewer::GraphicsWindow + Viewer
// example that provides the user with control over view position with basic picking.

#include <osg/Timer>
#include <osg/io_utils>
#include <osg/observer_ptr>

#include <osgUtil/IntersectionVisitor>
#include <osgUtil/PolytopeIntersector>
#include <osgUtil/LineSegmentIntersector>

#include <osgDB/ReadFile>
#include <osgDB/WriteFile>

#include <osgGA/TrackballManipulator>
#include <osgGA/StateSetManipulator>

#include <osgViewer/Viewer>

#include <osgFX/Scribe>

#include <iostream>

class CreateModelToSaveVisitor : public osg::NodeVisitor
{
public:

    CreateModelToSaveVisitor():
        osg::NodeVisitor(osg::NodeVisitor::TRAVERSE_ALL_CHILDREN)       
    {
        _group = new osg::Group;
        _addToModel = false;
    }
   
    virtual void apply(osg::Node& node)
    {
        osgFX::Scribe* scribe = dynamic_cast<osgFX::Scribe*>(&node);
        if (scribe)
        {
            for(unsigned int i=0; i<scribe->getNumChildren(); ++i)
            {
                _group->addChild(scribe->getChild(i));
            }
        }
        else
        {
            traverse(node);
        }
    }
   
    osg::ref_ptr<osg::Group> _group;
    bool _addToModel;
};

class DeleteSelectedNodesVisitor : public osg::NodeVisitor
{
public:

    DeleteSelectedNodesVisitor():
        osg::NodeVisitor(osg::NodeVisitor::TRAVERSE_ALL_CHILDREN)       
    {
    }
   
    virtual void apply(osg::Node& node)
    {
        osgFX::Scribe* scribe = dynamic_cast<osgFX::Scribe*>(&node);
        if (scribe)
        {
            _selectedNodes.push_back(scribe);
        }
        else
        {
            traverse(node);
        }
    }
   
    void pruneSelectedNodes()
    {
        for(SelectedNodes::iterator itr = _selectedNodes.begin();
            itr != _selectedNodes.end();
            ++itr)
        {
            osg::Node* node = itr->get();
            osg::Node::ParentList parents = node->getParents();
            for(osg::Node::ParentList::iterator pitr = parents.begin();
                pitr != parents.end();
                ++pitr)
            {
                osg::Group* parent = *pitr;
                parent->removeChild(node);
            }
        }
    }
   
    typedef std::vector< osg::ref_ptr<osgFX::Scribe> > SelectedNodes;
    SelectedNodes _selectedNodes;
   
};

// class to handle events with a pick
class PickHandler : public osgGA::GUIEventHandler
{
public:

    PickHandler():
        _mx(0.0),_my(0.0),
        _usePolytopeIntersector(false),
        _useWindowCoordinates(false) {}

    ~PickHandler() {}

    bool handle(const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& aa)
    {
        osgViewer::Viewer* viewer = dynamic_cast<osgViewer::Viewer*>(&aa);
        if (!viewer) return false;

        switch(ea.getEventType())
        {
            case(osgGA::GUIEventAdapter::KEYUP):
            {
                if (ea.getKey()=='s')
                {
                    saveSelectedModel(viewer->getSceneData());
                }               
                else if (ea.getKey()=='o')
                {
                    osg::notify(osg::NOTICE)<<"Saved model to file 'saved_model.osg'"<<std::endl;
                    osgDB::writeNodeFile(*(viewer->getSceneData()), "saved_model.osg");
                }
                else if (ea.getKey()=='p')
                {
                    _usePolytopeIntersector = !_usePolytopeIntersector;
                    if (_usePolytopeIntersector)
                    {
                        osg::notify(osg::NOTICE)<<"Using PolytopeIntersector"<<std::endl;
                    } else {
                        osg::notify(osg::NOTICE)<<"Using LineSegmentIntersector"<<std::endl;
                    }
                }
                else if (ea.getKey()=='c')
                {
                    _useWindowCoordinates = !_useWindowCoordinates;
                    if (_useWindowCoordinates)
                    {
                        osg::notify(osg::NOTICE)<<"Using window coordinates for picking"<<std::endl;
                    } else {
                        osg::notify(osg::NOTICE)<<"Using projection coordiates for picking"<<std::endl;
                    }
                }
                else if (ea.getKey()==osgGA::GUIEventAdapter::KEY_Delete || ea.getKey()==osgGA::GUIEventAdapter::KEY_BackSpace)
                {
                    osg::notify(osg::NOTICE)<<"Delete"<<std::endl;
                    DeleteSelectedNodesVisitor dsnv;
                    viewer->getSceneData()->accept(dsnv);
                    dsnv.pruneSelectedNodes();
                }
                return false;
            }
            case(osgGA::GUIEventAdapter::PUSH):
            case(osgGA::GUIEventAdapter::MOVE):
            {
                _mx = ea.getX();
                _my = ea.getY();
                return false;
            }
            case(osgGA::GUIEventAdapter::RELEASE):
            {
                if (_mx == ea.getX() && _my == ea.getY())
                {
                    // only do a pick if the mouse hasn't moved
                    pick(ea,viewer);
                }
                return true;
            }   

            default:
                return false;
        }
    }

    void pick(const osgGA::GUIEventAdapter& ea, osgViewer::Viewer* viewer)
    {
        osg::Node* scene = viewer->getSceneData();
        if (!scene) return;

        osg::notify(osg::NOTICE)<<std::endl;

        osg::Node* node = 0;
        osg::Group* parent = 0;

        if (_usePolytopeIntersector)
        {
            osgUtil::PolytopeIntersector* picker;
            if (_useWindowCoordinates)
            {
                // use window coordinates
                // remap the mouse x,y into viewport coordinates.
                osg::Viewport* viewport = viewer->getCamera()->getViewport();
                double mx = viewport->x() + (int)((double )viewport->width()*(ea.getXnormalized()*0.5+0.5));
                double my = viewport->y() + (int)((double )viewport->height()*(ea.getYnormalized()*0.5+0.5));

                // half width, height.
                double w = 5.0f;
                double h = 5.0f;
                picker = new osgUtil::PolytopeIntersector( osgUtil::Intersector::WINDOW, mx-w, my-h, mx+w, my+h );
            } else {
                double mx = ea.getXnormalized();
                double my = ea.getYnormalized();
                double w = 0.05;
                double h = 0.05;
                picker = new osgUtil::PolytopeIntersector( osgUtil::Intersector::PROJECTION, mx-w, my-h, mx+w, my+h );
            }
            osgUtil::IntersectionVisitor iv(picker);

            viewer->getCamera()->accept(iv);

            if (picker->containsIntersections())
            {
                osgUtil::PolytopeIntersector::Intersection intersection = picker->getFirstIntersection();

                osg::notify(osg::NOTICE)<<"Picked "<<intersection.localIntersectionPoint<<std::endl
                    <<"  Distance to ref. plane "<<intersection.distance
                    <<", max. dist "<<intersection.maxDistance
                    <<", primitive index "<<intersection.primitiveIndex
                    <<", numIntersectionPoints "
                    <<intersection.numIntersectionPoints
                    <<std::endl;

                osg::NodePath& nodePath = intersection.nodePath;
                node = (nodePath.size()>=1)?nodePath[nodePath.size()-1]:0;
                parent = (nodePath.size()>=2)?dynamic_cast<osg::Group*>(nodePath[nodePath.size()-2]):0;

                if (node) std::cout<<"  Hits "<<node->className()<<" nodePath size "<<nodePath.size()<<std::endl;   
                toggleScribe(parent, node);
            }

        }
        else
        {
            osgUtil::LineSegmentIntersector* picker;
            if (!_useWindowCoordinates)
            {
                // use non dimensional coordinates - in projection/clip space
                picker = new osgUtil::LineSegmentIntersector( osgUtil::Intersector::PROJECTION, ea.getXnormalized(),ea.getYnormalized() );
            } else {
                // use window coordinates
                // remap the mouse x,y into viewport coordinates.
                osg::Viewport* viewport = viewer->getCamera()->getViewport();
                float mx = viewport->x() + (int)((float)viewport->width()*(ea.getXnormalized()*0.5f+0.5f));
                float my = viewport->y() + (int)((float)viewport->height()*(ea.getYnormalized()*0.5f+0.5f));
                picker = new osgUtil::LineSegmentIntersector( osgUtil::Intersector::WINDOW, mx, my );
            }
            osgUtil::IntersectionVisitor iv(picker);

            viewer->getCamera()->accept(iv);

            if (picker->containsIntersections())
            {
                osgUtil::LineSegmentIntersector::Intersection intersection = picker->getFirstIntersection();
                osg::notify(osg::NOTICE)<<"Picked "<<intersection.localIntersectionPoint<<std::endl;

                osg::NodePath& nodePath = intersection.nodePath;
                node = (nodePath.size()>=1)?nodePath[nodePath.size()-1]:0;
                parent = (nodePath.size()>=2)?dynamic_cast<osg::Group*>(nodePath[nodePath.size()-2]):0;

                if (node) std::cout<<"  Hits "<<node->className()<<" nodePath size"<<nodePath.size()<<std::endl;
                toggleScribe(parent, node);
            }
        }       

        // now we try to decorate the hit node by the osgFX::Scribe to show that its been "picked"
    }

    void toggleScribe(osg::Group* parent, osg::Node* node) {
        if (!parent || !node) return;

        std::cout<<"  parent "<<parent->className()<<std::endl;

        osgFX::Scribe* parentAsScribe = dynamic_cast<osgFX::Scribe*>(parent);
        if (!parentAsScribe)
        {
            // node not already picked, so highlight it with an osgFX::Scribe
            osgFX::Scribe* scribe = new osgFX::Scribe();
            scribe->addChild(node);
            parent->replaceChild(node,scribe);
        }
        else
        {
            // node already picked so we want to remove scribe to unpick it.
            osg::Node::ParentList parentList = parentAsScribe->getParents();
            for(osg::Node::ParentList::iterator itr=parentList.begin();
                itr!=parentList.end();
                ++itr)
            {
                (*itr)->replaceChild(parentAsScribe,node);
            }
        }

    }

    void saveSelectedModel(osg::Node* scene)
    {
        if (!scene) return;
   
        CreateModelToSaveVisitor cmtsv;
        scene->accept(cmtsv);
       
        if (cmtsv._group->getNumChildren()>0)
        {
            std::cout<<"Writing selected compoents to 'selected_model.osg'"<<std::endl;
            osgDB::writeNodeFile(*cmtsv._group, "selected_model.osg");
        }
    }

protected:

    float _mx,_my;
    bool _usePolytopeIntersector;
    bool _useWindowCoordinates;
};

int main( int argc, char **argv )
{
    osg::ref_ptr<osg::Node> loadedModel;
   
    // load the scene.
    if (argc>1) loadedModel = osgDB::readNodeFile(argv[1]);
   
    // if not loaded assume no arguments passed in, try use default mode instead.
    if (!loadedModel) loadedModel = osgDB::readNodeFile("dumptruck.osg");
   
    if (!loadedModel)
    {
        std::cout << argv[0] <<": No data loaded." << std::endl;
        return 1;
    }
   
    // create the window to draw to.
    osg::ref_ptr<osg::GraphicsContext::Traits> traits = new osg::GraphicsContext::Traits;
    traits->x = 200;
    traits->y = 200;
    traits->width = 800;
    traits->height = 600;
    traits->windowDecoration = true;
    traits->doubleBuffer = true;
    traits->sharedContext = 0;

    osg::ref_ptr<osg::GraphicsContext> gc = osg::GraphicsContext::createGraphicsContext(traits.get());
    osgViewer::GraphicsWindow* gw = dynamic_cast<osgViewer::GraphicsWindow*>(gc.get());
    if (!gw)
    {
        osg::notify(osg::NOTICE)<<"Error: unable to create graphics window."<<std::endl;
        return 1;
    }

    // create the view of the scene.
    osgViewer::Viewer viewer;
    viewer.getCamera()->setGraphicsContext(gc.get());
    viewer.getCamera()->setViewport(0,0,800,600);
    viewer.setSceneData(loadedModel.get());
   
    // create a tracball manipulator to move the camera around in response to keyboard/mouse events
    viewer.setCameraManipulator( new osgGA::TrackballManipulator );

    osg::ref_ptr<osgGA::StateSetManipulator> statesetManipulator = new osgGA::StateSetManipulator(viewer.getCamera()->getStateSet());
    viewer.addEventHandler(statesetManipulator.get());

    // add the pick handler
    viewer.addEventHandler(new PickHandler());

    viewer.realize();

    // main loop (note, window toolkits which take control over the main loop will require a window redraw callback containing the code below.)
    while(!viewer.done())
    {
        viewer.frame();
    }

    return 0;
}

 

设置PolytopeIntersector需要注意的问题 设置PolytopeIntersector需要注意的问题 代码下载地址:  截图:   做了一个PolytopeIntersector的例子,如果飞机飞入和飞离这个多面体的时候可以正确的返回飞机是不是在区域内 关于有些节点不在NodePah里的问题 我加载了一个osg自带的模型cessna.osg,给他设置了名字"cessna",可是当它进入多面体后Node 阅读详情

相关推荐

[ADS]单端电感和差分电感的感值和Q值计算公式

单端电感和差分电感的感值和Q值计算公式

乾巽的博客 1万+

求交后高亮显示某个Drawable

求交后高亮显示某个Drawable: if (picker->containsIntersections())            {               osg::Vec3 ptWorldIntersectPointFirst= picker->getFirstIntersection().getWorldIntersectPoint();               cout

tmljs1988的专栏 1万+

R语言下载包报错?可能是IE浏览器在搞鬼!手把手教你修复(附CRAN镜像选择指南)

本文深入解析了R语言下载包时常见的网络报错问题,特别是Windows系统中因Internet Explorer代理设置导致的连接失败。文章提供了从重置IE配置、排查防火墙到优化CRAN镜像选择的完整解决方案,并附有详细的配置指南和自动化诊断脚本,帮助用户彻底解决R包安装难题。

weixin_29056781的博客 742

NodeVisitor & Picking

  这个星期基本上除了看完快速入门指导的第三章,应该就没做啥了,不知道明天开会说什么了,哈哈哈 3.2.3 NodeVisitors节点访问NodeVisitor is OSG’s implementation of the Visitor design pattern. In essence, NodeVisitor traverses a scene graph and c

glistenning的专栏 1万+

【文献阅读笔记】之基于注意力机制的深度学习路面裂缝检测

中文,计算机辅助设计与图形学学报,第 32 卷 第 8 期,2020 年 8 月。 DOI: 10.3724/SP.J.1089.2020.18059 摘要: 为实现自动准确地检测路面裂缝, 提升路面裂缝检测效果, 提出了一种基于注意力机制的裂缝检测网络 (attention-based crack networks, ACNet). 该网络采用编码器-解码器网络构架, 编码器采用 ResNet34 为骨干网, 提取路面裂缝特征; 在编码器和解码器间加入基于注意力机制的特征模块(attention-b

qq_44785998的博客 7593

BugkuCTF-PWN题pwn2-overflow超详细讲解

解题思路 1)计算出get_shell_的地址偏移量 2)算出来之后就直接溢出到后门函数 知识点 x64函数调用规则 解题之前我们先学下linux x64的函数调用规则。 x64机器在调用某个函数前,比如int func(int a, int b, int c, int d, int e, int f, int g, int h),首先他会把前6个参数从左往右存入到寄存器rdi、rsi、rdx、rcx、r8、r9,其余参数存入到栈里,保存的顺序是从右往左入栈。比如abcdef会存入到寄存器里,然后一次入栈h

am_03的博客 3013

第7题:判断两个链表是否相交

欢迎转载,转载请务必注明出处:http://blog.youkuaiyun.com/alading2009/article/details/44801889 插播一下第6题: 腾讯面试题,给你10分钟时间,根据上排给出的十个数,在其下排填出对应的十个数,要求下排每个数都是先前上排那十个数在下排出现的次数。 上排的十个数如下:【0,1,2,3,4,5,6,7,8,9】 (PS:既然是一个10分钟的面

围炉夜话 1808

摄像头读取出现VIDIOC_STREAMON: No space left on device 错误

先说下原因,linux中为usb camera提供了一个标准的V4L2的驱动以方便使用,只要符合驱动规范就可以实现即插即用usb camera设备,即免驱动安装。 但市面上的USB 摄像头都是2.0的。usb bus的 bandwidth是有限的,而V4L2驱动采用的是贪心原则,即camera会要求获取最大带宽;因此将两个camera接入一路usb bus,打开第二个camera(尤其是采用YUV...

houge101的博客 9289

osgkeyboard例子

osgkeyboard例子中包含的内容: (1)显示文本osgText. (2)在viewer中添加事件处理:GUIEventHandler. 解析如下: class KeyboardModel : public osg::Referenced { public: KeyboardModel() { createKeyboard(); }                 o

u010698150的专栏 644

用MSBlock重塑C2f,让你的模型又轻又强(参数量与精度的双重突破)

打开确保模型解析器能识别MSBlock模块。通过将MSBlock集成到YOLOv8的C2f模块中,我们实现了一个“轻量且多尺度感知”的目标检测模型。这个改进不仅在工程上能降低部署成本、提升推理速度,更在科研上提供了“多尺度+动态核”的创新思路——这种思路可以延伸到其他网络(如ResNet、MobileNet)的改进中,帮你在论文中打造独特的研究点。如果你在实现过程中遇到问题,比如代码报错、训练收敛异常,可以先检查模块集成的每一步是否到位,再尝试调整MSBlock的卷积核尺寸、动态权重的计算方式等超参数。

m0_71589036的博客 105

2026保姆级:1小时搞定C# OPC UA客户端开发——PLC与上位机全量数据交互零基础教程

本文介绍了使用C#开发OPC UA客户端的核心流程和关键代码实现。文章首先指出工业上位机开发中OPC UA的重要性,并针对新手常见问题提出了1小时掌握核心功能的解决方案。重点内容包括:选择官方.NET Standard库的优势、5分钟搭建开发环境的步骤、OPC UA客户端架构与通信流程的图解说明,以及完整的客户端基础类代码实现,涵盖了连接管理、证书配置、安全认证等关键功能。通过本文提供的代码模板,开发者可快速实现与PLC等工业设备的稳定数据交互。

这里只有干货:从 Modbus 通信到 MES 对接,从 YOLO 训练到工控机部署,带你搞定工业软件开发全流程。 799

OSG之框选节点的功能实现方式

OSG 框选功能实现参考代码

973

OpenStack ussuri 私有云平台搭建企业级实战

openstack是一个云操作系统,这个操作系统控制着数据中心中的计算,存储和网络资源。所有这些资源的管理都是通过API来来实现的,并且管理资源都有相应的认证机制。在openstack中有一个叫做dashboard的仪表盘,这个仪表盘通过web界面可以管理这些在DC中的资源。除了能提供IaaS功能外,你还可以使用orchestration,错误管理和服务管理等服务来确保应用的高可用性。

悦分享 2338

osg程序中osgDB::writeNodeFile和osgDB::readNodeFile总是失败

前言 osg程序中osgDB::writeNodeFile和osgDB::readNodeFile总是失败,比如下面的代码: int main(int argc, char** argv) { osg::ref_ptr<osg::Node> root = createSceneGraph(); if (!root.valid()) { osg::notify(osg::FATAL) << "Faile to createSceneGraph()

aoxuestudy的专栏 4164

IEM模型,地表粗糙度模拟

利用微波反演土壤水分时候,利用IEM模型可以实现对随机地表的模拟

计算机控制技术及应用

《计算机控制技术及应用》通过总结作者的科研成果和吸收国内外的先进理论、方法和技术,以计算机控制系统的网络化、开放化、智能化和集成化发展趋势为主线索,主要介绍计算机控制系统的基本概念和计算机控制系统的典型形式,计算机控制系统的数学描述与基本分析方法,以及数字PID控制器、最少拍控制系统、达林算法、状态变量设计法等设计方法及其各种改进算法。重点突出计算机控制系统输入输出通道接口的设计方法和典型控制系统的设计案例与实现方法等。

osg的polytopeintersector-备忘录

中实现多面体和三角形的轮廓线(顶点存在src中)求交,凸台polytope存着6个平面plane,每个plane法向正向指向体内部,遍历每个平面,切割src轮廓线,dest中存着在plane正半空间的那部分轮廓,然后src和dest交换,接着下一个plane再切src轮廓线,留下正半空间中的轮廓线…OSG的osgUtil::PolytopeIntersector类实现凸多面体和点线段三角形求交器的实现,在pick中框选肯定是用一个四棱锥凸台几何体,单选其实也是一个四棱锥凸台。

yrcpp的博客 657

VC中sqlite的使用

在VC中对sqlite的使用,实现数据库大批数据的快速插入,读取数据库中的数据在ListCtrl中显示

OSG笔记:对线求交失败

使用以下两个求交器,对一根直线进行求交,但始终得不出结果。 直线求交器 osgUtil::LineSegmentIntersector 多面体求交器 osgUtil::PolytopeIntersector

憧憬,思考,奋斗,飞翔 1225

OSG拾取点和线当然面也能拾取

if (ea.getButton() == osgGA::GUIEventAdapter::RIGHT_MOUSE_BUTTON) { osg::ref_ptr&amp;lt;osgUtil::PolytopeIntersector&amp;gt; picker = new osgUtil::PolytopeIntersector(osgUtil::Intersector::WINDOW, ea.getX...

封狼居胥 2830

osgFX扩展库-刻线特效、立方图镜面高光特效(2)

osgFX扩展库- 刻线特效、立方图镜面高光特效 osgFX::SpecularHighlights osgFX::Scribe

liangfei868的博客 1419

osgViewer中的WindowSizeHandler和osgGA中的StateSetManipulator事件处理器用法

osgViewer中的WindowSizeHandler和osgGA中的StateSetManipulator事件处理器用法

danshiming的博客 988

OSG 自带事件响应

osgGA::StateSetManipulator:该事件响应类的功能是对渲染状态进行控制,openGL的渲染管线使用了状态机的机制,此事件响应类对状态进行控制体现在当用户按w键时,可在体线点三种模式下进行切换。按1,照明与非照明切换;b是否开启背面剔除模式切换;t在是否开启纹理的情况下切换。        osgViewer::ThreadingHandler:该事件响应的功能是改变线程模式

wzh-whu 5201

osgkeyboard例子详解

class KeyboardModel : public osg::Referenced{public:        KeyboardModel() { createKeyboard(); }        osg::Group* getScene() { return _scene.get(); }        void keyChange(int key,int value);//每当用户按下或松开按钮时调用protected:        ~KeyboardModel() {}        o

tmljs1988的专栏 2650

osg窗口的创建(一)

osg的窗口创建过程之一

Frank的专栏 6219

OSG入门_场景图形与OpenSceneGraph概述01

osgUtil库集合了许多用于场景图形处理和几何修改的工具; osgDB使用插件管理的架构,支持大量常见的2D图形和3D模型文件格式; osgViewer库定义了一些视口类,因而可以将OSG集成到许多视窗设计工具中。

部落阁 1820

osgUtil::PolytopeIntersector源码解析

osgUtil::PolytopeIntersector源码解析!

qq_42491346的博客 842

OSG 中 相交测试 模块 工作流程及原理

OSG 中 相交测试 模块 的 工作流程及原理 分析

UnrealEngine4 、Delta3D、OSG 3954

OSG求交器(一)面求交器PlaneIntersector

OSG求交器之平面求交器

Frank的专栏 1万+
上一篇: osgrobot例子详解
下一篇: 用glTranslate,glRotate来模拟gluLookAt
tmljs1988
博客等级 码龄19年 134粉丝 107原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值