POV-Ray : Newsgroups : povray.newusers : *repeated* texture map (image or checkerboard) on cylinder? : Re: *repeated* texture map (image or checkerboard) on cylinder? Server Time
2 Nov 2024 15:24:01 EDT (-0400)
  Re: *repeated* texture map (image or checkerboard) on cylinder?  
From:
Date: 19 Dec 2003 20:28:15
Message: <3fe3a5af$1@news.povray.org>
//  Hi Richard,
//
//  rereading the doc (6.7.7 UV Mapping; 6.7.7.1 Supported Objects) I
//  realized that cylinders don't have an uv-mapping adapted to them.
//  POV-Ray doesn't complain -- planar mapping (using the xy-plane at
//  z=0, projected along the z-axis) seems to be used instead. So warp
//  probably is the best method (or make a cylinder with lathe or sor).
//
//  Below you will again find a little scene, this time without cylinder
//  caps and with an interior texture added (partially transparent: sort
//  of one-way transparency!).
//  Because the backslash has a special meaning inside strings, it has
//  to be denoted by "\\" -- I've corrected this in the string which
//  describes the path to the images.
//
//     Sputnik
//
//
//  P.S. POV-Ray doesn't recognize your intended camera location
//       <20 20 -10>, this is read as <20 20-10>, giving <20, 10>
//       which is expanded to <20, 10, 0>.
//       See 6.1.4.1 Vector Literals and 6.1.4.4 Operator Promotion.


// -F +A0.1 +AM2 +R2 +W512 +H384

#declare PicPath = "C:\\Programs\\POV-Ray for Windows v3.5\\include\\"
#declare OuterPic = "bumpmap_.png"
#declare InnerPic = "povmap.png"

#declare High   = 5;   // number of stacked images
#declare Around =10;   // number of images around a circumference

#declare Width  = 0.4; // width of a single image-patch
#declare Height = 0.3; // height of a single image-patch

#declare MyRadius = 0.4; // (see below)

#declare Radius = Around*Width/2/pi; // calculate Radius from circumference
#declare Length = High*Height; // calculate Length


cylinder { 0, Length*y, Radius open

  pigment {
    image_map {
      png OuterPic
      //once // only 1 image with lower left corner at Radius*x
      map_type 0 // planar map!; wrapping is done by warp
      interpolate 2
      }
    // checker {...} instead of image_map {...} works too
    // put Around X High images onto 1 X Length
    scale <1/Around, Height, 1>
    warp {
      // wrap around a cylinder: 1 X Length -> circumference X Length
      cylindrical
      // look onto the image's xy-plane
      orientation z
      dist_exp 0
      }
    }
  finish { ambient 1 }

  interior_texture {
    pigment {
      image_map { png InnerPic map_type 0 interpolate 2 }
      scale <-1/Around, Height, 1> // "-" gives mirror image
      translate x // this puts the mirror image back to <0,0>, <1,1>
      warp { cylindrical orientation z dist_exp 0 }
      }
    finish { ambient 1 }
    }

  //scale MyRadius/Radius // makes a cylinder with radius=MyRadius (and
                          // proportionally corrected length)
  }


// never without checkered plane and sphere ...
plane { y, -0.01 pigment { checker } finish { ambient 1 } }
sphere { Radius*x, Radius/10
  pigment { color red 2 }
  finish { ambient 1 }
  //scale MyRadius/Radius // corresponds to the cylinder's scale
  }


camera { location 0.4*<2, 3, -4> look_at 0 translate Length/2*y }


//  END  //


Post a reply to this message

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