//DELEK CODE

varying vec4 ShadowCoord;
varying vec2 textureCoordinate;
varying vec3 lightVector;
varying vec3 lightDir;
varying vec3 eyeVector;
varying vec3 normal;

void main()
{
	normal = normalize(gl_NormalMatrix * gl_Normal);
	ShadowCoord= gl_TextureMatrix[4] * gl_Vertex;
  	vec3 tangent = vec3( 1.0, 0.0, 0.0 );
  	gl_Position = ftransform(); 

 	gl_TexCoord[0].xy = gl_MultiTexCoord0.xy;  

  	if (gl_Normal.x == 0.0 && gl_Normal.z == 0.0)
  	{
   		tangent = vec3(1.0, 0.0, 0.0);
  	}
  	else
  	{
		tangent = vec3(gl_Normal.z, 0, -gl_Normal.x);
  	}
   
  	vec3 n = normalize(gl_NormalMatrix * gl_Normal);
	vec3 t = normalize(gl_NormalMatrix * tangent);
	vec3 b = cross(n, t);

	vec3 vVertex = vec3(gl_ModelViewMatrix * gl_Vertex);
	
        vec3 tmpVec = vec3(gl_LightSource[0].position) - vVertex;
	//HACK DELIRANTE
	lightDir=tmpVec;
        lightVector.x = dot(tmpVec, t);
        lightVector.y = dot(tmpVec, b);
        lightVector.z = dot(tmpVec, n);

        tmpVec = -vVertex;
        eyeVector.x = dot(tmpVec, t);
        eyeVector.y = dot(tmpVec, b);
        eyeVector.z = dot(tmpVec, n);
}
