OSG学习:OSG组成(三)——组成模块(续):OSG核心库中的一些类和方法
发布日期:2025-05-01 06:17:17 浏览次数:2 分类:技术文章

本文共 17280 字,大约阅读时间需要 57 分钟。

一、osg库

基本数据类,负责提供基本场景图类:渲染绘制、场景节点管理、图形绘制、渲染状态管理等。包含一些程序所需要的特定功能类,如命令行解析和错误调试信息等。

#include <osg/Node>

/*节点类*///继承关系:osg::Node-osg::Object-osg::Referenced#include 
//类中方法Node() //默认构造函数Node(const Node &node, const CopyOp &copyop=CopyOp::SHALLOW_COPY) //构造函数,重载函数,从已知的Node中构建出新的Node,参数1为已存在的源节点,用于构造新的节点,参数2表示拷贝类型,默认浅拷贝(深拷贝枚举值为DEEP_COPY_NODES)virtual Object *cloneType() const //返回该对象的一个拷贝,当Node初始化候才有效virtual Object *clone(const CopyOp &copyop) const //返回该Node的一个拷贝,参数为拷贝类型virtual bool isSameKindAs(const Object *obj) const //判断两类是否是一个类型,父类与子类应该算作同一类型。相同为真。virtual const char *libraryName() const //返回Node的库文件名virtual const char *className() const //返回Node的类类型名void dirtyBound() //提示更新节点的包围体const BoundingSphere &getBound() const //获取节点的包围体BoundingSphere computeBound() const //虚函数,计算节点包围体const ParentList getParents() const //获取节点的父节点列表const Group *getParent(unsigned int i) const //获取制定的父节点unsigned int getNumParents() const //获取父节点的数目void addParent(Group *node) //为当前节点追加一个父节点void removeParent(Group *node) //删除当前节点的某个父节点void accept(NodeVisitor &nv) //接受一个访问器void ascend(NodeVisitor &nv) //虚函数。向上一级节点推进访问器void traverse(NodeVisitor &nv) //虚函数。向下一级节点推进访问器//例:获取和操作节点的每一个父节点的方法for (unsigned int i = 0; i

 

#include <osg/Geometry>

/*基本绘制几何体类,用户绘制基本的几何体*///继承关系:osg::Geometry-osg::Drawable-osg::Object#include 

 

#include <osg/Geode>

/*是个几何节点,可以说是一个几何Group节点,一般的可绘制几何体都是通过它来传向root进行渲染,是OSG几何绘制的最高管理节点*/#include 
//类中方法Geode() //默认构造函数bool addDrawable(Drawable *) //从叶节点追加一个可绘制体对象boolremoveDrawable(Drawable *) //从叶节点删除一个可绘制体对象virtual bool removeDrawables(unsigned int i, unsigned int numToRemove)//从制定索引位置开始,删除制定数目的可绘制体bool replaceDrawable(Drawable *origDraw, Drawable *newDraw) //将当前节点中包含的一个可绘制体替换为新的可绘制体unsigned int getNumDrawables() const //获取可绘制体的数目Drawable *getDrawables(unsigned int i) //获取一个指定位置的可绘制体unsigned int getDrawableIndex(const Drawable *) const //获取一个可绘制体在叶节点的索引位置const DrawableList &getDrawableList() const //获取可绘制体的列表//例:在可绘制体drawable1和drawable2中加入一个叶节点,然后从叶节点中获取并操作索引位置为i的可绘制体osg::ref_ptr
geode = new osg::Geode;geode->addDrawable(drawable1);geode->addDrawable(drawable2);osg::Drawable *drawable = geode->getDrawable(i);

 

#include <osg/Group>

