POV-Ray : Newsgroups : povray.text.scene-files : Re: Draping cloth request : Re: Draping cloth request Server Time
3 Jul 2024 02:54:34 EDT (-0400)
  Re: Draping cloth request  
From: Patrick Dugan
Date: 28 Mar 2002 14:49:23
Message: <3ca373c3$1@news.povray.org>
Thank you!

"Mike Williams" <mik### [at] nospamplease> wrote in message
news:UF8### [at] econymdemoncouk...
> Wasn't it Patrick Dugan who wrote:
> >I'm sorry the the picture didn't come through.  Your example though looks
> >like the same idea.  Can you post any source showing how to do this or
> >is there a tutorial somewhere?  Thanks!
>
> Source as requested, but you'll have to find your own figure to drape it
> round.
>
>
> camera {
>     location <0,.5,-0.8 >
>     look_at <0,0.34,0>
> }
>
>
> light_source { <-0.2 , 1 ,-3 > rgb 1.2}
> light_source { <0.2 , 2 ,-1 > rgb 1}
> background {rgb<0.5,0.5,0.7>}
>
>
> // Insert your Poser model here
> // The one I used (P3 nude female) was 0.695 units tall,
> //     had a neck line at y=0.56
> //     had just its hands outside a cylinder of radius 0.16
>
> #declare Body = union {#include "Poser3.inc"}
>
> object {Body}
>
> // Can use other shapes as Base if you want the skirt to flare out
> #declare Base = plane {y,-0.1 pigment {rgb 0}}
>
> plane {y,0 pigment {rgb <.3,.6,.3>}}
>
>
> #declare Umax=100; // Number of points to generate
> #declare Vmax=100;
>
> #declare Points = array [Umax+1][Vmax+1];
> #declare Norms  = array [Umax+1][Vmax+1];
>
> #declare Norm=<0,0,0>;
> #declare FNorm=<0,0,0>;
>
> //Fudge factors. Becuase we're sampling at a finite number
> // of points, if we try to fit the cloth *exactly* to the body,
> // then there will be some places where the body will poke out
> #declare M=0.003;
> #declare MM=0.003;
>
> #declare U=0;
> #while (U<=Umax)
>   #declare OT=<0,0.58,0>;
>   #declare A=2*pi*U/Umax;
>   #declare V=0;
>   #while (V<=Vmax)
>     #declare R=0.16*V/Vmax;
>     #declare P=<R*cos(A), 0.58, R*sin(A)>;
>     #declare T=trace(Body, P, -y, Norm);
>     #declare F=trace(Base,P, -y, FNorm);
>     // If we missed or are below the base, use Base instead of Body
>     #if (vlength(Norm)=0 | T.y<F.y)
>       #declare T=F;
>       #declare Norm=FNorm;
>     #end
>     //Store the result in an array
>     #declare Points[U][V] = T+Norm*M-z*MM;
>     #declare Norms[U][V] = Norm;
>     #declare OT=T;
>     #declare V=V+1;
>   #end
>   #declare U=U+1;
> #end
>
> #declare N=0;
> #declare Robe = intersection {
>   // intersecting with cylinder to create the hemline
>   cylinder {<0,0.15,0><0,1,0>,1}
>   // the stored Points become a mesh2 object
>   mesh2 {
>   vertex_vectors {  (Umax+1)*(Vmax),
>     #declare U=0;#while (U<=Umax) #declare V=0;#while (V<=Vmax-1)
>       Points[U][V],
>       #declare q=Points[U][V];
>       #declare N=N+1;
>     #declare V=V+1;#end #declare U=U+1;#end
>   }
>
>   normal_vectors {   (Umax+1)*(Vmax),
>     #declare U=0;#while (U<=Umax) #declare V=0;#while (V<=Vmax-1)
>       Norms[U][V],
>       #declare q=Points[U][V];
>       #declare N=N+1;
>     #declare V=V+1;#end #declare U=U+1;#end
>   }
>
>   // omit the central region to create a neckline
>   #declare Start=floor(12/50*Vmax);
>   face_indices {
>    (Umax)*(Vmax-1-Start)*2,
>     #declare U=0;#while (U<Umax) #declare V=Start;#while (V<Vmax-1)
>       #declare p=U*(Vmax)+V;
>       <p,p+1,p+Vmax>, <p+1,p+Vmax,p+Vmax+1>,
>     #declare V=V+1;#end #declare U=U+1;#end
>   }
>   }
>   //pigment {rgbt <1,1,1,0.3>} // see-through version
>   pigment {rgbt <1,1,1,0>}
> }
>
> object {Robe}
>
> --
> Mike Williams
> Gentleman of Leisure


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.