Replacing old point sops with wrangles

   5017   4   1
User Avatar
Member
15 posts
Joined: Dec. 2016
Offline
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
User Avatar
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]
User Avatar
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
User Avatar
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.
Writing code for fun and profit since... 2005? Wow, I'm getting old.
https://www.youtube.com/channel/UC_HFmdvpe9U2G3OMNViKMEQ [www.youtube.com]
User Avatar
Member
4 posts
Joined: Aug. 2006
Offline
Someone should let Rohan Dalvi know!

Points Node should change to Attribute Wrangle and input:

float val1 = @ptnum;
float val2 = @numpt;
@Cd.x = 1 - val1/val2;
@Cd.y = 0;
@Cd.z = 0;
Edited by patrickkrebs - Feb. 18, 2020 13:02:12
  • Quick Links