Hi all,

i want to draw a bunch of vertices into my scene, using Openscenegraph 3.3.1.
Therefore, i oriented towared the createBase-function from the Animate-example. 
Now if i have a small Vec3Array everything is fine (see first picture 1), but 
if the numTilesX and numTilesY (see code) are both set to 300, a very strange 
thing happens (see picture 2).
What did i overlook?

Here is the code of the createBase-function used: (nothing except the values 
for numTilesX and numTilesY was changed)

Code:

int numTilesX = 300;
int numTilesY = 300;

float width = 2*radius;
float height = 2*radius;

osg::Vec3 v000(center - osg::Vec3(width*0.5f,height*0.5f,0.0f));
osg::Vec3 dx(osg::Vec3(width/((float)numTilesX),0.0,0.0f));
osg::Vec3 dy(osg::Vec3(0.0f,height/((float)numTilesY),0.0f));

// fill in vertices for grid, note numTilesX+1 * numTilesY+1...
osg::Vec3Array* coords = new osg::Vec3Array;
int iy;
for(iy=0;iy<=numTilesY;++iy)
{
for(int ix=0;ix<=numTilesX;++ix)
{
coords->push_back(v000+dx*(float)ix+dy*(float)iy);
}
}

//Just two colours - black and white.
osg::Vec4Array* colors = new osg::Vec4Array;
colors->push_back(osg::Vec4(1.0f,1.0f,1.0f,1.0f)); // white
colors->push_back(osg::Vec4(0.0f,0.0f,0.0f,1.0f)); // black

osg::ref_ptr<osg::DrawElementsUShort> whitePrimitives = new 
osg::DrawElementsUShort(GL_QUADS);
osg::ref_ptr<osg::DrawElementsUShort> blackPrimitives = new 
osg::DrawElementsUShort(GL_QUADS);

int numIndicesPerRow=numTilesX+1;
for(iy=0;iy<numTilesY;++iy)
{
for(int ix=0;ix<numTilesX;++ix)
{
osg::DrawElementsUShort* primitives = ((iy+ix)%2==0) ? whitePrimitives.get() : 
blackPrimitives.get();
primitives->push_back(ix +(iy+1)*numIndicesPerRow);
primitives->push_back(ix +iy*numIndicesPerRow);
primitives->push_back((ix+1)+iy*numIndicesPerRow);
primitives->push_back((ix+1)+(iy+1)*numIndicesPerRow);
}
}

// set up a single normal
osg::Vec3Array* normals = new osg::Vec3Array;
normals->push_back(osg::Vec3(0.0f,0.0f,1.0f));

osg::Geometry* geom = new osg::Geometry;
geom->setVertexArray(coords);

geom->setColorArray(colors, osg::Array::BIND_PER_PRIMITIVE_SET);

geom->setNormalArray(normals, osg::Array::BIND_OVERALL);

geom->addPrimitiveSet(whitePrimitives.get());
geom->addPrimitiveSet(blackPrimitives.get());



Thank you!

Cheers,
mfechter[/code][/quote]

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=61867#61867




Attachments: 
http://forum.openscenegraph.org//files/300x300_491.jpg
http://forum.openscenegraph.org//files/50x50_153.jpg


_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to