Jump to content

[SOLVED]getPivotMatrix xyz local values


DigiHz Data
 Share

Recommended Posts

Well.....

To set the pivot matrix is easy:

mesh.setPivotMatrix(BABYLON.Matrix.Translation(-1, -1, -1));//this sets the pivot in xyz axis

But how do we get the pivot matrix xyz values from the mesh?

console.log(mesh.getPivotMatrix());//This gives me only the pivot matrix of the mesh.

How do i go from here to get the local xyz values of the mesh pivot matrix?

Note: What i am looking for is to be able to show the position of the pivot of the mesh.

Edited by DigiHz Data
Solved
Link to comment
Share on other sites

i made a pg:

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

Look line 26-29.

However....When setting the pivot matrix, it also moves the mesh!

I not want to move the mesh,

Edit:

i know i can add a vector3 and parent it to the mesh and rotate/move the vector3, but is there no other easy way to do this?

I am working on a pg to illustrate, (trying to rotate a mesh with the pivot matrix changed without the need of a parent).

I be back here about this when i made my pg.

Link to comment
Share on other sites

The issue is like this....

When we use this line of code to change the pivot matrix...

mesh.setPivotMatrix(BABYLON.Matrix.Translation(x, y, z));

It moves the MESH to! (then we also have to reposition the mesh again)

And i am trying to find a solution for not moving the mesh itself by creating a new function that updates the pivot matrix but NOT move the mesh itself.

See PG:http://www.babylonjs-playground.com/#25TNA4

This PG works as intendeed as long as we not move, rotate or scale the mesh.(Have to implement code for this to!)

 

Link to comment
Share on other sites

IMHO the difference is that in your @adamPG if you move the small pivot sphere then the large orbiting sphere moves relative to the pivot, the orbit is the same just everything has been repositioned. What I think DigiHz Data wanted and what happens in the two PGs I linked in this topic if you move the pivot then the orbit changes, the orbiting mesh still passes through the position it was at when the pivot was moved.

Link to comment
Share on other sites

Giving you a function is not straight forward. Your function updateMeshPivotPosition is no longer needed since you no longer need to mesh with the mesh and using the GUI updates the position of the pivot. If you replace the three similar bits of code for rotation it is easy to produce a function that has mesh and axis as parameters and makes use of the given code. But this will only do rotation if you need a more general function for scaling etc then you need to first check out scaling

to see how you are going to handle scaling.

IMHO you could put what I have done into a function if you wish but you need to decide what you want the function to do first.

Link to comment
Share on other sites

11 minutes ago, DigiHz Data said:

@JohnK

http://www.babylonjs-playground.com/#25TNA4#2  not work perfetcly.

still see the red mesh jumping around when changing values. but hey.....thank you for trying.

What?????? in my browser the red mesh stays perfectly still when moving the pivot and rotates around the pivot when the angles are changed. Now I am confused as to what you want.

Link to comment
Share on other sites

Yes i know that it is not straight forward, (then it would allready be in BJS :) )

I try to be clear what i am looking for....

When we use setPivotMatrix , then it reposition the mesh and we have to position the mesh again to put it where it originally was.

What i am trying to archive is a new function for BJS that updates the pivot matrix WITHOUT changing the mesh position visiually, the cordinates are changed ofcourse.(So that we do NOT have to move the mesh manually after we call setPivotMatrix.)

 

Link to comment
Share on other sites

7 minutes ago, JohnK said:

What?????? in my browser the red mesh stays perfectly still when moving the pivot and rotates around the pivot when the angles are changed. Now I am confused as to what you want.

 

7 minutes ago, JohnK said:

What?????? in my browser the red mesh stays perfectly still when moving the pivot and rotates around the pivot when the angles are changed. Now I am confused as to what you want.

if you rotate in 1 axis and then rotate in another axis you see the jump.

Link to comment
Share on other sites

And in the top of my PG's it say's:

/*Moving the pivot point on a mesh without the need of a parent*/
/* (whithout moving the mesh itself)*/
/*(Taking into account move,scale and rotation)*/

/*The green sphere is the pseudo pivot point*/
/*(not parent to the red mesh and is only here for showing where the pivot is)*/

/*The red box is the mesh we are affecting*/

/*This is a function that may be implemnted in BJS ?*/
/*this function is called when we move our pseudo pivot*/

 

Anyone not read that?

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