JohnK Posted November 3, 2016 Share Posted November 3, 2016 Hey let's all calm down a bit. At the moment I am looking into the jumping bit - its because all the rotations take place from zero not the current rotation. I am trying to help you with the rotation bit and not moving the mesh. Putting into a function, when I have solved that bit is not something I am interested in, but helping doing the rotation around a pivot is. Quote Link to comment Share on other sites More sharing options...
adam Posted November 3, 2016 Share Posted November 3, 2016 It would also help if you told us why you need to do this, because I have a feeling that using pivotMatrix might not be the best solution. Quote Link to comment Share on other sites More sharing options...
DigiHz Data Posted November 3, 2016 Author Share Posted November 3, 2016 3 minutes ago, adam said: It would also help if you told us why you need to do this, because I have a feeling that using pivotMatrix might not be the best solution. @adam Plz read the post before, i allready tried to explain it. (To the best of my ability). Quote Link to comment Share on other sites More sharing options...
adam Posted November 3, 2016 Share Posted November 3, 2016 You explained what you want, but not why. Anyway, good luck. Quote Link to comment Share on other sites More sharing options...
JohnK Posted November 3, 2016 Share Posted November 3, 2016 Any better http://www.babylonjs-playground.com/#25TNA4#3 ? Quote Link to comment Share on other sites More sharing options...
DigiHz Data Posted November 3, 2016 Author Share Posted November 3, 2016 2 minutes ago, JohnK said: Any better http://www.babylonjs-playground.com/#25TNA4#3 ? Sorry @JohnK. Rotation is speed up for some reason and still jumpy. Give it a rest John. I try a little bit more myself. Thank you so far anyway. Have a nice day. Quote Link to comment Share on other sites More sharing options...
JohnK Posted November 10, 2016 Share Posted November 10, 2016 @DigiHz Data I'll keep my optimism toned down until you have tested. With a reminder from @adam about computeWorldMatrix I might have a solution. http://www.babylonjs-playground.com/#25TNA4#13 Quote Link to comment Share on other sites More sharing options...
DigiHz Data Posted November 11, 2016 Author Share Posted November 11, 2016 @JohnK My dear friend I appriciate VERY much your effort. But......Your PG uses a parent. I am still working on this problem, so bear with me. I inform you all later if i can crack this nut or not. I thank you JohnK for you codeing examples to. Quote Link to comment Share on other sites More sharing options...
DigiHz Data Posted November 13, 2016 Author Share Posted November 13, 2016 @JohnK I think i cracked it! Check it out.... http://www.babylonjs-playground.com/#M0UJB What you think about that? Quote Link to comment Share on other sites More sharing options...
DigiHz Data Posted November 13, 2016 Author Share Posted November 13, 2016 I would like to mark this thread as [SOLVED], but only a moderator can do that right? I am also interested in what @Deltakosh have to say about this PG / function implementation. Quote Link to comment Share on other sites More sharing options...
JohnK Posted November 13, 2016 Share Posted November 13, 2016 @DigiHz Data and I came up with this http://www.babylonjs-playground.com/#25TNA4#18 If you are happy that your original question has been solved edit your first post in this topic and put [SOLVED] in the title. DigiHz Data 1 Quote Link to comment Share on other sites More sharing options...
DigiHz Data Posted November 13, 2016 Author Share Posted November 13, 2016 @JohnK We have different appoaches you and me about this. I do believe my approach is better. because it is in a function. I not saying that your aproach is wrong. I been struggling with this issue now for over 2 weeks, and when i finally came up with a solution that can benefit most users (not only me), i felt proud of myself. Many people in this forum have asked about a solution of this pivot moving without moving the mesh itself(values change of course). Plz tell me what you think of my PG/approach. EDIT: I thank you so very much for all the time you put into this. Appriciated Quote Link to comment Share on other sites More sharing options...
JohnK Posted November 13, 2016 Share Posted November 13, 2016 You have every right to be pleased with yourself for working it out, it is very gratifying to work on a tricky problem and to solve it. As you say my approach is different and I will continue working through my method until I am happy with it. We all think our own way is best. Happy coding. Quote Link to comment Share on other sites More sharing options...
DigiHz Data Posted November 16, 2016 Author Share Posted November 16, 2016 Pinging @Deltakosh I am interested in what @Deltakosh have to say about this PG / function implementation. http://www.babylonjs-playground.com/#M0UJB Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted November 16, 2016 Share Posted November 16, 2016 What do you want me to comment on? It works so it's cool for me And this will be helpful for people having the same question Generaly speaking I'm more on the side of using only pivot + translation instead of baking (which could be slow) but both solution work Quote Link to comment Share on other sites More sharing options...
DigiHz Data Posted November 17, 2016 Author Share Posted November 17, 2016 @Deltakosh I was just wondering if you think it would be a good idea to implement the function updateMeshPivotPosition(mesh,value,axis) into BJS or not? Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted November 17, 2016 Share Posted November 17, 2016 I think so! Quote Link to comment Share on other sites More sharing options...
DigiHz Data Posted November 17, 2016 Author Share Posted November 17, 2016 Ok, i keep on working on the function then, to make it a bit smaller and better naming conventions. What you thin ´k of the function name? updateMeshPivotPosition Should we keep this function name or change it to something else? Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted November 17, 2016 Share Posted November 17, 2016 As this would be on Mesh class I would just name it updatePivotPosition Quote Link to comment Share on other sites More sharing options...
DigiHz Data Posted November 21, 2016 Author Share Posted November 21, 2016 Updated PG. http://www.babylonjs-playground.com/#M0UJB#1 Now uses a prototype. BABYLON.Mesh.prototype.updatePivotPosition = function (axis, value) (axis is either x y or z) Example to use: var result = mesh.updatePivotPosition('X',2.0); result is the new position of the mesh(a vector3). I PR this as soon as i get the time. Quote Link to comment Share on other sites More sharing options...
DigiHz Data Posted November 21, 2016 Author Share Posted November 21, 2016 Updated PG. http://www.babylonjs-playground.com/#M0UJB#1 Now uses a prototype. BABYLON.Mesh.prototype.updatePivotPosition = function (axis, value) (axis is either x y or z) Example to use: var result = mesh.updatePivotPosition('X',2.0); result is the new position of the mesh(a vector3). I PR this as soon as i get the time. I tried to do a pull request on github, but for some reason "Create pull request" is disabled. @Deltakosh Can you do the pull request of my prototype. BABYLON.Mesh.prototype.updatePivotPosition = function (axis, value) { var pivotCurrentValue = BABYLON.Vector3.TransformCoordinates(new BABYLON.Vector3(0, 0, 0), this.getPivotMatrix()); if (axis.toLowerCase() === 'x'){ this.setPivotMatrix(BABYLON.Matrix.Translation(value, pivotCurrentValue.y, pivotCurrentValue.z)); this.translate(BABYLON.Axis.X, -(BABYLON.Vector3.TransformCoordinates(new BABYLON.Vector3(0, 0, 0), this.getPivotMatrix()).x - pivotCurrentValue.x), BABYLON.Space.LOCAL); } else if (axis.toLowerCase() === 'y'){ this.setPivotMatrix(BABYLON.Matrix.Translation(pivotCurrentValue.x, value, pivotCurrentValue.z)); this.translate(BABYLON.Axis.Y, -(BABYLON.Vector3.TransformCoordinates(new BABYLON.Vector3(0, 0, 0), this.getPivotMatrix()).y-pivotCurrentValue.y), BABYLON.Space.LOCAL); } else if (axis.toLowerCase() === 'z'){ this.setPivotMatrix(BABYLON.Matrix.Translation(pivotCurrentValue.x, pivotCurrentValue.y, value)); this.translate(BABYLON.Axis.Z, -(BABYLON.Vector3.TransformCoordinates(new BABYLON.Vector3(0, 0, 0), this.getPivotMatrix()).z-pivotCurrentValue.z), BABYLON.Space.LOCAL); } else{ throw new Error("Axis " + axis + " not supported, use x, y, or z"); } return this.position; }; Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted November 21, 2016 Share Posted November 21, 2016 Hello you have to fork the repo in your own repo and then do the change in your repo From there you'll be able to do the PR (in Typescript :)) Quote Link to comment Share on other sites More sharing options...
DigiHz Data Posted November 21, 2016 Author Share Posted November 21, 2016 (edited) Ohh, my god! I know nothing about Typescript @Deltakosh. So i will not be able anyway to do the pull request. Feel free to pull it yourself. I not care about fame But please let me know , ok? Thx Edited November 21, 2016 by DigiHz Data Quote Link to comment Share on other sites More sharing options...
adam Posted November 29, 2016 Share Posted November 29, 2016 AbstractMesh now has setPivotPoint, getPivotPoint, getAbsolutePivotPoint. https://github.com/BabylonJS/Babylon.js/blob/master/src/Mesh/babylon.abstractMesh.ts#L1222 demo: http://www.babylonjs-playground.com/#WFLKH#6 DigiHz Data 1 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.