/*对节点起到组织作用,一般作为父节点或者根节点出现*/#include 
//类中方法Group() //默认构造函数bool addChild(Node *child) //追加一个子节点bool removeChild(Node *child) //删除一个子节点bool removeChildren(unsigned int pos, unsigned int numToRemove) //从指定索引位置开始删除指定数目子节点bool insertChild(unsigned int index, Node *child) //向指定索引位置插入一个子节点bool replaceChild(Node *origChild, Node *newChild) //将当前节点中包含一个子节点替换为新的子节点unsigned int getNumChildren() const //获取子节点的数目Node *getChild(unsigned int i) //获取一个指定位置的子节点unsigned int getChildIndex(const Node *node) const //获取一个子节点的索引位置

 

#include <osg/AnimationPath>

/*动画类,封装了一个随时间变化的转型过程,可用于更新相机位置和模型对象的位置*/#include 

 

#include <osg/AutoTransform>

/*自动变换节点类,使节点自动对齐于摄像机或屏幕*/#include 

 

#include <osg/Camera>

/*相机节点,管理OSG中的模型——视图矩阵,相机的管理主要是通过各种变换实现的*///继承关系1:osg::Camera-osg::Transform-osg::Group-osg::Node-osg::Object-osg::Referenced//继承关系2:osg::Camera-osg::CullSettings#include 
//类中方法Camera() //默认构造函数//设置/获取相机的视口void setViewport(Viewport *)void setViewport(int x, int y, int width, int height)Viewport *getViewport()//直接设置/获取投影矩阵的内容void setProjectionMatrix(const Matrix &matrix)Matrix &getProjectionMatrix()//设置正射投影矩阵的内容,6个参数分别表示平行视景体的6个面的位置void setProjectionMatrixAsOrtho(double left, double right, double bottom, double top, double zNear, double zFar)//设置二维正射投影矩阵的内容void setProjectionMatrixAsOrtho2D(double left, double right, double bottom, double top)//设置透视投影矩阵的内容,6个参数分别表示视锥体的6个面的位置void setProjectionMatrixAsFrustum(double left, double right, double bottom, double top, double zNear, double zFar)//设置透视投影矩阵的内容,其中fovy表示可观察的角度范围,aspectRatio表示近裁切平面处的长宽之比void setProjectionMatrixAsPerspective(double fovy, double aspectRatio, double zNear, double zFar)//直接设置/获取观察矩阵的内容void setViewMatrix(const Matrix &)Matrix &getViewMatrix()//设置观察矩阵的内容,所用参数为视点eye、参考中心点center是视点上方向upvoid setViewMatrixAsLookAt(const Vec3d &eye, const Vec3d &center, const Vec3d &up)//属于Transform类,设置/获取该相机的参考系,使用绝对参考系(ABSOLUTE_RF)意味着该相机将不受父节点的任何变换的影响void setReferenceFrame(ReferenceFrame rf)ReferenceFrame getReferenceFrame() const//设置/获取该相机进行绘制时需要清除的缓存数据,默认为GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT,即清除颜色和深度缓存void setClearMask(GLbitfield)GLbitfield getClearMask() const//设置/获取该相机进行绘制时的背景颜色void setClearColor(const Vec4 &)const Vec4 &getClearColor() const//设置/获取相机对应的图形设备对象void setGraphicsContext(GraphicsContext *context)GraphicsContext *getGraphicsContext()//设置/获取相机是否接收图形设备传递的人机交互事件void setAllowEventFocus(bool)bool getAllowEventFocus() const//设置相机工作时的用户更新回调。Camera支持4种回调类型,分别用于渲染启动时、正式渲染前、正式渲染后和渲染结束时。此时可以直接执行用户自定义的OpenGL命令void setInitialDrawCallback(DrawCallback *cb)void setPreDrawCallback(DrawCallback *)void setPostDrawCallback(DrawCallback* cb)void setFinalDrawCallback(DrawCallback *cb)//设置相机的渲染顺序,在主场景之前(PRE_RENDER)还是之后(POST_RENDER)void setRenderOrder(RenderOrder order, int orderNum)RenderOrder getRenderOrder() constint getRenderOrderNum() const//虚函数,派生自Transform类,用于系统内部计算局部坐标系到世界坐标系的级联矩阵bool computeLocalToWorldMatrix(Matrix &matrix, NodeVisitor *nv) const;//虚函数,派生自Transform类,用于系统内部计算世界坐标系到局部坐标系的级联矩阵bool computeWorldTocalMatrix(Matrix &matrix, NodeVisitor *nv) const;

 

