如何在OpenGL中更改旋转中心 [英] How to change the Center-of-Rotation in OpenGL

查看:97
本文介绍了如何在OpenGL中更改旋转中心的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个3D模型(OpenGL ES 1.1 iPhone SDK v3.0),该模型有些复杂(即成千上万的顶点和面),我想绕模型中心或附近的Y轴旋转此模型.问题是glRotate使我的模型绕其底部边缘之一的中心附近的点旋转,而不是靠近模型的中心.想象一下,一辆汽车在一个灯杆周围绕得很紧,这基本上就是我所得到的.我希望汽车插在灯柱上并围绕它旋转. (下面有一些来源)

I have a 3D Model (OpenGL ES 1.1 iPhone SDK v3.0) that is somewhat complex (i.e. Thousands of Vertexes and Faces) and I'd like to rotate this model around the Y-axis at or near the center of the Model. The problem is that glRotate rotates my model around a point at/near the center of one of its bottom edges, NOT near the center of the Model. Imagine a car driving very tight circles around a light-post, and that is basically what I've got. I want the car to be impaled on the light-post and be rotated around it. (Some source below)

   // BLUE BLOCK----------------------------------------------
    glPushMatrix();
    {
        glTranslatef(blueLocation[0], blueLocation[1], blueLocation[2]);
        glRotatef(blueRotAngle, 0.0, 0.0, 1.0);
        ...

问题:
在OpenGL中可以方便地更改旋转中心吗?

推荐答案

好的.向下平移对象.然后旋转它.

Sure. Translate the object down. THEN rotate it.

这篇关于如何在OpenGL中更改旋转中心的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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