PDA

View Full Version : Have an analysis this mapping graph...



reader1
06-16-2015, 06:10 AM
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?
1875

reader1
06-16-2015, 06:39 AM
here is mainly code for reference.


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();
}

reader1
06-18-2015, 07:15 AM
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.

reader1
06-18-2015, 05:24 PM
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.