Emit RBD pieces every frame with random attributes workflow

   1316   10   2
User Avatar
Member
27 posts
Joined: 1月 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 - 2024年7月31日 08:00:01

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

User Avatar
スタッフ
411 posts
Joined: 2月 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
27 posts
Joined: 1月 2023
Offline
Very neat solution, less code than in my version and it solves the offset problem, thanks!
User Avatar
Member
27 posts
Joined: 1月 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
92 posts
Joined: 8月 2017
Online
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
27 posts
Joined: 1月 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 - 2024年8月12日 10:03:58
User Avatar
スタッフ
411 posts
Joined: 2月 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
27 posts
Joined: 1月 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
スタッフ
411 posts
Joined: 2月 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
27 posts
Joined: 1月 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
スタッフ
411 posts
Joined: 2月 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)

  • Quick Links