03-06-2002, 06:37 AM

I've implemented Bezier-Splines into my engine, and they work fine,

but in order to get the lighting done, I need to place the correct Vectors on

every triangle. My code is something like this:

void DrawGLScene()

{

glBegin(GL_LINE_LOOP);

while (m < 1)

{

glVertex( CalcVertex(x, m), CalcVertex(y, m), CalcVertex(z, m) );

m = m + 0.1f;

}

glEnd();

}

CalcVertex know everything about the Bezier, meaning the two points, and the two vectors. Can I get a function the would return all three points? Because I feel that I'm kinda cheating; this isn't exactly vector-math, I just worked around it!

(In POV-Ray it was easy: just something like <1, 2, 5> * 5 would equal <5, 10, 25> ).

For an extruded spline I do the same as above, I only add the line

glVertex3d (CalcVertex(x,m),CalcVertex(y,m),CalcVertex(z,m)-2);

after the first glVertex3d(...), and use a GL_TRIANGLE_STRIP, rather than GL_LINE_LOOP. That way, I get a proper Spline-Surface.

But if I want lighting in my engine, I have to have Vectors on every triangle. Does anyone know how to calculate them?

but in order to get the lighting done, I need to place the correct Vectors on

every triangle. My code is something like this:

void DrawGLScene()

{

glBegin(GL_LINE_LOOP);

while (m < 1)

{

glVertex( CalcVertex(x, m), CalcVertex(y, m), CalcVertex(z, m) );

m = m + 0.1f;

}

glEnd();

}

CalcVertex know everything about the Bezier, meaning the two points, and the two vectors. Can I get a function the would return all three points? Because I feel that I'm kinda cheating; this isn't exactly vector-math, I just worked around it!

(In POV-Ray it was easy: just something like <1, 2, 5> * 5 would equal <5, 10, 25> ).

For an extruded spline I do the same as above, I only add the line

glVertex3d (CalcVertex(x,m),CalcVertex(y,m),CalcVertex(z,m)-2);

after the first glVertex3d(...), and use a GL_TRIANGLE_STRIP, rather than GL_LINE_LOOP. That way, I get a proper Spline-Surface.

But if I want lighting in my engine, I have to have Vectors on every triangle. Does anyone know how to calculate them?