Hi. First of all i have to say that i’m new to OpenGL programming and to this forums.
I’m trying to render lines in OpenGL. These lines connect related elements in different graph representations. The lines are curved, because there can be one or more elements in a specific graph, linked to one element in the other graph. So the lines first connect to a bundling point, then the lines connect to the related element.
So i have the start-, bundling- and end-point of the curve in a floatBuffer.
Then i’m using
glMap1f(GL.GL_MAP1_VERTEX_3, 0.0f, 1.0f, 3, 3, points)
and draw the line within the following loop
gl.glBegin(GL.GL_LINE_STRIP);
for (int i = 0; i <= 10; i++) {
gl.glEvalCoord1f((float) i / 10);
}
gl.glEnd();
So the line is drawn and curved. It works. But the problem is, when i increment the line-width, V-shaped gaps are appearing between the stippled lines. In my case, i really need this lines perfect at any width.
I used the search for a while and i did find someone with the exact same problem, but unfortunatly there was no sufficient solution. The tipp was, to fit in points in the V-shaped gaps. But as i mentioned, i need the lines to be perfect.
So my approached now would be to
a) setting up polygons instead of lines. This would mean, getting the points that would be connected with lines and calculate a normal vector. Add and subtract half of the width in the direction of the normal vector to get 4 instead of 2 points. Create a polygon with this 4 points. From the second stipple-piece on i would need to use GL_QUAD_STIPPLE i think. I would use the same approach as just mentioned, but the two end-points of the prevoius polygon would add up. So i would have 6 points. The 2 of the previous and then my 4 calculated.
b) creating a surface that looks like a line. Is this possible in OpenGL and would this be a good approach? The idea is the following. Given the 3 points (start, bundling and end) i first create a straigth between the start and the end and calculate the normal vector of this straight. Now i calculate 6 points by - like above - add and subtract (width/2) in the direction of the normal vector form the 3 points. Then i would try to create a surface using the 6 points which looks like a line but would no have the gaps. Does anybody know if this is possible?
What approach would you guys take? As i mentioned, OpenGL is new to me so a hint from you guys would be really helpful. Or maybe you have another idea? I also would appreciate some references with this problem. Used search on ACM, CiteSeer and also the library of my university but i didn’t find any papers on this problem. But i guess the solution of this (rather simple) problem could be far in the past, which could be the reason for not finding anything.