gpt4 book ai didi

actionscript-3 - ActionScript 3 : translating coordinates from object's 3D space to another's?

转载 作者:行者123 更新时间:2023-12-02 21:16:03 24 4
gpt4 key购买 nike

我觉得这个问题可能已经在这里被问/回答了,如果是这样,我对带宽表示歉意,但我没有看到任何解释。

在 Flash AS3 中如何从一个对象的坐标空间转换到另一个对象的坐标空间?我可以在一个对象中取一个点,并使用 local3DToGlobal() 将其转换为全局坐标,然后使用 globalToLocal3D() 将其转换为另一个对象的本地坐标 - 但有直接的方法吗?

因此,如果我希望一个对象能够对另一个对象说:“将你的左上角移动到我的左上角”,即使这两个对象位于不同的 z 空间、进行 3 维旋转等。

我假设它是在matrix3D矩阵操作中 -

矩阵乘法?变换向量()? deltaTransformVector()?

我一直在研究 API,但非常希望有一个具体的例子。

谢谢!

最佳答案

一种方法是 getRelativeMatrix3D() ,从显示对象的 transform 属性调用,如:transform.getRelativeMatrix3d(root).position

Returns a Matrix3D object, which can transform the space of a specified display object in relation to the current display object's space. You can use the getRelativeMatrix3D() method to move one three-dimensional display object relative to another three-dimensional display object.

来自 Adob​​e 的 Performing complex 3D transformations ,有一个使用 Matrix3D 对象重新排序显示的示例,其中对盒子的面进行重新排序,以确保 3D 显示对象的分层对应于应用旋转后的相对深度:

var faces:Array;

for (var i:uint = 0; i < 6; i++)
{
faces[i].z = faces[i].child.transform.getRelativeMatrix3D(root).position.z;
this.removeChild(faces[i].child);
}
faces.sortOn("z", Array.NUMERIC | Array.DESCENDING);
for (i = 0; i < 6; i++)
{
this.addChild(faces[i].child);
}

关于actionscript-3 - ActionScript 3 : translating coordinates from object's 3D space to another's?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15979702/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com