Nyanta Posted October 25, 2014 Share Posted October 25, 2014 Hi, currently, i've problems to move the ArcRotateCamera correctly around. I came up with this code:translation = BABYLON.Vector3.TransformNormal(translation, this._camera.getWorldMatrix());translation.y = 0;this._camera.target.addInPlace(translation);but the translation in z direction is slower, since the camera is tilted (i need to set translation.y to zero after transformation). Is there a good way to just rotate my desired translation around the y-axis in dependent to the alpha of the ArcRotateCamera? Kind Regards,Chris Quote Link to comment Share on other sites More sharing options...
Carlos R Posted October 25, 2014 Share Posted October 25, 2014 Hi Chris, I can't understand what you need. Isn't just translate the camara position and keep looking to the same point? Also, could you please give us a hand by using http://www.babylonjs.com/playground/ for a simple example? Regards, Carlos. Quote Link to comment Share on other sites More sharing options...
Nyanta Posted October 25, 2014 Author Share Posted October 25, 2014 Hey Carlos, if i could you a simple example, it wouldn't be necessary to ask for help, since i would solve my own problem But i could show you the behavior: http://area51.lypster.net:8888/ Here i'm using the ArcRotateCamera, you can move around with W,A,S,D and rotate with Q and E.If you move around you recognize that the forward and backward movement is slower than left and right movement. The reason is the transformation i need to do in order to translate in view direction:// // The keyboard movement logic // if (Keyboard.IsKeyDown(Key.W)) { translation.z += (deltaTime); } if (Keyboard.IsKeyDown(Key.S)) { translation.z -= (deltaTime); } if (Keyboard.IsKeyDown(Key.D)) { translation.x += (deltaTime); } if (Keyboard.IsKeyDown(Key.A)) { translation.x -= (deltaTime); } translation = BABYLON.Vector3.TransformNormal( translation, this._camera.getWorldMatrix()); translation.y = 0; this._camera.target.addInPlace(translation);I don't get it how i can transform the translation vector so that forward and backward is the same as the left and right speed. Kind Regards,Chris Quote Link to comment Share on other sites More sharing options...
macguyvok Posted October 26, 2014 Share Posted October 26, 2014 For me, it's actually very hard to notice the difference (and I'm still not sure there is an actual difference, it might be psychological). That being said, it seems that you can achieve what you want simply by scaling your movement. Here's an untested example://// The keyboard movement logic//var scaleX = .9;var scaleZ = 1.2;if (Keyboard.IsKeyDown(Key.W)) { translation.z += (deltaTime * scaleZ);}if (Keyboard.IsKeyDown(Key.S)) { translation.z -= (deltaTime * scaleZ);}if (Keyboard.IsKeyDown(Key.D)) { translation.x += (deltaTime * scaleX);}if (Keyboard.IsKeyDown(Key.A)) { translation.x -= (deltaTime * scaleX);}translation = BABYLON.Vector3.TransformNormal( translation, this._camera.getWorldMatrix());translation.y = 0;this._camera.target.addInPlace(translation);That example is mostly just illustrating the point; I wouldn't suggest having two variables when one can do the job just as easily. Quote Link to comment Share on other sites More sharing options...
Nyanta Posted October 26, 2014 Author Share Posted October 26, 2014 Hi Macguyvok, i already found a solution for my problem (just normalize the translation so that the distance is 1.0 ) thats why, you didn't notice a difference in the movement anymore (buildserver already deployed the new version). Kind Regards,Chris Quote Link to comment Share on other sites More sharing options...
macguyvok Posted October 26, 2014 Share Posted October 26, 2014 Ah, excellent! 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.