Houdini 11 VEX VEX functions

Returns a handle to a point cloud file.

Overview

  1. int pcopen(string filename, string Pchannel, vector P, float radius, int maxpoints)

  2. int pcopen(string filename, string Pchannel, vector P, string Nchannel, vector N, float radius, int maxpoints)

  3. int pcopen(string filename, string channel, int shaded)

This function opens a point cloud file (.pc) and queues up access to the points contained in it. You can then iterate over the points with pcunshaded or pciterate.

The first two versions of this function queue up points centered around a certain location P within radius, based on point positions found in Pchannel. Only the maxpoints closest points within the given radius will be queued. The file name may use the op: syntax to reference SOP geometry in the OP contexts. The Pchannel parameter indicates the channel in the texture which contains the positions to be searched. Pchannel will be made read-only if it is not already. Any subsequent attempts to use the channel with pcexport or pcunshaded will fail. Optionally, the Nchannel specifies a direction channel and the N vector specifies a search direction. Only points which are pointed in the same direction (i.e. dot(N, Npoint) > 0) will be queued.

In some cases you may need to add additional channels to a point cloud. You can do this by using pcexport and pcunshaded. Often, you will not need to add extra channel data to every point in the point cloud (for example, if only part of the point cloud is inside the camera’s frustum). In these cases, it is best to only add channel data to points returned by a proximity query. However, sometimes all points in a point cloud must receive extra channel data before meaningful queries can be made (for example, when adding a position channel). In these cases, the third version of this function can be used to queue up all shaded (shaded != 0) or unshaded (shaded == 0) points of a certain channel, channel. If channel does not exist, all points will be queued. This function, unlike the first two, does not lock channel.

You can specify an additional string parameter "prefix", with the next parameter being a channel prefix string, used to reference tiled block files.

Note

The preload option loads the entire point cloud into memory. Disabling this option will cause it to use a tile cache.

Example: Proximity Query

int handle = pcopen(texturename, "P", P, maxdistance, maxpoints);
while (pcunshaded(handle, "irradiance"))
{
   pcimport(handle, "P", cloudP);
   pcimport(handle, "N", cloudN);
   ir = computeIrraciance(cloudP, cloudN);
   pcexport(handle, "irradiance", ir);
}
pcfilter(handle, radius, "irradiance", ir);

Example: Shading An Entire Channel

vector sample;
int rval, handle;

handle = pcopen(texturename, "P", 0);
while (pcunshaded(handle, "P"))
{
   sample = set(nrandom("qstrat"), nrandom("qstrat"), 0.0);
   rval = sample_geometry(
      sample, sample, Time,
      "scope", getobjectname(),
      "pipeline", "displacement",
      "P", pos);
   if (rval)
      rval = pcexport(handle, "P", pos);
}
pcclose(handle);

On this page

Contexts: all

Related topics