Showing posts with label detail. Show all posts
Showing posts with label detail. Show all posts

Friday, 6 January 2023

doing things to for each sop loops

 

How to get information about the current loop

Sometimes you need to use the current loop or the current piece number in an expression on one of the nodes in the same loop. You can get this information with a  Block Begin SOP node that uses the Fetch Metadata method.

  1. Set up a looping block using the instructions above.

  2. Select the  Block Begin SOP node, and then in the Parameter Editor click Create Meta Import Node.

    This button adds a second Block Begin SOP node to the side of the existing one. This node is set up to generate an empty geometry with some detail attributes.

    The detail attributes are as follows:

    numiterations

    The expected total number of iterations, taking into account the Max Iterations and Single Pass parameters on the  Block End SOP node of the loop.

    iteration

    The current iteration number, always starting at 0 and increasing by 1 each loop.

    value

    In piecewise loops, this is the current value of the attribute. For example, the piece integer or name string, or if there is no attribute, the current point or primitive number.

    In simple repetition loops, this is a floating point value starting at the Block End SOP’s Start Value and increasing by the specified Increment each loop.

    ivalue

    In simple repetition, this is an integer version of value. This can be useful if the value is naturally an integer (for example, starts at 1 and increments by 2) and/or if values are over 24 million (where floating point numbers lose precision).

  3. To grab the value of these attributes in a node inside the loop, do the following:

Friday, 12 April 2019

Select a random point from a group each frame

Some code snippets from Walter to use points from a group randomly, for emission (or other things)

In a Detail Attribute Wrangle-

int npts = npoints(0);
float keep = rand(@Time + 235.624) * npts;
i@keep = int(keep);

Every time step, a random point id is chosen as the "keep" point.

Then in a blast, we kill everything but the kept point

`detail(0, "keep", 0)`

Don't forget to invert the blast selection