OSG学习:OSG组成(三)——组成模块(续):OSG核心库中的一些类和方法

一、osg库

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

#include <osg/Node>

/*节点类*/
//继承关系:osg::Node-osg::Object-osg::Referenced
#include <osg/Node>
//类中方法
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<getNumParents(); ++i)
{
    const osg::Group *parent = node.getParent(i);
    /*执行parent对象的操作*/
}

 //设置/获取节点的更新回调
void setUpdateCallback(NodeCallback *)
NodeCallback *getUpdateCallback()
//设置/获取节点的交互事件回调
void setEventCallback(NodeCallback *)
NodeCallback *getEventCallback()

//设置/获取一个新的渲染状态集
void setStateSet(StateSet *stateset)
const StateSet *getStateSet() const
osg::StateSet *getOrCreateStateSet() //尝试获取当前节点对应的渲染状态集对象,如果不存在则返回一个新的渲染状态集。这在大多数情况下是安全的

 

#include <osg/Geometry>

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

 

#include <osg/Geode>

/*是个几何节点,可以说是一个几何Group节点,一般的可绘制几何体都是通过它来传向root进行渲染,是OSG几何绘制的最高管理节点*/
#include <osg/Geode>
//类中方法
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<osg::Geode> geode = new osg::Geode;
geode->addDrawable(drawable1);
geode->addDrawable(drawable2);
osg::Drawable *drawable = geode->getDrawable(i);

 

#include <osg/Group>

/*对节点起到组织作用,一般作为父节点或者根节点出现*/
#include <osg/Group>
//类中方法
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 <osg/AnimationPath>

 

#include <osg/AutoTransform>

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

 

#include <osg/Camera>

/*相机节点,管理OSG中的模型——视图矩阵,相机的管理主要是通过各种变换实现的*/
//继承关系1:osg::Camera-osg::Transform-osg::Group-osg::Node-osg::Object-osg::Referenced
//继承关系2:osg::Camera-osg::CullSettings
#include <osg/Camera>
//类中方法
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是视点上方向up
void 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() const
int getRenderOrderNum() const
//虚函数,派生自Transform类,用于系统内部计算局部坐标系到世界坐标系的级联矩阵
bool computeLocalToWorldMatrix(Matrix &matrix, NodeVisitor *nv) const;
//虚函数,派生自Transform类,用于系统内部计算世界坐标系到局部坐标系的级联矩阵
bool computeWorldTocalMatrix(Matrix &matrix, NodeVisitor *nv) const;

 

#include <osg/CullFace>

/**/
#include <osg/CullFace>

 

#include <osg/Depth>

/*封装OpenGL glDepthFunc / Mask / Range函数*/
#include <osg/Depth>

 

#include <osg/Image>

/**/
#include <osg/Image>

 

#include <osg/Light>

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

 

#include <osg/LightSource>

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

 

#include <osg/LineWidth>

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

 

#include <osg/LOD>

/**/
#include <osg/LOD>
//类中方法
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 <osg/Matrix>

 

#include <osg/MatrixTransform>

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

 

#include <osg/NodeCallback>

/*节点更新回调*/
#include <osg/NodeCallback>

 

#include <osg/NodeVisitor>

/**/
#include <osg/NodeVisitor>
//类中方法
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 <osg/PolygonMode>
//类中方法
NodeCallback() //默认构造函数
void operator()(Node *node, NodeVisitor *nv) //虚函数。当回调动作发生时,将会执行这一操作符的内容,并将节点和访问器对象作为参数传入
void addNestedCallback(NodeCallback *) //添加一个临近回调,其内容将在节点回调的执行过程中被依次调用
void removeNestedCallback(NodeCallback *) //移除一个临近回调
void setNestedCallback(NodeCallback *) //直接设置一个临近回调
NodeCallback *getNestedCallback(NodeCallback *) //直接获取一个临近回调

 

#include <osg/PolygonMode>

/**/
#include <osg/PolygonMode>

 

#include <osg/PositionAttitudeTransform>

/*位置变换节点类,提供模型的位置变换、大小缩放、原点位置的设置、坐标系的变换*/
#include <osg/PositionAttitudeTransform>
//类中方法
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 <osg/ShapeDrawable>

 

#include <osg/StateSet>

