简体   繁体   English

min3D框架。 物体旋转与运动

[英]min3D framework. Object rotation & movement

I am trying to code a cessna flying around the world using the accelerometer with the min3D framework for android but the rotation is a bit weird. 我正在尝试使用带有用于Android的min3D框架的加速计来编码在世界各地飞行的塞斯纳,但是旋转有点奇怪。

I'm using this to apply the accelerometer rotation to the object: 我正在使用它来将加速度计旋转应用于对象:

cessna.rotation().x = rotX;
cessna.rotation().z = rotZ;

This works fine. 这很好。 I haven't figured out yet how to move in the direction of rotation (I think I have to use trigonometry). 我还没有想出如何沿旋转方向移动(我想我必须使用三角函数)。

I rotated the object with 我用旋转物体

cessna.rotation().y++;

just to test what will happen. 只是为了测试会发生什么。 At 180° the rotation around the x axis is mirrored. 绕x轴旋转180度时,将反映出来。 So the nose of the plane turns down instead of up. 因此,飞机的机头是向下而不是向上。 I think I rotate the Objects around the world axis and not around the local axis from the object. 我想我绕着对象轴绕着世界轴而不是绕着局部轴旋转对象。 How can I do this? 我怎样才能做到这一点? I didn't find any documentation about the min3D framework in the internet :/ . 我在互联网上找不到有关min3D框架的任何文档:/。

Thank you if you can help me. 谢谢您的帮助。 (sorry for the bad English) (对不起,英语不好)

If you want to rotate around object local axis. 如果要绕对象局部轴旋转。 Do this 做这个

(in pseudo code - you'll need to find similar functions in min3d) Translate(object.pos.x,object.pos.y,object.pos.z); object.rotation().x+=radians(45);// or whatever (用伪代码-您将需要在min3d中找到类似的函数) Translate(object.pos.x,object.pos.y,object.pos.z); object.rotation().x+=radians(45);// or whatever Translate(object.pos.x,object.pos.y,object.pos.z); object.rotation().x+=radians(45);// or whatever

if that doesn't work, try wrapping the above two lines in 如果不行,请尝试将以上两行换行

pushMatrix()
...
popMatrix()

Or similar functions in min 3d to save and then restore the current camera rotation translation matrix. 或在min 3d中使用类似功能保存并还原当前的摄像机旋转平移矩阵。

Have you considered, Processing, which also comes with an Android 'output'? 您是否考虑过Processing,它还带有Android“输出”?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM