Here's a really easy solution for ya!
Just AddMesh()ing all your cubes into a single mesh, leaving you with only one surface (try CountSurfaces() to check for yourself.) Don't forget to free the cubes after you've added them. The example program below will show the difference - you may have to adjust the constant "n" (number of cubes) depending on your computer.
Note that you'll need to do this for each terrain type (e.g. one for your stone walls, one for your doors) because all triangles on one surface must share the same texture and colour.
Of course, you still have a lot of wasted triangles between wall segments that will never be seen and are just eating up cycles. The next step (if necessary) would be to generate only the quads (two triangles forming a square) you need instead of relying on CreateCube().
Just AddMesh()ing all your cubes into a single mesh, leaving you with only one surface (try CountSurfaces() to check for yourself.) Don't forget to free the cubes after you've added them. The example program below will show the difference - you may have to adjust the constant "n" (number of cubes) depending on your computer.
; gfx init Graphics3D 800, 600 CreateLight() camera = CreateCamera() PositionEntity(camera, 0, 0, -25) ; level pivot level_pivot = CreatePivot() ; the cubes Const n = 2000 Dim c(n-1) For i = 0 To n-1 c(i) = CreateCube(level_pivot) PositionMesh c(i), Rnd(-20, 20), Rnd(-20, 20), Rnd(-20, 20) RotateMesh c(i), Rnd(0, 360), Rnd(0, 360), Rnd(0, 360) EntityColor c(i), Rnd(0, 255), Rnd(0, 255), Rnd(0, 255) Next ; show the level slowly rotating until user presses <esc> While Not KeyHit(1) TurnEntity level_pivot, .1, .2, .3 RenderWorld Text(0, 0, "press <esc> to collapse cubes") Flip Wend ; collapse cubes to single mesh level_mesh = CreateMesh(level_pivot) For i = 0 To n-1 AddMesh(c(i), level_mesh) FreeEntity(c(i)) Next ; show the level slowly rotating until user presses <esc> While Not KeyHit(1) TurnEntity level_pivot, .1, .2, .3 RenderWorld Text(0, 0, "press <esc> to end the program") Flip Wend End
Note that you'll need to do this for each terrain type (e.g. one for your stone walls, one for your doors) because all triangles on one surface must share the same texture and colour.
Of course, you still have a lot of wasted triangles between wall segments that will never be seen and are just eating up cycles. The next step (if necessary) would be to generate only the quads (two triangles forming a square) you need instead of relying on CreateCube().