如何实现在OpenGL程序的Andr​​oid平移 [英] how to implement panning in opengl program android

查看:98
本文介绍了如何实现在OpenGL程序的Andr​​oid平移的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在具有节目的OpenGL ES ,其中一个立方体越来越沿X,Y,Z轴。结果

现在我想要实现平移功能为同一(当用户触摸立方体至少2个手指 - 它西港岛线得到沿轴平移)...结果

请人给我建议我从哪里开始,我已经搜索在谷歌太多STIL无法找到任何令人满意的例子。

我的code是类似于API演示应用程序中的code这是由安装在其中一个立方体显示模拟器默认值。


解决方案

平移可以参考一些不同的东西在一个3D的背景下,但一般你只是将要四处移动相机。这仅仅是一个你如何设置你的模型视图矩阵事项;我建议使用某种形式的'LOOKAT功能来计算这一点,简单地改变你的眼睛坐标。

有关最自然的声像,坐标应当通过以w = 0的现有模型视图矩阵的屏幕空间位移向量乘以改性,将得到的矢量添加到你的眼睛坐标

I am having a program in opengl es, in which a cube is getting rotated on user-touch along X,Y,Z axis.

Now I want to implement panning feature for the same (when user touches the cube with atleast 2 fingers--it wil get panned along the axis)...

Please anyone suggest me where do I start, I have searched too much on google stil unable to find any satisfactory example.

My code is similar to the code in API demos application which is by default installed on the emulator in which a cube is shown.

解决方案

Panning can refer to a number of different things in a 3D context, but in general you're just going to be moving the camera around. This is just a matter of how you set up your modelview matrix; I recommend using some sort of 'lookat' function to calculate this, and simply change your eye coordinate.

For the most natural panning, the coordinate should be modified by multiplying your screenspace displacement vector by your existing modelview matrix with w=0, and add the resulting vector to your eye coordinate.

这篇关于如何实现在OpenGL程序的Andr​​oid平移的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