Mhh…under my RH7.3 with default lib and Blender2.25 I can see
the correct width, but the draw of Bezier is really slow…
I’m used a Bezier equation and a simple line to draw
it (one bezier line is composed by 20 simple and short line).
I must try the alternative metod of OpenGL evaluator …
I’ve try this, but I don’t know how declare a points buffer:
this code give me an error:
Traceback (most recent call last):
File "Text", line 7, in ?
TypeError: size mismatch in assignment
the line 7 is
Points[:]= [[-3.0, -3.0, 0.0], [-3.0, 1.5, 0.0],
[4.0, -2.0, 0.0], [2.0, 2.0, 0.0]];
from this code
import Blender
from Blender import *
from Blender.BGL import *
Points = Buffer(GL_FLOAT,(3,3,3,3))
Points[:]= [[-3.0, -3.0, 0.0], [-3.0, 1.5, 0.0],
[4.0, -2.0, 0.0], [2.0, 2.0, 0.0]];
glColor3f(1.0, 1.0, 1.0);
glMap1f(GL_MAP1_VERTEX_3, 0.0, 1.0, 3, 4, Points[0][0]);
glEnable(GL_MAP1_VERTEX_3);
glBegin(GL_LINE_STRIP);
for i in range(100):
glEvalCoord1f(i/100.0);
glEnd();
glPointSize(4.0);
glBegin(GL_POINTS);
for j in range(3):
glVertex3fv(Points[j][0]);
glEnd();
this is a poor transalion from this C code:
// white color.
glColor3f(1.0, 1.0, 1.0);
// Move the scene before drawing.
glTranslatef(0.0f, 0.0f, -13.0f);
// This will set up the Bezier curve. glMap1f defines a 1D evaluator.
// The prototype is...
// void glMap1f(GLenum target, float u1, float u2, int stride,
// int order, const float *points).
// target defines the vertex coordinates (ex. x, y, z), the u1 and u2
// define the range for the u parameter. Stride defines the distance
// between each point in the curve. and points is the array of points.
// Check the MSDN for a better explanation if you seek one.
glMap1f(GL_MAP1_VERTEX_3, 0.0, 1.0, 3, 4, &points[0][0]);
// Here we enable the GL_MAP1_VERTEX_3.
glEnable(GL_MAP1_VERTEX_3);
// Now lets draw the curve using line strips. All you need is to
// call glEvalCoord1f() to draw the curve and thats it.
glBegin(GL_LINE_STRIP);
for(int i = 0; i < 100; i++)
{
// Here you we are drawing 100 points along the curve to
// make the line. To do so you send in glEvalCoord1f
// and send to it i divided by 100.0f (don't forget to cast).
glEvalCoord1f((float)i/100.0f);
}
glEnd();
// And that is it. Here I will draw the points big so the user (you) can
// see them and where they are.
// glPointSize() will increase the size of a point (which is the size of a pixel)
// to whether size you would like. This is done here so you can see the points.
glPointSize(4.0);
glBegin(GL_POINTS);
for(int j = 0; j < 4; j++)
{
// Instead of using glVertex3f (which takes in three values) we use
// glVertex3fv which takes three dimensional arrays.
glVertex3fv(&points[j][0]);
}
glEnd();
Where is the error?
thx,
Manuel