// You need Chris Colefax's Clockmod include file, and MegaPOV // First, run this scene file to create example.cl. No need to wait for the scene to render. // then run: cloth -i example.cl -o example.inc -r example.raw -s 1000 // This will have written out the *.inc file and the *.raw file of the starting positions of the cloth // <> // Uncomment the 'read_file' line from below, so that each time Cloth is called as a Post_Process, // it will read in the previous cloth data. // Also uncomment the cloth object (so it is rendered), and then run example.ini // << Alter the -s value in the ini file to change the rate of change of the cloth from frame to frame. // The lower the value, the less the cloth changes. Experiment to find the best values. // The above information comes from my experiments with Cloth Simulator. It shouldn't be assumed that I am in // any way an authority on the use of the program.. some of my findings may be incorrect.. but I hope it is // of some assistance. // // Andy Cocker #version unofficial MegaPov 0.6; #include "AutoClck.mcr" // Use My_Clock when reading spline to 'ease into' the action declare My_Clock=0; Declare_From (My_Clock,0) Declare_To (My_Clock,0.8,1) Declare_To (My_Clock,1,1) #init_3d_spline {"My_Spline",<0,0,0>,<0.4,-0.1,0>,<0,-0.1,-0.2>,<-0.2,-0.1,0>,<-0.4,-0.3,0.2>,<0,-0.1,0.5>,<0,-0.5,-0.5>,<0,0,0>} #declare WindDirection=eval_3d_spline ("My_Spline",My_Clock); global_settings { assumed_gamma 1.0 } camera { location <16,5,-14> look_at <0,0,0> angle 45 } light_source { <1000, 1000, 200> rgb 1 } light_source { <-1000, 700, -200> rgb 1 shadowless } // Uncomment this object once you've created the .inc file /* object { #include "example.inc" uv_mapping pigment { object { sphere { 1.5*x+y, 0.5 } pigment { object { box { <0, 0.5, -0.5>, <1, 1.5, 0.5> } color rgb 0.75 color rgb 0.25 } } pigment { color rgb 0.5 } } warp { repeat 2*x } warp { repeat 2*y } scale 0.05 } } */ cylinder { // ground -10*y, -3.9*y, 30 pigment {checker rgb <.4,0,0>, rgb <.1,0,0> scale 3} finish {reflection .4} } // Green cones to point to 'attach' points union { cone { <0,5,-2>,0.0,<0,6,-3>,0.3} cone { <0,5,2>,0.05,<0,6,3>,0.3} pigment { rgb <0,1,0>} } // Yellow sphere shows the direction the wind is blowing towards. // Blue sphere is at origin <0,0,0> sphere {0,0.4 pigment { rgb <0,0,1> } finish { ambient 0.3}} union { sphere { *8,0.3} cylinder {<0,0.00001,0>,*8,0.075} pigment {rgb <1,1,0> } finish {ambient 0.3}} #debug concat("\nWindDirection is now <",str(WindDirection.x,0,3),",",str(WindDirection.z,0,3),",",str(WindDirection.y,0,3),">\n") //WRITE NEW .CL FILE // Notice how the values for Y and Z have been swapped, as the Cloth Simulator prog requires this. #fopen MyFile "example.cl" write #write (MyFile, "\n", "global_settings {\n", "step 0.2\n", "viscosity 0.1\n", "wind <",str(WindDirection.x,0,3),",",str(WindDirection.z,0,3),",",str(WindDirection.y,0,3),">\n", "}\n", "\n", "cloth {\n", "x_size 10\n", "y_size 20\n", "strenght 2\n", "dist 0.5\n", "hnoise 0.02\n", "vnoise 0.02\n", "damping 0.01\n", "intersections true\n", "position { <0,-2.5,5>,5*y,-5*z }\n", //"read_file \"example.raw\"\n", "attach { 0,0,<0,-2,5> }\n", "attach { 1,0,<0,2,5> }\n", "}\n", "\n", "ground {\n", "-4, 0.05\n", "}\n", "\n", "\n" ) #fclose MyFile