Showing posts with label rotate. Show all posts
Showing posts with label rotate. Show all posts

Tuesday 3 September 2019

rotating point normals, with vops

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.

Monday 24 June 2019

FETCH inverting transforms at object level

Recently I transformed a camera (scaled and rotated) to make things easier to work with in Houdini.
I did this with nulls at object level, rather than within the SOP themselves.
However, when transferring my assets back to Maya there was no clear way to invert the transformation (like in the SOP level Transform nodes).

The answer to this, is to use a FETCH node (thanks Matt Evans), which I pointed toward my rotation null and I told it to invert.. This Fetch node was then plugged into the geometry I was trying to return to the original camera orientation/scale (as you would with a null).

basically!
SCALE NULL--->ROTATE NULL--->CAMERA

FETCH(points to ROTATE NULL,with invert ticked on)--->GEO


Wednesday 19 June 2019

rotate packed primitives/ WALTER ROTATE

how to rotate a/bunch of packed primitive/s -
Use a WALTER ROTATE.

in a primitive wrangle:


float randomFactor=rand(@primnum+2323)*chf("randomMult");
matrix3 rot = primintrinsic(0, "transform", @primnum);
vector4 orient = quaternion(rot);
vector x = normalize(qrotate(orient, {1,0,0}));
vector y = normalize(qrotate(orient, {0,1,0}));
rotate(rot, radians(chf("angle") * randomFactor), x);
rotate(rot, radians(chf("angley")), y);
setprimintrinsic(0, "transform", @primnum, rot);

//////////////////
what we are doing is:
  • making a random factor to multiply the rotations, using primnum as a seed
  • creating a matrix called "rot", and initialising it to the transform of the primitive
  • create a vector called "orient", using the quarternion of the rot matrix
  • create vectors x and y
  • rotate the rot matrix using input angles for x and y
  • then finally set the primitive intrinsic using the rot matrix