当前位置: 首页 > news >正文

视频网站怎么做算法网站开发与维护都有些什么

视频网站怎么做算法,网站开发与维护都有些什么,网络营销策划的原则,wordpress怎样静态化在OpenSceneGraph开发中#xff0c;为了方便会经常使用到一些不是三角形片的数据#xff0c;比如四边形等数据。例如画一个管子用四边形带比用三角形片好计算得多。比如现在我们要画一个由两个平面组成的面#xff0c;我可以这样做#xff1a; osg::Geode*geodenewosg::Geo…在OpenSceneGraph开发中为了方便会经常使用到一些不是三角形片的数据比如四边形等数据。例如画一个管子用四边形带比用三角形片好计算得多。比如现在我们要画一个由两个平面组成的面我可以这样做 osg::Geode* geodenew osg::Geode;     osg::Geometry* polyGeom  new osg::Geometry;     osg::Vec3 myCoords[]     {         osg::Vec3(0,1,0),         osg::Vec3(0,0,0),         osg::Vec3(1,1,0),         osg::Vec3(1,0,0),         osg::Vec3(2,1,0),         osg::Vec3(2,0,0)     };     int numCoords  sizeof(myCoords)/sizeof(osg::Vec3);     osg::Vec3Array* vertices  new osg::Vec3Array(numCoords,myCoords);     polyGeom-setVertexArray(vertices);     polyGeom-addPrimitiveSet(new osg::DrawArrays(osg::PrimitiveSet::QUAD_STRIP,0,numCoords));     geode-addDrawable(polyGeom); 这样就用6个点用OpenGL提供的QUAD_STRIP方式画出了两个平面。 但是如果要把这个平面用于碰撞检测等技术那么就需要把这六个点所表示的四边形带转换成三角形片才行。这些三角形定点如下 0 1 0 0 0 0 1 1 0 0 0 0 1 0 0 1 1 0 1 1 0 1 0 0 2 1 0 1 0 0 2 0 0 2 1 0 可以看出两个平面由4个三角形组成而且都是逆时针排列朝向一致。 以前我自己做过转换但是感觉很麻烦。OpenSceneGraph的Example osggeometry中提供了一个printTriangles函数它可以打印出一个drawable所有的三角形片不管最初的数据结构如何 struct NormalPrint {     void operator() (const osg::Vec3 v1,const osg::Vec3 v2,const osg::Vec3 v3, bool) const      {         osg::Vec3 normal  (v2-v1)^(v3-v2);         normal.normalize();         std::cout  \t(v1) (v2) (v3) ) normal (normal)std::endl;     } }; // decompose Drawable primtives into triangles, print out these triangles and computed normals. void printTriangles(const std::string name, osg::Drawable drawable) {     std::coutnamestd::endl;          osg::TriangleFunctorNormalPrint tf;     drawable.accept(tf);       std::coutstd::endl; } 核心的思想就是利用osg::TriangleFunctor这个模版。这个模版会让你重载()运算符然后让Drawable去visit它。在这个过程中所有原始的数据不管是三角形片的还是四边形的都转换成了三角形片数据。 那么如何把三角形数据导出哪只需要修改一下借助这个思路将NormalPrint修改成我们需要的就对了。 struct GetVertex {     void operator() (const osg::Vec3 v1,const osg::Vec3 v2,const osg::Vec3 v3, bool) const      {         vertexList-push_back(v1);         vertexList-push_back(v2);         vertexList-push_back(v3);     }     osg::Vec3Array* vertexList;      }; void getTriangles(osg::Drawable drawable) {     osg::TriangleFunctorGetVertex tf;     tf.vertexListnew osg::Vec3Array;     drawable.accept(tf);     for(osg::Vec3Array::iterator itrtf.vertexList-begin();         itr!tf.vertexList-end();         itr)     {         osg::Vec3 vertex*itr;         std::coutvertexstd::endl;     }     std::coutstd::endl; } 以下是完整的示例文件 //PrimitiveSet.cpp : 定义控制台应用程序的入口点。 // #include stdafx.h#include iostreamstruct GetVertex {     void operator() (const osg::Vec3 v1,const osg::Vec3 v2,const osg::Vec3 v3, bool) const      {         vertexList-push_back(v1);         vertexList-push_back(v2);         vertexList-push_back(v3);     } osg::Vec3Array* vertexList;      }; void getTriangles(osg::Drawable drawable) {     osg::TriangleFunctorGetVertex tf;     tf.vertexListnew osg::Vec3Array; drawable.accept(tf); for(osg::Vec3Array::iterator itrtf.vertexList-begin();         itr!tf.vertexList-end();         itr)     {         osg::Vec3 vertex*itr;         std::coutvertexstd::endl;     } std::coutstd::endl; } osg::Node* createGeode() {     osg::Geode* geodenew osg::Geode;     osg::Geometry* polyGeom  new osg::Geometry;     osg::Vec3 myCoords[]     {         osg::Vec3(0,1,0),         osg::Vec3(0,0,0),         osg::Vec3(1,1,0),         osg::Vec3(1,0,0),         osg::Vec3(2,1,0),         osg::Vec3(2,0,0)     }; int numCoords  sizeof(myCoords)/sizeof(osg::Vec3);     osg::Vec3Array* vertices  new osg::Vec3Array(numCoords,myCoords);     polyGeom-setVertexArray(vertices);     polyGeom-addPrimitiveSet(new osg::DrawArrays(osg::PrimitiveSet::QUAD_STRIP,0,numCoords));     geode-addDrawable(polyGeom);     getTriangles(*polyGeom);     return geode; } int _tmain(int argc, _TCHAR* argv[]) {     //Set up viewer     osgViewer::Viewer viewer;     osg::ref_ptrosg::GraphicsContext::Traits traitsnew osg::GraphicsContext::Traits;     traits-x200;     traits-y200;     traits-width800;     traits-height600;     traits-windowDecorationtrue;     traits-doubleBuffertrue;     traits-sharedContext0;          osg::ref_ptrosg::GraphicsContext gcosg::GraphicsContext::createGraphicsContext(traits.get());     osg::ref_ptrosg::Camera cameranew osg::Camera;     //osg::Camera cameranew osg::Camera;     camera-setGraphicsContext(gc.get());     camera-setViewport(new osg::Viewport(0,0,traits-width,traits-height));     camera-setDrawBuffer(GL_BACK);     camera-setReadBuffer(GL_BACK);     osgGA::TrackballManipulator* tmnew osgGA::TrackballManipulator;          viewer.setCameraManipulator(tm);          viewer.addSlave(camera.get()); //Set up root node     osg::ref_ptrosg::Group rootnew osg::Group; root-addChild(createGeode());      //Start show!     viewer.setSceneData(root.get());     viewer.realize(); while(!viewer.done())     {         viewer.frame();     } }
http://www.zqtcl.cn/news/351792/

