Results 1 to 11 of 11

Thread: Instancing offset models in LW2018

  1. #1
    Super Member
    Join Date
    Jul 2003
    Location
    somewhere
    Posts
    1,129

    Instancing offset models in LW2018

    Not sure if this is a LW bug or a feature request.

    My physics based plugins require meshes that are modeled centered on the origin in order to rotate correctly in the physics engine. I handle offset meshes in LW by changing the LW pivot point programmatically to the center of the mesh. This normally works fine, but when I'm instancing a mesh whose pivot point I have reset, the instance transforms don't respect the new pivot point of the source mesh and so don't work correctly. I can easily fix the translate part of the transform but I can't find any way to make the rotation part work correctly. Any ideas how I can get around this problem?

  2. #2
    Big fan of coffee raw-m's Avatar
    Join Date
    Jul 2003
    Location
    London
    Posts
    2,280
    You could try parenting the object to a null, using the null as the pivot point. In the Instance Gen, point it at the null and click the little child/tree icon so it sees the object. (I may have misunderstood your issue, though!)

  3. #3
    creacon
    Join Date
    Nov 2005
    Location
    Belgium
    Posts
    1,294
    Without knowing exactly what you are doing, I wouldn't change the pivot, but (virtually) move the object to the center, add it to the physics engine and after the physic engine gives you the new position, move that back into place. Does that make sense?

    creacon

    Quote Originally Posted by hurley View Post
    Not sure if this is a LW bug or a feature request.

    My physics based plugins require meshes that are modeled centered on the origin in order to rotate correctly in the physics engine. I handle offset meshes in LW by changing the LW pivot point programmatically to the center of the mesh. This normally works fine, but when I'm instancing a mesh whose pivot point I have reset, the instance transforms don't respect the new pivot point of the source mesh and so don't work correctly. I can easily fix the translate part of the transform but I can't find any way to make the rotation part work correctly. Any ideas how I can get around this problem?
    Last edited by creacon; 08-08-2018 at 09:34 AM.

  4. #4
    Super Member
    Join Date
    Jul 2003
    Location
    somewhere
    Posts
    1,129
    No that wouldn't work for me. I'm using my own instance painter and I wouldn't want the user to have to jump through any hoops like that when using the tool.

    In LW2015, instances are "parented" to the source item and I was able to get around this problem using some extra transformations but it doesn't work in LW2018.

    Here's a video of the problem in LW2018

    In LW2018, when I set the pivot point of the item being instanced, I need LW to remap the items's vertices to be relative to the new pivot point when I transform an instance of this item. But it doesn't do that, instead it uses the original vertices relative to the origin. In the video the red block works fine when modeled at the origin. The green block is offset to x = 3. You can see in the wireframe that I've reset it's pivot to be in the center of the mesh but when I paint green instances they are drawn in the wrong spot because LW sees their vertices as relative to the origin instead of their new pivot point.

    Here's the code I'm using to transform the newly painted instance whose source mesh was not modeled on center

    Code:
    Pose pose = instance->spaceTime().worldTransform;
    pose.scale(instance->spaceTime().scale);
    Eigen::Vector3d pos = pose.translation().cast<double>();
    
    // LW doesn't know that the source's pivot point has changed
    // We can fix the position by subtracting the modeled offset
    if (source->getState().hasModeledOffset())
    {
    	Affine3d t;
    	t.translation() = pos + source->spaceTime().modeledOffset.cast<double>();
    	t.linear() = pose.linear().cast<double>();
    	//t.prerotate(t.linear());
    	Eigen::Matrix3d rot = t.linear().cast<double>();
    
    	pos -= source->spaceTime().modeledOffset.cast<double>();
    
    
    	helpers.iFuncs->setMotionStepAuto(instID, helpers.time, step, pos.data(), rot.data());
    }
    Last edited by hurley; 08-08-2018 at 04:05 PM.

  5. #5
    Super Member
    Join Date
    Jul 2003
    Location
    somewhere
    Posts
    1,129
    Quote Originally Posted by creacon View Post
    Without knowing exactly what you are doing, I wouldn't change the pivot, but (virtually) move the object to the center, add it to the physics engine and after the physic engine gives you the new position, move that back into place. Does that make sense?

    creacon
    Nope, that won't work. The physics engine gives me back a new pose on every tick which I pass to the LW motion plugin. LW will rotate the mesh around it's pivot point so unless the mesh is modeled on center or the pivot point is changed, it just won't work.
    Last edited by hurley; 08-08-2018 at 03:09 PM.

  6. #6
    creacon
    Join Date
    Nov 2005
    Location
    Belgium
    Posts
    1,294
    The user doesn't have to jump through any hoops, you offset ( in code ) the object (the geometry) to the world's center. So it's like moving the pivot without moving the pivot.

    creacon

    Quote Originally Posted by hurley View Post
    No that wouldn't work for me. I'm using my own instance painter and I wouldn't want the user to have to jump through any hoops like that when using the tool.

  7. #7
    Super Member
    Join Date
    Jul 2003
    Location
    somewhere
    Posts
    1,129
    Quote Originally Posted by creacon View Post
    The user doesn't have to jump through any hoops, you offset ( in code ) the object (the geometry) to the world's center. So it's like moving the pivot without moving the pivot.

    creacon
    Sorry, the "jump through hoops" was to raw-m's response.

    I already automatically center each mesh in my own code before sending to the physics engine. The problem with what you're suggesting is that when I pass the rotation from the physics engine to LW MotionHandler it will rotate the vertices around the LW pivot point. So if the vertices aren't centered around the pivot point then the rotation will be wrong
    Last edited by hurley; 08-09-2018 at 06:24 AM.

  8. #8
    Electron wrangler jwiede's Avatar
    Join Date
    Aug 2007
    Location
    San Jose, CA
    Posts
    6,161
    Quote Originally Posted by hurley View Post
    Sorry, the "jump through hoops" was to raw-m's response.

    I already automatically center each mesh in my own code before sending to the physics engine. The problem with what you're suggesting is that when I pass the rotation from the physics engine to LW MotionHandler it will rotate the vertices around the LW pivot point. So if the vertices aren't centered around the pivot point then the rotation will be wrong
    That it appears to be ignoring your programatic change of the pivot seems like a bug.

    If you query the pivot after programmatically changing it, is it still reporting the original value?
    John W.
    LW2015.3UB/2018.0.5 on MacPro(12C/24T/10.13.6),32GB RAM, NV 1080ti

  9. #9
    Super Member
    Join Date
    Jul 2003
    Location
    somewhere
    Posts
    1,129
    Quote Originally Posted by jwiede View Post
    That it appears to be ignoring your programatic change of the pivot seems like a bug.

    If you query the pivot after programmatically changing it, is it still reporting the original value?
    Hi John,

    Setting the pivot point programmatically works fine generally. You can see that in the above video when I'm tweaking the green box with the new pivot point and it's rotating correctly. The problem is when instancing an object whose pivot point has been changed, LW does not remap the vertices of that object to be relative to the new pivot point. So when an instance receives a rotation matrix, it rotates the vertices around the original modeled pivot point and not the new pivot point and the instance is not drawn where the plugin wants to place it as in the above video

  10. #10
    Quote Originally Posted by hurley View Post
    Not sure if this is a LW bug or a feature request.
    Its a bug, and been reported a few times.. hopefully we'll see a fix soon.

  11. #11
    Super Member
    Join Date
    Jul 2003
    Location
    somewhere
    Posts
    1,129
    Quote Originally Posted by oliverhotz View Post
    Its a bug, and been reported a few times.. hopefully we'll see a fix soon.
    Thanks for letting me know, Oliver. I hope it's fixed soon ... it's kinda of a showstopper for AP in LW2018

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •