简体   繁体   English

OpenGL:最终的坐标系混乱解决方案?

[英]OpenGL: the ultimate coordinate system confusion solution?

I'm tired of thinking how the hell my coodinates are working at each case. 我厌倦了思考我的同伙们在每种情况下如何工作。

I heard that I could flip the Y-axis by this code: 我听说可以通过以下代码翻转Y轴:

glScalef(1, -1, 1);

But should I? 但是我应该吗? Doesnt this break some other external functions and lighting etc? 这不会破坏其他一些外部功能和照明等吗?

我可能会说,习惯于opengl默认值是摆脱混乱的最快方法。

There's no correct yes/no answer to this question. 这个问题没有正确的是/否答案。 Calling glScalef(1, -1, 1) means using a left-handed instead of a right handed coordinate system, this has historically been the choice of for instance Direct3D and the RenderMan Interface. 调用glScalef(1, -1, 1)意味着使用左手坐标系而不是右手坐标系,这在历史上一直是例如Direct3D和RenderMan接口的选择。 Some people feel it's more intuitive to have the positive z-axis pointing in to the screen instead of out of it (which is one version of a left handed coordinate system, the y-axis pointing down is another). 有人认为将正z轴指向屏幕而不是指向屏幕更直观(这是左手坐标系的一种版本,指向下方的y轴是另一种)。

If you chose to switch coordinate system, you will have to change some of the standard settings in OpenGL to make it work. 如果选择切换坐标系,则必须更改OpenGL中的某些标准设置才能使其正常工作。 For instance you probably want to call glCullFace(GL_FRONT) (or reverse the order of all triangles sent to OpenGL). 例如,您可能要调用glCullFace(GL_FRONT) (或反转发送到OpenGL的所有三角形的顺序)。

I could be wrong, but it might turn your models inside-out. 我可能是错的,但可能会使您的模型由内而外。 You will probably also need to swap your vertex winding order. 您可能还需要交换顶点缠绕顺序。 If you use two-sided polygons, though, then you don't need to worry. 但是,如果使用双面多边形,则无需担心。

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

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