2013-12-13 22 views
0

我試圖用spritebatch執行一些矩陣轉換,我不明白尺度矩陣發生了什麼。Matrix創建規模,這裏發生了什麼?

 rotM = Matrix.CreateTranslation(0, 0, 0) 
       * Matrix.CreateFromYawPitchRoll(MathHelper.ToRadians(startRotations.Y) 
               , MathHelper.ToRadians(startRotations.X) 
               , MathHelper.ToRadians(startRotations.Z)) 
       * Matrix.CreateScale(endScale.X, endScale.Y, 0) 
       * Matrix.CreateTranslation((Origin.X + PositionRec.X + Offset.X) * endScale.X 
             , (Origin.Y + PositionRec.Y + Offset.Y) * endScale.Y, 0); 

     sp.Begin(SpriteSortMode.Deferred, null, null, null, null, null, rotM); 
     sp.Draw(BackgroundTexture, Vector2.Zero, PositionRec, BackgroundColor * alpha); 
     sp.End(); 

Usualy我得到最好的結果看這個順序,但是如果我更改比例是旋轉一切變得怪異前,即使使用(1.1.0)的規模,所以我剛開始的原始大小。

讓我們將標度固定爲1(不包括Z),爲什麼/如果我用標尺保留頂點(我認爲)會影響旋轉?

實例:

譯本> Rotation->橫向擴展>翻譯

http://imgur.com/ihdlepa

譯本>橫向擴展> Rotation->翻譯

http://imgur.com/YpbOnqw

感謝羅傑

回答

0

經過一番思考後,我想我明白了。

所以我在3D空間中繪製了精靈2d。 旋轉後,z座標具有值,因此使用0作爲z比例將破壞該值。

因爲我沒有使用燈光或陰影,所以很難檢查發生了什麼。

這是正確的嗎?

謝謝,羅傑

相關問題