#include "functions.inc" #declare MSim_Tex_N = texture {pigment {rgb 1}} #declare fn_Env = function {y+f_noise3d(x,y,z+1)*3} #version unofficial MegaPov 1.0; #include "mechsim.inc" // controls how many links are in the chain #declare Angle=2*pi/150; global_settings { mechsim { gravity <0,-9.81,0> method 1 // define the ground environment { function { fn_Env(x, y, z) } stiffness 60000 damping 100000 friction 0.8 method 1 } collision { 1, 0 stiffness 60000 damping 3000 } // normal processing #if (clock_on) step_count 1500 time_step (1/30)/1500 topology { load_file "chain.dat" save_file "chain.dat" } // Initial setup: create the chain topology #else step_count 0 topology { #declare a=0; #declare n=0; // each link is represented by a small mass #while (a < 2*pi -0.0001) // fudge factor to prevent duplicated point mass { < 2*sin(a),0.5,-2*cos(a)>, <0,0,0>, Angle/2 density 5000 } #declare a=a+Angle; #declare n=n+1; #end #declare m=0; // each link is connected to the next link #while (m*0.6 look_at <0.0, -1.5, 0.2> angle 20 } light_source { <0, 3000, 0> color rgb 1 } sky_sphere { pigment { gradient z color_map { [0.0 rgb <0.6,0.7,1.0>] [0.2 rgb <0.2,0.3,0.9>] } } } // ---------------------------------------- #declare T_Env= texture { pigment { color rgb <.7,.5,.6> } } // Only bother rendering objects properly if this is the last frame // Because the isosurface is fairly slow #if (clock > 0.99) //The link definition #declare crad=0.02; #include "chain.inc" // required for reorientation #include "transforms.inc" // The ground isosurface { function {fn_Env(x,y,z)} contained_by {box {<-5,-3,-5><5,0.49,5>}} max_gradient 10 texture { T_Env } } #declare m=0; #declare n=2*pi/Angle; #declare R1=2.5*pi/n; // for each mass, read the location, P, from mechsim #while (m