HI Qasim,

If you want a simple way of drawing a sphere then you can use
osg::ShapeDrawable to draw a shape.  The osgshadpe example is a good
guide to doing things this way.  ShapeDrawable is not the most
efficient way to draw an geometry, but its a least easy.

The way you are using osg::Geometry is inappropriate in this case as
setShape only sets the primitive shape reoresentation that collision
detection might use, it doesn't build any geometry for you.  You can
use osg::Geometry and create your own vertex arrays, normals and
primitive set to represent the sphere, and this will result in the
most OpenGL efficient path, but it requires more code.  See the
osggeometry example for a guide to creating your own geometry.

Loading a sphere from a file is equivilant to creating your own
geometry - only the plugin will build the geometry vertices and
primitives for you.

On 1/18/07, Qasim Mumtaz <[EMAIL PROTECTED]> wrote:
I am trying to draw a sphere using following code, but this isnt wokring.
Also please advise if its more efficent to draw a node like this sphere in
scenegraph or read file  e.g sphere.3DS ?
Any help will be appreciated.

 osg::ref_ptr<osg::Group> sphereNode = new osg::Group();

 osg::ref_ptr<osg::Geode> sphereGeode = new osg::Geode();
 osg::ref_ptr<osg::Geometry> sphereGeometry = new osg::Geometry();
 osg::ref_ptr<osg::Sphere> lightSphere = new
osg::Sphere(osg::Vec3(0,0,0),200.0f);
 sphereGeometry->setShape(lightSphere.get());
 sphereGeode->addDrawable(sphereGeometry.get());

 osg::Vec4Array* t_color = new osg::Vec4Array;
 t_color->push_back(osg::Vec4(1.0f,1.0f,1.0f,1.0f));
 sphereGeometry->setColorArray(t_color);
sphereGeometry->setColorBinding(osg::Geometry::BIND_OVERALL);

 osg::StateSet* state = sphereGeode->getOrCreateStateSet();
 state->setMode(GL_LIGHTING,osg::StateAttribute::ON);
//state->setMode(GL_DEPTH_TEST,osg::StateAttribute::OFF);

 sphereNode->addChild(sphereGeode.get());


 ________________________________
Never Miss an Email
Stay connected with Yahoo! Mail on your mobile. Get started!


_______________________________________________
osg-users mailing list
osg-users@openscenegraph.net
http://openscenegraph.net/mailman/listinfo/osg-users
http://www.openscenegraph.org/


_______________________________________________
osg-users mailing list
osg-users@openscenegraph.net
http://openscenegraph.net/mailman/listinfo/osg-users
http://www.openscenegraph.org/

Reply via email to