ozRocker Posted May 28, 2016 Share Posted May 28, 2016 Does anyone know how to get the rotation of an object in Babylon 2.4? mesh.rotation is always zero. I can't set absolute rotation either. Quote Link to comment Share on other sites More sharing options...
Temechon Posted May 28, 2016 Share Posted May 28, 2016 It's set to zero if there is a rotationQuaternion set. What is the value of mesh.rotationQuaternion ? Hans 1 Quote Link to comment Share on other sites More sharing options...
ozRocker Posted May 28, 2016 Author Share Posted May 28, 2016 ah ok. rotationQuaternion has values in it. The thing is all I'm doing is calling mesh.rotate(). I used to be able to do that and it would set the rotation vector Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted May 29, 2016 Share Posted May 29, 2016 You can try to transform quaternion to vecto3 with quaternion.toEulerAngles but I highly recommend keeping quaternions because they are far more reliable than euler angles Quote Link to comment Share on other sites More sharing options...
ozRocker Posted May 29, 2016 Author Share Posted May 29, 2016 so does that mean that the mesh.rotation property is no longer used in Babylon 2.4? If I'm spinning a cube like in here: http://www.babylonjs-playground.com/#GZLLH the rotation vector remains zero. But if that's the case then I'll just use quaternion.toEulerAngles Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted May 29, 2016 Share Posted May 29, 2016 Actually it is not new we always supported both. But if quaternion is set then rotation (euler angles) is ignored: http://doc.babylonjs.com/overviews/How_Rotations_and_Translations_Work Quote Link to comment Share on other sites More sharing options...
ozRocker Posted May 29, 2016 Author Share Posted May 29, 2016 oh right! I got it now so using mesh.rotate() sets the quaternion. Thanks for the link. I really needed to read that! Quote Link to comment Share on other sites More sharing options...
Wingnut Posted May 30, 2016 Share Posted May 30, 2016 On 5/28/2016 at 5:25 AM, ozRocker said: Does anyone know how to get the rotation of an object in Babylon 2.4? mesh.rotation is always zero. I can't set absolute rotation either. Hi OzR. You might have confused mesh.rotate() and mesh.rotation. mesh.rotation = new BABYLON.Vector3(x, y, z); ...will always work fine, but as you now know, mesh.rotate() sets the quat, and mesh.rotation doesn't get updated continuously. (you could do it yourself in the renderLoop, but no, don't do that, something will explode.) Okay, if you must... then in the render loop... if (mesh.rotationQuaternion ) { mesh.currentEulerAngles = mesh.rotationQuaternion.toEulerAngles() } Don't let the quat make "pokes" into mesh.rotation. Could be trouble. Also, this activity could mega-bog the scene. Yuh, you forgot all about the mesh.rotation = vec3 method... and it is a little offended by that uncaring neglect. You've been giving all of your love and attention to .rotate(), right? (just trying to be funny, OzR) No sweat... I tried to set the diffuseColor on a texture yesterday. MANY times I've tried to set a color with a vector3. hellllooooo... wingy? Anyone home? It's part of the fun. Hat's off to DK... excellent forum custodianship. (63rd time you've answered this question, DK? *nod* *hug*) Quats are the "ghosts" of the forum, it seems... generating many confusions and discussions. Quote Link to comment Share on other sites More sharing options...
ozRocker Posted May 30, 2016 Author Share Posted May 30, 2016 yeh, well the reason I was confused was because I was using both mesh.rotate() and mesh.rotation back in version 2.3. I'd rotate my avatar with relative movements using mesh.rotate() then if I wanted to find out where he was facing I'd read from mesh.rotation. But its all good now cos I can use quaternion.toEulerAngles instead Wingnut 1 Quote Link to comment Share on other sites More sharing options...
Wingnut Posted May 30, 2016 Share Posted May 30, 2016 Hi again. I don't know if that is true, OzR. I don't think there has been any recent changes, but maybe. As far as I know... any rotate()... or yawPitchRoll()... or physics rotational impulsing... will NOT be updated into mesh.rotation property. Thus, I don't see how you used mesh.rotate(), and got fresh values in mesh.rotation. As @Temechon mentions, mesh.rotation is set to 000 when quat is created. This is also why we see mesh rotations getting "nulled-out" when mesh.setPhysicsState. Physics needs the quat... and makes one, which nulls .rotation. (I think) Heck, I don't know. I'm probably wrong. Framework could have changed. Maybe you are correct, Oz. My curiosity is piqued, to say the least. GameMonetize 1 Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted May 31, 2016 Share Posted May 31, 2016 Actually you are right Mesh.Rotate will always update the quaternion (again to avoid gimbal lock issues with euler angles) Wingnut 1 Quote Link to comment Share on other sites More sharing options...
Wingnut Posted May 31, 2016 Share Posted May 31, 2016 nod, DK... thx. http://www.babylonjs-playground.com/#1JNDSK#12 Here I am using rotate() [a Quaternion thing] in both LOCAL and WORLD spaces (lines 43-48)... and I see no sphere.rotation updates happening. (normal, I think) (see blue-text reporter above canvas) @ozRocker If you DID see quat rotations... being reported in mesh.rotation... in BJS 2.x... I want to know about that, ok Oz? Thanks. I don't think that changed in any recent versions. http://www.babylonjs-playground.com/#1JNDSK#13 In the above PG, I added prop sphere.curEuler, and I am updating IT... from quat.toEulerAngles... continuously. We see some FPS loss... not much. Ozzy, keep in mind that sphere.rotation is a getter AND setter. I could have continuously sent sphere.rotationQuaternion.toEulerAngles() => sphere.rotation... but BECAUSE .rotation is a setter... it doesn't work. I tested it. http://www.babylonjs-playground.com/#1JNDSK#14 The sphere's rotation goes bonkers, and sphere.rotation STILL doesn't ever leave 0, 0, 0. I would have thought sphere.rotation would have been some garbage numbers. But nope, 0, 0, 0. This ALMOST indicates that... not only is sphere.rotation set to 0,0,0 when the quat is MADE, but it is also set to 0,0,0 each time the quat CHANGES. But, somebody once told me...that you can't "edit" (change) a Quat, you can only replace it with a different one. THAT might explain why .rotation stays at 0,0,0 even as we stream quat.toEulerAngles() into it. Maybe every time we do a .rotate(), a new quat is made... and thus... it re-zeroes .rotation during every .rotate() usage. sphere.curEuler (used in #13) doesn't have 'setter' power, so it is a good place to continuously monitor sphere.rotationQuaternion.toEulerAngles() values... on a case-by-case basis. DK and the core Gods COULD add .curEuler or similar and have it update just like I did in #13... but... it is likely not worth the bog-per-usefulness hit. Setters and getters... yuh yuh yuh. I wonder if Dublin-based @Nockawa has ever coded Irish setters? ar ar ar! Party on! PS: Anyone seen @Dad72? I miss him. If he doesn't come back and visit soon, I'm forming a search and rescue crew. He might have been kidnapped by Lerps or something. Quote Link to comment Share on other sites More sharing options...
adam Posted May 31, 2016 Share Posted May 31, 2016 5 hours ago, Wingnut said: But, somebody once told me...that you can't "edit" (change) a Quat I edit quats all the time. Maybe you are talking about editing a single x, y, z component thinking that it will affect the rotation like it does with eulers. You have to do the correct math and then set x, y, z, w. Quote Link to comment Share on other sites More sharing options...
Dad72 Posted May 31, 2016 Share Posted May 31, 2016 4 hours ago, Wingnut said: PS: Anyone seen @Dad72? I miss him. If he doesn't come back and visit soon, I'm forming a search and rescue crew. He might have been kidnapped by Lerps or something. @Wingnut I'm here, but I spend less often being on a creation project of a carpentry workshop,my first profession, I love. I also like manual works, make furniture. . . I need physical activity right now. But thank you for your attention. If you want to help me do my workshop, I give free training in carpentry after. GameMonetize, jerome and Wingnut 3 Quote Link to comment Share on other sites More sharing options...
Wingnut Posted May 31, 2016 Share Posted May 31, 2016 @adam - if you need to set all 4 values, isn't that replacing the quat? Ok, maybe it's not TRUE replacing... I guess. Thanks for the info, Adam. @Dad72 - good to hear from you. Sure, I'll come do some sanding (about the only thing I'm qualified to do). Good luck on the project. Remember the old joke about smelling the wood to identify where it came from? The punch line was something about a restroom door from a tuna boat... err something like that. You can imagine the rest of the joke. (eww) Ahem. Alrighty then. Moving right along. heh Dad72 1 Quote Link to comment Share on other sites More sharing options...
Wingnut Posted May 31, 2016 Share Posted May 31, 2016 Ok, I had to do some more fun tests. SO... I was thinking about what Adam taught me... no editing allowed... of the discreet components of sphere.rotationQuaternion. Changing quat x, y, z, or w... would not give ANY good/expected results. But I thought... hmm. I bet quat.w... could be animated/edited/changed... without meshing-up the mesh. I was right... http://www.babylonjs-playground.com/#1JNDSK#16 (line 61) Look at that! Animating quat.w has no affect whatsoever. Ok, we MUST try the other 3 quat values, now. "Line 58, 59, 60... animators... ENGAGE!" http://www.babylonjs-playground.com/#1JNDSK#15 Oh my goodness. It's easy to see that the sphere quickly becomes angry with us. Things like this... can void manufacturer warranties on your motherboard. And, you could lose a finger. Yuh, live-poking quat.w was certainly allowed, and no trouble seen... other than almost yawning to death. heh 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.