Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/actionscript-3/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Actionscript 3 纹理旋转';我走对了_Actionscript 3_Stage3d - Fatal编程技术网

Actionscript 3 纹理旋转';我走对了

Actionscript 3 纹理旋转';我走对了,actionscript-3,stage3d,Actionscript 3,Stage3d,我试图构建一个2d sprite类,在stage3d中工作,缩放和平移都可以,但旋转不正确 var m:Matrix3D = new Matrix3D(); m.appendRotation(getTimer()/40, Vector3D.Z_AXIS); context3D.setProgramConstantsFromMatrix(Context3DProgramType.VERTEX, 0, m, true); 它似乎旋转了整个3d上下文,

我试图构建一个2d sprite类,在stage3d中工作,缩放和平移都可以,但旋转不正确

        var m:Matrix3D = new Matrix3D();
        m.appendRotation(getTimer()/40, Vector3D.Z_AXIS);
        context3D.setProgramConstantsFromMatrix(Context3DProgramType.VERTEX, 0, m, true);
它似乎旋转了整个3d上下文,因为3d上下文有它自己的宽度和高度,所以图片看起来像被拉伸了,哈,当我写到这里时,我得到了答案,所以将context3D设置为正方形大小解决了问题

        context3D.configureBackBuffer(1600, 1600, 1, true);
因此,我的新问题是如何设置context3D仅显示在特定区域。如果swf阶段大小为1900x1000,我将配置一个后缓冲区1900x1900,希望它仅显示在矩形(2002001200600)中,该区域之外的任何内容都将被剪裁,我该怎么办

更新: 在2d舞台上画四个方块可以解决问题,需要更好的方法

更新2: 使用剪刀式api也可以解决这个问题

context3D.setScissorRectangle(new Rectangle(0,0,1600,900));
但修建广场仍然是巨大的浪费,需要更好的方法

更新3:
最后我得到了正确的答案。您需要使用matrix3d将每个像素从((0,0),(1,0),(0,1))坐标世界转换为((0,0),(0.5/stage3dwidth,0),(-0.5/Stage3dHight,0))坐标世界。这是转换矩阵,建议3d舞台尺寸为1600x900

    var m2:Matrix3D = new Matrix3D();
    m2.appendScale(1,-1,1);
    m2.appendTranslation(-800,450,0);
    m2.appendScale(1/800,1/450,1);
    m.append(m2);
var m2:Matrix3D = new Matrix3D();
m2.appendScale(1,-1,1);
m2.appendTranslation(-800,450,0);
m2.appendScale(1/800,1/450,1);
m.append(m2);

不确定您是否已经知道,但它可以减轻您在尝试创建自己的2D库包装阶段3D时所经历的痛苦

它拥有Adobe的强大支持,很可能是您在性能和可用性方面所能取得成就的缩影


如果你真的想让它自己工作,你至少可以看看Starling的源代码。

不确定你是否已经知道,但它可以减轻你在尝试创建自己的2D库包装阶段3D时所经历的痛苦

它拥有Adobe的强大支持,很可能是您在性能和可用性方面所能取得成就的缩影


如果你真的想让它自己工作,你至少可以看看Starling的源代码。

最后我得到了正确的答案。你需要使用matrix3d将每个像素从((0,0),(1,0),(0,1))坐标世界转换为((0,0),(0.5/stage3dwidth,0),(-0.5/Stage3dHight,0))坐标世界。这是转换矩阵,建议3d舞台尺寸为1600x900

    var m2:Matrix3D = new Matrix3D();
    m2.appendScale(1,-1,1);
    m2.appendTranslation(-800,450,0);
    m2.appendScale(1/800,1/450,1);
    m.append(m2);
var m2:Matrix3D = new Matrix3D();
m2.appendScale(1,-1,1);
m2.appendTranslation(-800,450,0);
m2.appendScale(1/800,1/450,1);
m.append(m2);

最后我得到了正确的答案。您需要使用matrix3d将每个像素从((0,0),(1,0),(0,1))坐标世界转换为((0,0),(0.5/stage3dwidth,0),(-0.5/Stage3dHight,0))坐标世界。这是转换矩阵,建议3d舞台尺寸为1600x900

    var m2:Matrix3D = new Matrix3D();
    m2.appendScale(1,-1,1);
    m2.appendTranslation(-800,450,0);
    m2.appendScale(1/800,1/450,1);
    m.append(m2);
var m2:Matrix3D = new Matrix3D();
m2.appendScale(1,-1,1);
m2.appendTranslation(-800,450,0);
m2.appendScale(1/800,1/450,1);
m.append(m2);