> As far as I can see you're creating 'approx/4' circles each 
> with 'approx'
> vertices. This means that the vertex array contains 
> '(approx/4)+1 * approx'
> vertices but the 'DrawArrays' only displays the first 
> 'approx' vertices.
> 
> If you change that last line to:
> 
> geom->addPrimitiveSet(new osg::DrawArrays(GL_LINE_LOOP, 0,
> approx*(approx/4)+1));
> 
> you should start to see more what you expect.

Yeah, that's a good start. But probably not perfect as the primitive type is
LINE_LOOP. Hard to tell though... When someone gives you code to "draw a
sphere" that doesn't work, and there are dozens of ways to draw a sphere,
it's difficult to tell what to fix.

One way to draw a sphere is to imagine the sphere is a globe and draw
circles to represent lines of latitude and longitude. I don't quite see an
attempt at this in the code. However, assuming this is the desired end
result, then you really want a separate PrimitiveSet for each LINE_LOOP.

(Such a lat/long sphere suffers from low approximation near the "equator"
and excessive approximation near the "poles". I prefer an alternate sphere
rendering algorithm, starting from the 20 triangles of an icosahedrons and
repetitively subdividing the triangles until a sufficient approximation is
achieved. This type of code is somewhat more complex to write, and consumes
more CPU cycles, however. Vanilla OpenGL code for this can be downloaded
from www.opengldistilled.com. Maybe at some point I'll adapt it for use with
OSG.)

Paul Martz
Skew Matrix Software LLC
http://www.skew-matrix.com
303 859 9466

_______________________________________________
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to