Hi,
I am working on the tutorial PROCEDURAL LAKE VILLAGE VOLUME 1. In one section of the tutorial, the instructor uses pcopen() to evaluate points in a box and their distance to each other. This is the following code:
int pcloud = pcopen(0,“P”, @P, 2.1, 10);
if (pcnumfound(pcloud) < 5) {
removepoint(0, @ptnum);
}
However, pcloud is always 0. I did exactly what the instructor did. Can someone help?
pcopen() always returns 0
2273 3 0-
- seaweed
- Member
- 3 posts
- Joined: Aug. 2020
- Offline
-
- tamte
- Member
- 9380 posts
- Joined: July 2007
- Offline
adambeharthat sounds correct, you are opening just one pointcloud per point so it's handle id is 0
However, pcloud is always 0. I did exactly what the instructor did. Can someone help?
not sure what your expected behavior would be, but pcloud being 0 is not the issue
the code simply says, delete points which find less than 5 points within their 2.1 unit radius (since its sampling first input that includes the point itself)
Edited by tamte - Aug. 28, 2020 14:28:28
Tomas Slancik
CG Supervisor
Framestore, NY
CG Supervisor
Framestore, NY
-
- seaweed
- Member
- 3 posts
- Joined: Aug. 2020
- Offline
Yes, that's what I want. Here's what the instructor wrote on the Chinese website that I translated. When I run the code to just get the points in the center of the box. None of the points disappear. They all equal zero. They should be integers of 5 4 3. Why am I not getting the same result as the teacher with the same code??
One of Houdini's basic ideas for making procedural buildings is to transform the base geometry (Base Mesh) into a point cloud constraint (Point Cloud Constrain), and each point will be used as the center point of the newly generated geometry to determine its placement . The point cloud is made as shown below:
https://pic1.zhimg.com/v2-b039d9abec461dab372afffe6a702463_b.webp [pic1.zhimg.com]
Note that the point cloud converted by the volume of the geometry is messy, and we only need to use integer points. In the fourth step, we use a Wrangle node to write a simple rint expression to deal with redundant points and only keep integer points.
rint VEX function
Round the number to the nearest whole number.
float rint(float n)
Code:
@P.x = rint(@P.x/2)*2;
@P.y = rint(@P.y/3)*3;
@P.z = rint(@P.z/2)*2;
The code principle is as follows:
https://pic1.zhimg.com/80/v2-a0f0d6dd8cd40cf14956a271e6f0a659_1440w.jpg [pic1.zhimg.com]
After finishing, our point cloud should be as shown below:
https://pic4.zhimg.com/80/v2-153328b417c6246001332c8127a917c4_1440w.jpg [pic4.zhimg.com]
But the problem came again.
The point on the edge line is not qualified as the center point of the new geometry. The image below shows the strange combination you would get if you used these points:
https://pic1.zhimg.com/80/v2-fd84e178bc7329050849a189cbaa2fc6_1440w.jpg [pic1.zhimg.com]
The solution is to write a pcopen expression with another Wrangle node to deal with the points on the edge line.
pcopen VEX function
Based on the point positions found in Pchannel, the points are sorted from the nearest to the farthest centered on a certain position P within the radius.
Code:
int pcloud = pcopen(0,“P”, @P, 2.1, 10);
if (pcnumfound(pcloud) <5) {
removepoint(0, @ptnum);
}
Here we use each point in turn to draw a circle with a radius slightly larger than the grid (2x2 grid) at the center of the circle, and each point covered by the circle will be found and returned. It can be clearly seen that the number of points on the edge line returned due to insufficient neighboring points is less than 5. The principle is as shown in the figure:
https://picb.zhimg.com/80/v2-a6012ef4809b8dd9788407b3182b80c8_1440w.jpg [picb.zhimg.com]
https://pic4.zhimg.com/80/v2-41ee5c49f2001d97f8b535394d59d678_1440w.jpg [pic4.zhimg.com]
One of Houdini's basic ideas for making procedural buildings is to transform the base geometry (Base Mesh) into a point cloud constraint (Point Cloud Constrain), and each point will be used as the center point of the newly generated geometry to determine its placement . The point cloud is made as shown below:
https://pic1.zhimg.com/v2-b039d9abec461dab372afffe6a702463_b.webp [pic1.zhimg.com]
Note that the point cloud converted by the volume of the geometry is messy, and we only need to use integer points. In the fourth step, we use a Wrangle node to write a simple rint expression to deal with redundant points and only keep integer points.
rint VEX function
Round the number to the nearest whole number.
float rint(float n)
Code:
@P.x = rint(@P.x/2)*2;
@P.y = rint(@P.y/3)*3;
@P.z = rint(@P.z/2)*2;
The code principle is as follows:
https://pic1.zhimg.com/80/v2-a0f0d6dd8cd40cf14956a271e6f0a659_1440w.jpg [pic1.zhimg.com]
After finishing, our point cloud should be as shown below:
https://pic4.zhimg.com/80/v2-153328b417c6246001332c8127a917c4_1440w.jpg [pic4.zhimg.com]
But the problem came again.
The point on the edge line is not qualified as the center point of the new geometry. The image below shows the strange combination you would get if you used these points:
https://pic1.zhimg.com/80/v2-fd84e178bc7329050849a189cbaa2fc6_1440w.jpg [pic1.zhimg.com]
The solution is to write a pcopen expression with another Wrangle node to deal with the points on the edge line.
pcopen VEX function
Based on the point positions found in Pchannel, the points are sorted from the nearest to the farthest centered on a certain position P within the radius.
Code:
int pcloud = pcopen(0,“P”, @P, 2.1, 10);
if (pcnumfound(pcloud) <5) {
removepoint(0, @ptnum);
}
Here we use each point in turn to draw a circle with a radius slightly larger than the grid (2x2 grid) at the center of the circle, and each point covered by the circle will be found and returned. It can be clearly seen that the number of points on the edge line returned due to insufficient neighboring points is less than 5. The principle is as shown in the figure:
https://picb.zhimg.com/80/v2-a6012ef4809b8dd9788407b3182b80c8_1440w.jpg [picb.zhimg.com]
https://pic4.zhimg.com/80/v2-41ee5c49f2001d97f8b535394d59d678_1440w.jpg [pic4.zhimg.com]
-
- seaweed
- Member
- 3 posts
- Joined: Aug. 2020
- Offline
-
- Quick Links

