DigiHz Data Posted October 31, 2016 Share Posted October 31, 2016 (edited) 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 November 13, 2016 by DigiHz Data Solved Quote Link to comment Share on other sites More sharing options...
adam Posted October 31, 2016 Share Posted October 31, 2016 http://www.babylonjs-playground.com/#147HRL#1 http://www.babylonjs-playground.com/#147HRL#2 http://www.babylonjs-playground.com/#147HRL#3 Quote Link to comment Share on other sites More sharing options...
DigiHz Data Posted October 31, 2016 Author Share Posted October 31, 2016 @adam Not exactly what i am looking for. I want to get the pivot matrix xyz values from the mesh (local values). So that i can show a pseudo mesh for the pivot's position. Quote Link to comment Share on other sites More sharing options...
adam Posted October 31, 2016 Share Posted October 31, 2016 Quote Link to comment Share on other sites More sharing options...
DigiHz Data Posted October 31, 2016 Author Share Posted October 31, 2016 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. Quote Link to comment Share on other sites More sharing options...
JohnK Posted November 1, 2016 Share Posted November 1, 2016 Here is an example of a moving pivot not parented to a box. Not sure if it what you are actually looking for though. http://www.babylonjs-playground.com/#29BGXO#4 Quote Link to comment Share on other sites More sharing options...
DigiHz Data Posted November 2, 2016 Author Share Posted November 2, 2016 @JohnK Not sure about this, but i am working on a PG so you all see what i mean and what i am looking for. ....Hold on until that. Quote Link to comment Share on other sites More sharing options...
DigiHz Data Posted November 3, 2016 Author Share Posted November 3, 2016 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!) Quote Link to comment Share on other sites More sharing options...
DigiHz Data Posted November 3, 2016 Author Share Posted November 3, 2016 Adding rotation sliders to the PG.....http://www.babylonjs-playground.com/#25TNA4#1 Now things become wrong when the mesh is rotated. How to fix this PG? I think it has to do with local /world values, but i am not sure. Quote Link to comment Share on other sites More sharing options...
JohnK Posted November 3, 2016 Share Posted November 3, 2016 How about this one http://www.babylonjs-playground.com/#25TNA4#2 Quote Link to comment Share on other sites More sharing options...
DigiHz Data Posted November 3, 2016 Author Share Posted November 3, 2016 that seams to work perfectly. BUT.... i want the code in the function. Can you update the code so that it works inside the function @JohnK? PLZ Quote Link to comment Share on other sites More sharing options...
adam Posted November 3, 2016 Share Posted November 3, 2016 I'm confused. Can you tell me how that is different from the first PG I posted? http://www.babylonjs-playground.com/#147HRL#1 Quote Link to comment Share on other sites More sharing options...
DigiHz Data Posted November 3, 2016 Author Share Posted November 3, 2016 1 minute ago, adam said: I'm confused. Can you tell me how that is different from the first PG I posted? http://www.babylonjs-playground.com/#147HRL#1 The difference is that i want it to work in a function, so that we might add this function to BJS. Quote Link to comment Share on other sites More sharing options...
DigiHz Data Posted November 3, 2016 Author Share Posted November 3, 2016 To make it clear to everyone.... Try make this work inside the function plz. Quote Link to comment Share on other sites More sharing options...
adam Posted November 3, 2016 Share Posted November 3, 2016 1 minute ago, DigiHz Data said: Try make this work inside the function plz. I think you need to study some basic javascript coding. Quote Link to comment Share on other sites More sharing options...
DigiHz Data Posted November 3, 2016 Author Share Posted November 3, 2016 Just now, adam said: I think you need to study some basic javascript coding. true, thats why i ask for help. Quote Link to comment Share on other sites More sharing options...
JohnK Posted November 3, 2016 Share Posted November 3, 2016 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. adam 1 Quote Link to comment Share on other sites More sharing options...
adam Posted November 3, 2016 Share Posted November 3, 2016 http://eloquentjavascript.net/03_functions.html Quote Link to comment Share on other sites More sharing options...
DigiHz Data Posted November 3, 2016 Author Share Posted November 3, 2016 Exactly. i want the mesh to not "reposition" even if we update the pivot matrix. Visually the mesh looks as it's in the same place all the time when we move the pivot matrix. Quote Link to comment Share on other sites More sharing options...
DigiHz Data Posted November 3, 2016 Author Share Posted November 3, 2016 @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. Quote Link to comment Share on other sites More sharing options...
JohnK Posted November 3, 2016 Share Posted November 3, 2016 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. Quote Link to comment Share on other sites More sharing options...
JohnK Posted November 3, 2016 Share Posted November 3, 2016 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. Quote Link to comment Share on other sites More sharing options...
DigiHz Data Posted November 3, 2016 Author Share Posted November 3, 2016 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.) Quote Link to comment Share on other sites More sharing options...
DigiHz Data Posted November 3, 2016 Author Share Posted November 3, 2016 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. Quote Link to comment Share on other sites More sharing options...
DigiHz Data Posted November 3, 2016 Author Share Posted November 3, 2016 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? 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.