Jump to content

Moving two objects to the same position. PivotMatrix problem


PierreDuc
 Share

Recommended Posts

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 by PierreDuc
Link to comment
Share on other sites

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?

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