Showing posts with label useful. Show all posts
Showing posts with label useful. Show all posts

Tuesday, 2 October 2018

emitting only 1 particle per point per frame


Obviously stole this from ODforce:

if you want just 1 particle emitted per point at a given frame, the basic expression would be in the rate of the source node of your pop network
if you decide to put it in the impulse rate :
npoints(opinputpath("../",0))
and turning off the const. activation
if you decide to put it in the const rate
npoints(opinputpath("../",0))*$FPS
and turning off the impulse activation
don't forget to put the emission type to points(ordered) or you won't have a particle per point
this will hower emit the exact amount of points your emitter sop has per frame, so if your emitter has points that last 2 frames, you'll have 2 particles per point after 2 frames.


*Also, you could use $NPT/10 instead of npoints... Dunno if this works

When would you use this?
If you have a source which is changing point count each frame, eg, a pattern of cracks being animated (like when Godzilla is underneath a road)... 

I think the $FPS version helps when it comes to substeps etc like with Maya, where you need to divide the perframe emission to account for the substeps... 

The first option works well if you divide the emission count (just add a /10 or whatever after the expression)

Friday, 29 September 2017

connecting points again..


Here're two expanded ways of connecting groups of points together!




The first method relies on you creating an attribute in a preceding point wrangle called "id". This is the value you'll search for, when making connections. The "destination" points go into the first input, the origin points go into the second.

int count = findattribvalcount(1,"point","id",i@id);

for (int i = 0; i < count; i++) {
    int find = findattribval(1,"point","id",i@id,i);
    
    int prim = addprim(0,"polyline");
    
    vector p2 = point(1,"P",find);
    
    int pt = addpoint(0,@ptnum);
    setpointattrib(0,"P",pt,p2);
    
    addvertex(0,prim,@ptnum);
    addvertex(0,prim,pt);
}


LINE BY LINE

int count = findattribvalcount(1,"point","id",i@id);
//count number of points that have the "id" value
for (int i = 0; i < count; i++) {
//start for loop, for the number of points it has found
    int find = findattribval(1,"point","id",i@id,i);
    //get point number for point that has the id value. The last i is the index of the for loop.
    int prim = addprim(0,"polyline");
    //add primitive, of polyline type
    vector p2 = point(1,"P",find);
   //create position vector based on point number found 
    int pt = addpoint(0,@ptnum);
//create point at the position of current point
    setpointattrib(0,"P",pt,p2);
    //set position of just created point to the vector created
    addvertex(0,prim,@ptnum);
//add vertex to the primitive at current point position
    addvertex(0,prim,pt);
//add vertex to the primitive at found point position
}





This method doesn't need the "id" value, but just grabs the closest point to it. Again the many destinations go into the first input and the few "origins" go to the second.

int nearpt = nearpoint(1,@P);
int prim = addprim(0,"polyline");
vector p2 = point(1,"P",nearpt);
int pt = addpoint(0,@ptnum);
setpointattrib(0,"P",pt,p2);
addvertex(0,prim,@ptnum);
addvertex(0,prim,pt);


LINE BY LINE

int nearpt = nearpoint(1,@P);
//get id number of point from second input to currently processed point's position
int prim = addprim(0,"polyline");
//create primitive of polyline type
vector p2 = point(1,"P",nearpt);
//set vector to nearpt's position
int pt = addpoint(0,@ptnum);
//add point at currently processed point's position
setpointattrib(0,"P",pt,p2);
//set position of new point to position of nearpt.
addvertex(0,prim,@ptnum);
//add vertex at currently processed point's position
addvertex(0,prim,pt);
//add vertex at nearpt's position

Wednesday, 27 September 2017

writing alembics for maya - path attribute

Covered this in an older post, but this is for more straightforward cases when you want to define a group and shape node name for Maya purposes. We do this to avoid multiple shape names in Maya (eg. lots of pSphereShape1's or multiple Houdini Merge listings ; Alembic will take whatever the penultimate node to your ROP-alembic is called!)

In a primitive wrangle, this bit of code will create two text entry boxes, so you can input a group name and a shape name. If you were to call the group "squareGrp" and the name "square", then the resultant hierarchy would be "squareGrp/square/squareShape" in Maya.


string group = chs("MayaGroup");
string name = chs("Name");

group += chs("groupSuffix");
name += chs("geoSuffix");

s@path = group + '/' + name + '/' + name + 'Shape';


Remember to tick the "build hierarchy" box in the ROP-Alembic node & also to tick "use path".