Re: Texture on torus
- From: Wolfgang Draxinger <wdraxinger@xxxxxxxxxxxxxxxx>
- Date: Mon, 24 Sep 2007 22:49:47 +0200
Wojciech Waga wrote:
Hi,
can anyone help me with stretching texture on torus? :)
my code is as follows:
for texture generation:
glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR);
glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR);
glEnable(GL_TEXTURE_GEN_S);
glEnable(GL_TEXTURE_GEN_T);
Why is everybody thinking, OpenGL will do smart texture
coordinate generation for them. Texture coordinate generation
makes only sense, if the geometry of the rendered object can be
sensefully incorporated into texcoord generation, which is in
only few cases, like reflection mapping.
Is it possible?
Consider the torus being a cylinder, that hes been bent into a
circle, so that it ends meet. A cylinder on the other hand is a
rectangle, which has been bent so that two opposing edges meet.
Now a cylinder, that might ring a bell: Cylinder coordinates.
Let be the angle \phi mapped to the U, and the length along the
cylinder as V.
Since this is a bijective mapping each point on the torus has a
unique texture coordinate.
Calculate those coordinates yourself and supply them as texture
coordnate (either by glTexCoord or texture coordinate array).
Wolfgang Draxinger
--
E-Mail address works, Jabber: hexarith@xxxxxxxxxx, ICQ: 134682867
.
- References:
- Texture on torus
- From: Wojciech Waga
- Texture on torus
- Prev by Date: Re: Google map-like bitmap problem.
- Next by Date: Re: Google map-like bitmap problem.
- Previous by thread: Texture on torus
- Index(es):
Relevant Pages
|