Notifications
Clear all

[Closed] Horizontal Branching Help

Hello,
I’m working on a project but I’m having trouble:sad: with rotating this branching script and was wondering whether you could help me . I’m trying to rotate this script about the x-axis to make the branching go horizontal. If you have any advice it would be welcome :

global maximumDepth = 6
global maximumBranches =2

treeTrunk = cylinder radius:2 height:20
fn branchATree parent depth =
(
branches = random 1 maximumBranches
if (depth < maximumDepth) then
(
for i = 1 to branches by 1 do
(
newBranch = copy parent
newBranch.parent = parent
newBranch.height = parent.height
newBranch.radius = parent.radius – can put random between 50% and 75% e.g.
in coordsys parent move newBranch [0,0,(parent.height)*(random 0.6 0.9)]
in coordsys parent rotate newBranch (eulerAngles (random -90 90) 0 0) – need to find script that says exactly -90 and 90 but randomly chosen
branchATree newBranch (depth + 1)
)
)
)

branchATree treeTrunk 1

2 Replies

I’m not sure I understand what youre asking, but can you not try changing the following line:

in coordsys parent rotate newBranch (eulerAngles (random -90 90) 0 0)

to

in coordsys parent rotate newBranch (eulerAngles 0 (random -90 90) 0)

and see if that helps and if not try

in coordsys parent rotate newBranch (eulerAngles 0 0 (random -90 90))

i do my branching in the following way

tm = matrixFromNormal  prevdir; -- dir of the branch we are growing off
 tm.translation = branchpos; 	   -- point we are branching from
 prerotatey tm branchangle;		   -- 0 - 180 with a random variation
 prerotatez tm radialangle;			 -- 0 - 360 dependent on number of branches plus random var 

tm is now the tranform for the start of the new branch (i use splines)