多自由度机械臂模拟6

匿名 (未验证) 提交于 2019-12-02 23:55:01

模拟一个完整的吊装流程,初始状态->起臂->放下吊绳->竖直起吊->水平旋转->放下物体->收缩吊绳。

osg::ref_ptr<osg::Node> createSimple()  {     osg::ref_ptr<osg::Geode> geode = new osg::Geode;     osg::ref_ptr<osg::Geometry> geo = new osg::Geometry;      //申请一些顶点     osg::ref_ptr<osg::Vec3Array> vers = new osg::Vec3Array;     geo->setVertexArray(vers.get()); #if 1     geo->addPrimitiveSet(new osg::DrawArrays(osg::PrimitiveSet::LINE_LOOP, 0, 4));//创建一个线圈 #else     geo->addPrimitiveSet(new osg::DrawArrays(osg::PrimitiveSet::QUADS, 0, 4));//创建一个正方形 #endif                                                                                 //设置顶点     vers->push_back(osg::Vec3(-15, 3.0, -15));     vers->push_back(osg::Vec3(15, 3.0, -15));     vers->push_back(osg::Vec3(15, 3.0, 15));     vers->push_back(osg::Vec3(-15, 3.0, 15));      //申请颜色     osg::ref_ptr<osg::Vec4Array> color = new osg::Vec4Array();     color->push_back(osg::Vec4(1.0, 0.0, 0.0, 0.5));     color->push_back(osg::Vec4(0.0, 1.0, 0.0, 0.5));     color->push_back(osg::Vec4(0.0, 0.0, 1.0, 0.5));     color->push_back(osg::Vec4(1.0, 1.0, 0.0, 0.5));      //设置颜色     geo->setColorArray(color.get());     geo->setColorBinding(osg::Geometry::AttributeBinding::BIND_PER_VERTEX);//设置颜色绑定                                                                             //设置法线,正对屏幕的时候最亮     osg::ref_ptr<osg::Vec3Array> norm = new osg::Vec3Array;     geo->setNormalArray(norm);     geo->setNormalBinding(osg::Geometry::AttributeBinding::BIND_OVERALL);     norm->push_back(osg::Vec3(0.0, -1.0, 0.0));      //打开透明度     geo->getOrCreateStateSet()->setMode(GL_BLEND, osg::StateAttribute::ON);      //设置线宽     osg::ref_ptr<osg::LineWidth> w = new osg::LineWidth;     w->setWidth(5.0);     geo->getOrCreateStateSet()->setAttributeAndModes(w.get(), osg::StateAttribute::ON);      geode->addDrawable(geo.get());      return geode; }//代码参考:https://blog.csdn.net/wb175208/article/details/80513775

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!