POV-Ray : Newsgroups : povray.binaries.images : Another feather : Re: Another feather Server Time
5 Nov 2024 06:22:02 EST (-0500)
  Re: Another feather  
From: Charles C
Date: 12 Nov 2007 02:12:19
Message: <4737fcd3@news.povray.org>
> "mmuylle" <nomail@nomail> wrote:
>> can you reveal a bit of the code as well?

Here's some of it. It's not necessarily all cleaned up. I could post a 
more complete file but I'm starting to feel self conscious about posting 
wip-code etc. :)

Charles



// This macro returns the scale_b equivalent of a value a_posi on scale_a.
// One possible use would be to convert celcius to farenheit or vice 
versa by knowning
// freezing and boiling temps: Range_Converter(25,0,100,32,212) returns: 
77 (degrees F)
//((25-0) *(212-32)/(100-0 )) + 32 = 77
//((77-32)*(100-0 )/(212-32)) + 0  = 25
// A more probable use for animation would be to convert one time scale 
to another.
//
#macro Range_Convert(a_posi, a_low, a_high, b_low, b_high)
       (   ( (a_posi-a_low)*(b_high-b_low)/(a_high-a_low) ) + b_low    )
#end // end macro Range_Converter




#macro Spline_From_Array (The_Array, Array_Length )
   //I'm not sure why, but for some reason POV-Ray crashes if this gets 
changed to #local:
   #declare ATempSpline = spline{
    cubic_spline
    #local Ctr = 0;
    #while (Ctr < Array_Length)
       #local Tempfloat = The_Array[Ctr].t;
       Tempfloat,  <The_Array[Ctr].x, The_Array[Ctr].y, 
The_Array[Ctr].z>, //The_Array should be an array of vectors
      #local Ctr = Ctr+1;
    #end //end while
   } //end spline
   //
   ATempSpline
   //
#end //end #macro Spline_From_Array (The_Array, Array_Length )


#macro Plot_Spline (TheSpline, Plot_Min_Val, 
Plot_Max_Val,Thickness,Frequency)//, PlotColor, PlotType)
   #if(Frequency < 1)
     #local Inc = (Plot_Max_Val-Plot_Min_Val)/(1/Frequency);
   #else
     #local Inc = (Plot_Max_Val-Plot_Min_Val)/Frequency;
   #end
   //
   object{
    union{
     #local Ctr = Plot_Min_Val;
     #while (Ctr < Plot_Max_Val)
       sphere {
         TheSpline(Ctr),Thickness
         pigment { rgb <1-Ctr,Ctr,0> }
         finish {ambient 1 }
         }
       #local Ctr = Ctr + Inc;
     #end
    } //end union
   } //end object
#end  //end #macro Plot_Spline()






#declare BasicFeather_Rachis_SplineArray_Length = 5;
#declare BasicFeather_Rachis_SplineArray =
array[BasicFeather_Rachis_SplineArray_Length]{
     < -.20000, -0.05,    0,   -1/20>, //tangent
     < 0.00000,     0,    0,    0/20>, //root
   //< 0.00000,     0,    0,    1/20>,
   //< 0.00000,     0,    0,    2/20>,
   //< 0.00000,     0,    0,    3/20>,
   //< 0.00000,     0,    0,    4/20>,
   //< 0.00000,     0,    0,    9/40>, //added precision control point
   //< 0.00000,     0,    0,    5/20>,
   //< 0.00000,     0,    0,    6/20>,
   //< 0.00000,     0,    0,    7/20>,
   //< 0.00000,     0,    0,    8/20>,
   //< 0.00000,     0,    0,    9/20>,
     < 2.00000,  0.25,    0,   10/20>, //halfway
   //< 0.00000,     0,    0,   11/20>,
   //< 0.00000,     0,    0,   12/20>,
   //< 0.00000,     0,    0,   13/20>,
   //< 0.00000,     0,    0,   14/20>,
   //< 0.00000,     0,    0,   15/20>,
   //< 0.00000,     0,    0,   16/20>,
   //< 0.00000,     0,    0,   17/20>,
   //< 0.00000,     0,    0,   18/20>,
   //< 0.00000,     0,    0,   19/20>,
     < 4.00000,     0,    0,   20/20>, //tip
     < 4.20000, -0.05,    0,   21/20>  //tangent
}; // end array BasicFeather_Rachis_SplineArray
//



