Hi, can someone help me out on this? I’m trying to draw a simple curve using glMap1f.
In my init() method I set up an array of 30 floats to represent 10 control points and call these commands :
gl.glEnable(GL.GL_MAP1_VERTEX_3);
gl.glMap1f(GL.GL_MAP1_VERTEX_3, 0f, 1f, 3, 10, FloatBuffer.wrap(pointsArray));
in my display() method I call:
gl.glBegin(GL.GL_LINE_STRIP);
for (int i=0; i<=100; i++)
{
gl.glEvalCoord1f((float)((float)i/100f));
}
gl.glEnd();
But nothing gets drawn. I also have tried an alternative method:
gl.glMapGrid1f(100, 0.0f, 1.0f);
gl.glEvalMesh1(GL.GL_LINES, 0, 100);
But it doesn’t work either.
I can however render my control points as follows:
gl.glPointSize(3);
gl.glBegin(GL.GL_POINTS);
for(int i=0;i<pointsArray.length;i+=3)
{
gl.glVertex3f(pointsArray[i], pointsArray[i+1], pointsArray[i+2]);
}
gl.glEnd();
Any ideas? I took this code right from a C code example I found on line. The only difference as far as I can tell is that JOGL uses a FloatBuffer instead of a multidimensional array for glMap1f
Thanks in advance!
-sprialjetty
1hr later…
I think I may have figured out where I went wrong. I was thinking that he glMap1f was a low level replacement for the NURBS methods. Instead, it’s like a piece of a NURBS. I was trying to use too many control points on a single Bezier curve. Once I used 8 or less control points it draws fine. Of course, I need to figure out how to stich them together.
If anyone is interested I have created a simple implementation of NURBS (curves, not surfaces yet) using the Cox-DeBoor algorithm. It works okay, but it is slow when I have too many knots/control points (over 100 or so), which is why I was investigating glMap1f and EvalCoord1f ni the first place.
Has anyone had luck with the JGeom package?
-sj