phil1234 Posted October 5, 2015 Share Posted October 5, 2015 Hello, I read in the doc that rotation is achieved before translation, but I try to have an offsetted object rotate around the 0,0,0 axis and I cant find any way to achieve this ... usualy(with other engines) I offset the object on its local axisthen simply rotate it globaly with a matrix/quaterion/rotate function I tried different combinations of these twomesh.translate(BABYLON.Axis.X, 3.0, BABYLON.Space.WORLD); //or LOCALmesh.rotate(BABYLON.Axis.Y, 1.0, BABYLON.Space.WORLD); //or LOCAL (I wanted to rotate the object position with a quaternion, but the Quaternion lacks of regular/usual .mult(Vector) or .rotate(Vector)and anyway, it wouldn't be what I want to achieve) any idea ? thanks Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted October 5, 2015 Share Posted October 5, 2015 You can use mesh.setPivotMatrix(BABYLON.Matrix.Translation(x, y, z) to achieve your goal. the complete operation is PivotMatrix x Scaling x Rotation x Translation Quote Link to comment Share on other sites More sharing options...
iiceman Posted October 5, 2015 Share Posted October 5, 2015 I guess this example fits Deltakoshs suggestion: http://www.babylonjs-playground.com/#H7V1D#8 (if not, just ignore me ) GameMonetize 1 Quote Link to comment Share on other sites More sharing options...
Wingnut Posted October 6, 2015 Share Posted October 6, 2015 Hi phil... (and hi ice and dk too) welcome to the forum.... good to have you with us. In case you ever need such, I have a cool "bootleg" forum searcher page at http://urbanproductions.com/wingy/babylon/search/form06/form06.htm (thx to Gryff for the gfx). Phil... tell us about you, and your project(s), if you want. Thanks! Quote Link to comment Share on other sites More sharing options...
phil1234 Posted October 6, 2015 Author Share Posted October 6, 2015 ok, but although I can make it work with rotate(), how come it does not work doing this mesh.rotationQuaternion=mesh.rotationQuaternion.multiply(BABYLON.Quaternion.RotationAxis(new BABYLON.Vector3(0,1,0),angle*Math.PI/180)); [edit: oops my bad it works actualy :-) ] Quote Link to comment Share on other sites More sharing options...
Wingnut Posted October 6, 2015 Share Posted October 6, 2015 Hi again, Phil. http://www.babylonjs-playground.com/#H7V1D#13 Your line is 34. Notice line 33. Standard mesh do not have a .rotationQuaternion by default. It is "turned on" as needed. https://github.com/BabylonJS/Babylon.js/blob/master/src/Mesh/babylon.abstractMesh.js#L227 (that line should look familiar). Lines 363 and 419 are also testers for the existence of a quaternion. Hope this helps. Party on! Quote Link to comment Share on other sites More sharing options...
ian Posted March 3, 2016 Share Posted March 3, 2016 http://babylonjs-playground.com/#1JUURV#18 local vs world rotation example 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.