Follyx Posted January 22, 2016 Share Posted January 22, 2016 (edited) is this right?If I create a normal and define just one point, Houdini assume that the other is selected at {0,0,0}?And is this valid for polylines and other objects too?And how can I reverse a normal and a polyline in an attribwrangle? Edited January 22, 2016 by Follyx Quote Link to comment Share on other sites More sharing options...
f1480187 Posted January 23, 2016 Share Posted January 23, 2016 (edited) 1. Yes, some "default" values will be assigned to points outside selection. If you haven't created an attribute with specified default value, most of the time it will be zeros. There is some special defaults for attributes like in id, where 0 is a normal value for first enumerated element, so, default here should be -1 to avoid collisions. If you create id by wrangling over subset of points, default for all other points will be -1. From my experience, all "known" special defaults assigned to same set of attributes with "assumed datatypes", for which we can write @P in a very first time in code, without need to specify it's type. Here the full list of them. Most of them still logically have defaults of zeros, however. // Assumed integer with default of -1, a special attribute. @id = @ptnum; // Float with default of 0.0 because we didn't specify a type. @my_id1 = @ptnum; // Integer with default of 0. i@my_id2 = @ptnum; @my_id2 = @ptnum+10000; // No need to specify type again. i@my_id2 = @ptnum; // But nobody said we can't. // Declare and assign custom attribute like @id. int @my_id3 = -1; @my_id3 = @ptnum; 2. For reversing part. Primitive Wrangle: // To reverse vertex numbers per polygon, like in Reverse SOP. int pts[] = primpoints(0, @primnum); foreach (int i; int pt; reverse(pts)) { setprimvertex(0, @primnum, i, pt); } // To reverse point numbers per polygon. int pts[] = primpoints(0, @primnum); foreach (int i; int pt; reverse(pts)) { removepoint(0, pts[i]); setprimvertex(0, @primnum, i, addpoint(0, pt)); } // To reverse point positions per polygon. int pts[] = primpoints(0, @primnum); foreach (int i; int pt; pts) { vector pos = point(0, "P", pts[-i-1]); setpointattrib(0, "P", pts[i], pos); } To reverse like in Sort SOP use Detail Wrangle: // To reverse both point and primitive numbers. for (int ptnum = 0; ptnum < @numpt; ptnum++) { removepoint(0, ptnum); addpoint(0, @numpt - (ptnum + 1)); } for (int primnum = 0; primnum < @numprim; primnum++) { int pts[] = primpoints(0, primnum); foreach (int i; int pt; reverse(pts)) { setprimvertex(0, primnum, i, @numpt + pt); } } // To reverse point numbers. for (int ptnum = 0; ptnum < @numpt; ptnum++) { removepoint(0, ptnum); addpoint(0, @numpt - (ptnum + 1)); } for (int primnum = @numprim - 1; primnum >= 0; primnum--) { int pts[] = primpoints(0, primnum); int newprim = addprim(0, "polyline"); removeprim(0, primnum, false); foreach (int i; int pt; reverse(pts)) { addvertex(0, newprim, @numpt + pt); } } // To reverse primitive numbers. for (int primnum = @numprim - 1; primnum >= 0; primnum--) { int pts[] = primpoints(0, primnum); int newprim = addprim(0, "polyline"); removeprim(0, primnum, false); foreach (int pt; pts) { addvertex(0, newprim, pt); } } To reverse vector, just negate it: @N = -@N. reverse.hipnc Edited January 23, 2016 by f1480187 2 Quote Link to comment Share on other sites More sharing options...
Follyx Posted January 26, 2016 Author Share Posted January 26, 2016 Perfect, thanks a lot.What could I wish more from an answer... Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.