I'll try to explain what I mean:
I'm finding myself needing the distance between two points over and over again so I want to create myself a DA for this.
So I would like to store the two points I want to meassure in a gruop and append an AttribCreate SOP. The value for that AttribCreate is supposed to be the distance() expression. This expression needs the x,y,z values of both points so it would be fine if there would be some expression that lets me read out the vector for each component of the group, something like group1.P, group1.P, … and so on. Is that possible or am I thinking in a completely wrong direction?
Expression for reading group indexes individually?
5139 13 0- anon_user_21411066
- Member
- 210 posts
- Joined: Jan. 2014
- Offline
- pezetko
- Member
- 387 posts
- Joined: Nov. 2008
- Offline
Use attrib wrangle, add Blast sop before it and into Blast's Group parameter fetch two selected points (e.g. via Group SOP or directly by their numbers) and in wrangle just compute distance between them like this:
vector p0 = point(0, “P”, 0);
vector p1 = point(0, “P”, 1);
@dist = length(p0 - p1);
This code computes distance between point with index 0 and point with index 1. So if you don't want to use Blast you had to specify point indices directly.
(Or it is possible to iterate over all points, check if they are in group and if do then use them - but ingroup() vex function works in PointWrangel not in AttribWrangle))
Edited to be more specific.
vector p0 = point(0, “P”, 0);
vector p1 = point(0, “P”, 1);
@dist = length(p0 - p1);
This code computes distance between point with index 0 and point with index 1. So if you don't want to use Blast you had to specify point indices directly.
(Or it is possible to iterate over all points, check if they are in group and if do then use them - but ingroup() vex function works in PointWrangel not in AttribWrangle))
Edited to be more specific.
Edited by - April 12, 2014 18:15:25
- anon_user_21411066
- Member
- 210 posts
- Joined: Jan. 2014
- Offline
Ok, thanks so far that looks a little more straight forward then my attempt. The attribute dist gets created but no matter how far appart these points are, the details view shows me that the returned value is always 1. Is there anything else I have to take care of?
Since this is VEX shouldn't this then also be able in a VOP SOP? Just because I would like to have some practice in VOPs too.
Since this is VEX shouldn't this then also be able in a VOP SOP? Just because I would like to have some practice in VOPs too.
- pezetko
- Member
- 387 posts
- Joined: Nov. 2008
- Offline
Sorry, I forgot that point function takes point exactly by indicies, so in the example above it always calculates distance between points with indices 0 and 1.
So change the indices directly in vex code (third parameter in point function) or keep the code as it is and put Blast SOP before attribwrangle and set your Group parameter there. That way you isolate points.
I added example file
So change the indices directly in vex code (third parameter in point function) or keep the code as it is and put Blast SOP before attribwrangle and set your Group parameter there. That way you isolate points.
I added example file
- anon_user_21411066
- Member
- 210 posts
- Joined: Jan. 2014
- Offline
- pezetko
- Member
- 387 posts
- Joined: Nov. 2008
- Offline
- anon_user_21411066
- Member
- 210 posts
- Joined: Jan. 2014
- Offline
Ah ok, I missed that my group SOP was set to prims it's working now, I appreciate
This trick with deleting the rest of the geometry and just feed in the two necessary points should work with VOP SOPs as well, shouldn't it? So I have a geometry with just two points in my VOP SOP and there is a distance VOP that takes two inputs for the two points, of course. But how do I use the two points in a VOP SOP individually? I would just like to get a bit more familiar with VOP SOPs or VOPs in general.
This trick with deleting the rest of the geometry and just feed in the two necessary points should work with VOP SOPs as well, shouldn't it? So I have a geometry with just two points in my VOP SOP and there is a distance VOP that takes two inputs for the two points, of course. But how do I use the two points in a VOP SOP individually? I would just like to get a bit more familiar with VOP SOPs or VOPs in general.
- pezetko
- Member
- 387 posts
- Joined: Nov. 2008
- Offline
- anon_user_21411066
- Member
- 210 posts
- Joined: Jan. 2014
- Offline
- eetu
- Member
- 606 posts
- Joined: May 2007
- Offline
- anon_user_21411066
- Member
- 210 posts
- Joined: Jan. 2014
- Offline
- eetu
- Member
- 606 posts
- Joined: May 2007
- Offline
- Platon
- Member
- 99 posts
- Joined: July 2007
- Offline
- anon_user_21411066
- Member
- 210 posts
- Joined: Jan. 2014
- Offline
eetu
Now just drag it to the shelf and you can just press a button to insert it in any scene.
Creating DAs is something I have to look up again. There are many things you can set up and since is my first one I'm not quite familiar with this process. Especially in regards of where to save it to. But that's probably the least problem.
-
- Quick Links