Rotating points before Copy to Points SOP

   1739   5   3
User Avatar
Member
107 posts
Joined: June 2020
Online
Hi!

How could you adjust rotation points before Copy to Points SOP?

I'm copying objects to points from popnet and I want to rotate the points to randomize a little their tilt. I could do it with vex after the copying but I belive it would require me to unpack those, and these are pretty heavy so I want to avoid that.

Here is the example scene. Red is popnet sim movement and I want to randomize the rotation along the green axis so that it still faces the red axis.

Thanks in advance!

Image Not Found
Edited by thimer - Oct. 3, 2024 05:58:08

Attachments:
tilt_setup.png (1.6 MB)

User Avatar
Member
2 posts
Joined: Oct. 2024
Offline
Copy to points orients objects using normal and up vector. Or vector4 "orient". Try normal and up vector. @up = {0,1,0}, And @N probably in your case will be equal to normalized @v.
User Avatar
Member
405 posts
Joined: April 2017
Offline
Easy way is MOPs Randomize [github.com], you can specify Euler ranges for each local axis of rotation.

Otherwise you just need to create a random axis/angle rotation using a bit of VEX and apply that to the orientation:
vector axis = {0,0,1}; // this is the "forward" axis for a copy
float amount = fit01(rand(@ptnum), -180, 180); // random amount to rotate around x
vector4 r = quaternion(radians(amount), axis);

// multiply existing orientation with this random rotation in local space
p@orient = qmultiply(p@orient, r);

This assumes your particles already have an orientation. If they don't, consider using a POP Lookat DOP to aim your particles towards the velocity vector in the simulation, or some other method to create the orientation that looks in the direction of movement.
Edited by toadstorm - Oct. 4, 2024 16:36:24
MOPs (Motion Operators for Houdini): http://www.motionoperators.com [www.motionoperators.com]
User Avatar
Member
107 posts
Joined: June 2020
Online
toadstorm
Easy way is MOPs Randomize [github.com], you can specify Euler ranges for each local axis of rotation.

Otherwise you just need to create a random axis/angle rotation using a bit of VEX and apply that to the orientation:
vector axis = {0,0,1}; // this is the "forward" axis for a copy
float amount = fit01(rand(@ptnum), -180, 180); // random amount to rotate around x
vector4 r = quaternion(radians(amount), axis);

// multiply existing orientation with this random rotation in local space
p@orient = qmultiply(p@orient, r);

This assumes your particles already have an orientation. If they don't, consider using a POP Lookat DOP to aim your particles towards the velocity vector in the simulation, or some other method to create the orientation that looks in the direction of movement.

Thanks!! That's what I wanted to accomplish. Seems that I was lacking the POP Lookat DOP.


Reman
vector axis = {0,0,1}; // this is the "forward" axis for a copy
float amount = fit01(rand(@ptnum), -180, 180); // random amount to rotate around x
vector4 r = quaternion(radians(amount), axis);

// multiply existing orientation with this random rotation in local space
p@orient = qmultiply(p@orient, r);


This is what I've tried and I doesn't give me the result I need.
User Avatar
Member
107 posts
Joined: June 2020
Online
I was happy to quickly.

Toadstorm, both methods don't work. That weird rotation switch happens both on the wrangle code you've written and on MOPs Randomize.

Attachments:
rotatnion.mp4 (5.1 MB)

User Avatar
Member
405 posts
Joined: April 2017
Offline
They work fine, you just didn't correctly set up the lookat vector in POPs.

The target needs to be set to Direction, then use a VEXpression to set the `target` parameter to the normalized velocity vector:

target = normalize(v@v);

Attaching a working example.

Attachments:
rotate_lookat_particles.hip (501.6 KB)

MOPs (Motion Operators for Houdini): http://www.motionoperators.com [www.motionoperators.com]
  • Quick Links