Jump to content

Help with tree growth without solver


c0y

Recommended Posts

Hi,

i'm currently working on a tree growth system without solver (just transforms).

and i'm stuck !

In this system, I import a tree skeleton from external file (curves), which I cannot edit.
My goal is to create a slider that grows all the branches, keeping their position onto their parent branches.

To be more specific :
when I import the tree, I have the branch level attribute, and the parent branch for each branch as well, and a gradient attribute.
With these three attributes, i'm trying to get the current position of each branch on their parent, and if it moves, then the children stay at the same pourcentage value...

In my file, I've got 3 levels :

level 0 is the trunk,
level 1 is branches from the trunk
level 2 is branches from level 1's branches.

tree_growth_levels.thumb.jpg.689926675707140bb5a3e3e31f4ba56d.jpg

tree_growth_nodes.jpg.80bfcd48b9681ae923791eadeb8f7c6c.jpg

In my loop, I'm taking each primitive, and I get their parent. I'm using a curvesect to get the intersection between parent and child, then I'm keeping only the root part of the line.

Then, I use a carve to change the length, and with a vex expression, I stick the branch onto the last point of the carve.

My problem comes from my "for loop" setup, which is working, but it doesn't take the transformations of the previous level.

 

So my question is :
is there a way to get the transformations of the previous level inside the for loop ?

-> For each level, I want the branches to be sticked to their parent at their relative position, even if they are moving (if the branch is at 45% of the curve, then if I'm carving the parent, it stays at 45%) .

Maybe it's possible directly in VEX ? but my knowledge is quite limited, i'm starting coding vex... but any help would be appreciated :)

 

Thanks !

tree_growth_help_001.rar

Edited by c0y
Link to comment
Share on other sites

wow, thanks brian for this example. I'll need some time to understand the animation vops, but the effects is quite good. I'll try to implement that inside a for loop nodes, if I have more branch levels !

I was also thinking of changing the way I record the parent primitive, maybe with arrays, and then use that to create transformation in a foreach function. But I need to dig a little bit more about that....

Thanks !

Link to comment
Share on other sites

Hi, I progressed on my tree growth effect, but I'm stuck on another part of it !

I can't find a way to offset my global animation (slider with keyframe 0 to 1) to the branches.

So I still have multiple levels of branching. I isolated each level and in the for each loop, I stick each branch to its parent by keeping its relative position.

My goal in this animation is :

- I have an attribute called "growth_grad". When this attribute reaches 1, it means that the branch is at is final position on the parent curve, and I want to start my animation from 0 to  1 at this time.

I was thinking of using CHOP to do that, but I never used it and I pain to find some example that match what I want...

So to resume : when my attribute "growth_grad" == 1, then the animation (from my global slider) starts.

 

If anybody has a solution or other idea... i'm more than interested !

Thanks !

tree_growth_help_002_CHOP.rar

Link to comment
Share on other sites

  • 2 weeks later...

Hi,

I've got another problem concerning now rotations.

I created a simple Hip file to discuss this, because my real setup is quite complicated, so it won't help.

So, let's say we have 1 trunk curve which is the parent and 2 branches which are children.
In my setup, I'm getting the full final tree skeleton and I'm starting from this. I cannot modify previous generation steps.

In my file, I have a wrangle node the stick the branches to the trunk. But it's only positions. I can translate the trunk in X, Y or Z, the branches follow. But I don't have rotations on them.

1) So first of all, I want the branches to follow the rotations of the parent.
How can I apply the relative rotations of the parent point onto all the points of the branches ?
I've looked for this on the forum, but all the examples I found were working with copy sop... but in my case, I already have the result. I really don't understand matrix rotations. I tried to apply transformation matrix, but it's always from the world origin, and not from my pivot point.


2) The I want a slider to rotate all the branches to be parallel to the parent point orientation.
For example, the 1st branch is sticked to the point 9 of the parent trunk. So when the slider is 0, the branch rotation is at initial position (no transformations), and when it's 1, it's aligned with the up vector of the point 9 ! It's exactly the same process Brian showed in his file, but if we transform the parent, the branches don't follow.

Thx !

growth_help_004_rotations.hip

tree_growth_rotations.jpg

Link to comment
Share on other sites

Ok, i've searched into all posts I could, and I finally found that solution for the second purpose : https://www.sidefx.com/forum/topic/43131/?page=1#post-193704

with point VOP and align node, I used qrotate to rotate my branches to the up vector from the trunk point parent :)

Now, when I rotate while the bias = 1 (branches are up), the branches follow any transformations. But I need to make the standard initial position follow the trunk as well...

Maybe if I calculate the angle between my up vector from the trunk and my up vector from the pivot point of the branch (which is pt 0)... but in the previous case, I transformed my branch at the world origin to make the rotation, and then move back to its position. But in that case, I don't know if it's gonna work...

Any clue would be appreciated :D

tree_growth_rotation_vertical_to_trunk.gif

growth_help_004_rotations_02.hip

Edited by c0y
Link to comment
Share on other sites

Well, I finally got it !!

I needed to create a rotation matrix of the parent point to get the orientation (in the copy SOP). The offset was corrected with the invert matrix of the parent point at the first frame (with a TimeShift).
So now, my sticking effect is working.

I provide the file if someone is interested.


By the way, I just ask : I'm using a polyframe to create the orthogonal axis, but it seems that the polyframe SOP doesn't work well on a straight line. It doesn't create the 3 orthogonal vectors.
Do anybody know how to create a "polyframe-like" on straight curve ? in VOP or VEX ?

And another question :
When I create a Line (Up vector, {0,1,0}), when I add a Wrangle node with :

v@x = {1,0,0};
v@y = {0,1,0};
v@z = {0,0,1};

if I put a transform node with random rotation, the vectors don't stay orthogonal, as if vectors were created in World Space. Should I create another matrix before ? or is there another way ?

Thanks !

stick_to_parent_08_working.hip

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...