   Matrix.RotationZ will mess up my sprite?
  Hi,I have a sprite which works fine as long as I do not rotate it. Basically, the location of the drawn sprite will change based on the rotation somehow... Please look at my code:GameEngine.Infantries.Sprite.Begin(SpriteFlags.AlphaBlend);GameEngine.Infantries.Sprite.Transform = Matrix.RotationYawPitchRoll(0,0,GameEngine.Infantries.Rotation);GameEngine.Infantries.Sprite.Draw(GameEngine.Infantries.Texture, new Vector3(64, 64, 0), new Vector3(GameEngine.Infantries.X + GameEngine.ViewX, GameEngine.Infantries.Y + GameEngine.ViewY, 0), Color.White.ToArgb());GameEngine.Infantries.Sprite.End();This code just does not work if I apply that rotation. The location of the sprite becomes wrong... why? The .X and .Y is the sprite location and ViewX and ViewY is obviously the "screen view port" location... it works fine until I rotate.. what am I doing wrong?The sprite has a size of 128x128 so the center rotation point should be 64,64,0... it's a 2D game.
  Is this MDX?  I've never used it, but I'm guess that it behaves like the old D3D9 sprite class where the transform is applied AFTER the vertices are transformed by the translation you supply to Draw.  You'll want to set Transform to a Matrix that is the result of Rotatation * Translation.   ;Quote:Original post by MJPIs this MDX?  I've never used it, but I'm guess that it behaves like the old D3D9 sprite class where the transform is applied AFTER the vertices are transformed by the translation you supply to Draw.  You'll want to set Transform to a Matrix that is the result of Rotatation * Translation.Yes this is C# and MDX. Hmm that sounds interesting. Can you elaborate this: You'll want to set Transform to a Matrix that is the result of Rotatation * Translation.So I should apply translation to that rotation?   ;Quote:Original post by kaisellgrenQuote:Original post by MJPIs this MDX?  I've never used it, but I'm guess that it behaves like the old D3D9 sprite class where the transform is applied AFTER the vertices are transformed by the translation you supply to Draw.  You'll want to set Transform to a Matrix that is the result of Rotatation * Translation.Yes this is C# and MDX. Hmm that sounds interesting. Can you elaborate this: You'll want to set Transform to a Matrix that is the result of Rotatation * Translation.So I should apply translation to that rotation?for exampleGameEngine.Infantries.Sprite.Transform = Matrix.RotationYawPitchRoll(0,0,GameEngine.Infantries.Rotation) * Matrix.Identity;;  Try using Matrix.Transformation2D.  This should apply your scale, rotation, and translation in the correct order.  Just make sure you pass <0,0,0> as the position to Sprite.Draw.   ;  Something is wrong, I do not see it drawing anything (draws probably outside the screen).GameEngine.Infantries.Sprite.Transform = Matrix.Transformation2D(new Vector2(0,0),0,Vector2.Empty,new Vector2(64,64), GameEngine.Infantries.Rotation,new Vector2(GameEngine.Infantries.X+GameEngine.ViewX,GameEngine.Infantries.Y+GameEngine.ViewY));GameEngine.Infantries.Sprite.Draw(GameEngine.Infantries.Texture, new Vector3(64, 64, 0), new Vector3(0, 0, 0), Color.White.ToArgb());I also tried passing the position to the Draw():GameEngine.Infantries.Sprite.Draw(GameEngine.Infantries.Texture, new Vector3(64, 64, 0), new Vector3(GameEngine.Infantries.X + GameEngine.ViewX, GameEngine.Infantries.Y + GameEngine.ViewY, 0), Color.White.ToArgb());Neither showed me anything.Did I do something wrong?;  You're passing <0, 0> as the scale, this will prevent you from drawing anything.  Pass <1, 1> if you want no scaling.   ;  Oh! It works now, thanks! :)   