osg::Shape类 继承自osg::Object类; osg::Shape类是各种内嵌几何体的基类,不但可以用于剔除和碰撞检测,还可用于生成预定义的几何体对象; osg::ShapeDrawable类: 派生自osg::Drawable类; 在osg::ShapeDrawable类的构造函数中提供了关联osg::Shape的方法 同时,因为它继承自osg::Drawable类,所以它的实例需要被添加...
doubleratio){// 绘制球体// 步骤一:创建一个用户保存几何信息的对象osg::Geodeosg::ref_ptr<osg::Geode>pGeode=newosg::Geode;// 步骤二:创建专门指明精细度的类osg::TessellationHints,并设置对应精细度osg::ref_ptr<osg::TessellationHints>pHints=newosg::TessellationHints;pHints->setDetailRatio(ratio);/...
shape1->setShape(newosg::Box(osg::Vec3(-3.0f,0.0f,0.0f),2.0f,2.0f,1.0f)); osg::ref_ptr<osg::ShapeDrawable> shape2 =newosg::ShapeDrawable; shape2->setShape(newosg::Sphere(osg::Vec3(3.0f,0.0f,0.0f),1.0f)); shape2->setColor(osg::Vec4(0.0f,0.0f,1.0f,1.0f)); osg::ref...
osg::ref_ptr<osg::ShapeDrawable> shape2 = new osg::ShapeDrawable; shape2->setShape(new osg::Cone(osg::Vec3(0.0f, 0.0f, 0.0f), 1.0f, 1.0f)); shape2->setColor(osg::Vec4(0.0f, 1.0f, 0.0f, 1.0f)); osg::ref_ptr<osg::ShapeDrawable> shape3 = new osg::ShapeDrawable; shape3...
h> #include <osgViewer/Viewer> #include <osgDB/ReadFile> #include <osg/Texture2D> #include <osg/ShapeDrawable> #include <gdal_priv.h> using namespace std; using namespace osg; using namespace osgViewer; //实现函数:从高程图创建地形 osg::Node* createHeightField(std::string heightFile, ...
1)Drawable:Drawable类是用于存储几何体信息的基类,是纯虚类无法直接实例化,用户必须实例化它的派生类,如Geometry或ShapeDrawable(这里可以让用户根据需要绘制预定义的几何形状如球体,长方体等) 2)Geometry:Geometry类与PrimitiveSet类相关联,实现堆OpenGL顶点数组功能的高级封装。Geometry保存顶点数组的数据,纹理坐标,颜色...
效果 直接上源码 需要包含的头文件很多,这里没全贴上 多定义XYZ枚举类 代码复制就能用 #include<osg/ShapeDrawable>// osg::ShapeDrawabletypedefenumAxis{X,Y,Z,NONE}Axis;/* @return 返回xyz坐标轴的组节点 */osg::ref_ptr<osg::Group>makeCoordinate(){// 创建空组节点osg::ref_ptr<osg::Group>group...
2.ShapeDrawable 则是内置一些形状的图元.诸如 圆柱.球体.圆锥等.自己实现尝试一下. 3.BING_PER_VERTEX 则指的每个顶点对应于一种属性(如例子中的颜色). 4.BING_OVERALL 则是全部顶点使用一样的属性(如例子中的法线) 实例源代码下载: ..下载地址
osgViewer::Viewer viewer;//创建一个正方体osg::ref_ptr<osg::Box>box=new osg::Box;box->setCenter(osg::Vec3(0.0,0.0,0.0));box->setHalfLengths(osg::Vec3(30.0,30.0,30.0));osg::ref_ptr<osg::ShapeDrawable>sd2=new osg::ShapeDrawable(box.get());osg::ref_ptr<osg::Geode>geode=new ...
简单渲染一个圆球 #include <osg/ShapeDrawable> //创建一个圆球 osg::ref_ptr<osg::Sphere> sphere = new osg::Sphere; sphere->set(osg::Vec3(0.0, 0.0, 50.0), 30); osg::ref_ptr<osg::ShapeDrawable> sd = new osg::ShapeDrawable(sphere.get()); ...