GL_MODELVIEW和GL_PROJECTION [英] GL_MODELVIEW and GL_PROJECTION

查看:293
本文介绍了GL_MODELVIEW和GL_PROJECTION的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的代码当前如下所示:

My code Currently looks like this :

glViewport (0, 0, this->w(), this->h());

glMatrixMode(GL_PROJECTION);

glLoadIdentity();
glFrustum(-1.0, 1.0, -1.0, 1.0, 1.5, 20.0);
//glTranslated (m_fXmovement, 0.0, m_fZmovement - 5);
//glRotated (m_fYangleView, 1.0, 0.0, 0.0);
//glRotated (m_fXangleView, 0.0, 1.0, 0.0);

///// Model View \\\\\

glMatrixMode(GL_MODELVIEW);

glTranslated (m_fXmovement, 0.0, m_fZmovement - 5 );
glRotated (m_fYangleView, 1.0, 0.0, 0.0);
glRotated (m_fXangleView, 0.0, 1.0, 0.0);

DrawWaveFrontObject (m_pDataObjectMedia);

glPushMatrix();
    glTranslated (0.0, -3.0, 0.0);  
    DrawArea();
glPopMatrix();  

DrawClickAnimation();

glLoadIdentity();

首先,我在GL_PROJECTION中安装了运动部件,直到我在雾中工作之前,所有部件都运转良好....感觉相机没有移动,感觉更像是指向该相机的附加相机...

First I had the movement part in GL_PROJECTION and all was running fine until I was working with fog.... It felt like the Camera isn't moving, it felt more like an additional camera pointing to that camera....

然后,我不小心将运动部件复制到了GL_MODELVIEW上,并且雾起了我想要的作用……..一切都很好,接受的是单击动画不再与该区域相关,现在动画已移动从我的自我角度来看...................................有人可以根据我的代码给我一些示例或解释,或者提示我可以在笔中进行哪些改进?

Then I accidentally copied the movement parts to the GL_MODELVIEW and the fog was acting as I wanted it to act..... all was fine accepting the click animation wasn't in relation to the area anymore, now the animation moved with my ego perspective.... and I don't really get it what kind of drawing I have to put in which of these two VIEW's. Could anyone give me examples or explanations according to my code or a hint what I could improve in my styl?

推荐答案

投影矩阵用于创建您的观看量.想象一个 现实世界中的场景.你真的看不到你周围的一切, 只有你的眼睛让你看到.例如,如果你是鱼,那你 看到的东西更广泛.所以当我们说建立投影时 矩阵表示我们要设置要从场景中看到的内容 我们创造.我的意思是您可以在世界上的任何地方绘制对象.如果他们 不在视图体积之内,您将看不到任何东西.创建时 该视图体积假设您创建了6个剪切平面,这些剪切平面定义了 您的视野.

The projection matrix is used to create your viewing volume. Imagine a scene in the real world. You don't really see everything around you, only what your eyes allow you to see. If you're a fish for example you see things a bit broader. So when we say that we set up the projection matrix we mean that we set up what we want to see from the scene that we create. I mean you can draw objects anywhere in your world. If they are not inside the view volume you won't see anything. When you create the view volume imagine that you create 6 clipping planes that define your field of view.

关于modelview矩阵,它用于制作各种 转换为您的世界中的模型(对象).这样你 只需定义一次对象,然后平移或旋转 它或缩放它.

As for the modelview matrix, it is used to make various transformations to the models (objects) in your world. Like this you only have to define your object once and then translate it or rotate it or scale it.

在绘制对象之前,应先使用投影矩阵 场景以设置视图音量.然后绘制对象并更改 因此,模型视图矩阵.当然可以改变矩阵 绘制模型的中途,例如,如果您想绘制场景 然后绘制一些文本(使用某些方法,您可以更轻松地工作 在正交投影中),然后改回Modelview矩阵.

You would use the projection matrix before drawing the objects in your scene to set the view volume. Then you draw your object and change the modelview matrix accordingly. Of course you can change your matrix midway of drawing your models if for example you want to draw a scene and then draw some text (which with some methods you can work easier in orthographic projection) then change back to modelview matrix.

至于名称模型视图,它与建模的双重性有关 并查看转换.如果将摄像机向后拉5个单位,或者 将对象向前移动5个单位,基本上是相同的.

As for the name modelview it has to do with the duality of modeling and viewing transformations. If you draw the camera 5 units back, or move the object 5 units forwards it is essentially the same.

这篇关于GL_MODELVIEW和GL_PROJECTION的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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