PDA

View Full Version : Texturing tesselated polygons



MrGiskard
07-08-2004, 01:37 AM
Hello,I've been thinking about this for sometime now and I couldn't find much over the net so I thought to pop in to a forum and see what happens :)

I'm trying to create a room-creating program(building walls,floors and ceilings etc). Problem is, I have to work with concave polygons as the walls must have holes to put the windows and doors in. I can use OpenGL's tesselation functions to create these perforated surfaces but my big problem is, how can you texture such a surface?

If the tesselation process creates new polygons on its own accord(automatically) then how can I know the shape of each one so that I can map texture coordinates to each one? Is there a way to texture the surface as a whole-ie as if it was not tesselated?

If anyone encountered this problem before,I'd really appreciate any help with it.

Thanks

jabe
07-08-2004, 02:49 AM
you can use automatic texturecoord generation. just map the texture linear in object space onto the wall while you are tesselating. to scale the texture properly you can use the texture matrix.

glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR);
glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR);

...

glMatrixMode(GL_TEXTURE);
glLoadScale(1./width, 1./height, 0);

...

jan