Here is my issue. I'm rendering axis alligned cubes that are all the same size. I created an algorithm that rendered around the player like this:
******
******
***p**
******
******
While this does work, the player does not see this whole radius. I know the player's rotation angle on the Y, so I was hoping to modify my algorithm based on this so that it would only render about, what the player can see more or less.
SetPlayerPosition();
float yrotrad;
yrotrad = (Camera.roty / 180 * 3.141592654f);
PlayerPosition.x += 70 * float(sin(yrotrad));
PlayerPosition.y -= 20;
PlayerPosition.z += 70 * -(float(cos(yrotrad)));
collids.clear();
for(int i = 0; i < 135; ++i)
{
for(int j = 0; j < 50; ++j)
{
for(int k = 0; k < 135; ++k)
{
if(!CubeIsEmpty(PlayerPosition.x + i, PlayerPosition.y + j, PlayerPosition.z + k))
{
collids.push_back(GetCube(PlayerPosition.x + i, PlayerPosition.y + j, PlayerPosition.z + k));
}
}
}
}
Basically, my original algorithm would just subtract 70 from the players location, and render the square that is 70 in size. So I tried to multiply these by the sin and cos os the Y rotation but it did not work. I'm sure this is possible, I just think i'm missing something. How could I achieve my goal of only rendering ~what the player sees.
Thanks
Just as a note, I tried frustrum culling and this got too slow, I'd rather this which works no matter how many cubes I have
instead of rendering the above id like it to only, ex if the player is facing ->
...... ****
...... ****
......P****
...... ****