I want to create a grid on the floor using the following function. For
test reasons I also create an SoSphere object inside this function.
My idea for the grid is a square with the drawstyle set to LINES. The
square is generated as SoFaceSet.
My problem is: I can see both sphere and square, but FILLED and the
material color is also ignored.
SoSeparator* tOIRobotViewerXML::createGrid()
{
SoSeparator *result = new SoSeparator;
SoCoordinate3 *vertices = new SoCoordinate3();
SbVec3f points[8];
points[0] = SbVec3f(-4000, 0, -4000);
points[1] = SbVec3f(4000, 0, -4000);
points[2] = SbVec3f(4000, 0, 4000);
points[3] = SbVec3f(-4000, 0, 4000);
points[4] = SbVec3f(-4000, 0, -4000);
points[5] = SbVec3f(-8000, 0, -4000);
points[6] = SbVec3f(-8000, 0, -8000);
points[7] = SbVec3f(-4000, 0, -8000);
vertices->point.setValues(0, 8, points);
SoFaceSet *fs = new SoFaceSet();
int32_t values[] = {4,4};
fs->numVertices.setValues(0, 2, values);
SoSphere* sphere = new SoSphere();
sphere->radius = 1000;
SoDrawStyle *drawStyle = new SoDrawStyle();
drawStyle->style = SoDrawStyle::LINES;
drawStyle->lineWidth = 1;
drawStyle->linePattern = 0xaa;
SoMaterial *material = new SoMaterial();
material->ambientColor.setValue(.33,.22,.27);
material->diffuseColor.setValue(.88,.57,.11);
material->specularColor.setValue(.99,.94,.81);
material->****niness =.28;
result->addChild(vertices);
result->addChild(fs);
result->addChild(sphere);
result->addChild(drawStyle);
result->addChild(material);
return result;
}


|