View Full Version : Some newbie texture mapping questions
04-12-2003, 12:05 PM
I have written some terrain code (will hopefully become an open source railroad simulator) and now want to add some skin to it.
I used triangle strips to render the height maps but from what I've read you have to use four points when specifying texture co-ordinates.
What will OpenGL do when I map a bit of texture over two triangles in a rectangular shape? Will it automatically bend the texture if the vertices are not in the same plane?
Also why do I have to render triangles (or quads for that matter) when I'm already defining a texture in 3D? Does OpenGL actually use the primitives underneath or does it just need the vertices which happen to be defined by the primitive shapes?
04-12-2003, 12:13 PM
your question is a 'lil hard to understand but i'll do my best.So let's begin.First there is no difference between texturing triangles,triangle strips/fans or quads.You just have to provide right texture coordinates.
04-12-2003, 08:41 PM
Have you tried lighting your scene yet? You'll have to define normals for each vertex on your terrain. To do this, average the normals for the 8 surrounding triangles. Find the normal for each of these triangles by using the cross product formula. Make sure your normals are normalised!
For textures, if you have a single texture you would like to place over your terrain, just scale the texture coordinates to the appropriate value. Let's say your terrain was square and it went from 0 to 1 (in the x and z axes), and there were 64x64 vertices. Then the texture coordinate for the (i,j) vertex would be:
glTexCoord2f(i/63, j/63); // i,j goes from 0 to 63
04-13-2003, 03:41 AM
Ok let me put one of my questions this way :
If you have a wall built from a quad in an OpenGL scene and you texture it do you still need to define the wall?
Why can't I just "hang up" the paint using co-ords and forget about the wall because you can't see it anyway.
Is there any point in OpenGL rendering primitives underneath a texture that will never be seen?
Hope that makes more sense.
04-14-2003, 03:49 AM
Hey you can´t just forget the wall , remember OpenGL is still a rasterizer ,you need to send the vertex coordinates of a polygon and the texture coordinates so then it will transform in screen coordinates http://www.opengl.org/discussion_boards/ubb/smile.gif
The texture is just a decal ( which may be modulated with other colors , textures and stuff...or not) what you´re really rendering is the geometry ..
hope this make any sense http://www.opengl.org/discussion_boards/ubb/smile.gif
[This message has been edited by raverbach (edited 04-14-2003).]
04-14-2003, 09:53 AM
Thanks, that makes more sense to me now.
Powered by vBulletin® Version 4.2.2 Copyright © 2016 vBulletin Solutions, Inc. All rights reserved.