/**********************************************************
  Include file for Toribash PovRay exporter (http://www.toribash.com)
  Radisity Include. Made for Toribash 2.1
  By Hampa 2006
  Edited by: Krin 2006
  To produce a screenshot.pov hit F8 inside toribash
  This file should be rendered with PovRay (http://www.povray.org)
  NOTE! All Y values needs to be negated to match Toribash coordinate system
************************************************************/


global_settings {
        radiosity {
                pretrace_start 0.08
                pretrace_end   0.01
                 count 500

                nearest_count 10
                error_bound 0.02
                recursion_limit 1

                low_error_factor 0.2
                gray_threshold 0.0
                minimum_reuse 0.015
                brightness 1

                adc_bailout 0.01/2
        }
}



background { color rgb <1,1,1> }

#macro Camera( xpos, ypos, zpos, lookatx, lookaty, lookatz)
camera {
location <xpos,-ypos, zpos>
sky <0, 0, 1>
look_at <lookatx, -lookaty, lookatz>
}
/* no light source at all */
//light_source { <xpos, -ypos, 1> color rgb <1,1,1>}
#end


// JOINTS
#macro Joint(xpos,ypos,zpos,Radius, xvel, yvel, zvel, xavel, yavel, zavel, r, g, b)
sphere { <xpos, -ypos, zpos>, Radius
	finish { ambient 0.45 phong .9 roughness 0.001 }
	pigment { color rgb <1, 1, 1> }
}
#end

// BLOOD
#macro Blood (xpos, ypos, zpos, Radius, xvel, yvel, zvel, xavel, yavel, zavel, r, g, b)
threshold 0.1
sphere {<xpos, -ypos, zpos>, Radius*5, 0.1
	finish { ambient 0.45 phong .9 roughness 0.001 }
	pigment { color rgb <0.8, 0, 0 > }
}
#end

// HEAD
#macro BodySphere (r, g, b, Radius,  rot0, rot3, rot6, rot1, rot4, rot7,  
rot2, rot5, rot8,  rot9, rot10, rot11, xvel, yvel, zvel, xavel, yavel, zavel)
sphere {
        <0, 0, 0>, Radius
    	matrix <rot0, -rot1, rot2,
	        rot3, -rot4, rot5,
	        rot6, -rot7, rot8,
	        rot9, -rot10, rot11>
	finish { ambient 0.45 phong .9 roughness 0.001 }
        pigment { color rgb <r, g, b> }
}
#end


// LEGS
#macro BodyCapsule (r, g, b, Radius, length, rot0, rot3, rot6,  rot1, rot4, 
rot7,  rot2, rot5, rot8,  rot9, rot10, rot11, xvel, yvel, zvel, xavel, yavel, zavel)
union {
	cylinder {
		<0,0,-length*0.5>,
		<0, 0, length - length*0.5>,
		Radius
	}
	sphere   { <0, 0, -length*0.5>,  Radius }
	sphere   { <0, 0, length - length *0.5>, Radius }

	matrix <rot0, -rot1, rot2,
	        rot3, -rot4, rot5,
	        rot6, -rot7, rot8,
	        rot9, -rot10, rot11>
	finish { ambient 0.45 phong .9 roughness 0.001 }
	pigment { color rgb <r, g, b> }
}
#end

// BODY PART
#macro Body (r, g, b, sidex, sidey, sidez, rot0, rot3, rot6,  rot1, rot4, 
rot7,  rot2, rot5, rot8,  rot9, rot10, rot11, xvel, yvel, zvel, xavel, yavel, zavel)
box {
	<-(sidex*0.5), -(sidey*0.5), -(sidez*0.5)>,
	<sidex*0.5, sidey*0.5, sidez*0.5>

	matrix <
	rot0, -rot1, rot2,
	rot3, -rot4, rot5,
	rot6, -rot7, rot8,
	rot9, -rot10, rot11> // y == x
	finish { ambient 0.45 phong .9 roughness 0.001 }
	pigment { color rgb <r, g, b> }

}
#end

#macro EnvBox (r, g, b, a, sidex, sidey, sidez, rot0, rot3, rot6,  rot1, rot4, rot7,  rot2, rot5, rot8,  rot9, rot10, rot11)
box {   
        <-(sidex*0.5), -(sidey*0.5), -(sidez*0.5)>,
        <sidex*0.5, sidey*0.5, sidez*0.5>
                
        matrix <rot0, -rot1, rot2, 
                rot3, -rot4, rot5, 
                rot6, -rot7, rot8, 
                rot9, -rot10, rot11>

	//Need Texture for this alpha
        pigment { color rgbf <r, g, b, a> }
	finish  {
                reflection 0.4  
                ambient 0.5     
                phong .5        
                specular 0.1    
                roughness .001
        }       
}  
#end

#macro EnvCapsule (r, g, b, a, Radius, length, rot0, rot3, rot6,  rot1, rot4, rot7,  rot2, rot5, rot8,  rot9, rot10, rot11)
union {
        cylinder {
                <0,0,-length*0.5>,
                <0, 0, length - length*0.5>,
                Radius
        }
        sphere   { <0, 0, -length*0.5>,  Radius }
        sphere   { <0, 0, length - length *0.5>, Radius }

        matrix <rot0, -rot1, rot2,
                rot3, -rot4, rot5,
                rot6, -rot7, rot8,
                rot9, -rot10, rot11>
	
	//Need Texture for this alpha
        pigment { color rgbf <r, g, b, a> }
        finish {
                reflection 0.4
                ambient 0.5
                phong .5
                specular 0.1
                roughness .001
        }
}
#end


#macro EnvSphere (r, g, b, a, Radius, rot0, rot3, rot6,  rot1, rot4, rot7,  rot2, rot5, rot8,  rot9, rot10, rot11)
sphere {
        <0, 0, 0>, Radius
        matrix <rot0, -rot1, rot2,
                rot3, -rot4, rot5,
                rot6, -rot7, rot8,
                rot9, -rot10, rot11>

	//Need Texture for this alpha
        pigment { color rgbf <r, g, b, a> }
        finish  {
                reflection 0.4
		ambient 0.5
		phong .5
                specular 0.1
                reflection .001
        }
}
#end

#macro Impact (xpos, ypos, zpos, Radius, time, r, g, b, a)
torus {
        Radius, 0.5
	scale <1, 0.05, 1>
	rotate <90, 0, 90>
	translate <xpos, -ypos, zpos>
	
        pigment { 
		color rgb <r, g, b>
		filter (1-a)	//aka alpha 		
	}

        finish  {
       		reflection 0.2
               	ambient 0.5
               	phong .5
               	specular 0.1
               	refraction 1
       	}
}
#end

// GROUND
plane { z, 0
	pigment { rgb <1,1,1> }

	finish {
		ambient .01
			diffuse .1
			specular 1
			roughness .001
			metallic
			reflection {
				.75
					metallic
			}
	}
}







