OpenGL ES:围绕自身旋转 3d 模型 [英] OpenGL ES: Rotating 3d model around itself

查看:28
本文介绍了OpenGL ES:围绕自身旋转 3d 模型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在 iPhone 上使用 OpenGL ES,我正在尝试通过用手指平移来旋转模型.我发现了开源应用 Molecules 可以让你做到这一点,我正在查看该代码,但是当涉及到旋转我的模型时,我只能围绕空间中远处的一个点旋转它(就像它是在轨道上作为卫星,我是固定行星).关于什么可能是错误的任何建议?我可以稍后发布代码,也许按需(多行)大多数情况下,您可以在此处找到分子"分子

I'm playing with OpenGL ES on iPhone and I'm trying to rotate a model by panning with the finger. I discovered the open source app Molecules that let's you do that and I'm looking at that code, but when it comes to rotate a model of mine I'm able to rotate it only around a point distant in the space (like it was in orbit as a satellite and I am the fixed planet). Any suggestion on what can be wrong? I can post the code later , maybe on demand (many lines) For the most part refer to Molecules you can find it here MOLECULES

推荐答案

如果我没记错的话,我想你需要将模型平移到原点,旋转,然后平移回起始位置才能得到你想要的效果之后.

If my memory serves me correctly, I think you need to translate the model to the origin, rotate, and then translate back to starting position to get the effect you are after.

我认为有一个 glTranslate() 函数,假设对象位于 1,0,0.然后你应该通过 -1,0,0 转换到原点.那是通过从对象中心到原点的向量进行平移.

I think there is a glTranslate() function, Say the object is at 1,0,0. You should then translate by -1,0,0 to go to origin. That is translate by a vector going from the center of the object to the origin.

这篇关于OpenGL ES:围绕自身旋转 3d 模型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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