|
|
John VanSickle wrote:
> Tor Olav Kristensen wrote:
> >
> > Here's my "Total Overkill" code for calculating position of corners
> > for a bevelled box.
>
> If all you want to do is make a bevelled box, use the BevelBox()
> macro from my Throughly Useful Macros file.
I have had a little look at your BevelBox macro.
It's a nice way to make a I bevelled box.
But I have a optimalization to suggest for you.
I belive that if you rewrite it like this:
#macro BevelBox(Start,End,Bevel)
#local pS=Start+<0,0,0>;
#local pE=End+<0,0,0>;
#local sB=Bevel/sqrt(8);
#local vC=(pS+pE)/2;
#local vD=<abs(pS.x-pE.x),abs(pS.y-pE.y),abs(pS.z-pE.z)>/2;
#local xE=(vD.y+vD.z)/2-sB;
#local yE=(vD.x+vD.z)/2-sB;
#local zE=(vD.x+vD.y)/2-sB;
intersection {
box { -1,1 matrix <vD.x,0,0, 0,xE,xE, 0,-xE,xE, vC.x,vC.y,vC.z> }
box { -1,1 matrix <yE,0,-yE, 0,vD.y,0, yE,0,yE, vC.x,vC.y,vC.z> }
box { -1,1 matrix <zE,zE,0, -zE,zE,0, 0,0,vD.z, vC.x,vC.y,vC.z> }
bounded_by { box { pS,pE } }
}
#end
then it will have 2 less divisions and 1 less addition and 1 less
subtraction.
This is how I would have done it (if I were to use your method):
#macro BevelledBox(pCorner1, pCorner2, sBevel)
#local vB=(pCorner2-pCorner1+<0,0,0>)/2;
#local vD=<abs(vB.x),abs(vB.y),abs(vB.z)>;
#local vE=(<vD.y+vD.z,vD.x+vD.z,vD.x+vD.y>-sBevel/sqrt(2)*<1,1,1>)/2;
intersection {
box { -1,1 matrix <vD.x,0,0,0,vE.x,vE.x,0,-vE.x,vE.x,0,0,0> }
box { -1,1 matrix <vE.y,0,-vE.y,0,vD.y,0,vE.y,0,vE.y,0,0,0> }
box { -1,1 matrix <vE.z,vE.z,0,-vE.z,vE.z,0,0,0,vD.z,0,0,0> }
bounded_by { box { -vD,vD } }
translate pCorner1+vB
}
#end // macro BevelledBox
I haven't done much testing, but it seems to do the same.
Regards,
Tor Olav
--
mailto:tor### [at] hotmailcom
http://www.crosswinds.net/~tok/tokrays.html
Post a reply to this message
|
|