|
![](/i/fill.gif) |
Peter Popov wrote:
>
> Can anyone help me to solve the following problem: I know the coordinates of
> a cylinder and I want to map a radial y pigment on it. I want to define the
> texture at the origin and then translate it. Or define a unit cylinder and
> somehow fit it into the coordinates I have.
Perhaps something like the below file will fit your needs; the syntax
(after including the file) is as follows (note that standard brackets
() are used, not {} braces):
Textured_Cylinder (<Base Point>, <Cap Point>, Radius, texture {...})
or:
Textured_Disc (<Centre>, <Normal>, Radius, texture {...})
where the texture {...} is aligned as desired along the +y axis. Other
shapes can be textured using the Fit_Texture_to_Cylinder macro, eg:
cone {<-5, -4, -2>, 2, <5, 4, 1>, 1 open
Fit_Texture_to_Cylinder (MyTexture, <-5, -4, -2>, <5, 4, 1>, 2)}
One thing to note - I've had to write out the second atan2 () function
in the first macro in full (it looks as though the fix I sent the
POV-Team got somewhat lost in the translation!), to avoid the irritating
Domain Error crash.
// -- CylTex.inc -----------------------------
#macro Fit_Texture_to_Cylinder (cyltexture, point1, point2, cylradius)
#local _CT_axis = (point2 - point1) * <1, 1, 1>;
#if (vlength(_CT_axis) = 0) texture {cyltexture} #else
#local _CT_rotx = degrees(atan2(vlength(_CT_axis * <1, 0, 1>), _CT_axis.y));
#if (_CT_axis.x = 0) #if (_CT_axis.z >= 0) #local _CT_roty = 0; #else #local
_CT_roty = 180; #end
#else #if (_CT_axis.z = 0) #if (_CT_axis.x > 0) #local _CT_roty = 90; #else
#local _CT_roty = -90; #end
#else #local _CT_roty = degrees(atan2(_CT_axis.x, _CT_axis.z)); #end #end
texture {cyltexture
scale <cylradius, vlength(_CT_axis), cylradius>
rotate <_CT_rotx, _CT_roty, 0>
translate point1}
#end
#end
#macro Textured_Cylinder (point1, point2, cylradius, cyltexture)
cylinder {point1, point2, cylradius
Fit_Texture_to_Cylinder (cyltexture, point1, point2, cylradius)}
#end
#macro Textured_Disc (disccentre, discnormal, discradius, disctexture)
disc {disccentre, discnormal, discradius
Fit_Texture_to_Cylinder (disctexture, disccentre, disccentre + discnormal,
discradius)}
#end
// -- End File -----------------------------
Post a reply to this message
|
![](/i/fill.gif) |