// load a VRML file if (mesh->openVRMLFile("vrml\\demo.wrl")!=OK) { MessageBox(NULL, "Unable to open file demo.wrl", "Error", MB_OK); return 0; } // set render mode renderer->setRenderMode(SOLID); // set label renderer->displayText("Playing Demo: Pick a face with the left mouse click (it's color will change)"); // pick a face FaceID pickedFace1, pickedFace2; renderer->pickFace(pickedFace1); Color pickedFaceColor1(1.0, 0.0, 1.0); renderer->setFaceColor(pickedFace1, &pickedFaceColor1); // set label renderer->displayText("Playing Demo: Pick a second face (it's color will change)"); // pick a second face renderer->pickFace(pickedFace2); Color pickedFaceColor2(1.0, 1.0, 0.0); renderer->setFaceColor(pickedFace2, &pickedFaceColor2); // set label renderer->displayText("Playing Demo: Highlighting the joined edge between the picked faces"); Sleep(1000); EdgeID edgeID1, edgeID2; RESULT result = mesh->getJoinedFacesEdge(pickedFace1, pickedFace2, edgeID1, edgeID2); if (result==OK) renderer->highlightEdge(edgeID1, true); Sleep(1000); // set label renderer->displayText("Playing Demo: Highlights and colors"); Sleep(2000); // change background color Color bgColor(0.8, 0.2, 0.7); renderer->setBgColor(bgColor); Sleep(1000); renderer->highlightVertex(8,true); renderer->highlightEdge(6,true); Color edgeColor(0.5, 0.2, 0.7); renderer->setEdgeColor(6,&edgeColor); // set color Sleep(1000); renderer->setEdgeColor(6); // set default color Sleep(1000); renderer->highlightEdge(6,false); renderer->highlightVertex(8,false); Sleep(1000); renderer->setAutoRefresh(false); // rotate (and translate) model for (int i=0; i<10; i++) { renderer->rotate(AXIS_X, -1); renderer->rotate(AXIS_Y, -1); renderer->translate(1, 0, 0); renderer->refreshScreen(); } renderer->setAutoRefresh(); renderer->displayText("Playing Demo: Removing highlighted vertex and triangulating the hole"); renderer->highlightVertex(12,true); Sleep(1000); LinkedList<Face>* faces = new LinkedList<Face>(); // a list of the new faces to be created VertexID faceVertices[] = {0, 1, 3}; Face face(faceVertices); faces->push_back(face); faceVertices[0] = 3; faceVertices[1] = 1; faceVertices[2] = 2; face.set(faceVertices); faces->push_back(face); LinkedList<FaceID> *newFaces = new LinkedList<FaceID>(); // remove the vertex with ID number 12 mesh->removeVertexTriangulate(12, faces, newFaces); // 2 faces were added, we read their ID's and color them FaceID newFace = newFaces->front(); Color color(1.0, 1.0, 0.0); renderer->setFaceColor(newFace, &color); newFace = newFaces->back(); color[R]=0.0; renderer->setFaceColor(newFace, &color); Sleep(2000); // rotate again for (i=0; i<40; i++) { renderer->rotate(AXIS_Y, 3); } renderer->displayText("Playing Demo: Splitting highlighted vertex"); renderer->highlightVertex(8,true); Sleep(2000); // splitting the vertex, moving it from {-0.6 1 -1} to {-0.8 1.1 -1.4} newFaces->clear(); Coord coord(-0.8, 1.1, -1.4); // coordinate of the new vertex VertexID newVertex; mesh->vertexSplit(8, coord, 3, 4, newVertex, newFaces); // color the new triangles renderer->colorFaces(newFaces); Sleep(2000); // rotate again for (i=0; i<30; i++) { renderer->rotate(AXIS_Y, 3); } renderer->displayText("Playing Demo: Edge Collapse between the highlighted vertices"); // highlighting the 2 vertices renderer->highlightVertex(13,true); renderer->highlightVertex(6,true); Sleep(2000); // this is just for demo purposes - move edge 6 closer and closer to 13 Coord coord13; Coord coord6; mesh->getCoord(13, coord13); for (i=0; i<20; i++ ) { mesh->getCoord(6, coord6); for (int i=0; i<3; i++) { coord6[i] = coord6[i]*0.9 + coord13[i]*0.1; } mesh->setCoord(6, coord6); } mesh->edgeCollapse(6, 13); // the actual edge collapse operation // this code has the same result as calling edgeCollapse(6, 13, 20) renderer->displayText();