Set attribute from @Frame, and hold that value
13096 12 2- Max Rose
- Member
- 77 posts
- Joined: 10月 2018
- Online
Simple problem, cannot find the solution.
I need to set an attribute based on the current frame, something like this:
if(@Cd.r >= 0.9){
f@t = @Frame;
}
…and I need @t to hold that value, and not change along with the current frames.
Why I need this: I'm trying to control the offset of animated instances (using “instancefile”) by starting the animation once @Cd.r passes a certain threshold. Once the animation starts, the counter for that specific instanced object needs to start at 0, and increase along with the time slider.
Any idea on how to do this?
I need to set an attribute based on the current frame, something like this:
if(@Cd.r >= 0.9){
f@t = @Frame;
}
…and I need @t to hold that value, and not change along with the current frames.
Why I need this: I'm trying to control the offset of animated instances (using “instancefile”) by starting the animation once @Cd.r passes a certain threshold. Once the animation starts, the counter for that specific instanced object needs to start at 0, and increase along with the time slider.
Any idea on how to do this?
- Tyler Britton2
- Member
- 85 posts
- Joined: 4月 2014
- Offline
This can easily be done. If you have all your points black, then color your points when you want them to start their animation, you can then throw down a sop solver, inside the solver, add a wrangle node and this expression below.
//Inside sop solver with Previous Frame being Input
vector Cd1 = point(1, “Cd”, @ptnum);
vector Cd2 = point(0, “Cd”, @ptnum);
@Cd = max(Cd1, Cd2);
if (Cd1 == 0 && Cd2 == 1)
i@hitframe = int(@Frame);
if (point(1, “hitframe”, @ptnum) != 0)
@hitframe = point(1, “hitframe”, @ptnum);
Just be sure to put the Previous Frame into input (second input on the wrangle). This script will record the frame that the point turns from black, to white. If you time shift to the end of the sop solver sim, and then transfer the hitframe attribute back into your original points, then that should get you started.
//Inside sop solver with Previous Frame being Input
vector Cd1 = point(1, “Cd”, @ptnum);
vector Cd2 = point(0, “Cd”, @ptnum);
@Cd = max(Cd1, Cd2);
if (Cd1 == 0 && Cd2 == 1)
i@hitframe = int(@Frame);
if (point(1, “hitframe”, @ptnum) != 0)
@hitframe = point(1, “hitframe”, @ptnum);
Just be sure to put the Previous Frame into input (second input on the wrangle). This script will record the frame that the point turns from black, to white. If you time shift to the end of the sop solver sim, and then transfer the hitframe attribute back into your original points, then that should get you started.
- patrickbaiti
- Member
- 11 posts
- Joined: 6月 2018
- Offline
Could you maybe share a .hip file with this Code working? I copied it into a SopSolver but it @hitframe is 0 at any Time. And I don't know what I'm doing wrong.
I'm transfering a color from a sphere on to a grid and I want to grap an attribute whixh holds the value of the Frame when the color change happend.
I'm transfering a color from a sphere on to a grid and I want to grap an attribute whixh holds the value of the Frame when the color change happend.
- Alexander_Nguyen
- Member
- 21 posts
- Joined: 1月 2018
- Offline
- patrickbaiti
- Member
- 11 posts
- Joined: 6月 2018
- Offline
- Alexander_Nguyen
- Member
- 21 posts
- Joined: 1月 2018
- Offline
- patrickbaiti
- Member
- 11 posts
- Joined: 6月 2018
- Offline
- Alexander_Nguyen
- Member
- 21 posts
- Joined: 1月 2018
- Offline
Dante Never Crypatrickbaiti
Could you explain me what this should change @born is still accumulating with each Frame. I feel super stupid that I have such a big problem with such a small thing.
Here you are xD
https://www.youtube.com/watch?v=8CrVp5CyR5s&list=PLzRzqTjuGIDhiXsP0hN3qBxAZ6lkVfGDI&index=20&ab_channel=JunichiroHorikawaJunichiroHorikawa [www.youtube.com]
https://www.sidefx.com/docs/houdini/nodes/sop/solver.html [www.sidefx.com]
- patrickbaiti
- Member
- 11 posts
- Joined: 6月 2018
- Offline
I am very familiar with the Node and how it works that's the reason why it is so frustrating right now that I can not figure out what I'm doing wrong to stop the accumulation. and the line of Code: @born += 0.1 won't change that.
I Don't understand why I can not transfer the concept you shared in the .hip file to work with the transfer of color.
I Don't understand why I can not transfer the concept you shared in the .hip file to work with the transfer of color.
- patrickbaiti
- Member
- 11 posts
- Joined: 6月 2018
- Offline
- Alexander_Nguyen
- Member
- 21 posts
- Joined: 1月 2018
- Offline
- patrickbaiti
- Member
- 11 posts
- Joined: 6月 2018
- Offline
- Alexander_Nguyen
- Member
- 21 posts
- Joined: 1月 2018
- Offline
patrickbaitiMy skill english not good . How can i say with you ..hmm.
Wow it finally workes thank you a lot for your Time. But why does it not work if you want to use the color as you selection option?
It's okay if you want to use Cd attribute . But just make sure the value ( like @born in your setup ) not increse if it's no have impact by attrib transfer .
Edited by Alexander_Nguyen - 2021年5月14日 08:59:53
-
- Quick Links