Hi, I want to draw a half cone. I have the code to draw an entire cone : osg::ref_ptr<osg::Geometry> geom = new osg::Geometry();
osg::Vec3Array* normals = new osg::Vec3Array; osg::Vec2Array* tcoords = new osg::Vec2Array; osg::Vec3Array* vertices = new osg::Vec3Array; unsigned int numSegments = 20; unsigned int numRows = 10; float ratio = 1.0f; float r = rayon; float h = hauteur; float normalz = r/(sqrtf(r*r+h*h)); float normalRatio = 1.0f/(sqrtf(1.0f+normalz*normalz)); normalz *= normalRatio; float angleDelta = 2.0f*osg::PI/(float)numSegments; float texCoordHorzDelta = 1.0/(float)numSegments; float texCoordRowDelta = 1.0/(float)numRows; float hDelta = hauteur/(float)numRows; float rDelta = rayon/(float)numRows; float topz=hauteur; float topr=0.0f; float topv=1.0f; float basez=topz-hDelta; float baser=rDelta; float basev=topv-texCoordRowDelta; float angle; float texCoord; for(unsigned int rowi=0; rowi<numRows; ++rowi,topz=basez, basez-=hDelta, topr=baser, baser+=rDelta, topv=basev, basev-=texCoordRowDelta) { angle = 0.0f; texCoord = 0.0f; for(unsigned int topi=0; topi<numSegments; ++topi,angle+=angleDelta,texCoord+=texCoordHorzDelta) { float c = cosf(angle); float s = sinf(angle); normals->push_back(osg::Vec3f(c*normalRatio,s*normalRatio,normalz)); tcoords->push_back(osg::Vec2f(texCoord,topv)); vertices->push_back(osg::Vec3f(c*topr,s*topr,topz)); tcoords->push_back(osg::Vec2f(texCoord,basev)); vertices->push_back(osg::Vec3f(c*baser,s*baser,basez)); } normals->push_back(osg::Vec3f(normalRatio,0.0f,normalz)); tcoords->push_back(osg::Vec2f(1.0f,topv)); vertices->push_back(osg::Vec3f(topr,0.0f,topz)); tcoords->push_back(osg::Vec2f(1.0f,basev)); vertices->push_back(osg::Vec3f(baser,0.0f,basez)); } geom->setVertexArray(vertices); osg::Vec4Array* colors = new osg::Vec4Array; colors->push_back(osg::Vec4f(0.0,1.0,1.0,1.0)); geom->setColorArray(colors); geom->setColorBinding(osg::Geometry::BIND_OVERALL); geom->setNormalArray(normals); geom->setTexCoordArray(0,tcoords); geom->addPrimitiveSet(new osg::DrawArrays(osg::PrimitiveSet::QUAD_STRIP,0,vertices->size())); But I can't draw a half-cone. Can you help me? Thank you! Cheers, lucie ------------------ Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=35703#35703 _______________________________________________ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org