XYZ Function
7222 10 2- _Christopher_
- Member
- 767 posts
- Joined: April 2014
- Offline
- sepu
- Member
- 420 posts
- Joined: Feb. 2012
- Online
- _Christopher_
- Member
- 767 posts
- Joined: April 2014
- Offline
- malbrecht
- Member
- 806 posts
- Joined: Oct. 2016
- Offline
Moin,
> What closest point, any point the center of the object point ?
the documentation actually explains it quite well: What you get back is the index of the primitive that is closest to the point in space that you specified PLUS the UV coordinate on that primitive. So you get both - a rough aproximation “this'll be the primitive you want to handle” and a fine grained detail of where the ray from your point to that primitive hits the later.
Functions like this are used to e.g. cut geometry by creating new polygons (Houdini speak “primitives”) inside the one you are “hitting”, e.g. when intersecting or creating your own boolean operations.
One simple way to use this is to have a “laser gun beam” emitting from your point in space towards the (rotating) geometry, setting a pixel on the diffuse/emission texture to red/yellow/white where the “closest point on UV” is defined. Laser-glow-effect done easy
Marc
> What closest point, any point the center of the object point ?
the documentation actually explains it quite well: What you get back is the index of the primitive that is closest to the point in space that you specified PLUS the UV coordinate on that primitive. So you get both - a rough aproximation “this'll be the primitive you want to handle” and a fine grained detail of where the ray from your point to that primitive hits the later.
Functions like this are used to e.g. cut geometry by creating new polygons (Houdini speak “primitives”) inside the one you are “hitting”, e.g. when intersecting or creating your own boolean operations.
One simple way to use this is to have a “laser gun beam” emitting from your point in space towards the (rotating) geometry, setting a pixel on the diffuse/emission texture to red/yellow/white where the “closest point on UV” is defined. Laser-glow-effect done easy
Marc
---
Out of here. Being called a dick after having supported Houdini users for years is over my paygrade.
I will work for money, but NOT for "you have to provide people with free products" Indie-artists.
Good bye.
https://www.marc-albrecht.de [www.marc-albrecht.de]
Out of here. Being called a dick after having supported Houdini users for years is over my paygrade.
I will work for money, but NOT for "you have to provide people with free products" Indie-artists.
Good bye.
https://www.marc-albrecht.de [www.marc-albrecht.de]
- _Christopher_
- Member
- 767 posts
- Joined: April 2014
- Offline
malbrecht - I assume the vector pt can be as simple as a point, or a point on another geometric object ?
What values must be entered for these arguments ?
uv
The uv coordinates the closest primitive. The primuv function can be used to evaluate attributes at that location.
maxdist
The maximum distance to search. The operation can be sped up if it is allowed to quit early.
What values must be entered for these arguments ?
【T】【C】【S】
- malbrecht
- Member
- 806 posts
- Joined: Oct. 2016
- Offline
Moin, Christopher,
> malbrecht - I assume the vector pt can be as simple as a point, or a point on another geometric object ?
I would think so, as a “point” in Houdini usually mostly only refers to a position in space. You will obviously have to *define* the point
> What values must be entered for these arguments ?
I am not 100% sure what you mean by that question - the maximum distance is *the* *maximum* *distance* the ray that is getting cast from the “check point” towards the geometry is allowed to intersect with the geometry.
Although I don't know the algorithm used in Houdini, usually you have to walk through all primitives in a given geometry and check if there are other primitives between the one you are testing and your point (and if other vertices' point positions may be closer), so you, eventually, have to check *a* *lot* of primitives, which can be slow. By limiting the ray length, the algorithm can do a simple bounding box check to filter out all primitives that are not to be checked, possibly speeding up the whole process by magnitudes.
And the UV coordinates are *the* *UV* *coordinates*, meaning the “position” on the UV map for the primitive being returned (by its index based on the geometry you provided), by using the UV coordinates you get the “point in space” (with the primitive's UV origin being the local 0/0/0) where your ray hits the primitive.
Note: This is based on “common sense understanding” on how functions like this usually work, I assume they work the same in Houdini.
When in doubt, try it out
Marc
> malbrecht - I assume the vector pt can be as simple as a point, or a point on another geometric object ?
I would think so, as a “point” in Houdini usually mostly only refers to a position in space. You will obviously have to *define* the point
> What values must be entered for these arguments ?
I am not 100% sure what you mean by that question - the maximum distance is *the* *maximum* *distance* the ray that is getting cast from the “check point” towards the geometry is allowed to intersect with the geometry.
Although I don't know the algorithm used in Houdini, usually you have to walk through all primitives in a given geometry and check if there are other primitives between the one you are testing and your point (and if other vertices' point positions may be closer), so you, eventually, have to check *a* *lot* of primitives, which can be slow. By limiting the ray length, the algorithm can do a simple bounding box check to filter out all primitives that are not to be checked, possibly speeding up the whole process by magnitudes.
And the UV coordinates are *the* *UV* *coordinates*, meaning the “position” on the UV map for the primitive being returned (by its index based on the geometry you provided), by using the UV coordinates you get the “point in space” (with the primitive's UV origin being the local 0/0/0) where your ray hits the primitive.
Note: This is based on “common sense understanding” on how functions like this usually work, I assume they work the same in Houdini.
When in doubt, try it out
Marc
---
Out of here. Being called a dick after having supported Houdini users for years is over my paygrade.
I will work for money, but NOT for "you have to provide people with free products" Indie-artists.
Good bye.
https://www.marc-albrecht.de [www.marc-albrecht.de]
Out of here. Being called a dick after having supported Houdini users for years is over my paygrade.
I will work for money, but NOT for "you have to provide people with free products" Indie-artists.
Good bye.
https://www.marc-albrecht.de [www.marc-albrecht.de]
- _Christopher_
- Member
- 767 posts
- Joined: April 2014
- Offline
- _Christopher_
- Member
- 767 posts
- Joined: April 2014
- Offline
- mestela
- Member
- 1742 posts
- Joined: May 2006
- Offline
Here's an example I knocked up, might be useful.
xyzdist can answer a few questions:
-whats the distance to the closest primitive to a given position?
-whats the primnum of that primitive?
-whats the closest uv on that prim?
Once you get that info, you can then query other things like the colour of that prim, and the exact worldspace position of that closest point.
Here I generate a point that shows where that closest position on the closest primitive is, generate a line from the original point to that closest point, and create a wireframe sphere that scales itself exactly to have its center on the target prim, and its radius on the original point, as well as colouring itself to match the closest prim.
xyzdist can answer a few questions:
-whats the distance to the closest primitive to a given position?
-whats the primnum of that primitive?
-whats the closest uv on that prim?
Once you get that info, you can then query other things like the colour of that prim, and the exact worldspace position of that closest point.
Here I generate a point that shows where that closest position on the closest primitive is, generate a line from the original point to that closest point, and create a wireframe sphere that scales itself exactly to have its center on the target prim, and its radius on the original point, as well as colouring itself to match the closest prim.
- _Christopher_
- Member
- 767 posts
- Joined: April 2014
- Offline
- mestela
- Member
- 1742 posts
- Joined: May 2006
- Offline
Most functions in vex assign to a variable, eg
result = pow(3,10);
Pow will raise 3 to the power of 10, and store it in the variable ‘result’ (lets assume I defined it earlier).
Other functions don't work this way, and store the result directly in one of the arguments. Eg:
matrix m = ident();
rotate(m, 0.2, {0,1,0});
That will rotate the matrix m 0.2 radians around the y axis. Note that it doesn't take the form
m = rotate(m, 0.2, {0,1,0});
The clue is if you look in the docs, the argument is preceded by an & symbol.
For xyzdist, the idea is to give it a position, and it will return the distance to the closest prim, the id of that prim and the closest uv position of that prim. Look at the definition, you can see that prim and uv are preceded by ampersands. That means they're not really input arguments, but placeholders to accept the found prim and found uv.
xyzdist is made more confusing because one of the results, distance, is returned in the regular way. But not that much more confusing.
If you're wanting to find the distance to a specific prim or a specific uv position of a specific prim, then xyzdist is not the function to do that.
result = pow(3,10);
Pow will raise 3 to the power of 10, and store it in the variable ‘result’ (lets assume I defined it earlier).
Other functions don't work this way, and store the result directly in one of the arguments. Eg:
matrix m = ident();
rotate(m, 0.2, {0,1,0});
That will rotate the matrix m 0.2 radians around the y axis. Note that it doesn't take the form
m = rotate(m, 0.2, {0,1,0});
The clue is if you look in the docs, the argument is preceded by an & symbol.
For xyzdist, the idea is to give it a position, and it will return the distance to the closest prim, the id of that prim and the closest uv position of that prim. Look at the definition, you can see that prim and uv are preceded by ampersands. That means they're not really input arguments, but placeholders to accept the found prim and found uv.
xyzdist is made more confusing because one of the results, distance, is returned in the regular way. But not that much more confusing.
If you're wanting to find the distance to a specific prim or a specific uv position of a specific prim, then xyzdist is not the function to do that.
-
- Quick Links