PDA

View Full Version : putting tex coords on bezier curves



robert
07-22-2001, 05:42 AM
hi,

I am using line strips to make a bezier curve and was wanting to apply a texture to the curve (3d).

for (j = 0; j <= 8; j++) {
glBegin(GL_LINE_STRIP);
for (i = 0; i <= 30; i++)
glEvalCoord2f((GLfloat)i/30.0, (GLfloat)j/8.0);
glEnd();

glBegin(GL_LINE_STRIP);
for (i = 0; i <= 30; i++)
glEvalCoord2f((GLfloat)j/8.0, (GLfloat)i/30.0);
glEnd();
}

Does anybody know how I would go about this?

Thanks :P

Rob The Bloke
07-23-2001, 02:52 PM
for (j = 0; j <= 8; j++) {
glBegin(GL_LINE_STRIP);
for (i = 0; i <= 30; i++)
{
glTexCoord2f( i/30,j/8);
glEvalCoord2f((GLfloat)i/30.0, (GLfloat)j/8.0);
}
glEnd();

glBegin(GL_LINE_STRIP);
for (i = 0; i <= 30; i++)
{
glTexCoord2f(j/8,i/30);
glEvalCoord2f((GLfloat)j/8.0, (GLfloat)i/30.0);
}
glEnd();
}

You could try to use evaluators to do it, but I wouldn't recommend it - it tends to look horrible. Doing it linearly gives *nice* coverage.

robert
07-23-2001, 04:22 PM
Great, thanks!

I will try it.. in my desperation i was going to use evaluators, but tough better of it http://www.opengl.org/discussion_boards/ubb/smile.gif

robert
07-24-2001, 03:09 AM
arrrg something's not working properly.. trying to figure out now

Rob The Bloke
07-24-2001, 03:52 PM
Mail me with an address I can post to & I'll send you some stuff that may be of use.....

robert
07-25-2001, 08:01 PM
yup, emailed you did you get it?

Rob The Bloke
07-26-2001, 01:55 PM
Tried to mail you some stuff, I hope you get it (I've problems with my e-mail at the moment)

robert
07-26-2001, 10:21 PM
Wow! that's great thanks! Im just trying it out now.. also thanks heaps for the document on bezier curves. :P

Rob The Bloke
07-27-2001, 04:00 AM
No Probs


[This message has been edited by Rob The Bloke (edited 07-27-2001).]

robert
07-28-2001, 01:44 AM
Would you be able to explain your code that init's m_pIndicies?

I think i understand, but I just want to get it sorted in my head :P

Thanks
ps do you have and icq num?

Rob The Bloke
07-28-2001, 06:00 AM
m_pIndicies is an array of vertex array indices that defines a load of triangle strips.

say you have a surface with a lod of three (4*4 vertices produced):

* * * *

* * * *

* * * *

* * * *

it lays out the indicies in the array as follows - these numbers relate to the position within the array itself - not the value.....

* * * *

* * * *

1 3 5 7

0 2 4 6

that will be the first strip. The numbers stored will be the position of the related vertex in the m_pVertexArray. Note - in the Draw() function it draws a bunch of triangle strips. For this surface, there will need to be three strips. The second would then be :

* * * *

9 11 13 15

8 10 12 14

* * * *

It uses triangle strips because they are the fastest openGL primative. Draw basically runs through each strip and passes a pointer to the position in the array, of the first index of the required strip.

Hope thats of help. I know the code is a bit un-readable, It used to make perfect sense, but then it got optimised a bit....