1 osgQT的移植
首先参考官方项目:
https://github.com/openscenegraph/osgQt
这里先给出结果图:
1.1 修改osgviewerqt.cpp如下: 这样你就能自己读模型了
#include <osgQOpenGL/osgQOpenGLWidget>
#include <osgDB/ReadFile>
#include <osgUtil/Optimizer>
#include <osg/CoordinateSystemNode>
#include <osg/Switch>
#include <osg/Types>
#include <osgViewer/Viewer>
#include <osgText/Text>
#include <osgViewer/Viewer>
#include <osgViewer/ViewerEventHandlers>
#include <osgGA/TrackballManipulator>
#include <osgGA/FlightManipulator>
#include <osgGA/DriveManipulator>
#include <osgGA/KeySwitchMatrixManipulator>
#include <osgGA/StateSetManipulator>
#include <osgGA/AnimationPathManipulator>
#include <osgGA/TerrainManipulator>
#include <osgGA/SphericalManipulator>
#include <osgGA/Device>
#include <QApplication>
#include <QSurfaceFormat>
#include <iostream>
int main( int argc, char** argv )
{
QSurfaceFormat format = QSurfaceFormat::defaultFormat();
#ifdef OSG_GL3_AVAILABLE
format.setVersion(3, 2);
format.setProfile(QSurfaceFormat::CoreProfile);
format.setRenderableType(QSurfaceFormat::OpenGL);
format.setOption(QSurfaceFormat::DebugContext);

本文档介绍了如何在Qt中移植和使用OpenSceneGraph(osg)库来加载和显示3D模型。首先,详细展示了如何修改osgviewerqt.cpp文件以实现模型读取。然后,创建了一个自定义的QOsgWidget类,用于初始化和管理osgViewer及相关的图形设置。最后,演示了如何在Qt应用中实例化和使用这个自定义类来加载和显示3D模型。
最低0.47元/天 解锁文章
109

被折叠的 条评论
为什么被折叠?



