Note that there are some explanatory texts on larger screens.

plurals
  1. POCulling techniques for rendering lots of cubes
    primarykey
    data
    text
    <p>I am working on a personal learning project to make a <a href="http://www.minecraft.net/play.jsp" rel="noreferrer">Minecraft</a> clone. It is working very well aside from one thing. Similar to Minecraft, my terrain has lots of cubes stacked on the Y so you can dig down. Although I do frustum culling, this still means that I uselessly draw all the layers of cubes below me. The cubes are X, Y and Z ordered (although only in 1 direction, so its not technically Z ordered to the camera). I basically from the player's position only add pointers to cubes around the player. I then do frustum culling against these. I do not do oct tree subdivision. I thought of simply not rendering the layers below the player, except this does not work if the player looks down into a hole. Given this, how could I avoid rendering cubes below me that I cannot see, or also cubes that are hidden by other cubes.</p> <p>Thanks</p> <pre><code>void CCubeGame::SetPlayerPosition() { PlayerPosition.x = Camera.x / 3; PlayerPosition.y = ((Camera.y - 2.9) / 3) - 1; PlayerPosition.z = Camera.z / 3; } void CCubeGame::SetCollids() { SetPlayerPosition(); int xamount = 70; int zamount = 70; int yamount = 17; int xamountd = xamount * 2; int zamountd = zamount * 2; int yamountd = yamount * 2; PlayerPosition.x -= xamount; PlayerPosition.y -= yamount; PlayerPosition.z -= zamount; collids.clear(); CBox* tmp; for(int i = 0; i &lt; xamountd; ++i) { for(int j = yamountd; j &gt; 0; --j) { for(int k = zamountd; k &gt; 0; --k) { tmp = GetCube(PlayerPosition.x + i, PlayerPosition.y + j, PlayerPosition.z + k); if(tmp != 0) { if(frustum.sphereInFrustum(tmp-&gt;center,25) != NULL) { collids.push_back(tmp); } } } } } </code></pre>
    singulars
    1. This table or related slice is empty.
    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.
 

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