uniform float animVal;
varying vec3 eye;
varying vec3 normal;
varying float color;
varying float glowHack;
uniform float explodeVal;

attribute vec3 spcVertexTangent;

void main()
{




 vec4 vertex= gl_Vertex;
 float transform = 0.0;
 float animArray[6];
 animArray[0]=spcVertexTangent.x;
 animArray[1]=fract(spcVertexTangent.x)*1000.0;
 animArray[2]=spcVertexTangent.y;
 animArray[3]=fract(spcVertexTangent.y)*1000.0;
 animArray[4]=spcVertexTangent.z;
 animArray[5]=fract(spcVertexTangent.z)*1000.0;
 
 int key=int(animVal*6.0*(max(0.0,1.0-explodeVal*10.0)));
  if(key<0)
key=0;
if (key>5)
key = 5;
 if(key==0)
	transform = animArray[0];
if(key==1)
	transform = animArray[1];
if(key==2)
	transform = animArray[2];
if(key==3)
	transform = animArray[3];
if(key==4)
	transform = animArray[4];
if(key==5)
	transform = animArray[5];
 color = transform/255.0;
 transform*=-0.5;
 
 //color*=animVal;
 color = clamp(color,0.3,1.0);
 
 glowHack=gl_FrontMaterial.ambient.r;
 
 //at this stage rotate some.

 mat3 rot; 
 float rotAngle=explodeVal*2.0*(sin(gl_MultiTexCoord0.x*0.4+gl_MultiTexCoord0.y*0.34))*3.9;
 
 rot[0]=vec3(cos(rotAngle),sin(rotAngle*0.2),0.0);
 
 rot[1].x=0.0;
 rot[1].y=cos(rotAngle);
 rot[1].z=sin(rotAngle);
 
 rot[2].x=0.0;
 rot[2].y=-sin(rotAngle);
 rot[2].z=cos(rotAngle);
 
 //we need to get out some baked values.
 vec3 bakedVal;
 bakedVal.x = floor(gl_MultiTexCoord0.x);
 bakedVal.y = 0.0;//floor(fract(gl_MultiTexCoord0.x/100.0)*100.0);
 bakedVal.z = floor(gl_MultiTexCoord0.y);
 vertex.xyz-=bakedVal;
 vertex = vec4(rot*vertex.xyz,1.0);
 vertex.xyz+=bakedVal;//*/
 
 vertex.y += transform;
 float exploTransform=sin(gl_MultiTexCoord0.x*0.03*explodeVal)*250.0*explodeVal;
 vertex.x+=sin(gl_MultiTexCoord0.x*4.03+explodeVal+gl_MultiTexCoord0.y*2.03)*50.0*explodeVal;
 vertex.z+=cos(gl_MultiTexCoord0.y*2.03+explodeVal)*50.0*explodeVal;
 vertex.y+=(cos(gl_MultiTexCoord0.x*3.06+explodeVal)*1650.0+1600.0)*explodeVal;
 
 
 
 
 eye =(gl_ModelViewMatrix*vertex).xyz;
 eye = normalize(eye);
 normal = normalize(gl_Normal).xyz;
 vertex = gl_ModelViewProjectionMatrix*vertex;
 gl_Position = vertex;
}