@Ignis wrote:
I'm having some issues trying to add indexes to my coons patch. I have all the calculations down for the mesh vertices. Drawing all of the individual points results in pretty much what I want. However, as soon as I try to draw my wireframe with indexes I get a bunch of lines that I don't want. I'm unsure as to what is the proper way to add indexes to a surface.
Currently, I'm drawing a coons patch from 4 CatmullRom curves. The code looks a bit like this:
ofPoint p1, p2, p3, p4; p1.x = 0; p1.y = 0; p1.z = 0; p2.x = 0; p2.y = 0; p2.z = size; p3.x = size; p3.y = 0; p3.z = size; p4.x = size; p4.y = 0; p4.z = 0; s1 = new CatmullRom(p1, p2, 2); s2 = new CatmullRom(p2, p3, 2); s3 = new CatmullRom(p4, p3, 2); s4 = new CatmullRom(p1, p4, 2); for(double i = 0; i <= size; i++){ for(double j = 0; j <= size; j++){ double s = i / (double)size; double t = j / (double)size; points.push_back(((1 - t) * s4->getPointX(i) + t * s2->getPointX(i)) + ((1 - s) * s1->getPointZ(j) + s * s3->getPointZ(j)) - ((1 - s) * (1 - t) * p1 + (1 - s) * t * p2 + s * (1 - t) * p4 + s * t * p3)); } } for(int i = 0; i < size * size; i++){ mesh.addVertex(points[i]); }
mesh.drawVertices:
mesh.drawWireframe, still good:
Now with the indexes calculations:
for (int y = 0; y<height; y++){ for (int x=0; x<width; x++){ mesh.addIndex(x+y*width); mesh.addIndex((x+1)+y*width); mesh.addIndex(x+(y+1)*width); mesh.addIndex((x+1)+y*width); mesh.addIndex((x+1)+(y+1)*width); mesh.addIndex(x+(y+1)*width); } }
Result:
My suspicion is that I'm adding too many indexes. So like, if I have point A from curve 1 connected to point B of curve 2 and the topmost point of the curve is C what's happening is something like the indexes are connecting A to B and C and also C to A. That last connection is not something I want. Again, that's my impression, I'm not sure that's the actual issue.Any ideas?
Posts: 1
Participants: 1