我试图在x轴上反映我的游戏世界。 我有一个相机,它计算变换矩阵:
_transform =
Matrix.CreateTranslation(new Vector3(-_pos.X, -_pos.Y, 0)) *
Matrix.CreateRotationZ(Rotation) *
Matrix.CreateScale(Zoom) *
Matrix.CreateTranslation(new Vector3(_graphicsDevice.Viewport.Width * 0.5f, _graphicsDevice.Viewport.Height * 0.5f, 0));
它工作正常,直到我放一个反射部分:
_transform = //first try, place here
Matrix.CreateTranslation(new Vector3(-_pos.X, -_pos.Y, 0)) *
Matrix.CreateRotationZ(Rotation) *
Matrix.CreateScale(Zoom) *
Matrix.CreateReflection(new Plane(Vector3.UnitY, 0)) * //here
Matrix.CreateTranslation(new Vector3(_graphicsDevice.Viewport.Width * 0.5f, _graphicsDevice.Viewport.Height * 0.5f, 0));
用“反思”
spriteBatch.Begin(SpriteSortMode.BackToFront,
BlendState.AlphaBlend,
null,
null,
null,
null,
Camera.Active.GetTransformation);
什么都没画。
请帮助和抱歉我的英语:)
UPD :我做了一些测试:
var v = new Vector2(0, 10);
var v2 = Vector2.Transform(v, _transform);
没有.CreateReflection v2 = {X:450 Y:370}
与.CreateReflection v2 = {X:450 Y:350} //好的。它被反映出来了。但是,为什么它不画画?
答案 0 :(得分:2)
使用X取反的比例应该完成这项工作:
_transform = //first try, place here
Matrix.CreateTranslation(new Vector3(-_pos.X, -_pos.Y, 0)) *
Matrix.CreateRotationZ(Rotation) *
Matrix.CreateScale(Zoom) *
Matrix.CreateScale(-1,1,1) * //here
Matrix.CreateTranslation(new Vector3(_graphicsDevice.Viewport.Width * 0.5f, _graphicsDevice.Viewport.Height * 0.5f, 0));