|
![](/i/fill.gif) |
mysdn wrote:
> on second thought, I don't think I can use
> // cabinet
> #declare CABINET = union {
> // case
> object{
> box_ //
> because as I said each cabinet may have different characteristics
As Chris already said you can use a macro for this. In addition
to his suggestion, note that macros can have parameters and do not
need to use global variables. From a software engineering view that
would be preferred because it avoids conflicts with other macros
or variable names you wish to use for something else (the name
of a parameter is *local* to a macro, as is a variable which is
declared using #local instead of #declare within the macro):
#macro Cabinet(Width,Height,Depth,Thickness,
Door_Thickness,Door_OpenAngle, HasDoor
Cabinet_Texture, Door_Texture)
union
{
// Cabinet
difference
{
box {<0,0,0><Width,Height,Depth>}
...
}
}
#end
You would then need to call it like
Cabinet(0.6,0.9,0.6,0.012,0.02,0,true)
To not always have to specify all parameters, you
can then specialize this with mechanisms like
#macro CabinetModelA(Width,Height,Depth,Door_OpenAngle)
#local T_DOOR = texture {...}
#local T_CABINET = texture {...}
Cabinet(Width,Height,Depth,0.012,0.02,Door_OpenAngle,true,
T_DOOR,T_CABINET)
#end
#macro CabinetModelB(Width,Height,Depth)
#local T_DOOR = texture {...}
#local T_CABINET = texture {...}
Cabinet(Width,Height,Depth,0.012,0.02,0,false,
T_DOOR,T_CABINET)
#end
CabinetModelA(1,1.5,0.4,30)
CabinetModelB(0.5,0.7,0.5)
Finally, you might wish to have a look at some existing
scene source code before losing yourself in the details of
your own. E.g., have a look at IRTC images such as those under
http://www.irtc.org/irtc/irtc?_n&pg=ViewSummary&id=StillImages_September-October2006
Many images provide a "source" link (and most of those are
done with POV-Ray). This helps prevent reinventing the wheel.
Reusing an object is useful, but not exactly "brilliant" ;)
Post a reply to this message
|
![](/i/fill.gif) |