第二天(六)osgDB::readObjectFile _string

本文详细解析了OSGViewer中的帧处理流程,包括初始化、实现检查、资源准备等关键步骤,深入探讨了事件队列创建、漫游器初始化及图形上下文的实现过程。

目前流程是:

osgViewer::viewBase:: frame()

{

viewerInit();[

                          //创建帧事件,并将漫游器与事件和视口相关联

                            ->   osgViewer::Viewer::ViewerInit()

                           ->  osgViewer::View::Init();

                          ->(1)osgGA::EventQueue::createEvent();

                            (2)osgGA::MatrixManipulator::Init();

                            ->(2.1)各种漫游器::init()

                 ]

isRealized();[

                                    //获取图形上下文数组。再遍历上下文数组,只要有一个准备好就Ok

                                  ->   osgViewer::Viewer::isRealized();

                                 ->(1)osgViewer::Viewer::getContexts().

                                          ->(1.1)osg::camera::getGraphicsContext()

                                          ->(1.2)osg::View::getNumSlaves()

                                         ->(1.3)osg::View::getSlave()

                                         ->(1.4)LessGraphicsContext()->osg::GraphicContext::getTraits()

                                ->(2)osg::GraphicContext::isRealized()

                                        ->(2.1)->(1)

                                       ->(2.2)osg::GraphicsContext::isRealized()

                                                ->osg::GraphicsContext::isRealizedImplementation()

                                               ->(2.2.1)osgViewer::GraphicsWindow::isRealizedImplementation()

                                                             ->(2.2.1.1)osgViewer:: GraphicsWindowWin32 ::isRealizedImplementation()

                                                             ->(2.2.1.2) osgViewer::GraphicsWindowEmbedded ::isRealizedImplementation()

                                              ->(2.2.2)osgViewer::PixelBufferWin32::isRealizedImplementation()

                               -

 

                    ]

realize(); [

                    //建立视口和相关的线程

                     ->osgViewer::Viewer::realize()

                     ->(1) osgViewer::Viewer::setCameraWithFocus()

                     ->(2)osgViewer::Viewer::getContexts()

                    ->(3)osgViewer::Viewer::readConfiguration()

                          ->(3.1)osgDB::readObjectFile(const std::string& filename)

                          ->(3.2)osgViewer::Viewer::take()

                    ->(4)待续

                ]

advance(simulationTime);

eventTraversal();

updateTraversal();

renderingTraversals();

}

接下来进行读取数据

osgDB::readObjectFile(const std::string& filename)

这个函数的定义是

/** Read an osg::Object from file.
  * Return valid osg::Object on success,
  * return NULL on failure.
  * The osgDB::Registry is used to load the appropriate ReaderWriter plugin
  * for the filename extension, and this plugin then handles the request
  * to read the specified file.*/
inline osg::Object* readObjectFile(const std::string& filename)
{
    return readObjectFile(filename,Registry::instance()->getOptions());
}

 

通过注释也可以看出,这个是从文件名读取生成osg::Object,根据文件扩展名加载相应的读写插件,并根据插件读指定的文件。

 

至于具体如何,不急,慢慢来。每天一函数即可。

目前流程是:

osgViewer::viewBase:: frame()

{

viewerInit();[

                          //创建帧事件,并将漫游器与事件和视口相关联

                            ->   osgViewer::Viewer::ViewerInit()

                           ->  osgViewer::View::Init();

                          ->(1)osgGA::EventQueue::createEvent();

                            (2)osgGA::MatrixManipulator::Init();

                            ->(2.1)各种漫游器::init()

                 ]

isRealized();[

                                    //获取图形上下文数组。再遍历上下文数组,只要有一个准备好就Ok

                                  ->   osgViewer::Viewer::isRealized();

                                 ->(1)osgViewer::Viewer::getContexts().

                                          ->(1.1)osg::camera::getGraphicsContext()

                                          ->(1.2)osg::View::getNumSlaves()

                                         ->(1.3)osg::View::getSlave()

                                         ->(1.4)LessGraphicsContext()->osg::GraphicContext::getTraits()

                                ->(2)osg::GraphicContext::isRealized()

                                        ->(2.1)->(1)

                                       ->(2.2)osg::GraphicsContext::isRealized()

                                                ->osg::GraphicsContext::isRealizedImplementation()

                                               ->(2.2.1)osgViewer::GraphicsWindow::isRealizedImplementation()

                                                             ->(2.2.1.1)osgViewer:: GraphicsWindowWin32 ::isRealizedImplementation()

                                                             ->(2.2.1.2) osgViewer::GraphicsWindowEmbedded ::isRealizedImplementation()

                                              ->(2.2.2)osgViewer::PixelBufferWin32::isRealizedImplementation()

                               -

 

                    ]

realize(); [

                    //建立视口和相关的线程

                     ->osgViewer::Viewer::realize()

                     ->(1) osgViewer::Viewer::setCameraWithFocus()

                     ->(2)osgViewer::Viewer::getContexts()

                    ->(3)osgViewer::Viewer::readConfiguration()

                          ->(3.1)osgDB::readObjectFile(const std::string& filename)

                                 ->(3.1.1)osg::Object* readObjectFile(const std::string& filename,const ReaderWriter::Options* options);

                          ->(3.2)osgViewer::Viewer::take()

                    ->(4)待续

                ]

advance(simulationTime);

eventTraversal();

updateTraversal();

renderingTraversals();

}

 

 

 

 

评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值