Hello together,
I am working through a H13 tutorial at the moment and it's using the old point sops frequently.
Most of them I could easily replace with an attribute wrangle but there is one that keeps fighting against me.
After a sort the point sop is coloring a 2D area with an Add Color and the expression 1-$PT/$NPT which makes the point in the center a clear red and the points at the border and farthest away almost black.
I tried this with the wrangle but to no success. I assumed it would have to look like this:
@Cd = set(@elemnum/@npt,0,0);
Since I am fearly new to houdini I look forward to any advise.
Regards
Dave
Replacing old point sops with wrangles
5008 4 1- David_Kahl
- Member
- 15 posts
- Joined: Dec. 2016
- Offline
- neil_math_comp
- Member
- 1743 posts
- Joined: March 2012
- Offline
$NPT coresponds with @numpt, and $PT corresponds with @ptnum (or @elemnum, as you found, when Run Over is set to Points).
Writing code for fun and profit since... 2005? Wow, I'm getting old.
https://www.youtube.com/channel/UC_HFmdvpe9U2G3OMNViKMEQ [www.youtube.com]
https://www.youtube.com/channel/UC_HFmdvpe9U2G3OMNViKMEQ [www.youtube.com]
- David_Kahl
- Member
- 15 posts
- Joined: Dec. 2016
- Offline
Thanks for the answer.
The solution was something else. I tried @ptnum and @numpt but since it did't work I thought they were wrong.
Silly me tried this: @Cd.x = 1 - @ptnum/@numpt;
Which looks right but will not work because of int -> float.
I needed to do this:
float val1 = @ptnum;
float val2 = @numpt;
@Cd.x = 1 - val1/val2;
Regards
Dave
The solution was something else. I tried @ptnum and @numpt but since it did't work I thought they were wrong.
Silly me tried this: @Cd.x = 1 - @ptnum/@numpt;
Which looks right but will not work because of int -> float.
I needed to do this:
float val1 = @ptnum;
float val2 = @numpt;
@Cd.x = 1 - val1/val2;
Regards
Dave
- neil_math_comp
- Member
- 1743 posts
- Joined: March 2012
- Offline
Oh, right! I should have thought to mention that. Expressions don't use integers for evaluation, but VEX does, when applicable. You can shorten it to:
@Cd.x = 1 - float(@ptnum)/@numpt;
It will automatically convert @numpt to a float, because it's dividing a float. Vice versa works too.
@Cd.x = 1 - float(@ptnum)/@numpt;
It will automatically convert @numpt to a float, because it's dividing a float. Vice versa works too.
Writing code for fun and profit since... 2005? Wow, I'm getting old.
https://www.youtube.com/channel/UC_HFmdvpe9U2G3OMNViKMEQ [www.youtube.com]
https://www.youtube.com/channel/UC_HFmdvpe9U2G3OMNViKMEQ [www.youtube.com]
- patrickkrebs
- Member
- 4 posts
- Joined: Aug. 2006
- Offline
-
- Quick Links