POV-Ray : Newsgroups : povray.general : What Function to use : Re: What Function to use Server Time
1 Aug 2024 04:17:14 EDT (-0400)
  Re: What Function to use  
From: Thomas de Groot
Date: 19 Apr 2006 03:43:02
Message: <4445ea06@news.povray.org>
"POVMAN" <s### [at] acom> schreef in bericht news:4444d969@news.povray.org...
> I have an irregular csg object and I want to have objects ( cylinders )
> stand perpendicular to the surface.  Imagine the csg as being a box,
sphere
> and cylinder union.
>

You may also want to try this little scene :-)

Thomas

//==========================================================================
==========
// Persistence of Vision Ray Tracer Scene Description File
// File: ?.pov
// Vers: 3.5
// Desc: Shows the trace() function and the Reorient_Trans() function in
action
// Date: may 2004
// Auth: ?
//

#version 3.5;

#include "colors.inc"
#include "rand.inc"
#include "transforms.inc"

global_settings {
  assumed_gamma 1.0
}

// ----------------------------------------

camera {
  location  <0.0, 3, -4.0>
  direction 1.5*z
  right     x*image_width/image_height
  look_at   <0.0, 0.0,  0.0>
}

sky_sphere {
  pigment {
    gradient y
    color_map {
      [0.0 rgb <0.6,0.7,1.0>]
      [0.7 rgb <0.0,0.1,0.8>]
    }
  }
}

light_source {
  <0, 0, 0>            // light's position (translated below)
  color rgb <1, 1, 1>  // light's color
  translate <-30, 30, -30>
}

// ----------------------------------------

plane {
  y, -1
  pigment { color rgb <0.7,0.5,0.3> }
}

#declare MySurface =
// uses image color index as height, extends along X-Z axes
// from <0 0 0> to <1 1 1>
height_field {
  png "plasma3.png"
  texture {
    pigment {
      image_map { png "plasma3.png" map_type 0 interpolate 2 once }
      rotate x*90 // lay X-Y image map down onto X-Z height field plane
    }
  }
  translate <-0.5,0,-0.5>
  scale <5, 1, 5>
}
object {MySurface}

//====================================
#declare CylRed =
cylinder {
  0*y,  0.25*y,  0.01
  texture {pigment { color rgb <1, 0, 0> }}
}
#declare CylGreen =
cylinder {
  0*y,  0.25*y,  0.01
  texture {pigment { color rgb <0, 1, 0> }}
}
#declare CylBlue =
cylinder {
  0*y,  0.25*y,  0.01
  texture {pigment { color rgb <0, 0, 1> }}
}
#declare Seed1=seed(29);
#declare Seed2=seed(4321);
#declare CylCol=0;
// -------- Placing the Objects -------------

#declare Spacing=0.1;
#declare Cnt=0;


#declare PosX = -10;

#while (PosX < 10)
  #declare PosZ = -10;

  #while (PosZ < 10)
    // trace function
    #declare Norm = <0, 0, 0>;
    //#declare Start = <PosX+Spacing, 10, PosZ+Spacing>;
    #declare Start = <PosX+(rand(Seed1)-0.5)*Spacing, 1.0,
PosZ+(rand(Seed2)-0.5)*Spacing>;
    #declare Pos = trace (
                  MySurface,     // object to test
                  Start,           // starting point
                  -y,              // direction
                  Norm );          // normal

    #if (Norm.x != 0 | Norm.y != 0 | Norm.z != 0)   // if intersection is
found, normal differs from 0

      #if ((vdot(Norm, y) > 0.95) & (Pos.y < 500))  // criteria for placing
objects: steep (0.1) to flat (0.95); and below certain level
        #declare CylCol= RRand(0,1,Seed2);
        //#warning concat("Value is ", str(CylCol,3,1), "\n")

        #if (CylCol<0.66)
            #if (CylCol<0.33)
              #declare CylObj=CylRed;
            #else
              #declare CylObj=CylGreen;
            #end
        #else
          #declare CylObj=CylBlue;
        #end // end of color selection

        object {
          CylObj
          Reorient_Trans(y, Norm)
          translate Pos
        }
        #declare Cnt = Cnt+1;
      #end // end of steep/heigth test
    #end // end of Norm intersection

    #declare PosZ = PosZ+Spacing;

  #end // end of while PosZ

  #declare PosX = PosX+Spacing;
#end // end of while PosX

//==========================================================================
==========


Post a reply to this message

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