Jump to content
Sign in to follow this  
louderthan11

Possible to iterate through a hierarchy of objects one by one?

Recommended Posts

Is it possible to iterate through a hierarchy of objects one by one based on a condition or event? (I think I'm saying this right) For example, I have a group of TPs affected by PGravity and I want to switch the position of that PGravity node by feeding a different Null into the object port when the particle's velocity is == 0. Could I have a hierarchy of Null/light objects, and iterate through them one by one each time a particle's (only emitting one at a time) velocity reaches 0?

 

I've been seeking a lot of help lately and getting lots of it! I really appreciate guys!

Share this post


Link to post
Share on other sites

This setup, based on your TP example, uses the event count to control the Maximum Iterations on a Hierarchy node. There's a two-frame delay between the event and object switching. An extra frame is caused by the need to use the Hierarchy node's Object Operator to access Maximum Iterations. The expression didn't work when this parameter was accessed directly from the Hierarchy Operator.

 

The expression cycles through the objects continuously and automatically adapts to changes in the object count. The objects must be on the same hierarchy level below the parent null.

Share this post


Link to post
Share on other sites

Thanks David!

 

This certainly works. I don't want to be ungrateful and I really appreciate your COFFEE expression in the xpresso setup but I don't even know where to begin with COFFEE. I couldn't write that expression on my own as I don't truly understand what's happening. Nor do I have any knowledge of COFFEE. I would like to be able to reproduce this setup on my own, if possible.

 

Is there a way to do this with just xpresso?

 

It seems like if I could figure out a way to incrementally increase a value by 1 based on conditions, I could get this to work. Let's say I have 3 inputs on a condition node. If I could start the switch at 0 and then when the velocity of the particle is equal to 0 add a value of 1 to the switch and then it would switch to a different input. I could set this up with compare and bool nodes but I don't know how to turn a math function on or off. It also seems like I could do the same with a hierarchy node by increasing the maximum iterations one by one. Which I believe is essentially what you did by using a COFFEE node/expression to define everything.

 

Attached my scene file to show how far I'm getting on my own. Again, I really appreciate you taking the time to help me out and certainly not trying to buck your generosity . . . just want to learn a bit so I can do this on my own the next time :) Cheers!

 

https://docs.google.com/open?id=0ByisW6OXOLfYSGRTRnRDelRlTWM

Share this post


Link to post
Share on other sites

I am not sure what your final setup should do,

because it's an awkward approach but nevertheless a nice challenge.

 

Here's a xpresso setup which does what you want, it utilizes

a Monoflop nodes count output which goes up one higher everytime

it's triggered. The new nodes are colored for better clarity.

http://dl.dropbox.com/u/28253825/SwitchExample_yader.c4d

Edited by tezuka

Share this post


Link to post
Share on other sites

Awesome! Thankyou tezuka! I really appreciate your help. That's exactly what I wanted to do. I'm learning a lot from both these examples provided by you and David. I have a couple questions for you: 1) I'm sure it's right in front of me but how do you change the color of the nodes? 2) When you say it's an awkward approach, what do you mean exactly? My expresso set up or the technique to achieve the desired effect?

 

Thanks again!

Share this post


Link to post
Share on other sites

1. The color is in the basic tab of every node

2. The technique to achieve the desired effect :-)

Did you try the Follow Position node?

Then you could just cycle through the follow positions instead of objects in the Gravity node.

And if it's really only one particle at a time, I would use an Align To Spline with a couple of Mosplines

and no TP at all.

Edited by tezuka

Share this post


Link to post
Share on other sites

- cool stuff David, that node goes straight into my Presets.

- funny abuse of the Monoflop, Derya.

 

Interesting little challenge indeed.

Let's add another option..

 

To me, dealing with events/counters in xpresso is always kind of a struggle.

Most often I end up incrementing a PSR Parameter on a dummy Object or, like in the attached example, a User Data.

 

I also used a Deflector to stop the Particles, switching PGroups and a velocity2speed-formula.

Maybe there's something useful in there.

 

http://www.mediafire.com/?u81v9h81x4vzru8

 

cheers,

d

Edited by douwe

Share this post


Link to post
Share on other sites

Tezuka, I did try the follow position node but for whatever reason it didn't seem to be as accurate as using PGravity nodes and cranking up the strength. The reason I started using this technique is because I need to animate a lot of these at once. I need lines growing out of a point one by one connecting to other points. And I need lots of points to be growing lines. I wanted to figure out a way to automate the effect without having to key frame/draw a ton of splines. I haven't used the MoSpline object very much but from what I can gather there doesn't seem to be a better way to do the same thing with MoSplines?

 

douwe, you're the man! Thanks for that example! That helped me out a lot too. I don't quite understand all of it though. I don't understand why you are passing particle group.1 into another PGroup--group.2 and turning it on when the compare nodes output true. Furthermore, I don't understand why the effect doesn't work when I disconnect that PGroup node for Group 2 because as far as I can tell PGroup.2 isn't passing/affected by any other nodes . . . could you help me understand what is going on there?

 

Cheers guys!

Share this post


Link to post
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.

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.

Sign in to follow this  

×
×
  • Create New...