Arthur Spooner Posted April 3, 2016 Share Posted April 3, 2016 I'm going though some VEX function commands to understand, and I'm having a little difficulty understanding for example addprim. What I have thus far, v@gm = addprim(); The docs state int, is this a hard and fast rule if the docs state an integer I shouldn't be making a vector variable, rather a integer variable ? Adds a primitive to the geometry. int addprim(int geohandle, string type)Creates a primitive in the geometry specified by geohandle. The returned value is a primitive number that can be used with the setprimattrib to change the value of the primitive, but is not the final primitive number of the primitive. Types can be: poly: Closed polygon. polyline: Open polygon. Another command is neighbors, which returns an array of the point numbers of the neighbors of a point. Once again the docs state, integer with an empty array followed by int input, int ptnum, what must I enter for those values ? Must I select a point on the mesh ? Quote Link to comment Share on other sites More sharing options...
Atom Posted April 3, 2016 Share Posted April 3, 2016 I got a lot out of Ari Danish's video on VEX. http://www.sidefx.com/index.php?option=com_content&task=view&id=2512&Itemid=254 Quote Link to comment Share on other sites More sharing options...
Arthur Spooner Posted April 3, 2016 Author Share Posted April 3, 2016 That is what I'm watching and where my questions are coming from. Quote Link to comment Share on other sites More sharing options...
bonsak Posted April 3, 2016 Share Posted April 3, 2016 (edited) That must be a typo, it should be int like you wrote: i@gm = addprim(...) You could use a vector as all the components of the vector wuold be set to the same value when using: v@gm = addprim(...) but it would just get messy unless you need it for som especial case. This is how you declare an array attribute: i[]@mypoints = neighbours(0, @ptnum);If you want to declare a variable, go like this: int mypoints[] = neighbours(0, @ptnum); The example code in the docs: http://www.sidefx.com/docs/houdini15.0/vex/functions/neighbours is not correct:To work it needs to look something like this: int input = 0; //Just passing in some values for testing. 0 is the first input of the Wrangle node. int ptnum = 20; //Just passing in some values for testing int myarray[] = neighbours(input, ptnum); int i, n; int result[]; n = neighbourcount(input, ptnum); resize(result, n); for (i = 0; i < n; i++) { result[i] = neighbour(input, ptnum, i); } i[]@test = myarray; // Set Geo Spreadsheet to Detail to see the members of the array Put down a Grid and an Attribute Wrangle set to Detail to test. Change "ptnum" to set a different point. Hope this answers your questions. Cheers Bonsak Edited April 3, 2016 by bonsak Quote Link to comment Share on other sites More sharing options...
Arthur Spooner Posted April 3, 2016 Author Share Posted April 3, 2016 (edited) That must be a typo, it should be int like you wrote: i@gm = addprim(...) You could use a vector as all the components of the vector wuold be set to the same value when using: v@gm = addprim(...) but it would just get messy unless you need it for som especial case. This is how you declare an array attribute: i[]@mypoints = neighbours(0, @ptnum);If you want to declare a variable, go like this: int mypoints[] = neighbours(0, @ptnum); The example code in the docs: http://www.sidefx.com/docs/houdini15.0/vex/functions/neighbours is not correct:To work it needs to look something like this: int input = 0; //Just passing in some values for testing. 0 is the first input of the Wrangle node. int ptnum = 20; //Just passing in some values for testing int myarray[] = neighbours(input, ptnum); int i, n; int result[]; n = neighbourcount(input, ptnum); resize(result, n); for (i = 0; i < n; i++) { result[i] = neighbour(input, ptnum, i); } i[]@test = myarray; // Set Geo Spreadsheet to Detail to see the members of the array Put down a Grid and an Attribute Wrangle set to Detail to test. Change "ptnum" to set a different point. Hope this answers your questions. Cheers Bonsak That must be a typo, it should be int like you wrote: i@gm = addprim(...) How do I use addprim ? The docs state it createa a primitive in the geometry specified by geohandle ? This is how you declare an array attribute:i[]@mypoints = neighbours(0, @ptnum); The above code is starting from the first point then giving each point an id followed by storing that in an array called @mypoints ? Edited April 3, 2016 by Arthur Spooner Quote Link to comment Share on other sites More sharing options...
bonsak Posted April 3, 2016 Share Posted April 3, 2016 (edited) How do I use addprim ? The docs state it createa a primitive in the geometry specified by geohandle ? Very basic example would be like this: int prim = addprim(geoself(), "poly"); int pt1 = addpoint(geoself(), {0,0,0}); int pt2 = addpoint(geoself(), {0,0,1}); int pt3 = addpoint(geoself(), {1,0,1}); int pt4 = addpoint(geoself(), {1,0,0}); int vt1 = addvertex(geoself(), prim, pt1); // Actually no need to set the int like this, just old habbit. int vt2 = addvertex(geoself(), prim, pt2); int vt3 = addvertex(geoself(), prim, pt3); addvertex(geoself(), prim, pt4); // This works as well Put down a null inside a Geo and then attach a Attribute Wrangle set to Detail to see how it works. The above code is starting from the first point then giving each point an id followed by storing that in an array called @mypoints ? No it's returning the neighbouring points around the point you supply in @ptnum from the geo from input 1. -b Edited April 3, 2016 by bonsak Quote Link to comment Share on other sites More sharing options...
Arthur Spooner Posted April 3, 2016 Author Share Posted April 3, 2016 I created a torus, connected a null, followed by a point wrangler, inserted the code, got a plane, sounds correct ? How do I know what to make a int, v etc in Houdini ? Breaking this line of code down; int prim = addprim(geoself(), "poly"); How did you know to make prim a integer ? I'm reading over and over in the docs for Prim & addPrim & Geoself and I'm not understanding, arghhh. Quote Link to comment Share on other sites More sharing options...
holycause Posted April 3, 2016 Share Posted April 3, 2016 when you look at the documentation, it s written: int addprim(int geohandle, string type) that "int" at the beginning means that it will return an integer value aka the new prim number. Quote Link to comment Share on other sites More sharing options...
Arthur Spooner Posted April 3, 2016 Author Share Posted April 3, 2016 Ahh, that helps to understand; geoself returns a integer, while prim gets an attribute using the node path. What is cd used for the example; prim ? Quote Link to comment Share on other sites More sharing options...
bonsak Posted April 3, 2016 Share Posted April 3, 2016 I created a torus, connected a null, followed by a point wrangler, inserted the code, got a plane, sounds correct ? How do I know what to make a int, v etc in Houdini ? Breaking this line of code down; int prim = addprim(geoself(), "poly"); How did you know to make prim a integer ? I'm reading over and over in the docs for Prim & addPrim & Geoself and I'm not understanding, arghhh. Adding the null is only for when you want to start creating geometry from scratch. Attribute Wrangle needs an input of some sort to not error out. What is cd used for the example; prim ? I don't understand. The string "poly" that we're passing to addprim() is only describing the type of poly you want to make: "poly" (closed) or "polyline" (open) -b Quote Link to comment Share on other sites More sharing options...
Arthur Spooner Posted April 3, 2016 Author Share Posted April 3, 2016 Adding the null is only for when you want to start creating geometry from scratch. Attribute Wrangle needs an input of some sort to not error out. I don't understand. The string "poly" that we're passing to addprim() is only describing the type of poly you want to make: "poly" (closed) or "polyline" (open) -b What is the attribute Cd ? That is what I should've asked ! Quote Link to comment Share on other sites More sharing options...
bonsak Posted April 3, 2016 Share Posted April 3, 2016 I see Cd is the attribute for color. It's a vector made up of 3 floats. Check out the other common attributes in Houdini: http://www.sidefx.com/docs/houdini15.0/model/attributes -b Quote Link to comment Share on other sites More sharing options...
Arthur Spooner Posted April 3, 2016 Author Share Posted April 3, 2016 What parameters can you add to geoself() ? Quote Link to comment Share on other sites More sharing options...
bonsak Posted April 3, 2016 Share Posted April 3, 2016 You don't add attributes to geoself(). geoself is just a function that returns a handle to the geometry being processed. If you want to set attributes to geometry for example, try a Point Wrangle for instance. To set the color of the points you go: @Cd = {1,0,0}; -b Quote Link to comment Share on other sites More sharing options...
holycause Posted April 3, 2016 Share Posted April 3, 2016 and if you're in the detail mode, you can set a point attribute like this: setpointattrib(geoself(), "Cd", ptNum, {1,0,0}) Quote Link to comment Share on other sites More sharing options...
Arthur Spooner Posted April 4, 2016 Author Share Posted April 4, 2016 You don't add attributes to geoself(). geoself is just a function that returns a handle to the geometry being processed. If you want to set attributes to geometry for example, try a Point Wrangle for instance. To set the color of the points you go: @Cd = {1,0,0}; -b The geometry, whether it be a sphere, or cube etc should've turned red ? Quote Link to comment Share on other sites More sharing options...
Arthur Spooner Posted April 4, 2016 Author Share Posted April 4, 2016 and if you're in the detail mode, you can set a point attribute like this: setpointattrib(geoself(), "Cd", ptNum, {1,0,0}) You mean detail mode in Geo Spreadsheet ? What is meant by "it returns a handle" to the geometry being processed, sorry it's the terms ! int prim = addprim(geoself(), "poly"); int pt1 = addpoint(geoself(), {0,0,0}); int pt2 = addpoint(geoself(), {0,0,1}); int pt3 = addpoint(geoself(), {1,0,1}); int pt4 = addpoint(geoself(), {1,0,0}); int prim is not a variable, rather the command which must be used. One imports the attribute value from geometry, in this case, it is importing an empty geohandle, then points are being creating, to create a closed polygon ? 0,0,0 > no points 0,0,1 > point at world z ? 1,0,1 > point at world, x & z ? 1,0,0 > point at world, x ? Quote Link to comment Share on other sites More sharing options...
holycause Posted April 4, 2016 Share Posted April 4, 2016 no, on the attribute wrangle - the Run Over parameter mode Quote Link to comment Share on other sites More sharing options...
Arthur Spooner Posted April 4, 2016 Author Share Posted April 4, 2016 no, on the attribute wrangle - the Run Over parameter mode Ah setpointattrib(geoself(), "Cd", ptNum, {1,0,0}) Reference to undefined variable ptNum is the error I get with VEX. Quote Link to comment Share on other sites More sharing options...
holycause Posted April 4, 2016 Share Posted April 4, 2016 that's normal, you gotta provide it with a point number something like that int npts = npoints(0); for(int i = 0; i<npts;i++){ setpointattrib(geoself(), "Cd", i, {1,0,0}) } but I would recommend to do as much as possible in point/prim/vertex mode instead of in the detail mode as that last one isn't multithreaded. 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.