0

I am really confused trying to understand the basics of how 3d works in Flash and ActionScript.

I think by explaining how I could do the following that might make things a bit clearer.

I have created a green rectangle in a MovieClip and assign it a class. I then create several instances of this class on the stage. If I put them in a line across the screen and set the rotationY property to 90 on all of them they all look different. They look like they would if you were looking at them through a camera.

This is the actionscript code:

package  {

    import flash.display.MovieClip;
    import flash.events.Event;


    public class Main extends MovieClip {

        public function Main() {

            for (var i:uint=0; i<21; i++)
            {
                var obj = new Test();
                obj.y = 300;
                obj.x = i * 80;
                obj.rotationY = 90;
                addChild(obj);
            }
        }
    }

}

This is a screenshot of the output: screenshot 1

This is a screenshot of the MovieClip: screenshot 2

How would I go about arranging these on the screen so that they all appeared side on (like one bang in the centre would)? I effectively want to disable looking at it through a camera.

Likewise does this mean that even objects that are on the stage that have a y rotation of 0 are also being treated like they are in a 3d space and rotated slightly?

Thanks!

4

1 回答 1

2

发现http://backroom.bostonproductions.com/?p=761很好地解释了它。

这是因为 90 度旋转与舞台的消失点有关(可以使用 IDE 中的 3D 变换工具进行设置)。默认情况下,消失点将影响所有显示对象,导致 3D 旋转成为消失点的产物。但是,如果您不希望显示对象根据消失点在 3D 空间中旋转怎么办?如果您想将正方形旋转 90 度并看到旋转 90 度的正方形,而不管它在舞台上的位置如何?您可以使用 ActionScript 3 和 PerspectiveProjection 来处理这个问题。通过变换正方形的 PerspectiveProjection 并将投影中心设置为正方形的 X 和 Y 位置,您现在可以独立于舞台的消失点旋转它。

因此,需要为每个 MovieClip 分配其自己的 PerspectiveProjection 对象。

此外,只有在设置 x 或 y 旋转或 z 位置时,元素才会转换为 3d(自动),如http://help.adobe.com/en_US/ActionScript/3.0_ProgrammingAS3/WS7D38179D-58B9-409c-9E5C-257DDECB1A02 .html

当您将显示对象的 z 属性显式设置为数值时,该对象会自动创建一个 3D 变换矩阵。您可以更改此矩阵以修改该对象的 3D 转换设置。

此外,3D 旋转不同于 2D 旋转。在 2D 中,旋转轴始终垂直于 x/y 平面 - 换句话说,在 z 轴上。在 3D 中,旋转轴可以围绕 x、y 或 z 轴中的任何一个。设置显示对象的旋转和缩放属性使其能够在 3D 空间中移动。

于 2013-06-01T15:50:23.487 回答