相关文章:

  • 广州网站定制开发方案南宁网站 制作
  • php做网站需要后台吗郑州建网站十大
  • 网站跳出率是什么意思百度服务
  • 建站 discuz开发者导航
  • 有哪些网站可以做毕业设计外贸网站发外链
  • 如何使用网站模板计算机培训班有用吗
  • 本地宁波网站建设电子商务网站建设工具都有那些
  • 网站建设的基本目标免费 wordpress企业主题
  • 专业网站建设微信商城开发规划馆网站建设
  • 网站建设公司沈阳西安建设工程信息交易中心官网
  • 青海住房和城乡建设部网站wordpress php7.3
  • 网站后台重置密码怎么做360网站怎么做网址链接
  • 广告网站建设及推广网站建设怎样推广
  • 做网站使网页不居中滁州注册公司流程和费用
  • 做网站广告经营者个性定制网站
  • 网站开发 北京外包公司软件公司网站建设
  • 网络认证入口seo免费诊断
  • 十大知名博客网站郑州企业建站公司定制
  • 视频网站如何做引流网站首页 关键词
  • 建设机械网站精英大港做网站
  • 潜山网站建设公司哪里有wordpress相册投票插件
  • 网站建设制作过程网站添加支付功能
  • 网站制作字体即墨公司做网站
  • vue 做pc网站可以吗哪个网站买域名便宜
  • 做销售网站那家好金华住房与城乡建设部网站
  • apple私人免费网站怎么下载无锡网站建设技术
  • 移动应用网站开发阶段作业信息型网站有哪些
  • 监控直播网站开发网站建设与管理总结
  • 青岛城阳网站设计免费网站成品
  • 做服装外贸的网站ghost wordpress