Now by visible I mean cubes that should theoretically be visible from the isometric point of view. Cubes that have a neighbor to the top, left and right are "not visible". If any of those three conditions is not met, then it "is visible".

After that I use two functions I made, normalToIsoX and normalToIsoY to find out the x,y coordinates of the cube, based on its x,y,z coordinate on the grid. After that I use cam:cameraCoords() on isoX and isoY to find the cubes x,y on the screen ( I use hump.camera )

Now here is the code :

Code: Select all

```
t.cubeIsVisible = function(x,y,z)
local xE = false
local yE = false
local zE = false
if (x + 1) > #grid then xE = true end
if (y + 1) > #grid[x] then yE = true end
if (z + 1) > #grid[x][y] then zE = true end
if xE or yE or zE then return true end
local n = 0
if grid[x + 1][y][z] ~= 0 then n = n + 1 end
if grid[x][(y + 1)][z] ~= 0 then n = n + 1 end
if grid[x][y][(z + 1)] ~= 0 then n = n + 1 end
local screenX, screenY = cam:cameraCoords(gridFuncs.normalToIsoX(x,y),gridFuncs.normalToIsoY(x,y,z,3))
if n == 3 then
return false
elseif not (((screenX < -100*zoom) or (screenX > wW + 100*zoom)) and ((screenY < -100*zoom) or (screenY > wH + 100*zoom))) then
return true
end
end
```