Hi
How do we fill color in a drawn object.Here I am trying to draw a circle
and also I want to fill it with yellow color.
1.What do you mean by actually setting this array ?
setTexCoordArray(0, texcoords);
2.What are these values or co-ordinates ?
(*texcoords)[j].set( 40.50f, 40.0f );
Even the tutorial doesn't have proper explanation for this
3.Can we support CGM(Computer Graphic Metadatafile) or Postscript
importing of the screen ?
4.I am trying to antalias or draw smooth lines but the opengl is not
drawing the lines smoothly even if I have set Stateset ?
osg::StateSet* StateSet = new osg::StateSet();
osg::ref_ptr<osg::Hint> antialias = new
osg::Hint(GL_LINE_SMOOTH_HINT, GL_NICEST);
StateSet->setAttributeAndModes(antialias.get(), osg::StateAttribute::ON);
what Am I doing wrong here ?
Srikanth Bemieni
/*****************************************************************************/
//degree to radian conversion
const float DEG2RAD = 3.14159/180;
osg::Geode* circle = new osg::Geode;
osg::Geometry* circleGeom = new osg::Geometry; //circle geometery
circle->addDrawable( circleGeom );
osg::Vec3Array* circleArray = new osg::Vec3Array;
//To calculate circle points
//here it is every 30 degrees 12 point circle or polygon what ever
int radius = 1000;
for (int i=0; i < 360; i = i + 30 )
{
float degInRad = i*DEG2RAD;
circleArray->push_back(
osg::Vec3(cos(degInRad)*radius,0,sin(degInRad)*radius ) );
}
circleGeom->setVertexArray( circleArray );
//attaching the points
osg::DrawElementsUInt* circleelementobj = new
osg::DrawElementsUInt( osg::PrimitiveSet::LINE_LOOP, 0 );
osg::Vec4Array* ccolors = new osg::Vec4Array;
osg::TemplateIndexArray <unsigned int,
osg::Array::UIntArrayType,4,4> *colorIndexArray;
colorIndexArray =new osg::TemplateIndexArray<unsigned int,
osg::Array::UIntArrayType,4,4>;
osg::Vec2Array* texcoords = new osg::Vec2Array(360/30);
for( int j=0 ; j < 360/30 ; j++ )
{
circleelementobj->push_back( j );
ccolors->push_back(osg::Vec4(1.0f, 1.0f, 0.0f, 1.0f) ); //index
0 redi
(*texcoords)[j].set( 40.50f, 40.0f ); //I really didn't get what
to do just copied from the tutorial
}
circleelementobj->push_back( 0 );
for( int k = 0 ; k < 360 /30 ; k++ )
{
colorIndexArray->push_back(0);
}
ccolors->push_back(osg::Vec4(1.0f, 1.0f, 0.0f, 1.0f) ); //index 0 red
circleGeom->addPrimitiveSet( circleelementobj );
circleGeom->setColorArray(ccolors);
circleGeom->setColorIndices(colorIndexArray);
circleGeom->setColorBinding(osg::Geometry::BIND_PER_VERTEX);
circleGeom->setTexCoordArray(0, texcoords);
osg::PositionAttitudeTransform* circleXForm =
new osg::PositionAttitudeTransform();
circleXForm->setPosition(osg::Vec3( 4000 ,0, 4100 ));
root->addChild(circleXForm);
circleXForm->addChild( circle );
/*****************************************************************************************************************/
--
With Regards
Srikanth Bemineni
Geotrace Technologies
281-497-8440 extn 228
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org