我有一個AS3位圖圖像,我想歪曲像這樣:在AS3中使用的4x4 3DMatrix歪斜的圖像
我只想扭曲圖像的底部,並單獨留下頂部。基於我迄今爲止所做的研究,看起來我想使用Matrix3D類,但我不太清楚如何有效地實現它。
由於下面一個答案,這篇文章是一個很好的資源,瞭解與3x3矩陣Matrix3D類: http://www.senocular.com/flash/tutorials/transformmatrix/ 然而,隨着真棒作爲教程,它不提供歪斜上述圖像的能力。我正在尋找的是關於如何使用4x4矩陣的類似教程。我想知道的是將數字放在矩陣中的位置,我應該能夠弄清楚其他的一切。
這裏是什麼我有這樣的一些示例代碼:
var tempLoader:Loader=new Loader();
var tempBitmap:Bitmap;
var fattenTheBottom:Number;
tempLoader.load(new URLRequest("image.png"));
tempLoader.contentLoaderInfo.addEventListener(Event.COMPLETE,castBitmap);
function castBitmap(e:Event):void
{
tempLoader.contentLoaderInfo.removeEventListener(Event.COMPLETE,castBitmap);
tempBitmap = Bitmap(tempLoader.content);
// Make the image into a trapezoid here using fattenTheBottom
addChild(tempBitmap);
}
任何建議,將奇妙的感謝!
也許使用3D旋轉將底部靠近觀察者會更容易?不確定3D旋轉工具是否與AS3等效,但如果不是,您可以嘗試實現基本的3D引擎。 – Marty
您希望能夠控制哪種約束,即您是否能夠明確定義梯形底部的寬度。如果不是馬蒂建議你應該只能使用rotationX http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/display/DisplayObject.html#rotationX否則我認爲使用3DMatrix可以工作http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/geom/Matrix3D.html#appendRotation()translate rotate around X translate then tempBitmap.transform.matrix3D = your3DMatrix。 – shaunhusain
如果您關心嚴格控制Bitmap大小的任何限制,而這些限制需要更加精確而非眼動,則可能需要更多的數學計算。 – shaunhusain