#declare BasicFeather_Rachis_Spline = Spline_From_Array 
(BasicFeather_Rachis_SplineArray,BasicFeather_Rachis_SplineArray_Length);
//Plot_Spline(BasicFeather_Rachis_Spline,0,1,.005,.001)




#declare BasicFeather_Profile_SplineArray_Length = 9;
#declare BasicFeather_Profile_SplineArray =
array[BasicFeather_Profile_SplineArray_Length]{
     < BasicFeather_Rachis_Spline(.05).x, 
BasicFeather_Rachis_Spline(.1).y, 
BasicFeather_Rachis_Spline(.1).z-.1,   -1/20> //tangent
     < BasicFeather_Rachis_Spline(.10).x, 
BasicFeather_Rachis_Spline(.15).y,    BasicFeather_Rachis_Spline(.15).z, 
      0/20> //root
   //<  1/20,     0.00000,    0,    1/20>
   //<  2/20,     0.00000,    0,    2/20>
   //<  3/20,     0.00000,    0,    3/20>
   //<     0,     0.00000,    0,    4/20>
   //<  9/40,     0.00000,    0,    9/40> //added precision control point
     <     2,        0.25,   .7,    5/20>
   //<  6/20,     0.00000,    0,    6/20>
   //<  7/20,     0.00000,    0,    7/20>
     <   3.5,        0.05,   .5,    8/20>
   //<  9/20,     0.00000,    0,    9/20>
     < BasicFeather_Rachis_Spline(1).x, 
BasicFeather_Rachis_Spline(1).y,    BasicFeather_Rachis_Spline(1).z, 
   10/20> //tip
   //< 11/20,     0.00000,    0,   11/20>
     <   3.5,        0.05,  -.5,   12/20>
   //< 13/20,     0.00000,    0,   13/20>
   //< 14/20,     0.00000,    0,   14/20>
     <     2,        0.25,  -.7,   15/20>
   //< 16/20,     0.00000,    0,   16/20>
   //< 17/20,     0.00000,    0,   17/20>
   //< 18/20,     0.00000,    0,   18/20>
   //< 19/20,     0.00000,    0,   19/20>
     < BasicFeather_Rachis_Spline(.10).x, 
BasicFeather_Rachis_Spline(.15).y,    BasicFeather_Rachis_Spline(.15).z, 
     20/20> //root
     < BasicFeather_Rachis_Spline(.05).x, 
BasicFeather_Rachis_Spline(.1).y, 
BasicFeather_Rachis_Spline(.1).z+.1,   21/20> //tangent
}; // end array BasicFeather_Profile_SplineArray



#declare BasicFeather_Profile_Spline = Spline_From_Array 
(BasicFeather_Profile_SplineArray,BasicFeather_Profile_SplineArray_Length);
//Plot_Spline(BasicFeather_Profile_Spline,0,1,.005,.001)




#declare BasicFeatherRand = seed(9930);

#macro BasicFeather_Make_Barb_Spline(RachisValue,ProfileValue,Vector, 
FlufTurbulance)//, FlufBarbPortion)
     #local RachisPoint = BasicFeather_Rachis_Spline(RachisValue);
     #local ProfilePoint = BasicFeather_Profile_Spline(ProfileValue);
     #local DistFromRachisToProfile = VDist(RachisPoint,ProfilePoint);
     #local TempVec = vnormalize(ProfilePoint - RachisPoint);
     #local TempVec = vnormalize(TempVec + Vector);
     //
     #if(ProfileValue <= 0.5)
         //do nothing
     #else
         #local TempVec = <TempVec.x,TempVec.y*-1,TempVec.z>;
     #end //end #if(ProfileValue <= 0.5)
     //
     #local TempVec = TempVec * DistFromRachisToProfile/4;
     #local StartTangentPoint = RachisPoint+(-1*TempVec/5);
     #local QuarterBarbPoint = RachisPoint + TempVec;
     #local EndTangentPoint = 
ProfilePoint+(-1*(ProfilePoint-2*QuarterBarbPoint)/10);
     //
     #local Random_ProfilePoint_Adjustment_Vec = 
(rand(BasicFeatherRand)-.5)*2*FlufTurbulance;
     #local Random_TangentPoint_Adjustment_Vec = 
