Question

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:
Image Distortion
How can I do that in XNA?

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top