PierreDuc Posted August 31, 2016 Share Posted August 31, 2016 (edited) This is a problem which I've been struggling for too long now. Probably my approach is completely wrong, and my knowledge of matrices are lacking. Scenario: Two parent meshes in a scene Each parent has one so called connector mesh as a child Both parents have a pivotMatrix which is not equal to Matrix.Identity() Both child connectors have a pivotMatrix which is not equal to Matrix.Identity() Problem Moving the second parent in such a way that both child connectors have the same global position. Unfortunately this does not come out okay, because the pivotMatrix is 'messing' things up. What have I tried The models are made using 3DS Max and then exported to .babylon. When I apply a ResetXForm within 3DS Max on the connectors it all works fine, and the models connect at the right position. Unfortunately I do not have the possibility to do this for all the models I have. I've tried using this piece of code (TypeScript): let subject: BABYLON.Mesh = <BABYLON.Mesh>con2.parent; let con1pos: BABYLON.Vector3 = con1.getAbsolutePosition(); let con2pos: BABYLON.Vector3 = con2.getAbsolutePosition(); let pos2: BABYLON.Vector3 = subject.getAbsolutePosition(); subject.setAbsolutePosition(pos2.add(con1pos.subtract(con2pos))); What I would really like is a way to make the pivotMatrix == Matrix.Identity() and have the mesh/geometry stay at the same position. Because before I can move these, I also need to rotate the subject, in such a way that con2 faces the exact opposite direction as con1. And I am pretty sure that the pivotMatrix is going to mess up that as well. Edit: I've created two playgrounds. http://www.babylonjs-playground.com/#1UMJXS#0 (3ds max export where the connectors have an altered pivot) http://www.babylonjs-playground.com/#1UMJXS#1 (3ds max export where the connectors are reset using resetXform) I was very convinced that I did get values using the getPivotMatrix() method, but checking today, I was horribly wrong. Apparently that data is not output by the babylon 3ds max exporter. Which gives me the feeling there is little I can do about it. Perhaps the exporter needs to be adjusted so that the adjusted pivot matrix gets exported as well Edited September 1, 2016 by PierreDuc Quote Link to comment Share on other sites More sharing options...
jellix Posted August 31, 2016 Share Posted August 31, 2016 I don't know exactly what you want to achieve. You want to turn the subject opposite to the second parent and then place the subject to a position where the children get the same position, right? So what happens by using your current code? Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted August 31, 2016 Share Posted August 31, 2016 Hello, to be more efficient to help you we need a repro in the Playground Quote Link to comment Share on other sites More sharing options...
PierreDuc Posted September 1, 2016 Author Share Posted September 1, 2016 10 hours ago, Deltakosh said: Hello, to be more efficient to help you we need a repro in the Playground I've updated my question, but i seem to have hit a deadend, considering the pivot values do not get exported from 3ds max to babylon Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted September 2, 2016 Share Posted September 2, 2016 Correct, pivot is integrated into world matrix but not exported separately. You can still export your meshes from 3dsmax and then setup pivot manually with mesh.setPivotMatrix() 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.