(rand(BasicFeatherRand)-.5)*2*FlufTurbulance;
     #local Random_ExtraPoint_Adjustment_Vec   = 
(rand(BasicFeatherRand)-.5)*2*FlufTurbulance/2;
     //
     #declare BasicFeather_New_Barb_Spline = spline{
               cubic_spline
               -0.2, StartTangentPoint,
                  0, RachisPoint,
               0.25, QuarterBarbPoint,
               #if(Random_ExtraPoint_Adjustment_Vec!= 0) .6, 
ProfilePoint+Random_ExtraPoint_Adjustment_Vec, #end
                  1, ProfilePoint+Random_ProfilePoint_Adjustment_Vec,
                1.2, EndTangentPoint+Random_TangentPoint_Adjustment_Vec,
     }; //end spline
#end  //end #macro 
BasicFeather_Make_Barb_Spline(RachisValue,ProfileValue,Vector)




#declare BasicFeather_Number_Of_Barb_Splines = 144/3;   // set number of 
barbs
#declare BasicFeather_Array_Of_Barb_Splines = 
array[BasicFeather_Number_Of_Barb_Splines];




#macro 
BasicFeather_Make_Lots_Of_Barbs(StartValue,EndValue,FlufTurbMax,FlufEnd)
     #local Ctr = 0;
     #while(Ctr < BasicFeather_Number_Of_Barb_Splines)

         #local AngleVec = vnormalize(<1,.1,1>)/3;

         #if(Ctr <= BasicFeather_Number_Of_Barb_Splines/2)
            #local RachisVal = 
Range_Convert(Ctr/BasicFeather_Number_Of_Barb_Splines,0,.5,StartValue,EndValue); 


         #else
            #local RachisVal = 
Range_Convert(Ctr/BasicFeather_Number_Of_Barb_Splines,.5,1,EndValue,StartValue); 

            #local AngleVec = <AngleVec.x,AngleVec.y,-AngleVec.z>;
         #end
         #local FlufActual = 0;
         #if (   ( (FlufEnd >=StartValue) & (FlufEnd <= EndValue) ) & ( 
(RachisVal >=StartValue) & (RachisVal <= FlufEnd) )   )
              #local FlufFactor = 
Range_Convert(Ctr/BasicFeather_Number_Of_Barb_Splines,StartValue,FlufEnd,1,0);
              #local FlufActual = FlufTurbMax*FlufFactor;
         #end

             //sphere{BasicFeather_Rachis_Spline(RachisVal), 0.02 
pigment {rgb <0,0,1>}   }


         #local ProfileVal = Ctr/BasicFeather_Number_Of_Barb_Splines;
         //BasicFeather_Make_Barb_Spline(RachisValue,ProfileValue,Vector)
         #debug "* HI *"
         //#declare BasicFeather_Array_Of_Barb_Splines[Ctr] = 
BasicFeather_Make_Barb_Spline(RachisVal,ProfileVal,AngleVec,FlufActual);
 
BasicFeather_Make_Barb_Spline(RachisVal,ProfileVal,AngleVec,FlufActual)
         #declare BasicFeather_Array_Of_Barb_Splines[Ctr] = 
BasicFeather_New_Barb_Spline;


             //#local TempSpline = BasicFeather_Array_Of_Barb_Splines[Ctr];

             //#local TempSpline = 
BasicFeather_Make_Barb_Spline(RachisVal,ProfileVal,AngleVec);
     //Plot_Spline(TempSpline,0,1,.005,.001)

         #local Ctr = Ctr + 1;
     #end //end #while


#end //end  #macro BasicFeather_Make_Lots_Of_Barbs()



BasicFeather_Make_Lots_Of_Barbs(.05,.8,.065,.30)


#local Ctr = 0;
#while(Ctr < BasicFeather_Number_Of_Barb_Splines)
     #local TempSpline = BasicFeather_Array_Of_Barb_Splines[Ctr];
     Plot_Spline(TempSpline,0,1,.002,.002)
     #local Ctr = Ctr + 1;
#end //end #while


Post a reply to this message


Attachments:
Download 'basicfeather 2007 11 03 03.png' (211 KB)

Preview of image 'basicfeather 2007 11 03 03.png'
basicfeather 2007 11 03 03.png


 

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