Hi there, any mesh experts out there?
Im appending vertices to a mesh to extend it, like this:
The red dots are the vertices (most of which are covered by the fill).
This is the relevant code that resulted in that image (where bigMesh is the original large rectangle):
void ofApp::keyPressed(int key){
ofMesh mesh2;
mesh2.addVertex(ofVec3f(bigMesh.getVertices()[9].x+50, bigMesh.getVertices()[9].y,0));
mesh2.addVertex(ofVec3f(bigMesh.getVertices()[19].x+50, bigMesh.getVertices()[19].y,0));
mesh2.addVertex(ofVec3f(bigMesh.getVertices()[29].x+50, bigMesh.getVertices()[29].y,0));
mesh2.setMode(OF_PRIMITIVE_TRIANGLES);
bigMesh.append(mesh2);
bigMesh.addTriangle(9, 19, 100);
bigMesh.addTriangle(19, 100, 101);
}
I have a couple questions about the best way to do it.
-
Do I need to call addTriangle on the mesh for every new vertex I add? Seems like if I dont add a triangle, the white fill will not cover the new vertex.
-
Is there any way to add a column or row of vertices on an arbitrary side? Say, the left side for example; can I add vertices on the left without complicated mesh copying/ for loop vertex appending? I’m going to be using this logic in randomized terrain generation in a large application, so Im looking for the easiest way to do this.
Thanks!