|
|
Hello;
I have made a tree macro and would like to add leaf on my tree. You can see
the result in the p.b.i.
So how to translate some object along all cylinder and orient them like an
umbrella ?
#include "colors.inc"
#include "math.inc"
#include "rand.inc"
camera {
location <12, 2, -30>
direction 1.5*z
right x*image_width/image_height
look_at <10,1,0>
}
light_source{< 1000, 500,-1000> color White}
// p0: Origin position of the lower cylinder
// p1: Upper position of the lower cylinder
// L: recursion level (WARNING: after 5 or 6 a big pc needed)
// d: Rayon of the lower cylinder
#macro arbre(p0,p1,L,d)
#local nd=d-(d*0.5);
cylinder{p0,p1,nd}
sphere{p1,nd}
#local ang=VAngle(p0,p1);
#local Np0=vrotate(p1,ang);
#local Np1=Np0+< rand(Ra)/3,rand(Ra)/2, rand(Ra)/3>*3;
#local Np2=Np0+<-rand(Ra)/3,rand(Ra)/2,-rand(Ra)/3>*3;
#local Np3=Np0+< rand(Ra)/3,rand(Ra)/2,-rand(Ra)/3>*3;
#local Np4=Np0+<-rand(Ra)/3,rand(Ra)/2, rand(Ra)/3>*3;
cylinder{Np0,Np1,nd/2}
cylinder{Np0,Np2,nd/2}
cylinder{Np0,Np3,nd/2}
cylinder{Np0,Np4,nd/2}
sphere{Np1,nd/2}
sphere{Np2,nd/2}
sphere{Np3,nd/2}
sphere{Np4,nd/2}
#if(L>0)
#local NL=L-1;
arbre(Np0,Np1,NL,nd)
arbre(Np0,Np2,NL,nd)
arbre(Np0,Np3,NL,nd)
arbre(Np0,Np4,NL,nd)
#end
#end
#declare r=seed(0);
#declare a=0;
#while(a<4)
#declare b=0;
#while (b<4)
#declare Ra=seed(RRand(100,500,r));
union{
arbre(<0,0,0>,<RRand(-0.2,0.2,r),RRand(0.3,1.5,r),RRand(-0.2,0.2,r)>,3,0.3)
translate<RRand(3,8,int(Ra))*a,0,RRand(6,8,int(Ra))*b>
}
#declare b=b+1;
#end
#declare a=a+1;
#end
plane{y,0 pigment{rgb<0.5,0.9,0.4>}}
sky_sphere {
pigment {
gradient y
color_map { [0.0 color rgb <0.7,0.7,1.0>] [1.0 color blue 0.5] }
}
}
Post a reply to this message
|
|
|
|
sap wrote:
> Hello;
>
> I have made a tree macro and would like to add leaf on my tree. You can see
> the result in the p.b.i.
...
> #local ang=VAngle(p0,p1);
> #local Np0=vrotate(p1,ang);
...
I have not looked at all of your code, but I spotted this:
In the code above you calculate an angle and then you rotate
a vector around all the x, y and z axes.
Is this intentionally ?
Note that:
vrotate(p1, ang)
evaluates to:
vrotate(p1, <ang, ang, ang>)
or equivalently:
vrotate(p1, ang*x + ang*y + ang*z)
I.e. the p1 vector is first rotated around the x-axis, then
around the y-axis and finally around the z-axis.
Also: vrotate() expects its 2nd argument to be a vector with
components in degrees, while the angle returned from the
VAngle() macro is in radians.
(The VAngleD() macro will return an angle in degrees.)
You may want to read these sections once more:
http://www.povray.org/documentation/view/3.6.1/459/
---> 2.7.9.2 Vector functions and macros
http://www.povray.org/documentation/view/3.6.1/229/
---> 2.2.1.4.5 Functions
Also note that there is a built in function; vaxis_rotate(),
which will rotate a vector around an arbitrary vector.
--
Tor Olav
http://subcube.net
http://subcube.com
Post a reply to this message
|
|
|
|
Thanks for your answer Tor, i use vrotate ans Vangle to attache my cylinder
at they extremity. When i use VDangle, cylinders are not attached. Then i
dont rotate my cylinder but i take the point Np0 and add it a random vector
in the +y direction to make my tree grow.
Its my firt macro in that way and i am now blocked because i cant translate
and rotate an object along and around cylinders.
My way to place cylinders is certenly the most rational way but it's the
onely one i found.
message de news: 417eea64$1@news.povray.org...
> sap wrote:
>> Hello;
>>
>> I have made a tree macro and would like to add leaf on my tree. You can
>> see the result in the p.b.i.
> ...
>> #local ang=VAngle(p0,p1);
>> #local Np0=vrotate(p1,ang);
> ...
>
> I have not looked at all of your code, but I spotted this:
>
> In the code above you calculate an angle and then you rotate
> a vector around all the x, y and z axes.
>
> Is this intentionally ?
>
> Note that:
>
> vrotate(p1, ang)
>
> evaluates to:
>
> vrotate(p1, <ang, ang, ang>)
>
> or equivalently:
>
> vrotate(p1, ang*x + ang*y + ang*z)
>
> I.e. the p1 vector is first rotated around the x-axis, then
> around the y-axis and finally around the z-axis.
>
> Also: vrotate() expects its 2nd argument to be a vector with
> components in degrees, while the angle returned from the
> VAngle() macro is in radians.
>
> (The VAngleD() macro will return an angle in degrees.)
>
>
> You may want to read these sections once more:
>
> http://www.povray.org/documentation/view/3.6.1/459/
> ---> 2.7.9.2 Vector functions and macros
>
> http://www.povray.org/documentation/view/3.6.1/229/
> ---> 2.2.1.4.5 Functions
>
>
> Also note that there is a built in function; vaxis_rotate(),
> which will rotate a vector around an arbitrary vector.
>
> --
> Tor Olav
> http://subcube.net
> http://subcube.com
Post a reply to this message
|
|