Jump to content

syncBoneWithImpostor function help


amo yeh
 Share

Recommended Posts

trying to test syncImpostorWithBone() and syncBoneWithImpostor() functions.
I know there is a nice example from http://playground.babylonjs.com/#PM5MFS#5 , 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.
http://www.babylonjs-playground.com/#1ZCM3K


could anyone please give me a right direction or fix?

much appreciated for any help, thanks  :)

testPhysic.jpg

Link to comment
Share on other sites

Hi @amo yeh

No solution found, yet, but...

https://www.babylonjs-playground.com/#1ZCM3K#1

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

Link to comment
Share on other sites

I seem to made it work by using different approach.

http://www.babylonjs-playground.com/#1ZCM3K#3

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

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

Quote

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

Quote

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

http://www.babylonjs-playground.com/#1ZCM3K#4

 

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

boneCenter.jpg

Link to comment
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

http://www.babylonjs-playground.com/#1ZCM3K#5

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

Quote

 

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.

 

 

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