Results 1 to 3 of 3

Thread: Help me texture this model.....

  1. #1
    Junior Member Newbie
    Join Date
    Nov 2002
    Posts
    20

    Help me texture this model.....

    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:
    Code :
    glBegin(GL_QUAD_STRIP);
    	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;
     
    		//rotate about z axis
    		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?

  2. #2
    Junior Member Newbie
    Join Date
    Nov 2002
    Posts
    20

    Re: Help me texture this model.....

    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?

  3. #3
    Member Contributor
    Join Date
    Apr 2002
    Posts
    94

    Re: Help me texture this model.....

    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.
    P4 2Ghz, GEFORCE4, 512 Meg RAM, WIN2000, VStudio 6.0

Similar Threads

  1. Texture behind 3d model
    By valkaaa in forum OpenGL: Basic Coding
    Replies: 0
    Last Post: 09-17-2016, 04:50 AM
  2. Render a model with a texture to a framebuffer/texture
    By Biaspoint in forum OpenGL: Basic Coding
    Replies: 0
    Last Post: 10-04-2015, 10:34 AM
  3. How set texture on 3D model use this
    By ljubomir993 in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 12-15-2014, 07:58 AM
  4. Loading 3ds model with texture
    By Sn00p in forum OpenGL: Basic Coding
    Replies: 0
    Last Post: 02-18-2010, 09:09 PM
  5. Replies: 1
    Last Post: 11-30-2005, 03:12 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean