
Wed, 10/29/2008 - 01:40
Forums:
Hi, all,
As we know, in OpenGL we can visualize the triangle by assigning different RGB color value to each vertex. e.g.:
glBegin(TRIANGLES);
glColor3f(1.0, 0.0, 0.0); glVertex3f(4.0, 4.0. 4.0);
glColor3f(0.0, 1.0, 0.0); glVertex3f(4.0, 5.0. 6.0);
glColor3f(0.0, 0.0, 1.0); glVertex3f(3.0, 4.0. 5.0);
glEnd();
So is there anybody knowing how to carry out in OCC. Thank you very much.
Wed, 10/29/2008 - 20:51
Hello Jun,
you could either use the MeshVS framework (haven't try it yet) or you need do sub-class AIS_InteractiveObject and build your own mesh class.
In the Compute method of your new AIS object, you should find something like this:
// build an array of triangle with color and normal at each vertex
Handle_Graphic3d_ArrayOfTriangles aTrianglesArray=new Graphic3d_ArrayOfTriangles(myMesh->NbTriangles()*3,0,Standard_True,Standard_True);
// for each triangle, add the 3 vertex/color/normal
foreach (triangle...) {
aTrianglesArray->AddVertex(vertex1, normal1,color1);
aTrianglesArray->AddVertex(vertex2, normal2,color2);
aTrianglesArray->AddVertex(vertex3, normal3,color3);
}
// draw the triangle as a shaded surface
Handle_Graphic3d_Group aGroup=Prs3d_Root::CurrentGroup(aPrs3d); // aPrs3d is the 3d presentation supplied by the Compute method
aGroup->SetPrimitivesAspect(myDrawer->ShadingAspect()->Aspect());
aGroup->BeginPrimitives();
aGroup->AddPrimitiveArray(aTrianglesArray);
aGroup->EndPrimitives();
So here is one way to do it, I know you could used the Triangle Array in different ways, have a look at the cdl files (Graphic3d_ArrayOfTriangles.cdl) for more details.
Good luck,
Francois.
Thu, 10/30/2008 - 20:01
Thank you so much for your answer.