Jump to content

Parent-child displacement


David78
 Share

Recommended Posts

These  are two simple questions, regarding parent-child relationships. It's not that I don't get this:

 

"

Any postion, rotation and scaling transformations made to the parent... prior to assigning it to children... will also be applied to the children when the parent is assigned.

"

 

What's happening rather is that when I load two meshes and make the first one the parent of the second or vice versa, there is an initial displacement in the child's position. On loading the meshes, this is the only line of code involving them, the rest sets up the camera, lights, etc:

newMeshes[1].parent = newMeshes[0];

Which results in newMeshes[1] being displaced. When newMeshes[0] is moved after this it works fine, whatever transformations are done on it are also done to newMeshes[1], the issue is this initial displacement. 

 

The second question is whether parent-child relationships can be defined between specific parts of a mesh and another mesh. For example, say a human-like mesh is loaded that has skeletal animation where one hand moves up and down, and I want a sphere or another mesh to also move based on the motion of this one hand and not of the entire body. (Without using sub-meshes) how can this be done? Can a mesh be attached to the motion of skeletal animation?

 

Still a noobie learning the ropes...

 

Thanks in advance.

Link to comment
Share on other sites

On question one: it sounds like your initial mesh parent ( newMeshes[0]) is already slightly displaced when loaded (from whichever program you use), which is then getting applied to the child. My approach for dealing with this is to create a new empty mesh (which will automatically be centered at 0) then attach all the other meshes to that as children. Then assuming you never move newMeshes[0], you can treat the new empty mesh as if it is newMeshes[0]....if that makes sense.

 

On the second point, that is an interesting question (which i will need to address for my own project actually..). I don't think there is anything built into Babylon, but there is no reason you couldn't select the deformation of a specific vertex (say one from the characters hand) and apply that to the sphere with a bit of coding.

Link to comment
Share on other sites

If you are using Blender, I had an issue when scaling and/or position was not all the same in Blender while in Object Mode . It seems as if all scaling and positioning needs to be done when you are in edit mode of the object.

 

For example when in object mode, both objects should have a scaling of x:1, y:1, z:1 and a position of x:0, y:0, z:0.

Link to comment
Share on other sites

Thank you both for your answers. It makes sense that the mesh is slightly displaced from loading it from blender. I never thought that that would affect it however, it is rather meticulous!

 

On the second question, yes I thought of using vertex deformation but before doing so was wondering if Babylon.js had an-in built way of handling this specific case.

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...