POV-Ray : Newsgroups : povray.general : What Function to use : Re: What Function to use Server Time
1 Aug 2024 04:12:56 EDT (-0400)
  Re: What Function to use  
From: Kyle
Date: 18 Apr 2006 09:11:35
Message: <09p942hq3okvvp67bafdhf7s91u4ujo9ei@4ax.com>
Here's a snipped of code from a test scene where I did this with cylinders...


#version 3.6;

//+w800 +h800 +a0.0
//+w800 +h800 +q3

#include "stdinc.inc"

global_settings {
  assumed_gamma 1
  max_trace_level 15
}

background { White * 0.75 } 

// primary light ( front, right )
light_source {
  vrotate (<0, 500, -500>, <0, -60, 0>), White
}

// shadow light ( front, left )
light_source {
  vrotate (<0, 500, -500>, <0, 60, 0>), White * 0.25
}

// back light ( rear )
light_source {
  vrotate (<0, 500, -500>, <0, 180, 0>), White * 0.50
}

camera {
  right x*image_width/image_height
  location <1.5, 1.5, -4>
  look_at <0, 0, 0>
}

#declare Model =
  union {
    sphere { 0.933*y, 1/2 }
    cone { -y/2, 1/2, y/2, 1/4 }
    box { -1/2, 1/2 translate -y }
  }
  
#declare ModelMaterial = material { texture { pigment { agate } } }
  
#declare M1 = object { Model rotate z*45 material { ModelMaterial } }

#declare spike = cylinder { 0, y, 0.0075 pigment { rgb <1, 0, 0> } }

// draw the spikes 
#declare S1 = seed(1);
#declare norm = <0, 0, 0>; 
#declare loop = 10000;
#declare BboxMin = min_extent(M1);
#declare BboxMax = max_extent(M1);
#while (loop > 0)
  #declare start = <rand(S1) * (BboxMax.x - BboxMin.x) + BboxMin.x, BboxMax.y + 1,
rand(S1) *
(BboxMax.z - BboxMin.z) + BboxMin.z>; // start above the surface at a random x, z
position
  #declare loc = trace(M1, start, <0, BboxMin.y - 1, 0>, norm); // trace to the
surface
  #if (vlength(norm) != 0)  // do we have a hit?
//    #if ( VAngleD(norm, y) < 10 )  // only place on relatively flat surfaces 
      cylinder {
        loc, loc + norm/20, 0.0075
        pigment { rgb <1, 0, 0> }
      }
//    #end
  #end
  #declare loop = loop - 1;
#end

// draw the object
object { M1 }



Kyle


Post a reply to this message

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