Jump to content

parented rotated non-uniform scaled meshes issue


haestflod
 Share

Recommended Posts

Hi, in our app we have parent & child relations tree that could be for example have this structure:
 

rootmesh
   mesh
   mesh
      mesh
        mesh

Each mesh should have their own scale so if a parent is scaled it will remove that scale by dividing the parents scale.

We recently added scaling and eventually found unintended behavior where rootmesh has a non-uniform scaling and if a mesh under has a rotation it skews that mesh.

As reproduced in this playground:

http://www.babylonjs-playground.com/#1CWAMX#2

So I was wondering if it was possible to solve somehow by math somehow.

 

Link to comment
Share on other sites

That's an interesting solution JohnK but is that applicable to a .babylon loaded mesh somehow? Like clone the geometry and alter all the vertice points?

And no the parent will not change scale as long as it has a child attached.

 

And thanks Adam for that piece of code if I can't find a way solve it without creating a helper mesh to act as parent.

Link to comment
Share on other sites

Why parent it then? Why not just position them to the "parents" position and have them to rotate in relation to the "parents" center axis then they will have their own scaling.

The other option is to just scale the child back after its parents resize, and all the sub children should come back to size.  So if you scale down by 0.5 I think you would have to scale the child up by 2 if I'm not mistaken to get it back to size.

Link to comment
Share on other sites

Because it made it simple to move & rotate them after adding as child mesh. All that is needed is to move & rotate the parent and children automatically does the same.

Also the child & parent relations can be edited on the fly by either adding a mesh or remove a mesh and the children of that mesh by selecting with mouse.

Edit:
So in the end I solved it using adam's approach by adding an empty mesh.
Here's a static version with 3 meshes:
http://www.babylonjs-playground.com/#1CWAMX#15
Here's the same but with some rotation & scale being altered each frame:
http://www.babylonjs-playground.com/#1CWAMX#18
I did try using some kind of matrix decomposition at first but it never worked so alas adam's approach it was!

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...