Hi,
As requested by Robert, I am splitting my questions into multiple mails.
How do we fill colors in a drawn object.Here I am trying to draw a
circle and also I want to fill it with yellow color.
/*/
//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::TemplateIndexArrayunsigned 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
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org