如何在 XNA 4.0 中创建角钉效果?
我正在尝试使用 XNA 4.0 编写一个带有动态生成地图的策略游戏,并且创建所有地面纹理确实很困难,必须在 Photoshop 中单独扭曲它们。
所以我想做的是创建一个平面图像,然后通过移动图像的角以编程方式应用扭曲来模拟透视。
这是在 Photoshop 中完成的示例:
我怎样才能在 XNA 中做到这一点?
I am trying to write a strategy game using XNA 4.0, with a dynamically generating map, and it's really difficult to create all the ground textures, having to distort them individually in photoshop.
So what I want to do is create a flat image, and then apply the distortion programatically to simulate perspective, by moving the corners of the image.
Here is an example done in photoshop:
How can I do that in XNA?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我的答案不是特定于 XNA 的,因为我从未真正使用过该库;然而这个概念仍然适用。
一般来说,获得良好透视效果的最佳方法是实际给出 3D 坐标和变换,然后让 DirectX/OpenGL 处理其余部分。与尝试自己做相比,这有很大的好处 - 具体来说,易于使用、性能(大部分工作都传递到您的显卡上)以及 透视校正纹理。如果您担心的话,没有什么可以阻止您在同一场景中进行 3D 和 2D 处理。网上有许多关于使用 XNA 在三维中进行设置的教程。我建议您访问 MSDN。
My answer isn't XNA-specific as I've never actually used the library; however the concept should still apply.
In general, the best way to get a good perspective effect is to actually give 3d coordinates and transformations and let DirectX/OpenGL handle the rest. This has great benefits over attempting to do it yourself - specifically, ease of use, performance (much of the work is passed on to your graphics card), and perspective-correct texturing. And nothing's stopping you from doing 3d and 2d in the same scene, if that's a concern. There are numerous tutorials online for getting set up in the third dimension with XNA. I'd suggest heading over to MSDN.