#include <osg/CullFace>

/**/#include 

 

#include <osg/Depth>

/*封装OpenGL glDepthFunc / Mask / Range函数*/#include 

 

#include <osg/Image>

/**/#include 

 

#include <osg/Light>

/*保存灯光的模式与属性参数信息*///继承关系:osg::StateAttribute#include 

 

#include <osg/LightSource>

/*灯光管理类,继承了osg::Group类的管理节点的接口,将灯光作为一个节点加入到场景图中进行渲染*///继承关系:osg::Group#include 

 

#include <osg/LineWidth>

/*定义场景中裁剪面的位置*///继承关系:osg::Group#include 

 

#include <osg/LOD>

/**/#include 
//类中方法LOD() //默认构造函数bool addChild(Node *child, float min, float max) //添加一个子节点,并设置其对应的观察范围void setRange(unsigned int childNo, float min, float max) //设置指定位置的子节点对应的观察范围float getMinRange(unsigned int childNo) const //获取某个子节点对应的观察最小值float getMaxRange(unsigned int childNo) const //获取某个子节点对应的观察最大值const RangeList &getRangeList() const //获取所有子节点观察范围的列表

 

#include <osg/Matrix>

/**/#include 

 

#include <osg/MatrixTransform>

/*移动节点的矩阵类,最常用的移动节点的类。可随动、旋转控制节点。*/#include 
//类中方法MatrixTransform() //默认构造函数//设置/获取空间变换矩阵的内容void setMatrix(const Matrix &mat)const Matrix &getMatrix() constvoid preMult(const Matrix &mat) //递乘,比较类似于++avoid postMult(const Matrix &mat) //递乘,比较类似于a++const Matrix &getInverseMatrix() const //得到逆矩阵

 

#include <osg/NodeCallback>

/*节点更新回调*/#include 

 

#include <osg/NodeVisitor>

/**/#include 
//类中方法NodeVisitor(TraversalMode tm) //构造函数。传入参数为节点树的遍历方式:TRAVERSE_NODE仅当前节点;TRAVERSE_PARENTS向当前节点的父节点遍历;TRAVERSE_ALL_CHILDREN向子节点遍历void traverse(Node &node) //向下一个需要访问的节点推进//虚函数。访问各种类型的节点,并执行访问器中自定义的节点操作void apply(Node &node)void apply(Node &node)void apply(Node &node)

 

#include <osg/PolygonMode>

/*指定多边形的绘制模式(点/线框/填充)*/#include 
//类中方法NodeCallback() //默认构造函数void operator()(Node *node, NodeVisitor *nv) //虚函数。当回调动作发生时,将会执行这一操作符的内容,并将节点和访问器对象作为参数传入void addNestedCallback(NodeCallback *) //添加一个临近回调,其内容将在节点回调的执行过程中被依次调用void removeNestedCallback(NodeCallback *) //移除一个临近回调void setNestedCallback(NodeCallback *) //直接设置一个临近回调NodeCallback *getNestedCallback(NodeCallback *) //直接获取一个临近回调

 

#include <osg/PolygonMode>

/**/#include 

 

#include <osg/PositionAttitudeTransform>

