Away3D (4.x broomstick) 如何将对象的全局位置转换为局部位置?

发布于 2024-12-01 22:48:29 字数 96 浏览 6 评论 0原文

我正在构建一个向目标(平面)发射球的游戏。飞机向后旋转 45 度。我想将全局球位置(x,y,z)转换为目标的本地坐标,以便我可以检测它击中的位置。

有什么想法吗?

I am building a game that launches a ball at a target(Plane). The Plane is rotated back 45 degrees. I want to convert the global ball position(x,y,z) into the local coords of the target so I can detect where it hits.

Any ideas?

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

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

发布评论

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

评论(2

时间你老了 2024-12-08 22:48:29

使用目标平面的 inverseSceneTransform 来变换球的position 向量。应该可以做到这一点。

var localPosition : Vector3D;
localPosition = plane.inverseSceneTransform.transformVector( ball.position );

这应该可以告诉你球在飞机局部空间中的位置。

Use the target plane's inverseSceneTransform to transform the position vector of the ball. That should do it.

var localPosition : Vector3D;
localPosition = plane.inverseSceneTransform.transformVector( ball.position );

That should give you the ball's position in the plane's local space.

若水般的淡然安静女子 2024-12-08 22:48:29

上述解决方案仅在物品/球直接位于舞台上时才有效。如果不是,您应该使用 ball.scenePosition!

item.position = targetContainer.inverseSceneTransform.transformVector(item.scenePosition);

Above solution only works if the item/ball is directly on the stage. If it isnt, you should use ball.scenePosition!

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