PDA

View Full Version : Help me texture this model.....

KenR7A
12-04-2002, 09:35 PM
Ok, here is some code used in generating a quad strip with many sections. How could I texture it? Is there any way to place the texture over every 20 strips instead of eachone? Is it not possible the way I have it drawn? I cant think of any way to do this. Its modeling the bending of a beam with an end load:

do{

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

w=5*((P*x*x)*((3*L)-x))/(6*E*I); //beam deflection equation for end load
theta=atan2(-w,incx); //angle caused by deflection

/**begin translation and rotation**/
GLfloat savx=oldx;
GLfloat savwp=-oldw+(m_height/2);
GLfloat savwn=-oldw-(m_height/2);

//move to origin
savx=savx-oldx;
savwp=savwp+oldw;
savwn=savwn+oldw;

GLfloat xp1= savx*cos(theta)-savwp*sin(theta);
GLfloat yp1= savx*sin(theta)+savwp*cos(theta);
GLfloat xp2= savx*cos(theta)-savwn*sin(theta);
GLfloat yp2= savx*sin(theta)+savwn*cos(theta);

//move back to original coordinates
xp1=xp1+oldx;
yp1=yp1-oldw;
xp2=xp2+oldx;
yp2=yp2-oldw;
/**end translation and rotation**/

if(side==1){

glNormal3d(0.0,0.0,1.0);
glVertex3f(xp1,yp1,m_width/2);
glVertex3f(xp2,yp2,m_width/2);}
if(side==2){
glNormal3d(0.0,0.0,-1.0);
glVertex3f(xp2,yp2,-m_width/2);
glVertex3f(xp1,yp1,-m_width/2);}
if(side==3){
glNormal3d(0.0,1.0,0.0);
glVertex3f(xp1,yp1,-m_width/2);
glVertex3f(xp1,yp1,m_width/2);}
if(side==4){
glNormal3d(0.0,-1.0,0.0);
glVertex3f(xp2,yp2,m_width/2);
glVertex3f(xp2,yp2,-m_width/2);}

GLfloat var1=(incx-oldx);
GLfloat var2=(w-oldw);

GLfloat dx2=var1*var1;
GLfloat dy2=var2*var2;

length=length+(sqrt(dx2+dy2)); //actual length of beam

endx=oldx;
oldx=incx;
endw=oldw;
oldw=w;

}while(length<=L &amp;&amp; length>0); //draw strips until section is L units long
glEnd();

It a do while loop to preserve the actual length of the quad strip as it bends and rotates. I need 500 or more so the strip looks like a curve. Any ideas?

KenR7A
12-05-2002, 07:01 AM
anyone? ignore the code...its just a quad strip with 500 strips over 20 units. how would you texture that so the texture is at least visible?

GameMaker
12-06-2002, 07:39 AM
If I understand correctly, you want to put a texture over the entire mesh. You should look into automatic texture coordinate generation which will automatically map it for you. This should give you what you want. You can find this in the Redbook in the texture mapping section.

I hope that helps.