|
![](/i/fill.gif) |
> Thanks, I really should have seen that. The problem now is passing the
> correct values for position to the recursive calls. The thing about LOGO
> is that it remembers the position and direction of the turtle at all
> times,
> it will continue moving on a set vector unless you tell it otherwise.
> POV,
> on the other hand, has to be told where to go and what to do once it gets
> there.
// Macros for treating POV-Ray like LOGO -- by Tim Attwood 4/2/2007
#declare PenSize = 0.025;
#declare PenColor = Yellow;
#declare PenStep = 0.1;
#declare PenState = on;
#declare PenDir = <0,0,1>;
#declare PenUp = <0,1,0>;
#declare PenLoc = <0,0,0>;
#macro Turtle() cone{PenLoc,PenSize*2,PenLoc+PenDir*PenStep*4,0
pigment{color PenColor}} #end
#macro PU() #declare PenState = off; #end
#macro PD() #declare PenState = on; #end
#macro FD(a)
#local b = PenLoc+PenDir*PenStep*a;
#if (PenState = on)
cylinder{PenLoc, b, PenSize pigment{color PenColor} }
sphere{b,PenSize pigment{color PenColor}}
#end
#declare PenLoc = b;
#end
#macro BK(a)
#local b = PenLoc-PenDir*PenStep*a;
#if (PenState = on)
cylinder{PenLoc,b,PenSize pigment{color PenColor}}
sphere{b pigment{color PenColor}}
#end
#declare PenLoc = b;
#end
#macro LT(a) #declare PenDir = vaxis_rotate(PenDir,PenUp,-a); #end
#macro RT(a) #declare PenDir = vaxis_rotate(PenDir,PenUp,a); #end
#macro TiltUp(a)
#local r = vnormalize(vcross(PenDir,PenUp));
#declare PenDir = vaxis_rotate(PenDir,r,a);
#declare PenUp = vaxis_rotate(PenUp,r,a);
#end
#macro TiltDown(a)
#local r = vnormalize(vcross(PenDir,PenUp));
#declare PenDir = vaxis_rotate(PenDir,r,-a);
#declare PenUp = vaxis_rotate(PenUp,r,-a);
#end
// example
#macro Tree(a, stopat)
#if (a > stopat)
RT(30)
FD(a)
Tree( a/2, stopat)
PU()
BK(a)
LT(60)
PD()
FD(a)
Tree( a/2, stopat)
PU()
BK(a)
RT(30)
PD()
#end
#end
PU()
TiltUp(90)
BK(10)
PD()
#declare PenColor = Brown;
FD(5)
#declare PenColor = Green;
Tree(10,0.5)
#declare PenColor = Yellow;
FD(4)
Turtle()
Post a reply to this message
|
![](/i/fill.gif) |