如何在OSX(或跨平台)c ++上实现没有GLU的FPS相机 [英] How to implement an FPS camera without GLU on OSX (Or cross platform) c++

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

问题描述

我试图让一个FPS风格的相机工作,同时沿着openGL SuperBible书中的例子。

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.

类似问题

这个问题基本上是问同样的问题,但我希望有人能够更详细地介绍实现,理想情况下使用SuperBible 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代码,我已经编译,但是我在复制所需的函数时犯了一个错误,或者在使用它时传递了错误的参数。

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.

我想我找到了有点混乱,因为SuperBible代码抽象了一些如何相机的工作,所以我发现很难正确实现它。当测试我的当前版本,我传递参数如下

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.

任何人都可以帮助,或指向一个坚实的教程路径的方向?我试图避免做任何废弃的东西,但在这一点上,我真的很高兴只是为了工作。

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超级圣经中,我使用他们内置的引用类框架,我遇到的问题是两个函数,一个叫rotate和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.

我需要使用旋转上/下移动,旋转世界左移。这使得相机正常运行(飞行相机)。

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!

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

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