/*位置变换节点类,提供模型的位置变换、大小缩放、原点位置的设置、坐标系的变换*/#include 
//类中方法PositionAttitudeTransform() //默认构造函数//设置/获取空间中平移的距离void setPosition(const VEC3D &)const Vec3d &getPosition() const//设置/获取空间中旋转的四元数void setAttitude(const Quat &)const Quat &getAttitude() const//设置/获取空间缩放的倍数void setScale(const Vec3d &)const Vec3d& getScale() const//设置/获取空间旋转与缩放的轴心位置void setPivotPoint(const Vec3d&)const Vec3d& getPivotPoint() const

 

#include <osg/ShapeDrawable>

/*预定义几何体类,派生自osg::Drawable类。OSG中使用该类来将OSG内嵌的预定义几何体与osg::Drawable关联以渲染这些几何体*/#include 

 

#include <osg/StateSet>

/**/#include 
//类中方法StateSet() //默认构造函数int compare(const StateSet &rhs, bool) const //比较两个渲染状态集,如果是一样的,则可采用共享状态集的方式进行优化ParentList getParents() //获取渲染状态集的父对象,一个渲染状态集可以被多个节点或可绘制体共享void setMode(StateAttribute::GLmode, StateAttribute::GLModeValue) //启用或禁用一种渲染模式。渲染模式集可以使用glEnable()/glDisable()管理的OpenGL状态量;状态的开关设置可取ON/OFF/OVERRIDE/PROTECTED/INHERITStateAttribute::GLModeValue getMode(StateAttribute::GLMode) const //获取一种已设置的渲染模式void setAttribute(StateAttribute *attribute, StateAttribute::OverrideValue) //设置一个渲染属性,并设置其开关值void setAttributeAndMode(StateAttribute *attribute, StateAttribute::GLModeValue) //设置一个渲染属性,同时设置与之绑定的渲染模式StateAttribute *getAttribute(StateAttribute::Type type, unsigned int member) //获取一个已设置的渲染属性void setTextureMode(unsigned int unit, StateAttribute::GLMode mode, StateAttribute::GLModeValue) //启用或禁用纹理相关的渲染模式,此时要额外指定纹理单元StateAttribute::GLModeValue getTextureMode(unsigned int unit, StateAttribute::GLMode) const //获取一个已设置的纹理相关的渲染模式void setTextureAttribute(unsigned int unit StateAttribute *attribute, StateAttribute::OverrideValue) //设置一个纹理相关的渲染属性,并设置其开关值void setTextureAttributeAndModes(unsigned int unit, StateAttribute *attribute, StateAttribute::GLModeValue) //设置一个纹理相关的渲染属性,同时设置与之绑定的渲染模式StateAttribute *getTextrueAttribute(unsigned int unit, StateAttribute::Type type) //获取一个已设置的纹理相关的渲染属性

 

#include <osg/StateAttribute>

/**/#include 
//类中方法StateAttribute() //默认构造函数unsigned int getMember() const //虚函数。用于获取属性的成员号bool getModeUsage(StateAttribute::ModeUsage &) const //虚函数。用于获取与属性绑定的渲染模式int compare(const StateAttribute &) const //虚函数。用于比较两个渲染属性;这个函数可以用于两个渲染状态集的比较const ParentList &getParents() const //获取属性的父对象列表,渲染属性的父对象是渲染状态集类型void apply(State &) const //虚函数。应用这个渲染属性,可被派生类继承void compileGLObjects(State &) const //虚函数。用于编译OpenGL对象,某些渲染属性(如纹理)需要预先进行编译void releaseGLObjects(State *) const //虚函数。用于释放编译得到的OpenGL对象

 

#include <osg/Switch>

/*控制子类的显示与隐藏,这种隐藏不消耗内存*/#include 
//类中方法Switch() //默认构造函数bool addChild(Node *child, bool) //添加一个子节点,同时设置其开关值//设置/获取指定索引pos位置子节点的开关值void setValue(unsigned int pos, bool)bool getValue(unsigned int pos) const//设置/获取新加节点的初始值void setNewChildDefaultValue(bool value)bool getNewChildDefaultValue() const//设置/获取child的值void setChildValue(const Node *child, bool value)bool getChildValue(const Node *child) const//设置所有子节点显示/不显示bool setAllChildrenOff()bool setAllChildrenOn()bool setSingleChildOn(unsigned int pos) //设置索引pos单个节点显示

 

