AS3 碰撞盒 + papervision3d +吉格利布

发布于 2024-10-15 22:22:43 字数 578 浏览 6 评论 0原文

我正在尝试重新创建下面网站上解释的“教程”。场景中有 5 个骰子在弹跳。但我一开始就陷入困境:)

papervision3d -jiglib-dice-demo

我的问题是边界框。我想根据舞台的大小创建一个有地板和 4 壁的盒子。我可以使用相机上的变焦/聚焦来获得正确的尺寸。但问题是骰子会穿过它。

我如何建造 4 堵墙并确保当我对其施加力时骰子不会穿过它?

我尝试了以下源中的解决方案,但不知怎的,骰子继续通过:(

投掷骰子-with-the-jiglib-physical-engine-and-away3d

有人知道怎么做吗?或者有更好的方法让骰子保持在屏幕上?

I'm trying to recreate the "tutorial" explained on the site below. It's 5 dices bouncing around on the scene. But i'm stuck at the very beginning :)

papervision3d-jiglib-dice-demo

My problem is the bounding box. I want to create a box with a floor and 4 walls based on the size of the stage. I can get it the right size using zoom/focus on the camera. But the problem is the dices go through it.

How can i build 4 walls and make sure a dice doesnt go through it when i apply forces to it?

I tried the solution in the following source, but somehow the dices keep going through :(

throwing-dice-with-the-jiglib-physics-engine-and-away3d

Anybody knows how to do it? Or a better way to keep the dices on screen?

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

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

发布评论

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

评论(1

淡淡の花香 2024-10-22 22:22:43

我解决了这个问题。只是与其他想要尝试相同的人分享:

  • 设置相机变焦 = 2
  • 设置相机焦距 = 距离 / 变焦
  • // 现在场景宽度和高度与舞台的实际尺寸匹配。

  • 添加所有面的平面,并确保使线段小于骰子的大小。 (例如:骰子大小 = 30;舞台宽度 = 300;段 = 舞台宽度/骰子大小 = 10)。

  • 确保你对结果进行ceil,因为segments需要int。
  • 当然你可以把它做得更大,但是这样会更难渲染。
  • 我将平面的高度设置得比骰子大小的两倍小,以确保它们永远不会相互重叠。

  • 最后通过将另一个具有小段的平面放置在其他平面的顶部来添加天花板

I solved the problem. Just to share with others who want to try the same:

  • Set camera zoom = 2
  • Set camera focus = distance / zoom
  • // now the scene width and height match the actual size of the stage.

  • add the planes for all sides and make sure you make the segments smaller then the dice size. (EG: dice size = 30; stage width = 300; segments = stage width/ dice size = 10).

  • make sure you ceil the results because segments require int
  • Ofcourse you can make it larger, but then it will be harder to render.
  • I made the height of the planes a little smaller then twice the dice size to make sure they never get on top of eachother.

  • And finally add a ceiling by placing another plane with small segments on top of the other planes

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