OpenGL 中的广告牌效果

发布于 2024-12-20 01:54:26 字数 88 浏览 2 评论 0原文

我如何概念化让图像始终面向相机。我尝试使用三角函数与反正切以及从相机到图像的距离,但这看起来不太优雅。它还设置了图像旋转方式的界限。有没有更好的方式来进行广告牌?

How would I conceptualize getting an image to always face a camera. I tried using trigonometry with arctan and the distances from the camera to the images, however this did not seem very graceful. It also set a bound on how for the image can rotate. Is there a better way to go about billboarding?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

紫南 2024-12-27 01:54:26

根据涉及的角度,广告牌有 3 种类型:

  • 1 轴面对摄像头 - 通常在旧游戏中用作树,如果你从垂直高度看它们,它们会“消失”;
  • 通过 2 个轴面对相机并在剩余的 1 个轴上围绕自身旋转 - 这些通常用于粒子(烟雾、火焰、星星);
  • 通过 2 轴面对相机并跟随相机的滚动(组) - 这些通常用于游戏内文本和标题。

正如您可能已经注意到的 - 如果广告牌与摄像机角度匹配,一切都与旋转有关。你有一个具有不同方向的相机对象吗?如果是 - 你只需采取角度并使用它们(广告牌应该面向相机,而不是模仿它,因此法线方向将被反转(当相机朝北时,广告牌朝相反的方向 - 南))。如果没有 - 你应该买一台相机。

There are 3 type of billboards, by angles involved:

  • face camera by 1 axis - usually used as trees in older games, if you look at them from straight up height they will "disappear";
  • face camera by 2 axis and rotate around themselves in remaining 1 axis - those are usually used for particles (smoke, fire, stars);
  • face camera by 2 axis and follow camera's roll(bank) - those are usually used for ingame texts and captions.

As you might have already noticed - everything is about rotation, if billboard matches the camera angles. Do you have a Camera object with distinct orientation? If yes - you just take the angles and use them (billboard should face the camera, not mimic it, so the normal direction gonna be inversed (when camera faces north, billboard faces the opposite - south)). If no - you should get a Camera.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文