#include <osg/TexEnv>

/**/#include 

 

#include <osg/TexGen>

/*指定用于自动生成纹理坐标的函数,可以设置纹理的计算方式是以物体坐标空间还是相机坐标空间来进行不同的计算*/#include 

 

#include <osg/TexMat>

/**/#include 

 

#include <osg/Texture>

/**/#include 
//类中方法Texture() //默认构造函数 //获取纹理S方向宽度、T方向高度,R方向深度int getTextureWidth() constint getTextureHeight() constint getTextureDepth() const//设置/获取纹理边界的颜色void setBorderColor(const Vec4d &)const Vec4d &getBorderColor() const//设置/获取纹理边界的厚度void setBorderWidth(GLint)GLint getBorderWidth() const//设置/获取纹理边界截取方式,其中which参数可以选择3个纹理坐标轴(WRAP_S/WRAP_T/WRAP_R),wrap参数可以选择CLAMP等多种边界截取方案void setWrap(WrapParameter which, WrapMode wrap)WrapMode getWrap(WrapParameter which) const//设置/获取纹理滤波方式,其中which参数可以选择MIN_FILTER或MAG_FILTER,filter参数可以选择LINEAR等多种滤波方案void setFilter(FilterParameter which, FilterMode filter)FilterMode getFilter(FilterParameter which) const//设置/获取是否自动转换纹理图片尺寸到2的幂次方void setResizeNonPowerOfTwoHint(bool)bool getResizeNonPowerOfTwoHint() const//设置/获取纹理的内部压缩方式void setInternalFormatMode(InternalFormatMode)InternalFormatMode getInternalFormatMode() const//设置纹理内部格式,仅在压缩方式为USE_USER_DEFINED_FORMAT时有效void setInternalFormat(Glint)GLint getInternalFormat() const//设置/获取纹理图象源的数据格式void setSourceFormat(GLenum)GLenum getSourceFormat() const//设置/获取纹理图象源的数据类型void setSourceType(GLenum)GLenum getSourceType() const//虚函数。设置/获取某个面的纹理图像void setImage(unsigned int face, Image *)Image *getImage(unsigned int face)//虚函数。获取已设置的纹理图像数目unsigned int getNumImages() const

 

#include <osg/Texture2D>

/**/#include 
Texture2D() //默认构造函数Texture2D(Image *image) //构造函数。以一个2D纹理的图片源作为输入参数//设置/获取该2D纹理的输入图片源对象void setImage(Image *image)Image *getImage()//设置2D纹理图像的大小void setTextureWidth(int width)void setTextureHeight(int height)

 

#include <osg/Texture3D>

/**/#include 

 

#include <osg/TextureCubeMap>

/*立方体纹理映射*///继承自osg::Texture-osg::StateAttribute-osg::Object#include 

 

#include <osg/Transform>

/*一个组节点,所有子节点都通过4x4矩阵进行变换,通常用于在场景中定位对象,生成轨迹球功能或用于动画*/#include 
//类中方法Transform() //默认构造函数//设置/获取节点所用的参考坐标系void setReferenceFrame(ReferenceFrame rf)ReferenceFrame getReferenceFrame() constbool computerLocalToWorldMatrix(Matrix &matrix, NodeVisitor *nv) const //虚函数。计算从局部坐标系到世界坐标系的级联矩阵,保存到matrix变量中bool computerWorldToLocalMatrix(Matrix &matrix, NodeVisitor *nv) const //虚函数。计算从世界坐标系到局部坐标系的级联矩阵,保存到matrix变量

 

二、osgDB库

