void updateModel(OBJModel m, GLModel gm, GLTexture tm) {
//-------- UPDATE VERTICES -----------
gm.beginUpdateVertices(); int j=0; for ( int f =0; f<m.getFaceCount();f++) { PVector[]fverts = m.getFaceVertices(f); for ( int v=0; v<fverts.length; v++) { gm.updateVertex(j++, fverts[v].x, fverts[v].y, fverts[v].z); } } gm.endUpdateVertices();
// ------------ UPDATE NORMALS ----------------
gm.initNormals(); gm.beginUpdateNormals(); int index = 0; for (int s=0; s<m.getSegmentCount(); s++) { Segment segment = m.getSegment(s); Face[]faces = segment.getFaces();
//check if there is a shape (shape is filled with black) if (get(clickX, clickY) == color(0) ) { for (int i = 0; i < numXmax; i++) { for (int j = 0; j < numYmax; j++) {
//points[i][j] contains informations to where to place my shape PVector point = new PVector(points[i][j].pX, points[i][j].pY); PVector mouse = new PVector(clickX, clickY); points[i][j].dist = PVector.dist(point, mouse); if (points[i][j].dist <= 15) { points[i][j].hit = true; println("hit"); // just to check if i hit my shape } } } } }