/**********************************************************************************/ // Persistence of Vision Ray Tracer Scene Description File // File name : ClothRay_utility.pov // Version : Megapov 1.21 // Description : ClothRay example (nappe.pov); adapted to fit RusHHouR's table, // by Thomas de Groot // Date : December 2006 // Author : Christophe Bouffartigue // E-mail : tofbouf@free.fr // Copyright (C) 2004. All rights reserved. /**********************************************************************************/ #version unofficial MegaPov 1.21; #default {pigment {rgb <1,0,0>}} #default {finish {ambient 0 diffuse 1}} //=============================================================================== // This macro creates a cloth for the first time. // A few settings have been changed by me to allow easier rotation and translation // of the cloth, prior to dropping. #macro WriteClothFile(nomfile, n1, n2, nlng, ks, ht) #debug "\nWriting new .cth file...\n" #fopen file nomfile write #write(file, n1, ",", n2, ",", nlng, ",", ks, ",\n") #local l1 = nlng*(n1-1); #local l2 = nlng*(n2-1); #local st = seed(1234); #local i=0; #while (i; //here you can move the cloth prior to dropping it: #local vtemp = vaxis_rotate (vtemp,y, 0); // rotate around y (change 0 into your rotation angle) #local vtemp = vaxis_rotate (vtemp,z, 0); // rotate around z (change 0 into your rotation angle) #local vtemp = vtemp + tempy*y - 0*x; // translate along x //#local vtemp = vtemp - 4*x; //#write(file, tempx, ",", tempy, ",", tempz, ", 0.0, 0.0, 0.0,\n") #write(file, vtemp.x, ",", vtemp.y, ",", vtemp.z, ", 0.0, 0.0, 0.0,\n") #local j=j+1; #end #local i=i+1; #end #fclose file #debug "\nFinished writing new .cth file\n" #end //of macro //=============================================================================== // Original object(s) to be covered: #declare Table = box { <-100, 29, -17.5>, <100, 31, 17.5> } // Slightly scaled-up object(s) to be tested by cloth // (to make the cloth fit better): #declare Dummy = object {Table scale <1.10, 1.05, 1.10> // adapt scaling carefully by trial and error } //-------------------------------------------------------------------------------- //Step 1: //Writing a cloth file: //Parameters: file name; n points x and z; normalized distance between neighbouring points; spring strength; altitude //The size of the cloth is determined by: n points * normalized distance (n1*nlng and n2*nlng) //de-comment the next line to create a new cloth file. Comment it again once created to satisfaction: WriteClothFile("TableCloth.cth", 130, 50, 2.00, 30, 32) //-------------------------------------------------------------------------------- //Step 2: //If you want some wind influencing the cloth: #declare P_Wind = pigment { bozo scale <40, 20, 40> color_map { [0.00 rgb <-0.1, 0, 0>] [0.25 rgb <-0.25, -0.1, -0.50>] [0.50 rgb <-1, -0.1, -1>] [0.50 rgb <-0.2, -0.1, -0.25>] [1.00 rgb <-0.1, 0, 0>] } } //-------------------------------------------------------------------------------- //Step 3: //drop the table cloth on the table: #debug "\nStarted simcloth...\n" simcloth { environment Dummy friction 0.0 //influences the contact between table and cloth gravity -1*y //wind { P_Wind } //de-comment this line if you want wind influence viscosity 0.0 //influences the contact between table and cloth neighbors 0 internal_collision on damping 0.90 intervals 0.10 //these are the steps between iterations. Start with larger steps. Decrease for better resolution. iterations 600 //Number of times the cloth drops from the original altitude. Start low and increase in steps input "TableCloth.cth" //output "TableCloth.cth" mesh_output "TableCloth.msh" //creates the mesh smooth_mesh on uv_mesh on } #debug "\n...finished.\n" //-------------------------------------------------------------------------------- //Step 4: //Once satisfied, finish embroidering your table cloth: #declare TableCloth = mesh { #include "TableCloth.msh" uv_mapping texture { pigment { checker color rgb <1, 0, 0> , color rgb <.0, 0, 1> } scale 0.1 } } //-------------------------------------------------------------------------------- //Step 5: //Render your table with the table cloth: union { object { TableCloth translate <0, 0.01, 0>} //you may have to translate it slightly upwards object { Table pigment { rgb <1, 1, 0> } } } //======================================================================================================================================================= // perspective (default) camera camera { location <-110.0, 100.0, -210.0> look_at <0.0, 31.0, 0.0> right x*image_width/image_height angle 60 } // set a color of the background (sky) background { color rgb <0.7, 0.7, 0.7> } light_source { // Arealight Arealight_sunlight <0.0, 0.0, 0.0> color rgb <1.000, 1.000, 1.000> area_light <2.000, 0.000, 0.000>, <0.000, 2.000, 0.000>, 3, 3 adaptive 2 jitter orient circular media_interaction off scale 5.0 translate <-1000.0, 1000.0, -1000.0> }