数据的读写库,负责提供场景中数据的读写工作,包括数据分页管理等功能,提供了一个文件工具类。注意,OSG中场景图管理是通过遍历场景图层次结构来完成大部分的数据处理工作的。

#include <osgDB/ReadFile>

#include <osgDB/WriteFile>

 

三、 osgViewer库

是在OSG2.0后逐步发展稳定的一个视窗管理库,可以集中各种窗体系统,提供OSG与各种GUI的结合。因此,它是跨平台的3D管理窗口库,有了它,其他库的功能才得以发挥,可以理解为场景管理库。

#include <osgViewer/Viewer>

/*显示场景*/#include 

 

 #include <osgViewer/ViewerBase>

/*线程管理、设置线程模式、启动线程等*///继承关系:osgViewer::ViewerBse-osg::Object-osg::Referenced#include 

 

 #include <osgViewer/CompositeViewer>

/*多视图的管理,负责多个视图的管理及同步工作*///继承关系1:osgViewer::CompositeViewer-osgViewer::ViewerBse-osg::Object-osg::Referenced//继承关系2:osgViewer::CompositeViewer-osg::Object-osg::Referenced#include 
//类中方法//添加/移除一个视图void addView(osgViewer::Viewer *view)void removeView(osgViewer::Viewer::Viewer *view)//得到视图的索引osgViewer::View *getView(unsigned i)const osgViewer::View *getView(unsigned i) const//得到视图的个数unsigned int getNumViews() const

 

#include <osgViewer/ViewerEventHandlers>

/*事件监听*/#include 

 

#include <osgViewer\api\Win32\GraphicsWindowWin32>

/**/#include 

 

四、 osgGA库

提供事件响应功能,通过与操作系统交互,使得程序可以响应外来事件,如键盘、鼠标、方向盘等多个类型事件。

#include <osgGA/GUIEventAdapter>

/*事件适配器 常见窗口系统中的鼠标、键盘、触屏版(主要用于Mas OS X)的操作*/#include 
//类中方法GUIEventAdapter() //默认构造函数//获取该事件所来源的图形设备const osg::GraphicsContext *getGraphicsContext() const//指示/判断该事件是否已经被处理void setHandled(bool handled) constbool getHandled() const//设置/获取事件的类型void setEventType(EventType)EventType getEventType() const//设置/获取该事件持续的时间void setTime(double)double getTime() const//设置/获取事件所来源的图形窗口的位置和尺寸信息,如果该事件来源于窗口的话void setWindowRectangle(int x, int y, int width, int height, bool updateMouseRange)int getWindowX() constint getWindowY() constint getWindowWidth() constint getWindowHeight() const//设置/获取键盘按键事件void setKey(int key)int getKey() const//设置/获取鼠标按键事件void setButton(int buutton)int getButton const//设置/获取鼠标输入的控制范围void setInputRange(float Xmin, float Ymin, float Xmax, float Ymax)float getXmin() constfloat getXmax() constfloat getYmin() constfloat getYmax() const//设置/获取当前事件的鼠标光标位置void setX(float x)void setY(float x)void getX() constvoid getY() const//获取当前事件的鼠标光标位置,并将光标位置限制在[-1, +1],无论实际的窗口坐标是多少float getXnormalized() constfloat getYnormalized() const//设置/获取当前窗口Y坐标的增长方向,例如Windows窗口上端Y值为0,下端为最大值,即Y_INCREASING_DOWNWARDSvoid setMouseYOrientation(MouseYOrientation)MouseYOrientation getMouseYOrientation() const//设置/获取持续作用的鼠标按键事件,例如一直按下的鼠标左键/中键/右键vlid setButtonMask(unsigned int)unsigned int getButtonMask() const//设置/获取持续作用的键盘控制键事件,例如一直按下的Shift键、Alt键、Ctrl键等void setModKeyMask(unsigned int)unsigned int getModKeyMask() const//设置/获取鼠标滚轮的滚动方向void setScrollingMotion(ScrollingMotion)ScrollingMotion getScrollingMotion() const//设置/获取鼠标滚轮的滚动增量值,对于Windows兼容鼠标而言,一般只有Y方向的滚动增量值void setScrollingMotionDelta(float x, float y)float getScrollingDeltaX() constfloat getScrollingDeltaY() const//设置/获取Mac OS X手写笔的触压值void setPenPressure(float)float getPenPressure() const//设置/获取Mac OS X手写笔的X/Y方向偏移值void setPenTiltX(float)void setPenTiltY(float)float getPenTiltX() constfloat getPenTiltY() const//设置/获取Mac OS X手写笔的旋转值void setPenRotation(float)float getPenRotation() const//设置/获取Mac OS X手写板的类型,包括PEN/PUCK/ERASERvoid setTabletPointerType(TabletPointerType)TabletPointerType getTabletPointerType() const

 

