peshang Posted April 9, 2020 Share Posted April 9, 2020 hello guys! I have a pop sim that runs for like 30 frames as they fall .. then I want to revert(attract?!) them back to their initial position (as they were before falling)... I tried the per point attract on the attract node.. and I get their positions back .. how can I get their orientation also to be targeted to the initial orientation? Quote Link to comment Share on other sites More sharing options...
brassmonkey Posted April 9, 2020 Share Posted April 9, 2020 (edited) Cache it out and play it in reverse? You can play around with a per point time offset using for-each loops, check out CGWiki! Another way would be to use a VOP and interpolate between the point's current position/orientation and a rest position/orientation. Edited April 9, 2020 by brassmonkey Quote Link to comment Share on other sites More sharing options...
toadstorm Posted April 9, 2020 Share Posted April 9, 2020 If you want to simply revert to the original orientation without applying forces, you can do this post-sim by blending your original orient before the sim (save the starting orientation of your particles to a vector4 attribute) and then interpolating that orientation with the current orientation: p@orient = slerp(p@orig_orient, p@orient, bias) where bias is a value from 0-1. If you want to apply this as a force via a POP Wrangle, you'd have to figure out the amount of spin necessary to rotate from your current orientation to the goal orientation. You could then assign that to v@torque, or using wind-like spin forces via v@targetw and f@spinresist. The math for this gets a bit... complicated. First, you want to compute the delta between your current orientation and the goal orientation. You can do this by multiplying your goal orientation by the inverse of the original orientation: vector4 delta_orient = qmultiply(goal_orient, qinvert(p@orient)); However, in order to avoid a situation where the delta is computed as being a greater than 180-degree difference due to the nature of quaternion rotations, which would cause wild flipping behavior, you'd need to compute the dot product of your goal and current orientations and negate one of the quaternions if this is the case: vector4 current_orient = p@orient; if(dot(goal_orient, current_orient) < 0) { current_orient = -current_orient; } vector4 delta_orient = qmultiply(goal_orient, qinvert(current_orient)); Now you can convert this quaternion to an axis/angle representation of a quaternion, which is how the v@torque and v@targetw attributes work: v@torque = qconvert(delta_orient) * chf("spin_force"); The "spin_force" channel would modulate the amount of torque you're applying so the parts don't oscillate too much around their goal orientation. If you want the particles to ignore their mass attribute when doing this, just multiply v@torque by f@mass. 2 2 Quote Link to comment Share on other sites More sharing options...
peshang Posted April 9, 2020 Author Share Posted April 9, 2020 thank you so much for this! @toadstorm <3 Quote Link to comment Share on other sites More sharing options...
nuki Posted April 9, 2020 Share Posted April 9, 2020 (edited) nice job @toadstorm! I was looking into this myself but my solution was about transporting N and up with the sim. Was wondering how to do it with quaternions! Edited April 9, 2020 by nuki 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.