|
本帖最后由 张逸 于 2013-3-1 21:27 编辑
example osggeometry
osg::Geometry* polyGeom = new osg::Geometry();
// note, first coord at top, second at bottom, reverse to that buggy OpenGL image..
osg::Vec3 myCoords[] =
{
// TRIANGLES 6 vertices, v0..v5
// note in anticlockwise order.
osg::Vec3(-1.12056, -2.15188e-09, -0.840418),
osg::Vec3(-0.95165, -2.15188e-09, -0.840418),
osg::Vec3(-1.11644, 9.18133e-09, -0.716827),
// note in anticlockwise order.
osg::Vec3(-0.840418, 9.18133e-09, -0.778623),
osg::Vec3(-0.622074, 9.18133e-09, -0.613835),
osg::Vec3(-1.067, 9.18133e-09, -0.609715),
// TRIANGLE STRIP 6 vertices, v6..v11
// note defined top point first,
// then anticlockwise for the next two points,
// then alternating to bottom there after.
osg::Vec3(-0.160668, -2.15188e-09, -0.531441),
osg::Vec3(-0.160668, -2.15188e-09, -0.749785),
osg::Vec3(0.0617955, 9.18133e-09, -0.531441),
osg::Vec3(0.168908, -2.15188e-09, -0.753905),
osg::Vec3(0.238942, -2.15188e-09, -0.531441),
osg::Vec3(0.280139, -2.15188e-09, -0.823939),
// TRIANGLE FAN 5 vertices, v12..v16
// note defined in anticlockwise order.
osg::Vec3(0.844538, 9.18133e-09, -0.712708),
osg::Vec3(1.0258, 9.18133e-09, -0.799221),
osg::Vec3(1.03816, -2.15188e-09, -0.692109),
osg::Vec3(0.988727, 9.18133e-09, -0.568518),
osg::Vec3(0.840418, -2.15188e-09, -0.506723),
};
int numCoords = sizeof(myCoords)/sizeof(osg::Vec3);
osg::Vec3Array* vertices = new osg::Vec3Array(numCoords,myCoords);
// pass the created vertex array to the points geometry object.
polyGeom->setVertexArray(vertices);
// use the shared color array.
polyGeom->setColorArray(shared_colors.get());
polyGeom->setColorBinding(osg::Geometry::BIND_OVERALL);
// use the shared normal array.
polyGeom->setNormalArray(shared_normals.get());
polyGeom->setNormalBinding(osg::Geometry::BIND_OVERALL);
// This time we simply use primitive, and hardwire the number of coords to use
// since we know up front,
polyGeom->addPrimitiveSet(new osg::DrawArrays(osg::PrimitiveSet::TRIANGLES,0,6));
polyGeom->addPrimitiveSet(new osg::DrawArrays(osg::PrimitiveSet::TRIANGLE_STRIP,6,6));
polyGeom->addPrimitiveSet(new osg::DrawArrays(osg::PrimitiveSet::TRIANGLE_FAN,12,5));
geode->addDrawable(polyGeom);
一个geometry里头加了三个primitiveSet,但是最终显示结果是
后面两个都没显示出来
是我的显示有问题,还是程序不对?
|
|