KenR7A

11-29-2002, 09:57 PM

Hi, Im in the middle of writing my first opengl project. Its attempting to simulate a cantilever square beam bending under an end load. Im using VS.NET

Im trying to draw a quad strip down the length of each side of the beam to generate the sides. I also have to take into consideration the fact that the beam is bending so each strip must be rotated a little as theyre being drawn. Here is a bit of code from my project:

glPushMatrix();

glBegin(GL_QUAD_STRIP);

do{

x=L*(i/500);

i=i+1;

incx=(x+(L/500));

w=5*((P*x*x)*((3*L)-x))/(6*E*I);

theta=atan2(w,incx)*(180/PI);

glTranslatef(incx,-w,0.0);

glRotatef(-theta,0.0,0.0,1.0);

glTranslatef(-incx,w,0.0);

glColor4f(0.0,1.0,0,1.0);

glVertex3f(incx,-w+1,0.0);

glVertex3f(incx,-w-1,0.0);

GLfloat var1=(incx-oldx);

GLfloat var2=(w-oldw);

GLfloat dx2=var1*var1;

GLfloat dy2=var2*var2;

length=length+(sqrt(dx2+dy2)); //length of curve

oldx=incx;

oldw=w;

}while(length<=L && length>0);

glEnd();

glPopMatrix;

Im basically starting a Quad strip and then generating 2 verticies until the length is determined. But it seems as though my translate and rotate lines arent doing anything.

Ive tested this little loop using polygons and they rotate fine. The main problem is translating and rotating the next set of points to be used in a quad/line strip. is that possible? or do you have to wait until the whole strip is done?

[This message has been edited by KenR7A (edited 11-29-2002).]

Im trying to draw a quad strip down the length of each side of the beam to generate the sides. I also have to take into consideration the fact that the beam is bending so each strip must be rotated a little as theyre being drawn. Here is a bit of code from my project:

glPushMatrix();

glBegin(GL_QUAD_STRIP);

do{

x=L*(i/500);

i=i+1;

incx=(x+(L/500));

w=5*((P*x*x)*((3*L)-x))/(6*E*I);

theta=atan2(w,incx)*(180/PI);

glTranslatef(incx,-w,0.0);

glRotatef(-theta,0.0,0.0,1.0);

glTranslatef(-incx,w,0.0);

glColor4f(0.0,1.0,0,1.0);

glVertex3f(incx,-w+1,0.0);

glVertex3f(incx,-w-1,0.0);

GLfloat var1=(incx-oldx);

GLfloat var2=(w-oldw);

GLfloat dx2=var1*var1;

GLfloat dy2=var2*var2;

length=length+(sqrt(dx2+dy2)); //length of curve

oldx=incx;

oldw=w;

}while(length<=L && length>0);

glEnd();

glPopMatrix;

Im basically starting a Quad strip and then generating 2 verticies until the length is determined. But it seems as though my translate and rotate lines arent doing anything.

Ive tested this little loop using polygons and they rotate fine. The main problem is translating and rotating the next set of points to be used in a quad/line strip. is that possible? or do you have to wait until the whole strip is done?

[This message has been edited by KenR7A (edited 11-29-2002).]