在opengl中获取最近的聚焦对象
我正在通过 Java LWJGL 制作一款受《我的世界》启发的游戏,该游戏已经投入大量开发。然而,我不太确定我会使用什么方法来选择/突出显示玩家视锥体正中心的最近的块。
我已经存储了可以使用的截锥体和位置数据。
我对使用光线投射有一个模糊的想法,但这似乎与人们对光线投射所做的事情无关。
那么我将使用哪个函数或测试来确定这一点?
I'm making a minecraft-inspired game through Java LWJGL, which is heavy into development already. However, I am not quite sure what method I would use to pick/highlight the nearest block in the exact center of the player's view frustum.
I am already storing frustum and positional data, which I could use.
I had a vague idea about using raycasting, but this seems to be unrelated based on what people have done with raycasting.
So which function or test would I use to determine this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
光线投射肯定会起作用。您需要根据相机的方向及其位置创建一条射线。
如果您的相机旋转矩阵没有比例,则轴是第三列( z 轴)。现在,根据您的约定,z 轴可能指向屏幕或世界
Raycasting will definitively work. You need to create a ray from the orientation of your camera and its position.
If your camera rotation matrix has no scale, the axis is the third column ( the z-axis ). Now depending on your convention, z axis may point to screen or to the world