我知道Texture2D可以在Draw()过程中旋转,但我要求的有点不同。在绘制之前,我需要旋转的Texture2D,并将其存储到另一个Texture2D中以便进一步操作。大致是这样的:
Texture2D rotated = getRotatedTexure(originalTexture);然而,我甚至不知道从哪里开始。我是否要将纹理转换为图像,然后在那里进行工作?任何建议都将不胜感激。
这样做的原因既长又复杂,但从本质上讲,我是在尝试构建一个旋转动画引擎(又称“骨骼动画”、“骨骼动画”或“裁剪动画”)。
发布于 2013-01-29 13:06:38
发布于 2013-12-27 18:06:48
您可以做的事情是定义一个RenderTarget2D并在其中绘制旋转纹理。示例:
RenderTarget2D rotated_texture = new RenderTarget2D(GraphicsDevice, texture_width, texture_height);
GraphicsDevice.SetRenderTarget(rotated_texture);
spriteBatch.Begin();
//Draw the texture with rotation
spriteBatch.End();
GraphicsDevice.SetRenderTarget(null); //Reset to screen drawing如果你想在屏幕上绘制rotated texture,你可以这样做:
//GraphicsDevice.SetRenderTarget(null); //Considering this done
spriteBatch.Begin();
spriteBatch.Draw(rotated_texture, vector_position, Color.White);
spriteBatch.End();https://stackoverflow.com/questions/14575883
复制相似问题