POV-Ray : Newsgroups : povray.text.scene-files : Final Twyst (No hole in the middle) : Final Twyst (No hole in the middle) Server Time
28 Jul 2024 18:12:24 EDT (-0400)
  Final Twyst (No hole in the middle)  
From: Larry Fontaine
Date: 15 Sep 1999 00:00:39
Message: <37DF1826.65DB629A@isd.net>
//Added a prism to the middle to eliminate that hole in the center of
it.

//The spike macro:
//  twyst(1,2,3,4,5,6,7)
//  1 = Points array, dim. [#points][2]
//  2 = Height of spike
//  3 = Rotation between two layers
//  4 = Radius of rounded edge at base
//  5 = Spacing ratio (should be almost 1)
//      formula is height = (1-pow(Ratio,Layer))*Height
//  6 = Number of layers, not enough will cut the spike short
//         because of the spacing ratio
//  7 = color difference between layers
//        rainbow cycles every mult. of 3
#macro twyst(Points,Height,Rot,Rad,Rat,Num,Clr)
#local Nctr = 0;
#local RecH = 0;     //RecH = current layer's height
#local RecR = -Rot;  //RecR = current layer's rotation
#local Scale = 1;    //Scale = scale factor for current layer
#local Color = (clock*3);    //stores 0-3 indicating rainbow position
#local numpoints = dimension_size(Points,1);
union {
 #while (Nctr < Num)   //Layer counter
  #local RecR = RecR+Rot; //increase rotation
  #local Rctr = 0;
  #local Color = mod(Color+Clr,3);
  #local CTemp = mod(Color,1);
  #declare Vary = color rgb<0,1-CTemp,CTemp>;  //rainbow colors
  #if (Color < 2) #declare Vary = color rgb<1-CTemp,CTemp,0>; #end
  #if (Color < 1) #declare Vary = color rgb<CTemp,0,1-CTemp>; #end
  // here you can average Vary with other colors
  #declare Vary = color Vary*.5+SkyBlue*.3+Gray95*.2;
  #while (Rctr < numpoints)  //points counter
   cylinder { < Points[Rctr][0], 0, Points[Rctr][1] >,
              < Points[mod(Rctr+1,numpoints)][0], 0,
                Points[mod(Rctr+1,numpoints)][1] >, Rad
              rotate RecR*y scale Scale
              translate RecH*y pigment { Vary }
              finish { specular .9 roughness .005 } }
   sphere { < Points[Rctr][0], 0, Points[Rctr][1] >, Rad
              rotate RecR*y scale Scale
              translate RecH*y pigment { Vary }
              finish { specular .9 roughness .005 } }
   #local Rctr = Rctr + 1;
  #end
  #local Rctr = 0;
  prism { -Rad,Rad,numpoints+1
  #while (Rctr < numpoints)  //points counter
   <Points[Rctr][0],Points[Rctr][1]>,
   #local Rctr = Rctr + 1;
  #end
  <Points[0][0],Points[0][1]>
    rotate RecR*y scale Scale
    translate RecH*y pigment { Vary }
    finish { specular .9 roughness .005 } }
  #local RecH = Height-RecH;  //adjust RecH for next layer
  #local RecH = RecH*Rat;
  #local Scale = RecH/Height; //adjust scale for next layer
  #local RecH = Height-RecH;
  #local Nctr = Nctr + 1;
 #end
} #end


Post a reply to this message

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