ok, here ya go =):
Please excuse the mess and the use of unecassary variables… once i have it working i will tidy it up
and make it a bit nicer
float Normal[] = {0,1,0,
0,1,0,
0,1,0,
0,1,0,
0,1,0,
0,1,0};
float Vertex[] = { -20,0,20,
20,0,20,
-20,0,-20,
20,0,20,
20,0,-20,
-20,0,-20};
float Binormal[] = {0,0,-1,
0,0,-1,
0,0,-1,
0,0,-1,
0,0,-1,
0,0,-1};
float Tangent[] = { 1,0,0,
1,0,0,
1,0,0,
1,0,0,
1,0,0,
1,0,0};
those are the quad values, like i said before they are two triangles
This is the code to get the light and eye vector and mult them into Object space:
light = (lightPosition.x, lightPosition.y, lightPosition.z);
eye = (TheCam.pos.x,TheCam.pos.y,TheCam.pos.z);
// convert light to object space by multiplying by inverse modelview matrix
li[0]=(light[0]*temp[0])+(light[1]*temp[4])+(light[2]*temp[8]);
li[1]=(light[0]*temp[1])+(light[1]*temp[5])+(light[2]*temp[9]);
li[2]=(light[0]*temp[2])+(light[1]*temp[6])+(light[2]*temp[10]);
// convert eye to object space by multiplying by inverse modelview matrix
e[0]=(eye[0]*temp[0])+(eye[1]*temp[4])+(eye[2]*temp[8]);
e[1]=(eye[0]*temp[1])+(eye[1]*temp[5])+(eye[2]*temp[9]);
e[2]=(eye[0]*temp[2])+(eye[1]*temp[6])+(eye[2]*temp[10]);
This is the start of the loop to draw the poly’s
glBegin(GL_TRIANGLES);
for (int blah = 0; blah < 6; blah++)
{
// Get light vector from vertex and normalize
l[0]=(li[0] - Vertex[(blah * 3)+ 0]);
l[1]=(li[1] - Vertex[(blah * 3)+ 1]);
l[2]=(li[2] - Vertex[(blah * 3)+ 2]);
eye[0]=(e[0] - Vertex[(blah * 3)+ 0]);
eye[1]=(e[1] - Vertex[(blah * 3)+ 1]);
eye[2]=(e[2] - Vertex[(blah * 3)+ 2]);
eyeT = l + eye; // h vector
ma[0] = Tangent[(blah * 3)+ 0];
ma[1] = Binormal[(blah * 3)+ 0];
ma[2] = Normal[(blah * 3)+ 0];
ma[3] = Tangent[(blah * 3)+ 1];
ma[4] = Binormal[(blah * 3)+ 1];
ma[5] = Normal[(blah * 3)+ 1];
ma[6] = Tangent[(blah * 3)+ 2];
ma[7] = Binormal[(blah * 3)+ 2];
ma[8] = Normal[(blah * 3)+ 2];
//light x component times tangent x comp plus light y comp times tangent y comp....
lightT[0]=(l[0]*ma[0])+(l[1]*ma[3])+(l[2]*ma[6]);
// light x comp times binormal x comp plus light y comp times binormal y comp...
lightT[1]=(l[0]*ma[1])+(l[1]*ma[4])+(l[2]*ma[7]);
// light x comp times normal x comp plus light y comp times normal y comp...
lightT[2]=(l[0]*ma[2])+(l[1]*ma[5])+(l[2]*ma[8]);
lightT.normalize();
//light x component times tangent x comp plus light y comp times tangent y comp....
h[0]=(eyeT[0]*ma[0])+(eye[1]*ma[3])+(eye[2]*ma[6]);
// light x comp times binormal x comp plus light y comp times binormal y comp...
h[1]=(eyeT[0]*ma[1])+(eye[1]*ma[4])+(eye[2]*ma[7]);
// light x comp times normal x comp plus light y comp times normal y comp...
h[2]=(eyeT[0]*ma[2])+(eye[1]*ma[5])+(eye[2]*ma[8]);
h.normalize();
h *= .5f;
h += .5f;
lightT *= .5;
lightT += .5;
glMultiTexCoord2fARB(GL_TEXTURE0_ARB, s , t );
glMultiTexCoord2fARB(GL_TEXTURE1_ARB, s , t );
glColor3fv(&lightT[0]); // put the light vector into the primary color
glSecondaryColor3fvEXT(&h[0]); // put the h vector into the secondary color
// glNormal3f(Normal[(blah * 3)+ 0],Normal[(blah * 3)+ 1],Normal[(blah * 3)+ 2]);
glVertex3f(Vertex[(blah * 3)+ 0],Vertex[(blah * 3)+ 1],Vertex[(blah * 3)+ 2]);
}
glEnd();
Done!
[This message has been edited by robert (edited 03-11-2002).]