for (xIdx = 0; xIdx < 36; xIdx++) // x-direction
{ for (yIdx = 0; yIdx < 18; yIdx++) // y-direction
{ // calculate texture coordinates for current quad
texLeft = float(xIdx) / 35.0f; // left texture coordinate
texBottom = float(yIdx) / 18.0f; // bottom texture
coordinate texRight = float(xIdx+1) / 35.0f; // right texture coordinate
texTop = float(yIdx+1) / 18.0f; // top texture coordinate
When :
0 == xldx : texLeft = 0
35== xldx : texLeft = 1
texRight is texLeft + 1/35 always
0 == yldx :texBottom = 0
17 == yldx: texBottom = 1
textTop is textBottom + 1/18 always
The texture coordinates for many systems are taken in the range of 0 - 1, the guy adjusted the code to achieve that. (Although it range from 0 - 1 1/35 & 0 - 1 1/18 here)
=====================================
Intro to 3D graphics programming articles I - V (1 - 5) :http://www.gamedev.net/reference/art...article795.asp
Matrix & Quaternion Faq : http://skal.planet-d.net/demo/matrixfaq.htm
//Matrix here...
( 2, -2, 1, 3)
( 3, 5, -4, 4)
(-5, 6, 4, 5)
// Each column is a vector, read from top to bottom
This is the column major mode I guess.
Everyone (except GL) I've seen uses the other mode where :
Code:
(x , y , z , w) // Unit Vector of X axis
(x , y , z , w)// Unit vector of Y axis
(x , y , z , w)// Unit vector of Z axis
(x , y , z , w)// Origin of coordinate system
When you mutliply a vector by a matrix, you just modify the vector's coordinates from the ordinary coordinate system to the coordinate system defined by the matrix' axis
Here is a rotation by 90 degree around Y axis matrix (Z increases into the screen, Y increases upwards, X increases to the right : i.e A left hand system)
Code:
( 0 , 0 , 1 , 0) // X axis now points into the screen
( 0 , 1 , 0 , 0) // Y axis unmodified
( -1, 0 , 0 , 0 )// Z axis points to the left (-ve old X)
( 0 , 0 , 0 ,1)// Origin is as is
Translation matrices are obtained by simply using the x,y,z values of the origin as tx,ty,tz (translation)
Paul nettle has made some nice explanation of matrices at : http://www.flipcode.com/cgi-bin/msg....m=askmid&id=-1
He did it in his Ask midnight column on flipcode.com