如何实现一个FPS相机而无需GLU在OSX(或跨平台)的C ++ [英] How to implement an FPS camera without GLU on OSX (Or cross platform) c++

查看:159
本文介绍了如何实现一个FPS相机而无需GLU在OSX(或跨平台)的C ++的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图得到一个FPS风格的摄像头的工作,而来自于对OpenGL OpenGL超级本书的例子如下沿。

I'm trying to get an FPS style camera working, while following along from the examples in the openGL SuperBible book.

这是所有进行得非常顺利,直到我遇到了,你最终不得不侧倾发生的,当你真的只想要俯仰和偏航的问题。

It was all going very well until I ran into the problem where you end up having roll happen, when you really only want pitch and yaw.

<一个href="http://stackoverflow.com/questions/788226/can-someone-explain-how-i-can-use-quanternions-to-use-the-mouse-to-look-around-li">Similar问题

这个问题基本上是问同样的事情,但我希望有人也许能够更详细一点关于实施,理想与OpenGL超级GLTools框架的经验。

This question is basically asking the same thing, but I was hoping someone might be able to be a bit more verbose about the implementation, ideally with experience of the SuperBible GLTools framework.

我已经尝试过实施 GluLookAt code 我'已经得到了编译,但无论是我复制的功能,在需要的时候犯了一个错误,或者说我在使用它传递了错误的参数。

I've already tried implementing GluLookAt code which I've got to compile, but either I made a mistake when duplicating the functions needed, or I'm passing in the wrong parameters when using it.

我想我发现它有点混乱的OpenGL超级code提炼了一下相机如何工作的,所以我觉得很难正确地执行它。当测试我目前的版本中,我传递这样的参数

I guess I'm finding it a bit confusing as the SuperBible code abstracts a bit of how the camera works, and so I'm finding it hard to implement it correctly. When testing my current version, I'm passing in parameters like this

M3DMatrix44f mCamera;
cameraFrame.GetCameraMatrix(mCamera);   //returns the matrix of the CameraFrame.

M3DVector3f up =   { 0.0f, 1.0f, 0.0f };    
M3DVector3f look = { xHeading,yHeading,0.0f }; 

//xHeading & yHeading ranges from -1 to 1 based on mouse movement, is this correct?

我应该如何进行管理和传递的外观变量?看来当前的外观值是住在同一个地方,所以如果我向后移动,我结束了在场景旋转。

How should I be managing and passing in the look variables? It appears currently that the look value is staying in the same place and so if I move backwards, I end up rotating around the scene.

glhLookAtf2(mCamera, mCamera, look, up);

我觉得我必须更好地管理我的观察方向,并有可能我的相机的位置为好。这似乎很奇怪的样子立场似乎并没有改变。

I feel that I have to be managing my look direction better, and possibly my camera location as well. It seems odd that the look position doesn't seem to change.

谁能帮助,或点我在一个坚实的教程路径的方向?我试图避免做任何事情去precated,但在这一点上,我会真的很高兴刚刚得到的东西的工作。

Can anyone help, or point me in the direction of a solid tutorial path? I'm trying to avoid doing anything deprecated, but at this point I'd be really happy just to get something working.

推荐答案

谢谢大家的答案,但这个问题我是这样的。在OpenGL的超级宝典,我是用自己的内置引用类的框架,而这个问题我已经是两个功能,一个叫旋转,并rotateWorld。

Thanks for everyones answers but the problem I had was this. In the openGL super bible, I was using their built in frame of reference class, and the problem I had was two functions, one called rotate, and rotateWorld.

我需要使用旋转上/下运动,和rotateWorld为左右移动。这使得相机的行为正确(飞摄像头)。

I needed to use rotate for up/down movement, and rotateWorld for left right movement. This made the camera behave correctly (fly camera).

这是有道理的,无论你在哪里寻找向上/向下的,你想整个世界总是不停地旋转垂直轴。唷!

It makes sense as regardless of where you are looking up/down, you want the whole world to always spin around the vertical axis. Phew!

这篇关于如何实现一个FPS相机而无需GLU在OSX(或跨平台)的C ++的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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