文档章节

osg源码分析osgViewer/Viewer

哈全文
 哈全文
发布于 2016/11/18 20:11
字数 635
阅读 176
收藏 0

/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
 *
 * This library is open source and may be redistributed and/or modified under 
 * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
 * (at your option) any later version.  The full license is in LICENSE file
 * included with this distribution, and on the openscenegraph.org website.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * OpenSceneGraph Public License for more details.
*/

#ifndef OSGVIEWER_Viewer
#define OSGVIEWER_Viewer 1

#include <osg/ArgumentParser>
#include <osgGA/EventVisitor>
#include <osgUtil/UpdateVisitor>
#include <osgViewer/GraphicsWindow>
#include <osgViewer/View>


namespace osgViewer {

/** Viewer holds a single view on to a single scene.*/
class OSGVIEWER_EXPORT Viewer : public ViewerBase, public osgViewer::View
{
    public:

        Viewer();

        Viewer(osg::ArgumentParser& arguments);

        Viewer(const osgViewer::Viewer& viewer, const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY);

        virtual ~Viewer();

        META_Object(osgViewer,Viewer);

        /** Take all the settings, Camera and Slaves from the passed in view(er), leaving it empty. */
        virtual void take(osg::View& rhs);


        /** Set the Stats object used for collect various frame related timing and scene graph stats.*/
        virtual void setViewerStats(osg::Stats* stats) { setStats(stats); }

        /** Get the Viewers Stats object.*/
        virtual osg::Stats* getViewerStats() { return getStats(); }

        /** Get the Viewers Stats object.*/
        virtual const osg::Stats* getViewerStats() const { return getStats(); }


        /** read the viewer configuration from a configuration file.*/
        virtual bool readConfiguration(const std::string& filename);
       
        /** Get whether at least of one of this viewers windows are realized.*/
        virtual bool isRealized() const;

        /** set up windows and associated threads.*/
        virtual void realize();

        virtual void setStartTick(osg::Timer_t tick);
        void setReferenceTime(double time=0.0);

        /** Set the sene graph data that viewer with view.*/
        virtual void setSceneData(osg::Node* node);


        /** Convenience method for setting up the viewer so it can be used embedded in an external managed window.
          * Returns the GraphicsWindowEmbedded that can be used by applications to pass in events to the viewer. */
        virtual GraphicsWindowEmbedded* setUpViewerAsEmbeddedInWindow(int x, int y, int width, int height);


        virtual double elapsedTime();

        virtual osg::FrameStamp* getViewerFrameStamp() { return getFrameStamp(); }

        /** Execute a main frame loop.
          * Equivalent to while (!viewer.done()) viewer.frame();
          * Also calls realize() if the viewer is not already realized,
          * and installs trackball manipulator if one is not already assigned.
          */
        virtual int run();

        /** check to see if the new frame is required, called by run(..) when FrameScheme is set to ON_DEMAND.*/
        virtual bool checkNeedToDoFrame();

        virtual void advance(double simulationTime=USE_REFERENCE_TIME);

        virtual void eventTraversal();

        virtual void updateTraversal();

        void setCameraWithFocus(osg::Camera* camera) { _cameraWithFocus = camera; }
        osg::Camera* getCameraWithFocus() { return _cameraWithFocus.get(); }
        const osg::Camera* getCameraWithFocus() const { return _cameraWithFocus.get(); }

        virtual void getCameras(Cameras& cameras, bool onlyActive=true);

        virtual void getContexts(Contexts& contexts, bool onlyValid=true);

        virtual void getAllThreads(Threads& threads, bool onlyActive=true);

        virtual void getOperationThreads(OperationThreads& threads, bool onlyActive=true);

        virtual void getScenes(Scenes& scenes, bool onlyValid=true);

        virtual void getViews(Views& views, bool onlyValid=true);

        /** Get the keyboard and mouse usage of this viewer.*/
        virtual void getUsage(osg::ApplicationUsage& usage) const;


    protected:
   
        void constructorInit();
       
        virtual void viewerInit() { init(); }

        osg::observer_ptr<osg::Camera>              _cameraWithFocus;
       

};


}

#endif

© 著作权归作者所有

共有 人打赏支持
哈全文
粉丝 14
博文 92
码字总数 22122
作品 0
海淀
其他
私信 提问
OpenSceneGraph 应用的问题

OpenSceneGraph 我都已经编译通过,环境变量添加好了,可在命令行(CMD)进行测试osgversion,osglogo,osgviewer cow.osg,都通过了。但是 在 vs2010中新建一个项目,测试时 出现了这样的错误...

yuxinabc1
2015/07/07
355
1
OSG向场景中添加osgParticle粒子效果

目的: 向场景中添加自定义的osgParticle实例,模拟坦克模型在地形上运动时产生的烟尘。 ----------------------------- 概述: 添加粒子效果可以有效提高仿真程序的外观和真实性。粒子引擎一...

长平狐
2012/10/08
1K
0
lemonrong/osg3DViewer

osg3DViewer A 3D File Viewer based on OSG. Use QT UI. Created for self learning for OSG. It's re-writed from osGraphX. CMake files was changed. It's more easy to build by cmake.......

lemonrong
2016/05/07
0
0
osg源码分析osgGA/KeySwitchMatrixManipulator

/ --c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield * * This library is open source and may be redistributed and/or modified under * the terms of the OpenSceneGra......

哈全文
2016/11/18
16
0
osg的一些小问题 关于漫游器的 求解答

分析了一个漫游器 , 其中有一点不是很明白,就是在交互操作的时候 响应键盘的WASD的字母,例如 W 前进 ChangePosition(osg::vec3(0,m_speed*sinf(osg::PI_2+m_Vposition.v[2]),0)) ChangePo...

追寻灯火阑珊
2014/05/09
328
0

没有更多内容

加载失败,请刷新页面

加载更多

SAP订单编排和流程增强概述

SAP产品里的订单处理,无论是On-Premises解决方案还是云产品,我认为归根到底可以概括成四个字:订单编排,包含两个层次的内容: 1. 单个订单通过业务流程或者工作流驱动的状态迁移; 2. 多种...

JerryWang_SAP
17分钟前
1
0
Tomcat shutdown.sh不能关掉tomcat进程的解决方法

Tomcat shutdown.sh不能关掉tomcat进程的解决方法 2018年08月14日 16:21:55 脚踏一方土 阅读数:184 标签: Tomcat 更多 个人分类: Tomcat 版权声明:本文为博主原创文章,未经博主允许不得...

linjin200
25分钟前
1
0
Linux添加PYTHONPATH方法以及3种修改环境变量方法

在用Linux(OS:Centos 7.2)时看到有一行代码是: export PYTHONPATH=$PYTHONPATH:/home/usrname/models:/home/usrname/models/one 意思是将models以及其目录下的one文件夹加入系统环境中。 ...

dragon_tech
28分钟前
2
0
redis数据结构

redis不只是一个简单的键(key)-值(value)数据库,实际上它是一个数据结构服务器,支持各种类型的值。也就是说,在传统的键-值数据库中,你把字符串键与字符串值联系起来,而在redis,值不仅限...

hblt-j
29分钟前
2
0
MySQL事务的的介绍及使用

1. 事务的特性 1.1 原子性(Atomicity): 原子性是指事务是一个不可分割的工作单位,事务中的操作要么都发生,要么都不发生。 1.2. 一致性(Consistency): 在一个事务中,事务的前后数据的完...

kuchawyz
35分钟前
1
0

没有更多内容

加载失败,请刷新页面

加载更多

返回顶部
顶部