#macro Table (X_Top_size, Z_Top_size, Top_Thickness, TableHeight, LegLength, LegWidth, BeltThickness, BeltHeight, RecessAlongX, Recess_along_Z) /**************************************************************************************************************************************/ /************************** *******************************/ /* INITIAL POSITIONNING FOR ALL ELEMENTARY OBJECT */ /************************** *******************************/ /**************************************************************************************************************************************/ #local TopPosition = <0, TableHeight - Top_Thickness, 0>; #local BeltPositionAlongX= ; #local BeltPositionAlongZ= < BeltThickness/2 + RecessAlongX + (LegLength/2), TableHeight -((Top_Thickness) + (BeltHeight)), Recess_along_Z + LegWidth>; #local LegPosition= ; #local TablePosition = <-X_Top_size/2, -TableHeight/2, -Z_Top_size/2>; /**************************************************************************************************************************************/ /************************ ******************************/ /* DECLARATION OF THE ELEMENTARY OBJECTS */ /************************ ******************************/ /**************************************************************************************************************************************/ #local Leg = box { <0,0,0>, } #local BeltAlongX = box { <0,0,0>, } #local BeltAlongZ = box { <0,0,0>, rotate y*-90 } #local Top = box { <0,0,0>, } /**************************************************************************************************************************************/ /************************************************ ****************************************************/ /* OBJECTS COPYING */ /************************************************ ****************************************************/ /**************************************************************************************************************************************/ #local Legs = union { #local CompteLegs = 4; #while ( CompteLegs > 0) #if (CompteLegs = 4) object {Leg translate LegPosition} #end #if (CompteLegs = 3) object {Leg translate LegPosition+ } #end #if (CompteLegs = 2) object {Leg translate LegPosition+ <0, 0, BeltLengthAlongZ + LegWidth>} #end #if (CompteLegs = 1) object {Leg translate LegPosition+ } #end #local CompteLegs = CompteLegs - 1; #end } #local BeltsAlongX = union { #local Compte = 2; #while ( Compte > 0) #if (Compte = 2) object {BeltAlongX translate BeltPositionAlongX} #end #if (Compte = 1) object {BeltAlongX translate BeltPositionAlongX+ <0, 0, (BeltLengthAlongZ + LegWidth)>} #end #local Compte = Compte -1; #end } #local BeltsAlongZ = union { #local Compte = 2; #while ( Compte > 0) #if (Compte = 2) object {BeltAlongZ translate BeltPositionAlongZ} #end #if (Compte = 1) object {BeltAlongZ translate BeltPositionAlongZ+ } #end #local Compte = Compte -1; #end } #local Top = object {Top translate TopPosition} /**************************************************************************************************************************************/ /****************************** **************************************/ /* REUNION OF ALL THE ELEMENTS FOR EASE OF MANIPULATION */ /****************************** **************************************/ /**************************************************************************************************************************************/ #local Table2 = union { object {Legs pigment {Red} } object {BeltsAlongX pigment {Blue} } object {BeltsAlongZ pigment {Green} } object {Top pigment {Yellow} } } /**************************************************************************************************************************************/ /************************************************** *****************************************************/ /* CALLING FOR THE OBJECTS */ /************************************************* ******************************************************/ /**************************************************************************************************************************************/ object {Table2 translate TablePosition} #end /**************************************************************************************************************************************/