amo yeh Posted August 22, 2017 Share Posted August 22, 2017 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 Quote Link to comment Share on other sites More sharing options...
Wingnut Posted August 22, 2017 Share Posted August 22, 2017 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. Quote Link to comment Share on other sites More sharing options...
adam Posted August 22, 2017 Share Posted August 22, 2017 Create a test with at least 2 bones and 2 physics imposters connected by a joint. I never tested a 1 bone 1 imposter set up. Quote Link to comment Share on other sites More sharing options...
amo yeh Posted August 23, 2017 Author Share Posted August 23, 2017 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. Wingnut 1 Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted August 23, 2017 Share Posted August 23, 2017 Question is: how can we detect that bones are not centered ? Quote Link to comment Share on other sites More sharing options...
amo yeh Posted August 24, 2017 Author Share Posted August 24, 2017 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. Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted August 24, 2017 Share Posted August 24, 2017 I get it but my question was more: how can determine that the bone center is at the bottom. I mean doing a detection based on what? Quote Link to comment Share on other sites More sharing options...
amo yeh Posted August 25, 2017 Author Share Posted August 25, 2017 Hi @Deltakosh , from the 3ds max software, the anchor point is at the bottom of the bone, that's why I thought it is at bottom. Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted August 25, 2017 Share Posted August 25, 2017 Yes I know but how could we detect it when reading the bone in the babylon file. I think it is not possible so just thinking out loud. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.