Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>First things first: Sort your angles and their corresponding vertices from least to greatest.</p> <p>Start with your viewer 'aiming' to the left, and store the nearest visible point (which happens to be on the wall) in tmpPoint or something like that.</p> <p><img src="https://i.stack.imgur.com/iMawU.png" alt="enter image description here"></p> <p>Then, you go through your list of angles you calculated. You are going to sweep out the whole area of the screen, clockwise (do this by iterating through your list of sorted angles). The first ray you are testing is the bottom left of the little rectangle (it has the lowest angle that you calculated). The nearest visible point is on the left wall somewhere. Your visible triangle list, add the triangle formed by the viewer, tmpPoint, and the point you just found. (see picture) Finally, store that point in tmpPoint.</p> <p><img src="https://i.stack.imgur.com/jlmae.png" alt="enter image description here"></p> <p>The next point we check is the upper left of the little rectangle. Here is where we really need to check for visibility. The nearest point is the visible one. (see picture) Then, add your triangle (composed again of the point you just found, the viewer, and tmpPoint). Just repeat this process over and over, and you will eventually fill your whole screen with triangles representing visibility.</p> <p><img src="https://i.stack.imgur.com/PHAM5.png" alt="enter image description here"></p> <p>I hope this helps. I made some nice pseudocode, but I was doing it wrong, so here are just the graphics. :P</p> <p>Edit:<br> So you have your verticy array all calculated out, and by calculated I mean visibility of the rays. What you do is something almost like this:</p> <pre><code>for(int i = 0; i &lt; calculatedVertices.size()-1; i++) { triangle t = triangle( calculatedVertices[i], calculatedVertices[i+1], centerViewer); triangleArray.add(t); } //the loop above misses one triangle, so just add the last one triangle final = triangle( calculatedVertices[0] calculatedVertices[calculatedVertices.size()-1], centerViewer); triangleArray.add(final); </code></pre> <p>This nearly fully works, except for one terrible issue:</p> <p><img src="https://i.stack.imgur.com/6LYoJ.png" alt="enter image description here"></p> <p>You see, when you have your far-wall cast triangle, the intersection should occur on the wall, but when you have your triangle cast to the rectangle, the intersection should occur on the rectangle itself. If the intersections don't occur in this manner, this will happen:</p> <p><img src="https://i.stack.imgur.com/9svS6.png" alt="enter image description here"></p> <p>I'm not entirely sure if this is an actual problem, or if its just something i'm thinking of, but a way you can solve it is by adding a slight bias (of your intersection detection) towards your other vertex, if you know what I mean. That should fix this problem.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload