项目实战:Qt+OSG三维建模基础框架v1.0.0(绘制直线,输入参数,绘制通道,支持windows、linux、国产麒麟系统)
需求
1.使用osg替换opengl建模,osg三维对象管理,性能优化,而opengl依赖cpu计算,且对场景管控不好;
2.右侧鼠标绘图,绘制长度的通道,可以一边画图,同步根据图来进行长度的创建通道;(这部分暂没继续实现了);
3.左侧侧是三维场景的框架,实现基本的功能:缩放、旋转、拽托场景中心,固定轴旋转;(这块是三维引擎,没有针对项目进行漫游器、事件处理器、相机口的调整了。)
4.基准面,绘制预计大小的基准面(这块要做无限平面,暂时这么多,无限平面得做显示范围正交投影,否则远处的会扎堆成一块黑色,已解决未放入);
本项目v1.0.0,实现一个建模的雏形,后续会逐渐完善。
《OSG开发笔记(三十):OSG加载动力学仿真K模型文件以及测试Demo》
《项目实战:Qt+OSG爆破动力学仿真三维引擎测试工具v1.1.0(加载.K模型,子弹轨迹模拟动画,支持windows、linux、国产麒麟系统)》
《项目实战:Qt+OSG三维建模基础框架v1.0.0(绘制直线,输入参数,绘制通道,支持windows、linux、国产麒麟系统)》
#ifndef OSGMANAGER_H
#define OSGMANAGER_H
#include "osgQt/GraphicsWindowQt.h"
#include <osgViewer/Viewer>
#include <osgViewer/ViewerEventHandlers>
#include <osgGA/CameraManipulator>
#include <osgGA/StandardManipulator>
#include <osgGA/OrbitManipulator>
#include <osgGA/TrackballManipulator>
#include <osgGA/MultiTouchTrackballManipulator>
#include <osgGA/NodeTrackerManipulator>
#include <osgGA/TerrainManipulator>
#include <osgGA/FirstPersonManipulator>
#include <osgGA/FlightManipulator>
#include <osgGA/AnimationPathManipulator>
#include <osgGA/SphericalManipulator>
#include <osgGA/CameraViewSwitchManipulator>
#include <osgGA/DriveManipulator>
#include <osgGA/KeySwitchMatrixManipulator>
#include <osgGA/UFOManipulator>
#include <osgGA/StateSetManipulator>
#include <osgDB/ReadFile>
#include <osgDB/WriteFile>
#include <osg/Switch>
#include <osg/MatrixTransform>
#include <osg/Depth>
#include <osg/LineWidth>
#include <osg/Point>
#include <osg/Shape>
#include <osg/ShapeDrawable>
#include <osg/Multisample>
#include <osg/PositionAttitudeTransform>
#include "osgCommon.h"
class OsgManager
{
public:
OsgManager();
public:
// 创建一个隧道
static osg::ref_ptr<osg::Node> createTunnel(Point3F centerP, double width, double height, double length, double thickness);
public:
// 创建一个面,输入四个点,输入四个点颜色
static osg::ref_ptr<osg::Node> createOneFace(Point3F p1, Point3F p2, Point3F p3, Point3F p4,
double r = 1.0f, double g = 1.0f, double b = 1.0f,double a = 1.0f,
Point3F normal = Point3F(0.0f, 1.0f, 0.0f));
// 创建一个长方体,输入中心点坐标,输入宽度,输入长度,输入颜色
static osg::ref_ptr<osg::Node> createOneCuboid(Point3F centerP, double width, double height, double length,
double r = 1.0f, double g = 1.0f, double b = 1.0f,double a = 1.0f);
public:
static QString debugInfo(Point3F point3f);
};