ozRocker Posted June 14, 2016 Share Posted June 14, 2016 I know how to get world rotation from the rotation quaternion using the eulerAngles function. I know how to set the world rotation using the RotationYawPitchRoll function. I also want to have the option to read and set local rotation but I have no idea how to do this using the rotation quaternion. I've checked the docs and searched the forums but I can't find an example. Does anyone know if its possible to read and set absolute local rotation? Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted June 14, 2016 Share Posted June 14, 2016 Hey to get the local value of the worldmatrix, you have to do localMatrix = this.getWorldMatrix() * inverse(parent.getWorldMatrix()) Then you can decompose the matrix to get the local rotation. If you are using a mesh then mesh.rotationQuaternion is the local rotation Quote Link to comment Share on other sites More sharing options...
ozRocker Posted June 14, 2016 Author Share Posted June 14, 2016 3 minutes ago, Deltakosh said: If you are using a mesh then mesh.rotationQuaternion is the local rotation oh right, so mesh.rotationQuaternion is actually storing the local rotation. I got it backwards. So how do I set and retrieve the world rotation? Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted June 14, 2016 Share Posted June 14, 2016 Then it is the opposite mesh.getWorldMatrix().decompose() should do the trick Quote Link to comment Share on other sites More sharing options...
ozRocker Posted June 14, 2016 Author Share Posted June 14, 2016 4 minutes ago, adam said: If the mesh doesn't have a parent, isn't the rotationQuaternion both local and world? Actually, you have a good point here. I'm trying to rotate this object in relation to the ground via local and world rotations, but I guess I need to make it a child of the ground first 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.