#include <osgGA/GUIActionAdapter>

/*动作适配器 实现用户向系统传递的请求,常见的用户请求包括窗口的刷新及鼠标坐标的设置*/#include 
//类中方法void requestRedraw()void requestContinuousUpdate(bool)void requestWarpPointer(float x, float y)

 

#include <osgGA/EventQueue>

/*记录所有输入设备和系统事件的一个数据队列,并使用GUIEventHandler及其派生类将这些事件传递给用户进行处理可以理解为一个交互事件的集合,它保存了一个GUIEventAdapter的队列,并提供向队列中新增元素的方法*/#include 
//类中方法EventQueue(GUIEventAdapter::MouseYOrientation)void setEvents(Events &events)bool takeEvents(Events &events)bool copyEvents(Events &events) constvoid appendEvents(Events &events)void addEvent(GUIEventAdapter *)GUIEventAdapter *getCurrentEventState()

 

#include <osgGA/GUIEventHandler>

/*OSG键盘和鼠标交互事件的处理终端*/#include 
//类中方法GUIEventHandler() //默认构造函数void operator()(osg::Node *node, osg::NodeVisitor *nv) //虚函数,作为节点事件回调使用时,调用处理函数handler()并传入相应参数void event(osg::NodeVisitor *nv, osg::Drawable *drawable) //虚函数,作为可绘制事件回调使用时,调用处理函数handle()并传入相应参数bool handle(const GUIEventAdapter &ea, GUIActionAdapter &aa, osg::Object *obj, osg::NodeVisitor *nv) //事件处理函数,重构此函数以完成各种用户自定义的交互操作。传入参数包括当前交互事件、反馈动作、保存该处理器的对象以及传递该事件的访问器EventVisitor(该访问器作为场景访问的主要执行者,负责区分和调用各个节点、可绘制体以及渲染状态集的事件回调对象)

 

#include <osgGA/StateSetManipulator>

/*事件响应类,对渲染状态进行控制*/#include 

 

#include <osgGA/TrackballManipulator>

/**/#include 

五、 osgUtil库

工具类库,提供通用的共用类,用于操作场景图形及内容,如更新、裁剪、遍历、数据统计及场景图的一些优化。包括Delaunay三角面绘制功能、发现生成功能等。

#include <osgUtil/Optimizer>

/*性能优化器*/#include 

 

#include <osgUtil/Simplifier>

/*简化几何体*///osgUtil::Simplifier类继承自osg::NodeVisitor类#include 

 

#include <osgUtil/SmoothingVisitor>

/*生成法线*/#include 

 

上一篇:OSG学习:OSG组成(二)——场景树
下一篇:OSG学习:OSG组成(一)——组成模块

发表评论

最新留言

关注你微信了!
[***.104.42.241]2025年04月28日 05时28分07秒

关于作者

    喝酒易醉,品茶养心,人生如梦,品茶悟道,何以解忧?唯有杜康!
-- 愿君每日到此一游!

推荐文章