Emit RBD pieces every frame with random attributes workflow

   1692   12   2
User Avatar
Member
28 posts
Joined: Jan. 2023
Offline
Hello,
i have scene where i want to emit rbd piece every frame into sim. After that i want to have proper attributes(actual transforms from rest state) on points because i want use them in "Instancer LOP". By default points from RBD dont take into account transforms made before sim of objects. So i have to bring them back, to achieve this i am using 4@restxform which solver returns to me on every piece. I think I almost have it with scale and rotation, but i have slighty offset on everypiece and I don't know what it comes from.



I made a test scene to illustrate scenario I'm talking about. The whole setup is done in LOPs and rbd sim is in the "Instancer LOP".
Image Not Found

If anyone has an idea what this offset is caused by or has a better way to deal with this scenario, I would be grateful ^^
Thanks,
Dawid
Edited by Dawid Wizor - July 31, 2024 08:00:01

Attachments:
EMIT_RBD.hiplc (424.9 KB)
rbd_offset.png (2.3 MB)

User Avatar
Staff
413 posts
Joined: Feb. 2008
Offline
The problem is you have "Compute Center of Mass" on on the RBD Packed Object > Physical. This changes the pivot of the RBD points.

Either turn that off, or if you want to keep the automatically computed center of mass, you'll need to create a new transform for each point that considers the original restxform and the new pivot.

Here's an example that shows the latter.

Attachments:
EMIT_RBD_v02.hiplc (428.8 KB)

User Avatar
Member
28 posts
Joined: Jan. 2023
Offline
Very neat solution, less code than in my version and it solves the offset problem, thanks!
User Avatar
Member
28 posts
Joined: Jan. 2023
Offline
Hey, i have one more question (your solution works perfectly but I'm curious if it's possible). After using method you showed using maketransform(), points change their positions and only after copy to points, everything looks as in RBD sim. I wonder if it would be possible to have a perfect representation of the point position in space already before copy to points(with correct rotation and scale at this points).
User Avatar
Member
96 posts
Joined: Aug. 2017
Offline
Dawid Wizor
Hey, i have one more question (your solution works perfectly but I'm curious if it's possible). After using method you showed using maketransform(), points change their positions and only after copy to points, everything looks as in RBD sim. I wonder if it would be possible to have a perfect representation of the point position in space already before copy to points(with correct rotation and scale at this points).


Isn't that whats coming out of the rbd solver?
User Avatar
Member
28 posts
Joined: Jan. 2023
Offline
Unfortunately not ;/ That's why I made this thread. Points from RBD sim don't take into account transformations made just before simulation and have an offsets on the pivot. Approach that npetit showed is fine, just in case I wanted to ask if it is possible to achieve good transforms with good point position after copy to poitns because this method moves points.
Edited by Dawid Wizor - Aug. 12, 2024 10:03:58
User Avatar
Staff
413 posts
Joined: Feb. 2008
Offline
In the "transform" wrangle, use this VEX code instead

4@transform = maketransform(0, 0, {0,0,0}, degrees(quaterniontoeuler(p@orient, 0)), v@scale, v@pivot);
4@transform = 4@restxform * 4@transform;
@P -= v@pivot;
User Avatar
Member
28 posts
Joined: Jan. 2023
Offline
Hey, I haven't checked this solution before, but now it would be useful to me. What is "transform" wrangle? Before checking I thought you meant about deformation wrangle but this code doesn't work here.
User Avatar
Staff
413 posts
Joined: Feb. 2008
Offline
It's the wrangle called "transform" in your original hip file, under /stage/instancer1.

Here's the updated hip file.

Attachments:
EMIT_RBD_v03.hiplc (429.5 KB)

User Avatar
Member
28 posts
Joined: Jan. 2023
Offline
Do you have any idea why this doesn't work in this scenario? Thas is, when i dont emit RBDs, just init pieces.

Attachments:
INIT_RBD.hiplc (400.3 KB)

User Avatar
Staff
413 posts
Joined: Feb. 2008
Offline
Here's an updated hip file with it working in all cases - the point position however doesn't reflect the pivot offset but should still give you a pretty decent idea of where the pieces are.

Attachments:
INIT_RBD.hiplc (425.2 KB)

User Avatar
Member
28 posts
Joined: Jan. 2023
Offline
Hello, it's me again xD This method actually works in almost every case, except when using RBD SOP Solver, I assume it does something under the hood(there's a little offset of pieces). Maybe you have a way to make it work here too.

Attachments:
SOP_SOLVER_RBD.hiplc (1.2 MB)

User Avatar
Staff
413 posts
Joined: Feb. 2008
Offline
The RBD Bullet Solver SOP stores all the emitted geometry in a solver SOP, at its emission position, rotation and scale. From there it's a straight forward transform pieces SOP.
The reason it does this is there is no guarantee that all the unique emitted geometry is always available through the first and/or third inputs.
For example, on frame 1 you have a cube plugged into the first frame - a cube is emitted. On frame 2 you switch to no geometry, so nothing gets emitted and on frame 3 you switch to a sphere which gets emitted. On frame 4 and up you switch to no geo.
Without caching the emitted geo, you'd only see the cube on the first frame and the sphere on the 3rd frame and then nothing.

Storing the emitted geo at its emission position, rotation and scale is the same as baking in its rest xform.
  • Quick Links