varying vec4 color;

#vertexshader

//const int NUMBONES = 40;
//uniform mat4 Bones[NUMBONES];

uniform float explosion_amount;
attribute vec3 center;


vec3 calc_pos(vec3 vel, vec3 gravity, float time)
{
	return vel*time + gravity*(time*time);
}

void main()
{
	vec3 gravity = vec3(0,-9.82,0);

	float a = clamp(1-pow((center.y + 250.0)/500.0, 1.25), 0.0, 1.0);
	float t = clamp(explosion_amount*0.5-a*3, 0.0, 100000.0);
	vec3 normal = normalize(center);
	vec3 vel = normalize(center)*vec3(2.0, 0.5, 2.0)*2.0;
	vec3 p = calc_pos(vel*100.0, gravity*100.0, t);
	
	vec4 Pos = vec4(gl_Vertex.xyz+p, 1.0);

	float l = 0.1 + (dot(normal, normalize(vec3(1.0,0.0,1.0))) + 1.0) * 0.035;
	color = gl_Color * l;
	gl_Position = gl_ModelViewProjectionMatrix * Pos;
}

#fragmentshader

void main()
{
	gl_FragColor = color; //vec4(1,1,1,1);
}
