|
|
Hello Frans,
F.VERBAAS wrote:
>
> Could it be that it does not like the lines arrowed below? You are fiddling
> with variables used to call your macro, declared outside the macro's scope.
>
> Better try giving XX and YY a different name within the macro. They are
> local variables, and you avoid a lot of confusion by naming them
> differently.
>
> I am not certain whether a macro is called by value or by reference. Calling
> by value would mean that any changes to the value of the local variables
> will not be found in the calling body.
>
Right, but if you tranform the scrip with different variables name,
it does the same thing. And be carefull (interesting experience) if
you miss to put the #declare vv=vv-deltay; (line 33) in the
macro, it
is wrong ! It means that variables are passed with address and that
yy (in the body) <=> vv (in the macro). So there absolutely no
ambiguity on the names. Also, #declare variables in the body must be
transmit
in arguments to the macro, else they are undefined. #declare in the
body are undefined in the macro. But #declare in the macro define
variable in the body. That's why there is a #local directive.
It seems that argument must be modified using #declare rather
then #local. So, the following scrip is as correct as the
previous one. But I think that POV 3.1 is rendering wrong
in that case ... It produces the same image as :
http://www.ief.u-psud.fr/~lecoat/vrml/etoile.pov
with #version 3.0; directive ...
Thanks for replying ...
Bye for now,
-- Francois LE COAT
Author of Eureka 2.12 (2D Graph Describer 3D Modeller)
WEB : http://www.ief.u-psud.fr/~lecoat
E-mail : mailto:lec### [at] iefu-psudfr
________________________________________________________________________
#declare Green_Phong = texture {
pigment { color rgb <0.0,0.5,0.5> }
normal { ripples 0.5 scale 0.1 }
finish { phong 1.0 phong_size 5.0 }
}
#declare xmin = 0;
#declare xmax = 2*pi;
#declare ymin = 0;
#declare ymax = pi;
#declare xiter = 11;
#declare yiter = 5;
#declare ix = (xmax-xmin)/(xiter-1.0);
#declare iy = (ymax-ymin)/(yiter-1.0);
#declare deltax = (xmax-xmin)/((xiter-1.0)*4.0);
#declare deltay = (ymax-ymin)/((yiter-1.0)*4.0);
#macro point(uu,vv)
#local ro=max((1-3*sin(2*vv)*sin(5*uu+pi/2)),0);
#declare zn=-ro*sin(vv)*cos(uu);
#declare xn=ro*sin(vv)*sin(uu);
#declare yn=ro*cos(vv);
#declare uu=uu+deltax;
#local ro=max((1-3*sin(2*vv)*sin(5*uu+pi/2)),0);
#local zp=-ro*sin(vv)*cos(uu);
#local xp=ro*sin(vv)*sin(uu);
#local yp=ro*cos(vv);
#declare uu=uu-deltax;
#declare vv=vv+deltay;
#local ro=max((1-3*sin(2*vv)*sin(5*uu+pi/2)),0);
#local zq=-ro*sin(vv)*cos(uu);
#local xq=ro*sin(vv)*sin(uu);
#local yq=ro*cos(vv);
#declare vv=vv-deltay;
#declare vn=vcross(<xp-xn,yp-yn,zp-zn>,<xq-xn,yq-yn,zq-zn>);
#end
#declare etoile = mesh {
#declare xx = xmin;
#while (xx<xmax) //outer loop
#declare yy = ymin;
#while (yy<ymax) //inner loop
//POINTS
point(xx,yy)
#declare n1=vnormalize(vn);
#declare p1=<xn,yn,zn>;
#declare yy=yy+iy;
point(xx,yy)
#declare n2=vnormalize(vn);
#declare p2=<xn,yn,zn>;
#declare xx=xx+ix;
point(xx,yy)
#declare n3=vnormalize(vn);
#declare p3=<xn,yn,zn>;
#declare yy=yy-iy;
point(xx,yy)
#declare n4=vnormalize(vn);
#declare p4=<xn,yn,zn>;
#declare xx=xx-ix;
#if(!(p1.x=p2.x&p1.y=p2.y&p1.z=p2.z)|(p2.x=p3.x&p2.y=p3.y&p2.z=p3.z)|(p1.x=p3.x&p1.y=p3.y&p1.z=p3.z))
smooth_triangle {
p1,n1,
p2,n2,
p3,n3
}
#end
#if(!(p1.x=p3.x&p1.y=p3.y&p1.z=p3.z)|(p3.x=p4.x&p3.y=p4.y&p3.z=p4.z)|(p1.x=p4.x&p1.y=p4.y&p1.z=p4.z))
smooth_triangle{
p1,n1,
p3,n3,
p4,n4
}
#end
#declare yy = yy+iy;
#end //inner loop
#declare xx = xx+ix;
#end //outer loop
scale 1/5
}
object {
etoile
no_shadow
texture { Green_Phong }
}
//Lights, camera, action
camera
{ location < 1, 1.25, -1>
direction 1*z
look_at < 0, 0, 0>
}
light_source { < 0, 1.25, -1> color rgb 1 }
light_source { < 1, 1.25, -1> color rgb 1 }
object { box{-2,2 inverse} pigment{color rgb 0.8} }
________________________________________________________________________
Post a reply to this message
|
|