/**/
#include <osg/StateSet>
//类中方法
StateSet() //默认构造函数
int compare(const StateSet &rhs, bool) const //比较两个渲染状态集,如果是一样的,则可采用共享状态集的方式进行优化
ParentList getParents() //获取渲染状态集的父对象,一个渲染状态集可以被多个节点或可绘制体共享
void setMode(StateAttribute::GLmode, StateAttribute::GLModeValue) //启用或禁用一种渲染模式。渲染模式集可以使用glEnable()/glDisable()管理的OpenGL状态量;状态的开关设置可取ON/OFF/OVERRIDE/PROTECTED/INHERIT
StateAttribute::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 <osg/StateAttribute>
//类中方法
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 <osg/Switch>
//类中方法
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 <osg/TexEnv>

 

#include <osg/TexGen>

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

 

#include <osg/TexMat>

/**/
#include <osg/TexMat>

 

#include <osg/Texture>

/**/
#include <osg/Texture>
//类中方法
Texture() //默认构造函数
 //获取纹理S方向宽度、T方向高度,R方向深度
int getTextureWidth() const
int getTextureHeight() const
int 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 <osg/Texture2D>
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 <osg/Texture3D>

 

#include <osg/TextureCubeMap>

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

 

#include <osg/Transform>

/*一个组节点,所有子节点都通过4x4矩阵进行变换,通常用于在场景中定位对象,生成轨迹球功能或用于动画*/
#include <osg/Transform>
//类中方法
Transform() //默认构造函数
//设置/获取节点所用的参考坐标系
void setReferenceFrame(ReferenceFrame rf)
ReferenceFrame getReferenceFrame() const
bool 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 <osgViewer/Viewer>

 

 #include <osgViewer/ViewerBase>

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

 

 #include <osgViewer/CompositeViewer>

/*多视图的管理,负责多个视图的管理及同步工作*/
//继承关系1:osgViewer::CompositeViewer-osgViewer::ViewerBse-osg::Object-osg::Referenced
//继承关系2:osgViewer::CompositeViewer-osg::Object-osg::Referenced
#include <osgViewer/CompositeViewer>
//类中方法
//添加/移除一个视图
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 <osgViewer/ViewerEventHandlers>

 

#include <osgViewer\api\Win32\GraphicsWindowWin32>

/**/
#include <osgViewer\api\Win32\GraphicsWindowWin32>

 

四、 osgGA库

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

#include <osgGA/GUIEventAdapter>

/*事件适配器 常见窗口系统中的鼠标、键盘、触屏版(主要用于Mas OS X)的操作*/
#include <osgGA/GUIEventAdapter>
//类中方法
GUIEventAdapter() //默认构造函数
//获取该事件所来源的图形设备
const osg::GraphicsContext *
getGraphicsContext() const
//指示/判断该事件是否已经被处理
void setHandled(bool handled) const
bool 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() const
int getWindowY() const
int getWindowWidth() const
int 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() const
float getXmax() const
float getYmin() const
float getYmax() const
//设置/获取当前事件的鼠标光标位置
void setX(float x)
void setY(float x)
void getX() const
void getY() const
//获取当前事件的鼠标光标位置,并将光标位置限制在[-1, +1],无论实际的窗口坐标是多少
float getXnormalized() const
float getYnormalized() const
//设置/获取当前窗口Y坐标的增长方向,例如Windows窗口上端Y值为0,下端为最大值,即Y_INCREASING_DOWNWARDS
void 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() const
float getScrollingDeltaY() const
//设置/获取Mac OS X手写笔的触压值
void setPenPressure(float)
float getPenPressure() const
//设置/获取Mac OS X手写笔的X/Y方向偏移值
void setPenTiltX(float)
void setPenTiltY(float)
float getPenTiltX() const
float getPenTiltY() const
//设置/获取Mac OS X手写笔的旋转值
void setPenRotation(float)
float getPenRotation() const
//设置/获取Mac OS X手写板的类型,包括PEN/PUCK/ERASER
void setTabletPointerType(TabletPointerType)
TabletPointerType getTabletPointerType() const

 

#include <osgGA/GUIActionAdapter>

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

 

#include <osgGA/EventQueue>

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

 

#include <osgGA/GUIEventHandler>

/*OSG键盘和鼠标交互事件的处理终端*/
#include <osgGA/GUIEventHandler>
//类中方法
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 <osgGA/StateSetManipulator>

 

#include <osgGA/TrackballManipulator>

/**/
#include <osgGA/TrackballManipulator>


五、 osgUtil库

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

#include <osgUtil/Optimizer>

/*性能优化器*/
#include <osgUtil/Optimizer>

 

#include <osgUtil/Simplifier>

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

 

#include <osgUtil/SmoothingVisitor>

/*生成法线*/
#include <osgUtil/SmoothingVisitor>

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值