Sign in to follow this  
Dad72

Gizmo and pivot of meshes merged

Recommended Posts

@trevordev, Hello,

I find a bug on the gizmos when we merge objects.

If I am merging two objects and then replacing the pivot in the center of this new merge object. The gizmo is no longer on the pivot of this new objects but anywhere, corresponding to vector3(0,0,0).

http://playground.babylonjs.com/#8GY6J8#160

On my project the pivot is totally shift to several units of the object (it depends on the meshes)  See the picture :

1257664290_2018-09-1615_15_52-Greenshot.png.f202727574a048315692353a7b3f03e6.png

Share this post


Link to post
Share on other sites

@Deltakosh

In fact it is not the gizmo that is misplaced, but setPivotPoint which is not updated when objects are merged.

On this PG we can see that the gizmo is placed in the same place, whether I use setPivotPoint or not.

The point of the center of the object is the good one, it is the small white sphere which serves as indication

http://playground.babylonjs.com/#8GY6J8#161

Share this post


Link to post
Share on other sites

Due to Babylons current implementation of pivot points not supporting any order manipulation operations, I would say using the pivot for this would not be supported. Would using a parent mesh as the pivot point work for your scenario?

See this playground: http://playground.babylonjs.com/#8GY6J8#163

Share this post


Link to post
Share on other sites

@trevordev,

No, it does not work completely.

If I want to select the object later, the gizmo is not well placed, it comes back as before.

Moreover, we have to select one of the two rabbits. the object is not considered as a single sectionable with pickResult.pickedMesh.

The fact of creating a new BABYLON.Mesh  makes me lose all give to serialize the merge object.

http://playground.babylonjs.com/#8GY6J8#164

The pivot seems to place correctly on the merge object. Why the gizmo can not be placed on this pivot point?

Looks like MergeMesh has a lot of different problems at home? problem of placement of the Gizmo, problem of material which disappears with multiple materials. I'm starting to wonder if I will not remove the merge from my software, because I can not do anything right.

Share this post


Link to post
Share on other sites

To get the gizmo in the right position again, maybe you could check if the selected mesh has a parent and use that if it exists to attach the gizmo.

 

Can you provide more details about what you are trying to build?

Are you looking for the ability to group any number of objects and move them around with gizmos or something else?

How would you like the serialization to work?

Share this post


Link to post
Share on other sites

other solution: you can bake the transform:  http://playground.babylonjs.com/#8GY6J8#165 (this way you are centering the new mesh on its origin)

And this is not "problems" but how the merge works :) The MergeMesh takes data from both meshes and merge then. It is not responsible for centering the mesh or whatever

Share this post


Link to post
Share on other sites

Your solution seems to work well Deltakosh. Thank you. 👍

Yes trevor I am trying to regroup several objects and to be able to move this new object merged. It's for a MMORPG editor:

More detail here:

 

Share this post


Link to post
Share on other sites

I add the last two lines that allow to replace the object to merge to its original place and refreshing the BoundingInfo Speckle my object to disappear when I am too close to the object.

I can solve, it works on my project. Thanks again

let boundingInfo = meshMerged.getBoundingInfo().boundingBox;
let middlePivot = new BABYLON.Vector3(boundingInfo.center.x, boundingInfo.center.y, boundingInfo.center.z);                        
meshMerged.setPivotMatrix(BABYLON.Matrix.Translation(-boundingInfo.center.x, -boundingInfo.center.y, -boundingInfo.center.z), false);
meshMerged.bakeCurrentTransformIntoVertices();
meshMerged.setPivotMatrix(BABYLON.Matrix.Identity());                        
meshMerged.position = middlePivot;
meshMerged.refreshBoundingInfo();

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.