POV-Ray : Newsgroups : povray.general : an extraordinary rotation question : Re: an extraordinary rotation question Server Time
30 Jul 2024 16:21:45 EDT (-0400)
  Re: an extraordinary rotation question  
From: Chris B
Date: 23 Jun 2009 08:50:44
Message: <4a40cfa4$1@news.povray.org>
"mysdn" <kam### [at] hotmailcom> wrote in message 
news:web.4a409e00cfb6d60e4e47a1b0@news.povray.org...
> Tim,
> I don't think I can use
> #declare CABINET = union { ...
> because as I said each cabinet may have different characteristics, even no
> characteristics such as no door, no handle, then our "declare CABINET" 
> would be
> useless, cause it defines a solid , fixed model. We need an adjustable 
> model
> definition, with following specifications adjusted diffrently for each 
> cabinet.
>
> location
> scale
> case texture
> door texture
> handle texture
> door model
> handle model
>
> all these may be diffrent for each cabinet, I think we should construct a
> separate Union for each cabinet, What do you think?
>

One approach could be to use a macro. The example below adds 3 different 
cabinets, generated based on variable settings. Each variable has a default 
value that is set at the start of the macro.  The first macro call generates 
the default cabinet. The second uses a Cyan colored door with the door half 
open. The third has no door.

You mentioned a 2D application at the start of this thread. This would 
enable you to use a 2D graphics application to define a layout for the 
cabinets. Your application could pick up the positions, sizes and 
orientations from a 2D vector image and use this POV-Ray macro (which you 
can make as sophisticated as you like) to generate cabinets with the 
required specifications. I did something similar a few years back using SVG 
graphics to define the layout of a some houses 
(http://www.geocities.com/povstairs/povhouse/).

camera {location <-1, 1.2, -1> look_at <0.6,0.3,0>}
light_source {<2,20,-4> color rgb 2}

#macro Cabinet ()

  // Default Cabinet Variables
  #ifndef (Height) #declare Height = 0.9; #end
  #ifndef (Width)  #declare Width  = 0.6; #end
  #ifndef (Depth)  #declare Depth  = 0.6; #end
  #ifndef (Thickness)  #declare Thickness  = 0.012; #end
  // Default Door Variables
  #ifndef (Door_Thickness) #declare Door_Thickness  = 0.02; #end
  #ifndef (Door_OpenAngle) #declare Door_OpenAngle  = 0;    #end
  #ifndef (HasDoor)        #declare HasDoor  = true;        #end

  // Default Textures
  #ifndef (Cabinet_Texture)
    #declare Cabinet_Texture = texture {pigment {rgb 1}}
  #end
  #ifndef (Door_Texture)
    #declare Door_Texture = texture {pigment {rgb <1,1,0>}}
  #end

  union {
    // Cabinet
    difference {
      box {<0,0,0><Width,Height,Depth>}
      box {<Thickness,0.15,-0.001>
           <Width,Height,Depth>-Thickness
      }
      texture {Cabinet_Texture}
    }
    // Door
    #if (HasDoor)
      box {<0,0,0><Width,Height,-Door_Thickness>
        texture {Door_Texture}
        rotate y*Door_OpenAngle
      }
    #end
  }

#end

// Add 3 cabinets to the scene by calling the macro

// Default Cabinet
object {Cabinet()}

// Custom Cabinet
#declare Width = 0.8;
#declare Door_Texture = texture {pigment {rgb <0,1,1>}}
#declare Door_OpenAngle  = 45;
object {Cabinet() rotate y*45 translate 0.62*x}

// Doorless Cabinet
#declare Width = 0.3;
#declare HasDoor  = false;
object {Cabinet() translate -0.32*x}


Regards,
Chris B.


Post a reply to this message

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