u v + normal calc
can someone explain how the u,v components work
i think it relates to corner coordinates and scale?
glTexCoord2f(u,v);
anyhelp would be usefull
just started playing with textures
+
Any help with how to and when and what vertex and face normals would help.
using tutorial 10 while learning (added light + a more flexible texture routine)
thanks
uv coordinates go from 0 to 1, 0 defining the left/topmost relative edge of the texture and 1 defining the opposite edge. Coordinates < 1 will cause the texture to be clipped while coordinates > 1 will cause it to tile. It doesn''t matter ho large the target surface is: the texture is mapped in its own space and based on its own coordinates.


"Literally, it means that Bob is everything you can think of, but not dead; i.e., Bob is a purple-spotted, yellow-striped bumblebee/dragon/pterodactyl hybrid with a voracious addiction to Twix candy bars, but not dead."- kSquared
clipping / tiling is defined on texture creation.
glTexParameteri(GL_TEXTURE_XD,GL_TEXTURE_WRAP(s/t),GL_CLAMP/GL_REPEAT);
eg to create a repeating 2d texture, when creating the texture put..
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S,GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_T,GL_REPEAT);
or to make one that clamps put...
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S,GL_CLAMP);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_T,GL_CLAMP);
glTexParameteri(GL_TEXTURE_XD,GL_TEXTURE_WRAP(s/t),GL_CLAMP/GL_REPEAT);
eg to create a repeating 2d texture, when creating the texture put..
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S,GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_T,GL_REPEAT);
or to make one that clamps put...
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S,GL_CLAMP);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_T,GL_CLAMP);
blah!!
I just realised when I whipped that up I was thinking in terms of Direct3D.. in D3D textures are either clamped or wrapped.. in GL it''s clamped or repeat... as the code Thorin_nz put shows.
| - Project-X - | - adDeath - | - my windows XP theme - | - email me - |
I just realised when I whipped that up I was thinking in terms of Direct3D.. in D3D textures are either clamped or wrapped.. in GL it''s clamped or repeat... as the code Thorin_nz put shows.
| - Project-X - | - adDeath - | - my windows XP theme - | - email me - |
So (RipTorn)from your example if its set to GL_CLAMP can i just interprate U V as just being X Y on my texture
quote:
Original post by unfinished
So (RipTorn)from your example if its set to GL_CLAMP can i just interprate U V as just being X Y on my texture
Yes, and GL_REPEAT means if you go outside of the 0,0 -> 1,1 area, it will simply repeat the texture (aka, wrap the x,y coord). All that means is .5,.5 is the center of your texture, and 1.5,1.5 would be the exact same point! The benefit of this (in some cases) is that you can repeat a texture over a large object. (Say you wanted your sky to repeat, you can simply go from 0,0 -> 2,2 and it''d draw it 4 times (two wide, two tall). You could go from 0,0->3,3 and it''d draw 3x3, etc. If you clamp it, any value you input over 1 will automagically be set to 1. So 0,0 -> 2,2 would be clamped to 0,0->1,1, and 0,0->3,3 would ALSO be clamped to 0,0->1,1
thanks for your help very useful
found another problem that i was drawing triagnles wrong they reacted differently to light split surfaces. now all drawn the same direction.
is normal routine correct
float vector1x = x_m2 - x_m1; // x plane vector 1
float vector1y = y_m2 - y_m1; // y plane vector 1
float vector1z = z_m2 - y_m1; // z plane vector 1
float vector2x = x_m3 - x_m1; // x plane vector 2
float vector2y = y_m3 - y_m1; // y plane vector 2
float vector2z = z_m3 - z_m1; // z plane vector 2
// calculate magnitude of both vectors
float mag1 = sqrt ((vector1x * vector1x) + (vector1y * vector1y) + (vector1z * vector1z));
float mag2 = sqrt ((vector2x * vector2x) + (vector2y * vector2y) + (vector2z * vector2z));
// normalize both vectors
vector1x = (vector1x / mag1);
vector1y = (vector1y / mag1);
vector1z = (vector1z / mag1);
vector2x = (vector1x / mag2);
vector2y = (vector1y / mag2);
vector2z = (vector1z / mag2);
// makeCrossProduct
nx_m = (vector1y * vector2z) - (vector1z * vector2y);
ny_m = (vector1z * vector2x) - (vector1x * vector2z);
nz_m = (vector1x * vector2y) - (vector1y * vector2x);
i did it longhand at the moment to make it easy to read
wanted to get it working first
found another problem that i was drawing triagnles wrong they reacted differently to light split surfaces. now all drawn the same direction.
is normal routine correct
float vector1x = x_m2 - x_m1; // x plane vector 1
float vector1y = y_m2 - y_m1; // y plane vector 1
float vector1z = z_m2 - y_m1; // z plane vector 1
float vector2x = x_m3 - x_m1; // x plane vector 2
float vector2y = y_m3 - y_m1; // y plane vector 2
float vector2z = z_m3 - z_m1; // z plane vector 2
// calculate magnitude of both vectors
float mag1 = sqrt ((vector1x * vector1x) + (vector1y * vector1y) + (vector1z * vector1z));
float mag2 = sqrt ((vector2x * vector2x) + (vector2y * vector2y) + (vector2z * vector2z));
// normalize both vectors
vector1x = (vector1x / mag1);
vector1y = (vector1y / mag1);
vector1z = (vector1z / mag1);
vector2x = (vector1x / mag2);
vector2y = (vector1y / mag2);
vector2z = (vector1z / mag2);
// makeCrossProduct
nx_m = (vector1y * vector2z) - (vector1z * vector2y);
ny_m = (vector1z * vector2x) - (vector1x * vector2z);
nz_m = (vector1x * vector2y) - (vector1y * vector2x);
i did it longhand at the moment to make it easy to read
wanted to get it working first
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement