Geometry.rar

  • PUDN用户
    了解作者
  • Visual C++
    开发工具
  • 17KB
    文件大小
  • rar
    文件格式
  • 0
    收藏次数
  • 1 积分
    下载积分
  • 6
    下载次数
  • 2009-03-29 00:15
    上传日期
索引绑定几何体绘制(Geometry)示例
Geometry.rar
  • 索引绑定几何体绘制(Geometry)示例
  • osgVR
  • main.cpp
    3KB
  • osgVR.vcproj
    4.1KB
  • osgVR.vcproj.DCED96CCF2F246F.Administrator.user
    1.4KB
  • release
  • osgVR.exe
    44KB
  • osgVR.suo
    11KB
  • osgVR.sln
    880B
内容介绍
/********************************************************** *Write by FlySky *zzuxp@163.com http://www.OsgChina.org **********************************************************/ #include <osgViewer/Viewer> #include <osg/Node> #include <osg/Geode> #include <osg/Group> #include <osgDB/ReadFile> #include <osgDB/WriteFile> #include <osgUtil/Optimizer> //创建一个四边形节点 osg::Node* createQuad() { //创建一个叶节点对象 osg::Geode* geode = new osg::Geode(); //创建一个几何体对象 osg::Geometry* geom = new osg::Geometry(); //创建顶点数组 osg::Vec3Array* v= new osg::Vec3Array(); //添加数据 v->push_back(osg::Vec3(0.0f,0.0f,0.0f)); v->push_back(osg::Vec3(1.0f,0.0f,0.0f)); v->push_back(osg::Vec3(1.0f,0.0f,1.0f)); v->push_back(osg::Vec3(0.0f,0.0f,1.0f)); v->push_back(osg::Vec3(0.0f,-1.0f,0.0f)); //设置顶点数据 geom->setVertexArray(v); //创建四边形顶点索引数组,指定绘图基元为四边形,注意添加顺序 osg::DrawElementsUInt* quad= new osg::DrawElementsUInt(osg::PrimitiveSet::QUADS,0); //添加数据 quad->push_back(0); quad->push_back(1); quad->push_back(2); quad->push_back(3); //添加到几何体 geom->addPrimitiveSet(quad); //创建三角形顶点索引数组,指定绘图基元为三角形,注意添加顺序 osg::DrawElementsUInt* triangle = new osg::DrawElementsUInt(osg::PrimitiveSet::TRIANGLES,0); //添加数据 triangle->push_back(4); triangle->push_back(0); triangle->push_back(3); //添加到几何体 geom->addPrimitiveSet(triangle); //创建颜色数组 osg::Vec4Array* vc = new osg::Vec4Array(); //添加数据 vc->push_back(osg::Vec4(1.0f,0.0f,0.0f,1.0f)); vc->push_back(osg::Vec4(0.0f,1.0f,0.0f,1.0f)); vc->push_back(osg::Vec4(0.0f,0.0f,1.0f,1.0f)); vc->push_back(osg::Vec4(1.0f,1.0f,0.0f,1.0f)); //创建颜色索引数组 osg::TemplateIndexArray<unsigned int ,osg::Array::UIntArrayType,4,4>* colorIndex = new osg::TemplateIndexArray<unsigned int ,osg::Array::UIntArrayType,4,4>(); //添加数据,注意添加数据顺序与顶点一一对应 colorIndex->push_back(0); colorIndex->push_back(1); colorIndex->push_back(2); colorIndex->push_back(3); colorIndex->push_back(2); //设置颜色数组 geom->setColorArray(vc); //设置颜色索引数组 geom->setColorIndices(colorIndex); //设置颜色的绑定方式为单个顶点 geom->setColorBinding(osg::Geometry::BIND_PER_VERTEX); //创建法线数组 osg::Vec3Array* nc = new osg::Vec3Array(); //添加法线 nc->push_back(osg::Vec3(0.0f,-1.0f,0.0f)); //设置法线数组 geom->setNormalArray(nc); //设置法线的绑定方式为全部顶点 geom->setNormalBinding(osg::Geometry::BIND_OVERALL); //添加到叶节点 geode->addDrawable(geom); return geode; } int main() { //创建Viewer对象,场景浏览器 osgViewer::Viewer* viewer = new osgViewer::Viewer(); osg::Group* root = new osg::Group(); //添加到场景 root->addChild(createQuad()); //优化场景数据 osgUtil::Optimizer optimizer ; optimizer.optimize(root) ; viewer->setSceneData(root); viewer->realize(); viewer->run(); return 0 ; }
评论
    相关推荐
    • geometry.rar
      00AD SOFT HYPHEN is displayed on most terminals as a space or a dash. Some text editors display it only when a line is broken at it, some use it as a line-break hint, but don t display....
    • a060_Export_geometry.zip
      toolbox link cst mws for geometry
    • geometry operations.rar
      串口源码,代码附带说明很详细,新手可参考练习
    • geometry.rar
      This is an initial implementation of some geometrical structures. This is likely to grow and become more sophisticated in the future.
    • Geometry.rar
      It is used for geometrical transsformation in images and codes are of chris soloman book.
    • geometry.zip
      echart地图全国344区县的基础数据,百度已停止下载。...如:{"type": "FeatureCollection", "features": [{"type":"Feature","properties":{"name":"洪湖市"},"geometry":{"type":"MultiPolygon","coordinates
    • Geometry-开源
      几何是方便的程序,可帮助解决根据GNU通用公共许可协议发布的几何,三角学和相关的代数问题。
    • Geometry.zip
      几何表示系统类、支持点、矩阵、圆形、三角形、线段、折线
    • geometry-develop.zip
      一个GIS开发案例,开源代码,供大家学习参考
    • ogr_geometry.zip
      通用的导航栏,可以自定义颜色 、线条 、图片等,方便用户自定义