To rotate a point's normals (or any vector for that matter) you need to multiply it with a matrix and an angle (usually in radians) and around a specified axis.
A much neater/easier-to-grasp method is to use a VOP.
Give your points some initial Normal values, eg point them in X.
Make a point VOP.
Connect the N output into a multiply. We want to multiply this N vector and get a vector output.
The output of the multiply should go to the N output.
Make a DegToRad node (skip if you speak radians) and connect that to the angle input of a Rotate node. Promote the DegToRad's angle input so you can tweak it at object level.
In the Rotate node, set the vector that you wish to spin the normal vector around. It might be Y. 0,1,0.
Or you could be doing something cool like calculating the vector that an edge lies on and spinning something around that.
Connect the output of the Rotate to the second input of the Multiply.
Now jump back out of the VOP and you should be able to see your normals rotating when you change the angle input.
-------------------------------------------------------
Of course this is just a couple, maybe one, of lines in VEX, but who really has time to memorise that? heh.
Showing posts with label vops. Show all posts
Showing posts with label vops. Show all posts
Tuesday, 3 September 2019
Thursday, 22 March 2018
point cloud open, point cloud iterate, point cloud import, while loop VOPS
I'll probably never memorise the proper VEX code for iterating points in a point cloud:
pcopen(something something what?)
So lets look at how to do a basic VOPS setup.
pcopen(something something what?)
So lets look at how to do a basic VOPS setup.
- Lay down a "Point Cloud Open" node. Connect the P attribute into P.. and then most likely you'll want to plug Opinput1 into the "file" input. "File" refers to the points you are running over. Set the radius and max number of points to whatever you want. They are probably going to be useful promoted to SOP level.
- Make a "Point Cloud Iterate" node. Plug the result "handle" of the Point Cloud Open node into this. The "handle" is a list of all the points that are within the radius you specified earlier. The iterate node is generally used in conjunction with a ....
- "While" loop node. The iterate node's handle is used as the opening condition for the While loop. As long as we're running through the points within range, the loop will continue. So plug the Iterate's "Success" output into Condition.
- Attach the "handle" from Point Cloud Open to one of the other While Loop inputs. This is important!
- Attach anything else you want processing into the other inputs of the While Loop. Eg. Maybe Cd? Or a constant value.
- Within the While loop, make ANOTHER "Point Cloud Iterate". We're going to use this is to ensure the While loop ENDS. Hook up the "handle" you attached in step 4, into the input of the iterate. Then connect it's output to the While Loop's End block condition.
- OK! The loop is fine now. We can use a "Point Cloud import" node to get any data we want. We'll use the "handle" value from step 4 again as an input. Make sure to set the parameters correctly. Eg. if a value is a float,vector,integer etc.
- Do what you want...maybe import the X position of a point and add it to the red of Cd?
- Plug any outputs into the While Loop End's box
- Connect the outputs to things. It might be the global output, or to some bind-exports.
Labels:
iterate,
pcimport,
pciterate,
pcopen,
point cloud,
vops,
while loop
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
Labels:
connect,
findattribval,
findattribvalcount,
for loop,
loops,
useful,
vops,
wrangle
Subscribe to:
Posts (Atom)