POV-Ray : Newsgroups : povray.bugreports : Bad cylinder warp causes crash : Re: Bad cylinder warp causes crash Server Time
15 Jun 2021 09:05:45 EDT (-0400)
  Re: Bad cylinder warp causes crash  
From: Bald Eagle
Date: 1 Dec 2018 20:35:02
Message: <web.5c0336237cc2800765e06870@news.povray.org>
OK, so I fought with this for far longer than I should have had to.
I've worked out most of it.
The vertical scaling doesn't seem to be quite right yet.

Just call the macro using the aspect ratio of the pattern/image, the number of
times to make it wrap around the cylinder, and the radius of the base cylinder
(before scaling).

Pattern gets changed between lines 15 & 16 so you can test with a built-in
pattern.


I think jr was having an orientation problem - I changed orientation from y to z
so the pattern didn't have to get rotated when using the wiki code.

Haven't tried to crash it yet.  :)
------------------------------------------------------------------------


#version 3.8;
#declare SDL = true;

global_settings {assumed_gamma 1.0}

#declare Origin = <0, 0, 0>;
#declare Feet = 12;
#declare Meters = 39.37;
#declare Miles = 5280*Feet;

light_source { <0, 15, -10>  color rgb <1, 1, 1>}

#declare Camera_Aspect_Ratio = image_width/image_height;

#declare Image = pigment {image_map {png "_Riveted_Panel.png"}}
//#declare Image = pigment {checker}


//###########################################################################################
#macro WrapTexture (_Aspect2, _n, _CR)
 // Apparently the cylindrical warp already compensates for the 2*pi in the
circumference
 // so treat the circumference as 1 unit around
 // Scale in y direction to adjust for aspect ratio of image
 #local _Circumference = 1;
 //#local _Rscale = <_Circumference*_CR/_n, _Aspect2, _Circumference*_CR/_n>;
 #local _Rscale = <_Circumference*_CR/_n, _Aspect2/(2*pi*_CR/_n),
_Circumference*_CR/_n>;
 pigment {
  Image
  warp {
   cylindrical
   orientation z
   dist_exp 1
  }
  scale _Rscale
 }
#end // end macro WrapTexture
//###########################################################################################

#declare L = 0.25;
#declare T = 0.01;
#declare S = 0.8;
#declare Arrow = union {
 cone {Origin, 0, <L, 0, 0>, T*3 pigment {rgb 1} translate <0, 1.125, 0>}
 cylinder {<L, 0, 0>, <(pi)*S, 0, 0> T pigment {rgb 1} translate <0, 1.125, 0>}
}

object {Arrow}
object {Arrow scale <-1, 1, 1> translate <2*pi, 0, 0>}
text{ttf "cyrvetic.ttf" "2 * pi" 0.01, 0 scale 0.25 translate x*pi  translate
<-0.25, 1.125, 0> pigment {rgb 1} no_shadow}
box {<0, 0, 0>, <2*pi, 1, 0.1> texture {Image scale <2*pi/4, 1, 1>}}

#declare TankH = 6;
#declare TankR = 1;
#declare Crad = 2;
#declare C =
 cylinder {Origin, y Crad
 //scale <TankR, 1, TankR> // scaling before texture causes crash
 texture {WrapTexture (480/960, 4, Crad) finish {ambient 0.5}}
 scale <TankR, TankH, TankR> // after is fine
 no_shadow
}

object {C rotate y*  0 translate <-TankR*Crad*2, 2, 0>}
object {C rotate y* 90 translate < TankR*Crad*1, 2, 0>}
object {C rotate y*180 translate < TankR*Crad*4, 2, 0>}
object {C rotate y*270 translate < TankR*Crad*7, 2, 0>}


#declare Location = <(TankR*5/2)*Crad, TankH, -(TankR*20/2)*Crad>;
#declare LookAt = <(TankR*5/2)*Crad, TankH/4, 0>;

camera {
  location Location
 look_at  LookAt
 right x*image_width/image_height           // horizontal size of view
 up y // vertical size of view
}


Post a reply to this message

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