i need a constant random spinning on my particles, the same that the spin operator in pflow does, the reason i do not just cache the orientation out is that my flow sends out to events with forces and stuff so i dont get a consisten spinning in pflow and would like to get that by a magma flow but i have no idea of how that quaternion stuff works, maybe someone already created a magmaflow like that and would like to share ? or maybe there is another simple solution for this ? any help would be great
*edit ah ok just pipe in pflow again and make them spin at a second go but would be anyway good to know how to do it in magma flow
The Spin via second PFlow is probably the simpler way to go, but if you want to do some simple spinning with MagmaFlow, here is one approach:
*Let’s assume your particles were already saved with an Orientation Channel to PRT files that reflects the initial orientation (Rotation Operator) but no Spinning (which is the change in orientation). So they have some arbitrary orientation in space which is not changing.
*Once you load these particles in a PRT Loader, add a KCM to the stack and create the following flow:
*In this flow, the original orientation of the particle is loaded from the Orientation channel, transformed by a Quaternion and output back into Orientation.
*The Quaternion to transform by is made like this:
**An angle value is taken using a Script operator reading the current time and converting its frames to radians. This will produce a full rotation of 360 degrees over 360 frames. You can use any other value to manipulate this input to give each particle a different spin, for example you could use a Noise operator to define a random value based on the particle’s ID to speed up or slow down or revert the sign of this angle.
**The angle is then used to build a vector by taking the Cosine, the Sine and 0 into a ToVector. This creates a unit vector spinning CCW in XY plane as the input angle changes.
**This vector is then crossed with the UP axis [0,0,1] to produce the Y axis perpendicular to both. This gets normalized.
**These tree vectors (which at time 0 have values [1,0,0], [0,1,0] and [0,0,1]) are then fed into the ToQuat and produce a rotation matrix.
As result, the orientation of the particle is rotated about its Z axis over time.
This could be expanded to do more complex things, but if you intend to spin your particles about the X, Y or Z axis of their local space, this should do.
Your kidding me, that is just plain marvelous Nice with time integration. That script node is a great addition, I was using currentTime for something similar with ID’s (must have seen you use it somewhere) and it worked great.