PDA

View Full Version : Automatic Texture Generation --> Need Help...



Erakis
04-06-2001, 11:25 AM
Hello.

I have two basic questions about the Automatic texture generation.

sPlane :Array[1..4] Of TGLFloat = ( 1.0, 0.0, 0.0, 0.0 );
tPlane :Array[1..4] Of TGLFloat = ( 0.0, 1.0, 0.0, 0.0 );

{Set the way of the texture is appplicated on pixels}
glPixelStorei( GL_UNPACK_ALIGNMENT, 1 );
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
glTexGeni( GL_S, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR );
glTexGeni( GL_T, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR );

{Set the plane of what ???
And how it can effect the texture application ?}
glTexGenfv( GL_S, GL_OBJECT_PLANE, @sPlane );
glTexGenfv( GL_T, GL_OBJECT_PLANE, @tPlane );

{Activate the Automatic texture generation}
glEnable( GL_TEXTURE_GEN_S );
glEnable( GL_TEXTURE_GEN_T );



First, I need help to understand how work the planes coord....

Secondly, when I use the Automatic texture generation I got two principal problems :

The texture is applicated but with a too very small scale.
With a Sphere, I obtain some badly textured one some meridians lines.
With a cube, I obtain the left and right face side badly textured, But I've notice that when I change the planes array,
I obtain differents texture application on the right and left side, maybe it's the solution to my problem but how can I correct this ???

About the scale problem, the only way that I've found is to rescale the Texture Matrix.
But It's is normal or something wrong ?


A BIG Thank to help me fastest possible....
Martin

eraquila@bigfoot.com

PS :Excuse my poor english...

Deiussum
04-07-2001, 02:35 PM
From the OpenGL specification...



If TEXTURE_GEN_MODE indicates OBJECT_LINEAR then the generation function for the coordinate indicated by coord is

g = p1x0 + p2y0 + p3z0 + p4w0

x0, y0, z0, and w0 are the object coordinates of the vertex. p1,..., p4 are specified by calling TexGen with pname set to OBJECT_PLANE in which case params points to an array containing p1, ..., p4.

RandyU
04-08-2001, 11:21 AM
It's best to use SPHERE_MAP for sphere.
For cube you can change plane's equation(AFAIK first three numbers are normal to face).
Another way is doing side faces of cube by rotating it's front face.
AutoTexGen can slowdown a little, so use it only when needed.