Results 1 to 4 of 4

Thread: Have an analysis this mapping graph...

  1. #1
    Senior Member Regular Contributor
    Join Date
    Mar 2015
    Posts
    296

    Have an analysis this mapping graph...

    Texture is a 1D strip. Objects in a space RE sphere and cone. use auto gentex api with planar mode, the planes are individually...
    static GLfloat xequal[] = {1.0, 0.0, 0.0, 0.0};
    static GLfloat slanted[] = {1.0, 1.0, 1.0, 0.0};
    static GLfloat zequal[] = {0.0, 0.0, 3.0, 0.0};//x
    static GLfloat yequal[] = {0.0, 2.0, 0.0, 0.0};

    When use zequal plane, we get graphic 1 and 4 for object_plane. change to eye_plane, it shows 3, and the 2 is for slanted plane.
    Let's have an analysis, why get this diferent images from differnt planes? why does it form a cycle of different direction from bar graph?
    texture auto.JPG

  2. #2
    Senior Member Regular Contributor
    Join Date
    Mar 2015
    Posts
    296
    here is mainly code for reference.
    Code :
    void init(void)
    {
       glClearColor (0.0, 0.0, 0.0, 0.0);
       glEnable(GL_DEPTH_TEST); 
       glShadeModel(GL_SMOOTH);
     
       makeStripeImage();	//draw strip texture
       glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
       glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_WRAP_S, GL_REPEAT);
       glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
       glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
     
       glTexImage1D(GL_TEXTURE_1D, 0, 4, stripeImageWidth, 0,
                    GL_RGBA, GL_UNSIGNED_BYTE, stripeImage);
     
     
       glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
       currentCoeff = xequalzero;   
       currentGenMode = GL_OBJECT_LINEAR;
       currentPlane = GL_OBJECT_PLANE; 
       glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, currentGenMode);
       glTexGenfv(GL_S, currentPlane, currentCoeff);
     
       glEnable(GL_TEXTURE_GEN_S);
       glEnable(GL_TEXTURE_1D);
       glEnable(GL_CULL_FACE);
       glEnable(GL_LIGHTING);
       glEnable(GL_LIGHT0);
       glEnable(GL_AUTO_NORMAL);
       glEnable(GL_NORMALIZE);
      // glFrontFace(GL_CW);
      // glCullFace(GL_BACK);
       glMaterialf (GL_FRONT, GL_SHININESS, 64.0);
    }
     
    void display(void)
    {
       glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
       glRasterPos2i(4,-3.5);
       glDrawPixels(stripeImageWidth,32, GL_RGB, GL_UNSIGNED_BYTE, stripeImage);
       //draw chechimage, but apear not.
       glPushMatrix ();
       glutSolidTeapot(2.0);
       glTranslatef(2.0, 2.0, 0.0);
       glColor3f(255, 0, 0);
       glutSolidTeapot(1.0);
     
       glTranslatef(-4, 1.0, 0.0);
       glutSolidSphere(1.5, 22, 22);
       //glutSolidDodecahedron(void); 
       glPopMatrix ();
       glPushMatrix();
      glTranslatef(-2.0f,-4.0f,0.0f);
      glRotatef(-90.0f,1.0f,0.0f,0.0f);
      glutSolidCone(2,3.5,20,20);
      glPopMatrix();
       glFlush();
    }
     
    void reshape(int w, int h)
    {
       glViewport(0, 0, (GLsizei) w, (GLsizei) h);
       glMatrixMode(GL_PROJECTION);
       glLoadIdentity();
       if (w <= h)
          glOrtho (-5, 5, -5*(GLfloat)h/(GLfloat)w, 
                   5*(GLfloat)h/(GLfloat)w, -5, 5); //3.5
       else
          glOrtho (-6.0*(GLfloat)w/(GLfloat)h, 
                   6.0*(GLfloat)w/(GLfloat)h, -6.0, 6.0, -6.0, 6.0);
       glMatrixMode(GL_MODELVIEW);
       glLoadIdentity();
    }

  3. #3
    Senior Member Regular Contributor
    Join Date
    Mar 2015
    Posts
    296
    This seems not too difficult to analysis their mapping picture. cthe first, left top corner, the mapping tex is circles.
    for the plane is chose x=1 plane, the texture drawed by a function is strips, s, t ...[0,1];
    and s=n.(i+w), i=line width, w=span;
    the slice plane of the sphere is parallel the teture plane .thus, has equal distance. the mapping pic on the sphere is shown cirlcle.

  4. #4
    Senior Member Regular Contributor
    Join Date
    Mar 2015
    Posts
    296
    Quote Originally Posted by reader1 View Post
    This seems not too difficult to analysis their mapping picture. cthe first, left top corner, the mapping tex is circles.
    for the plane is chose x=1 plane, the texture drawed by a function is strips, s, t ...[0,1];
    and s=n.(i+w), i=line width, w=span;
    the slice plane of the sphere is parallel the teture plane .thus, has equal distance. the mapping pic on the sphere is shown cirlcle.
    correct, the axes should be z=1 at present, not x=1; if it were x=1, the graph should be lines conform to the texture direction for the first sphere.
    This provides us with a criterion how to choose the reference plane, in order to get a suitable texture.
    and this also solve my question posted two weeks ago.

Similar Threads

  1. OpenGl ES VShader analysis
    By sienaiwun in forum OpenGL: Advanced Coding
    Replies: 0
    Last Post: 09-22-2016, 08:10 PM
  2. VBO perfs analysis
    By adrien in forum OpenGL: Basic Coding
    Replies: 4
    Last Post: 06-23-2005, 05:11 AM
  3. performance analysis without CPU stall?
    By MalcolmB in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 11-23-2004, 01:22 PM
  4. GL performance analysis?
    By markfcsl in forum OpenGL: Advanced Coding
    Replies: 2
    Last Post: 06-02-2003, 06:30 AM
  5. Hardware pixel analysis
    By MojoMagic in forum OpenGL: Advanced Coding
    Replies: 8
    Last Post: 04-18-2003, 11:48 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