List of pixel coordinates inside a triangle

I make a game in C # and XNA, and I tried to come up with a method for rendering massive landscapes without using a huge amount of memory or transmitting a poly-limit hardcoded in XNA.

My solution so far is to create a massive height map, and this height map is loaded into memory at the beginning of the game at the initialization stage. Then the relief is created only closest to the camera. This is achieved by projecting a triangle whose vertex is a symbol, and the other two endpoints extend to the sides of the symbol viewing area. Then all the pixels inside this triangle on the height map are visualized and drawn into the game, so only what is visible is displayed.

The problem is that I successfully found (I think I can’t check until I get the rendering of the landscape) the three vertices of the triangle. Now I need to find a list of coordinates for each pixel inside this triangle - integers, because I just need a list of pixels for rendering.

I know this sounds a bit confusing, so here's the gist:

I have an image and I am projecting a triangle onto this image. The only thing I know about this triangle is three peaks. I need a list of pixels inside this triangle.

I’m going to take a walk for several minutes, and I thought that Midas is moving well and publishing something here due to the fact that what I'm trying to do is not so common. If I find an answer, I will definitely post it here.

But until then, can someone tell me how to do this?

Edit: Formula please. If you can provide a formula or algorithm and explanation, this will be just perfect.

Edit: I posted a new question since I removed this method of rendering large territories. The question is here .

+4
source share
1 answer

Start here:

http://mathworld.wolfram.com/TriangleInterior.html

One of the non-trivial issues not mentioned here is that you have to deal with pixelation along the border.

+3
source

All Articles