Sign in to follow this  
amo yeh

syncBoneWithImpostor function help

Recommended Posts

trying to test syncImpostorWithBone() and syncBoneWithImpostor() functions.
I know there is a nice example from , yet I don't know how exactly it works by using my own model.

I created a simple 3d model from 3ds max, with a box and a single bone attached, and applied with skin modifier. (as attached image shown)
Also, there is no transformation, scaling or any rotation on the bone and box.

Then I tried to run my version , I think I am missing something , the loaded model is not syncing properly.

could anyone please give me a right direction or fix?

much appreciated for any help, thanks  :)


Share this post

Link to post
Share on other sites

Hi @amo yeh

No solution found, yet, but...

Change 'false' to 'true' at end-of line 62.  Does that cause it to start working?  I'm not sure what "working" should look-like.  :) 

Just experimenting... trying to discover something.  You know... Wingnut = blind squirrel... sometimes finds acorn, but more likely, deer turd.  :)

Share this post

Link to post
Share on other sites

I seem to made it work by using different approach.

syncImpostorWithBone() works fine , the mesh is moved to bone position at beginning.

to change boneA transformation to match meshA,  for rotation, I used:


boneA.setRotationMatrix(meshA.getWorldMatrix(), BABYLON.Space.LOCAL, loadedMesh);


For the position, the center point of the bone in 3ds max is different from the center point generated in Babylon physic objects. (see attached image)

I had to move half of the width (as if the bone center point is at the center of the box) to make this work


var result = BABYLON.Vector3.TransformCoordinates(new BABYLON.Vector3(-1, 0, 0), meshA.getWorldMatrix())
boneA.setPosition(result, BABYLON.Space.LOCAL, loadedMesh);


to further test it , I  made a chain with three boxes, it seems working


however , I still don't know if this is the correct way,  and what will happen if more complex physic objects are added.


Share this post

Link to post
Share on other sites
10 hours ago, Deltakosh said:

Question is: how can we detect that bones are not centered ?

Hi @Deltakosh  , here is an example

If I use the position directly from mesh, such as:



boneA.setPosition(meshA.getAbsolutePosition(), BABYLON.Space.LOCAL, loadedMesh);


you can tell that the BoneAxesViewer shows  the bone center is at the center of the mesh box.

for my case, the bone center is at the bottom from 3ds max exported bones, so I need to apply  TransformCoordinates add an -1 on x axis for it to work.



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.