POV-Ray : Newsgroups : povray.general : Help needed with texture mapping : Re: Help needed with texture mapping Server Time
13 Aug 2024 19:19:47 EDT (-0400)
  Re: Help needed with texture mapping  
From: Ron Parker
Date: 10 Jul 1998 19:05:11
Message: <35a69017.0@news.povray.org>
On Fri, 10 Jul 1998 07:16:33 -0500, Dan Connelly <djc### [at] flashnet> wrote:
>Peter Popov wrote:
>> 
>> Hi!
>> 
>> 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.

>* define the texture, then scale it and/or translate it to match
>  the object location.
>
>   example (not debugged) :
>
>   cylinder {
>     V,              // V:  a vector
>     V2,             // V2: a vector
>     R               // R : a scalar
>     texture {
>       CylinderTexture
>
>       // the following transformations apply to the texture
>       // only :
>       #declare H = vlength(V2 - V);
   
        #declare DX = V2.x-V.x;
        #declare DY = V2.y-V.y;
        #declare DZ = V2.z-V.z;

        #declare RX = atan2( DZ, DY );
        #declare RZ = atan2( DX, DY );

>       scale <R, H, R>

        rotate RX * x
        rotate RZ * z

>       translate V
>     }
>   }

I haven't tested this, and I'm not sure it's quite right.  In particular,
the terms inside the atan2 might be different than I have here.  For example,
where I have DY, you might really need -DY.  If it doesn't work, try 
different combinations of signs.  I'm also assuming that the axis of your
texture lies along the +Y axis.


Post a reply to this message

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