PDA

View Full Version : SoQuadMesh + color node interpolation



crabsody
01-23-2007, 11:55 AM
I have a collection of points (nodes) that define a 2d quad mesh. The third dimension is a scalar function. From this 3rd value of every node I define a color. So I want to draw a 2d mesh with different colors in the area. Has anyone any knowlegde in coin3d or open inventor and help me with this?

My Code:

SbVec3f *verts;
SbColor *colors;

SoSeparator *signalMesh = new SoSeparator;

for(i=0;i<totalvertices;i++){
pointV = pointList->at(i);

x = pointV->getPoint()[0];
y = pointV->getPoint()[1];
signalLevel = pointV->getSignalLevel();

verts[i].setValue(x, y, z);

nSignalLevel = normSigLevel(signalLevel,rangeMin,rangeMax);
//Get the RGB color for this signal level
h2RGB(nSignalLevel,&cr,&cg,&cb);

colors[i].setValue(cr, cg, cb);
}


// Define material for signalMesh
SoMaterial *myMaterial = new SoMaterial;
myMaterial->diffuseColor.setValues(0,pointList->count(), colors);
signalMesh->addChild(myMaterial);

// Define coordinates for vertices
SoCoordinate3 *myCoords = new SoCoordinate3;
myCoords->point.setValues(0, pointList->count(), verts);
signalMesh->addChild(myCoords);


SoQuadMesh * mesh = new SoQuadMesh;
mesh->verticesPerRow = xpoints;
mesh->verticesPerColumn = ypoints;
signalMesh->addChild(mesh);