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

查看:23
本文介绍了如何在 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天全站免登陆