I am importing an RBD bullet sim out of dops as points. Those points have orient and pivot attributes to work with the Transform Pieces sop to retransform my input geometry, which is working great. However, I am going to use those points to instance geometry through another program, and that program only uses an @orient attribute and not @pivot.
My question is, is there a way I can alter my orient attribute so that I don't need the pivot? I tried methods such as creating a new orient attribute using the fulltransform primitinsic from the output RBD, copy that onto the output points, delete the pivot, and then used Transform Pieces to check my rotations and they were a bit off. I also tried subtracting the pivot from the position. Is there a better way to do it?
In short, how can I get correct rotations on my points from dops without a pivot attribute?
Transform Pieces with removed @pivot attribute
7061 8 2-
- Tyler Britton2
- Member
- 89 posts
- Joined: 4月 2014
- オフライン
-
- toadstorm
- Member
- 402 posts
- Joined: 4月 2017
- オフライン
I'm not sure it's your orient attribute that's going to need to be modified by removing the pivot… it's your @P attribute. If you want to do away with your pivot, essentially you want to set your pivot to (0,0,0), and then move P in the opposite direction to compensate. However, pivots are in local space, which means that you need to counter-rotate your pivot vector by your orient attribute before adding the result to @P, or multiplying the offset by your original transform matrix.
Something like this:
P.S. if you have MOPs installed, MOPs Align can set pivots directly for you, without moving the packed primitives. The default “center pivot” mode does this.
Edit: missed the part where you're fetching the info as points. In this case you could substitute the pivot primitive intrinsic with v@pivot, and build the xform matrix by using maketransform() like this:
Something like this:
matrix xform = primintrinsic(0, "transform", @ptnum); vector new_pivot = {0,0,0}; vector old_pivot = primintrinsic(0, "pivot", @ptnum); vector offset = new_pivot - old_pivot; setprimintrinsic(0, "pivot", @ptnum, new_pivot); @P = offset * xform;
P.S. if you have MOPs installed, MOPs Align can set pivots directly for you, without moving the packed primitives. The default “center pivot” mode does this.
Edit: missed the part where you're fetching the info as points. In this case you could substitute the pivot primitive intrinsic with v@pivot, and build the xform matrix by using maketransform() like this:
vector N = qrotate(p@orient, {0,0,1}); vector up = qrotate(p@orient, {0,1,0}); matrix xform = maketransform(N, up, @P);
Edited by toadstorm - 2020年4月14日 15:37:34
MOPs (Motion Operators for Houdini): http://www.motionoperators.com [www.motionoperators.com]
-
- Tyler Britton2
- Member
- 89 posts
- Joined: 4月 2014
- オフライン
Thanks, that seemed to have done it. There is what I ended up using in the wrangle. I just substituted the the intrinsics part with attributes since that's what my points had. It seemed to work fine for me.
Should this effect precomputed motion blur at all?
vector N = qrotate(p@orient, {0,0,1}); vector up = qrotate(p@orient, {0,1,0}); //matrix xform = primintrinsic(0, "transform", @ptnum); matrix xform = maketransform(N, up, @P); vector new_pivot = {0,0,0}; //vector old_pivot = primintrinsic(0, "pivot", @ptnum); vector old_pivot = v@pivot; vector offset = new_pivot - old_pivot; //setprimintrinsic(0, "pivot", @ptnum, new_pivot); v@pivot = new_pivot; @P = offset * xform;
Should this effect precomputed motion blur at all?
-
- Tyler Britton2
- Member
- 89 posts
- Joined: 4月 2014
- オフライン
Edit: Actually this doesn't seem to work for me. The points work with no pivot when I test it with the start frame RBD objects with a Transform Pieces, however when I instance the files it looks off, which is due to the instances being at the origin (of course). Is there something I am doing wrong here?
-
- toadstorm
- Member
- 402 posts
- Joined: 4月 2017
- オフライン
It's pretty tough to say what's going wrong without seeing your file, or a repro of it. Can you post anything?
MOPs (Motion Operators for Houdini): http://www.motionoperators.com [www.motionoperators.com]
-
- Tyler Britton2
- Member
- 89 posts
- Joined: 4月 2014
- オフライン
-
- toadstorm
- Member
- 402 posts
- Joined: 4月 2017
- オフライン
I can't say I've used this “Simulation Points” workflow from the RBD Solver SOP much, so maybe there's a better way to handle this, but personally I'd rather just yank the transform information directly from the simulated packed primitives. One of the things complicating your setup is that you're assembling your objects into packed primitives after copying them, so as far as Bullet is concerned the orient attribute of all your starting points is (0,0,0,1) which doesn't reflect the randomization you applied earlier. The transform intrinsics, however, never lie.
I'm just taking the first output of your RBD solver and creating temporary attributes for the primitive intrinsic transform and the intrinsic pivot, like this:
Then I use code similar to what I posted earlier to remove the pivot without moving the world space position of the copies:
Then you can just instance directly to those same points and you should be good. I'm attaching the fixed file.
I'm just taking the first output of your RBD solver and creating temporary attributes for the primitive intrinsic transform and the intrinsic pivot, like this:
// get packed transform and pivot, and store them as temporary attributes. matrix m = getpackedtransform(0, @ptnum); vector pivot = primintrinsic(0, "pivot", @ptnum); 4@__xform = m; v@__pivot = pivot; // convert the matrix orientation to the orient attribute. p@orient = quaternion(m);
Then I use code similar to what I posted earlier to remove the pivot without moving the world space position of the copies:
vector new_pivot = {0,0,0}; vector offset = new_pivot - v@__pivot; v@pivot = new_pivot; @P = offset * 4@__xform;
Then you can just instance directly to those same points and you should be good. I'm attaching the fixed file.
Edited by toadstorm - 2020年4月15日 21:23:18
MOPs (Motion Operators for Houdini): http://www.motionoperators.com [www.motionoperators.com]
-
- Tyler Britton2
- Member
- 89 posts
- Joined: 4月 2014
- オフライン
-
- HUGHSPEERS
- Member
- 84 posts
- Joined: 9月 2008
- オフライン
-
- Quick Links