Adding points with normal direction and up vector

   9885   2   1
User Avatar
Member
5 posts
Joined: 3月 2008
Offline
Hi,

I guess I am missing something obvious, but I am new to Houdini and didn´t find a working solution so far.
I have a circle, added normal and up attributes with help of an attribute wrangle. When using Copy to points, the duplicated geometry is aligned properly.
Instead of just duplicating one object per point, I wanted to duplicate several per point, number according to a certain attribute (in the example I just used @ptnum).
To do so I used an attribute wrangle with a for loop, @ptnum defining the number of iterations:
int zaehler = 1 ;
int ende = int(@ptnum + 1) ;
for (zaehler = 1; zaehler<ende; zaehler++)
{
    addpoint(0 , @P+@N*ch("abstand")*zaehler);
//    setpointattrib(0, “N”, ????, @N);
}

And this basically works, just with one problem - the geometry is not aligned properly (apart from the geometry that is copied to the first “original” points of the circle).
I did not find a way to set the orientation - basically the new point(s) just would have to take the same orientation as the according point of the circle already has.

Thanks in advance!

P.S Probably there is a better way to produce something like that, like nested Copy nodes, but it seems like I can´t drive the number parameter of the Copy node with an attribute

Attachments:
test.hiplc (517.7 KB)
test.jpg (267.0 KB)

User Avatar
Member
900 posts
Joined: 2月 2016
Offline
Problem is that you create new points in the wrangle, but you don't set any N for them. So by default they will get a N = (0,0,0).

That's why only the first ring of instances has correct orientation.

If you want to set an attribute after you just created a point in a wrangle you have to reference that new point. So better if you assign a variable to it.

int newpoint = addpoint(0, position)
setpointattrib(0, “N”, newpoint, @N);


then you set the upvector for all the points, which houdini reads as default with @up;
add a new wrangle with following line:
@up = set(0,0,1);
Edited by Andr - 2018年11月6日 15:30:55
User Avatar
Member
5 posts
Joined: 3月 2008
Offline
thanks!
As this was my first post, it took a while until it was approved. So almost during sleep I was struck by an insight ;-)
What I did not fully understand was the part, that addpoint not only creates a new point, but also returns the “index” of this point.
So with that in mind I was finally able to remove the question marks from my setpointattrib line.
And comparing that to your answers shows, that this solution seems to be legit.

Thanks Andr!
  • Quick Links