POV-Ray : Newsgroups : povray.newusers : Box with different texture in each side : Re: Box with different texture in each side Server Time
2 Nov 2024 11:27:32 EDT (-0400)
  Re: Box with different texture in each side  
From: Mike Williams
Date: 13 May 2004 14:09:02
Message: <pNWW9DAHV7oAFwvC@econym.demon.co.uk>
Wasn't it Bin2Hex who wrote:
>Hi all,
>
>I've worked some time ago with PovRay for a little time and now I needed to
>do a simple thing, but don't know how to do it.
>
>How can I have a different texture in each side of a box?
>
>I know how to create the textures and the box and all the rest I need, but
>don't know how to assign a different texture to each side.

You could uv_map the box, or you could replace the box by an
intersection of planes (like the way "cube" used to be defined in early
versions of POV).

// Write a macro, so we don't have to check the order of the X Y and Z
// values manually.

#macro CUBE(P1,P2,T1,T2,T3,T4,T5,T6)
  #local X1=min(P1.x,P2.x);
  #local X2=max(P1.x,P2.x);
  #local Y1=min(P1.y,P2.y);
  #local Y2=max(P1.y,P2.y);
  #local Z1=min(P1.z,P2.z);
  #local Z2=max(P1.z,P2.z);
  intersection {
    plane { x, X2 texture {T1}}
    plane {-x,-X1 texture {T2}}
    plane { y, Y2 texture {T3}}
    plane {-y,-Y1 texture {T4}}
    plane { z, Z2 texture {T5}}
    plane {-z,-Z1 texture {T6}}
  }
#end

//Invoke the macro, passing it the points at opposite corners
//and six textures

CUBE(<0,0,0>,<1,1,1>,
  texture{pigment{rgb x}},
  texture{pigment{rgb x}},
  texture{pigment{rgb y}},
  texture{pigment{rgb y}},
  texture{pigment{rgb z}},
  texture{pigment{rgb z}}
)

-- 
Mike Williams
Gentleman of Leisure


Post a reply to this message

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