I'll write out a short tutorial explaining just what each of the fields are for. Once the header is created, it can be copied to any mesh memblock that uses the same structure.

Type Vertex x as float y as float z as float nx as float ny as float nz as float u as float v as float color as integerendtypeType Triangle v1 as integer v2 as integer v3 as integerendtypeType Mesh VertexList as Vertex[] TriangleList as Triangle[]endtypeFunction AddVertex(m ref as Mesh, x as float, y as float, z as float, nx as float, ny as float, nz as float, u as float, v as float, color as integer) vert as vertex vert.x = x vert.y = y vert.z = z vert.nx = nx vert.ny = ny vert.nz = nz vert.u = u vert.v = v vert.color = color m.VertexList.Insert(vert)endfunctionFunction AddTriangle(m ref as Mesh, v1 as integer, v2 as integer, v3 as integer) t as Triangle t.v1 = v1 t.v2 = v2 t.v3 = v3 m.TriangleList.Insert(t)endfunctionFunction CreateObjectFromMesh(m ref as mesh) VertexCount = m.VertexList.Length + 1 IndexCount = (m.TriangleList.Length + 1) * 3 IndexOffset = 72 + VertexCount*36 memblock = CreateMemblock(IndexOffset+IndexCount*4) SetMemblockInt(memblock,0,VertexCount) SetMemblockInt(memblock,4,IndexCount) SetMemblockInt(Memblock,8,4) SetMemblockInt(memblock,12,36) SetmemblockInt(memblock,16,72) SetMemblockInt(memblock,20,IndexOffset) SetMemblockInt(memblock,24,0x0c000300) SetMemblockString(Memblock,28,"position") SetMemblockInt(memblock,40,0x08000300) SetMemblockString(memblock,44,"normal") SetMemblockInt(memblock,52,0x04000200) SetMemblockString(memblock,56,"uv") SetMemblockInt(memblock,60,0x08010401) SetMemblockString(memblock,64,"color") for i = 0 to m.VertexList.Length SetMemblockFloat(memblock,72+i*36,m.VertexList[i].x) SetMemblockFloat(memblock,76+i*36,m.VertexList[i].y) SetMemblockFloat(memblock,80+i*36,m.VertexList[i].z) SetMemblockFloat(memblock,84+i*36,m.VertexList[i].nx) SetMemblockFloat(memblock,88+i*36,m.VertexList[i].ny) SetMemblockFloat(memblock,92+i*36,m.VertexList[i].nz) SetMemblockFloat(memblock,96+i*36,m.VertexList[i].u) SetMemblockFloat(memblock,100+i*36,m.VertexList[i].v) SetMemblockInt(memblock,104+i*36,m.VertexList[i].color) next for i = 0 to m.TriangleList.Length SetMemblockInt(memblock,IndexOffset+i*12,m.TriangleList[i].v1) SetMemblockInt(memblock,IndexOffset+i*12+4,m.TriangleList[i].v2) SetMemblockInt(memblock,IndexOffset+i*12+8,m.TriangleList[i].v3) next id = CreateObjectFromMeshMemblock(memblock) DeleteMemblock(memblock)endfunction id

// Project: Cube // Created: 2018-03-06#insert "mesh.agc"// show all errorsSetErrorMode(2)// set window propertiesSetWindowTitle( "Cube" )SetWindowSize( 1024, 768, 0 )SetWindowAllowResize( 1 ) // allow the user to resize the window// set display propertiesSetVirtualResolution( 1024, 768 ) // doesn't have to match the windowSetOrientationAllowed( 1, 1, 1, 1 ) // allow both portrait and landscape on mobile devicesSetSyncRate( 30, 0 ) // 30fps instead of 60 to save batterySetScissor( 0,0,0,0 ) // use the maximum available screen space, no black bordersUseNewDefaultFonts( 1 ) // since version 2.0.22 we can use nicer default fontscube as Mesh//face 1AddVertex(Cube,-5,-5,-5,0,0,-1,0,1,0xFFFFFFFF) //0AddVertex(Cube,-5,5,-5,0,0,-1,0,0,0xFFFFFFFF) //1AddVertex(Cube,5,5,-5,0,0,-1,1,0,0xFFFFFFFF) //2AddVertex(Cube,5,-5,-5,0,0,-1,1,1,0xFFFFFFFF) //3AddTriangle(Cube,0,2,1)AddTriangle(Cube,0,3,2)//face 2AddVertex(Cube,5,5,-5,1,0,0,0,0,0xFF0000FF) //4AddVertex(Cube,5,5,5,1,0,0,1,0,0xFF0000FF) //5AddVertex(Cube,5,-5,5,1,0,0,1,1,0xFF0000FF) //6AddVertex(Cube,5,-5,-5,1,0,0,0,1,0xFF0000FF) //7AddTriangle(Cube,4,7,5)AddTriangle(Cube,5,7,6)//face 3AddVertex(Cube,5,5,5,0,0,1,0,0,0xFF00FF00) //8AddVertex(Cube,5,-5,5,0,0,1,0,1,0xFF00FF00) //9AddVertex(Cube,-5,-5,5,0,0,1,1,1,0xFF00FF00) //10AddVertex(Cube,-5,5,5,0,0,1,1,0,0xFF00FF00) //11AddTriangle(Cube,8,9,10)AddTriangle(Cube,10,11,8)//face 4AddVertex(Cube,-5,5,5,-1,0,0,0,0,0xFFFF0000) //12AddVertex(Cube,-5,5,-5,-1,0,0,1,0,0xFFFF0000) //13AddVertex(Cube,-5,-5,-5,-1,0,0,1,1,0xFFFF0000) //14AddVertex(Cube,-5,-5,5,-1,0,0,0,1,0xFFFF0000) //15AddTriangle(Cube,12,14,13)AddTriangle(Cube,14,12,15)//face 5AddVertex(Cube,-5,5,5,0,1,0,0,0,0xFF00FFFF) //16AddVertex(Cube,5,5,5,0,1,0,1,0,0xFF00FFFF) //17AddVertex(Cube,5,5,-5,0,1,0,1,1,0xFF00FFFF) //18AddVertex(Cube,-5,5,-5,0,1,0,0,1,0xFF00FFFF) //19AddTriangle(Cube,16,18,17)AddTriangle(Cube,16,19,18)//face 6AddVertex(Cube,5,-5,-5,0,-1,0,1,0,0xFFFFFF00) //20AddVertex(Cube,-5,-5,-5,0,-1,0,0,0,0xFFFFFF00) //21AddVertex(Cube,-5,-5,5,0,-1,0,0,1,0xFFFFFF00) //22AddVertex(Cube,5,-5,5,0,-1,0,1,1,0xFFFFFF00) //23Addtriangle(Cube,20,21,22)Addtriangle(Cube,20,22,23)cubeObject = CreateObjectFromMesh(cube)image = loadimage("mesh3-1.jpg")SetObjectImage(cubeObject,image,0)do RotateObjectLocalX(cubeObject,.1) RotateObjectLocalY(cubeObject,.2) RotateObjectLocalZ(cubeObject,.3) Print( ScreenFPS() ) Sync()loop

Here is a first attempt at adding mesh helper functions to AGK2.

Graphics3D(640,480,32,2)SeedRnd(MilliSecs())Global Camera = CreateCamera()CameraRange(Camera,0.1,100)CameraClsColor(Camera,000,000,000)Mesh = CreateMesh()Surface = CreateSurface(Mesh)VerticesCount% = 0TrianglesCount% = 0PositionEntity(Camera,0,0,-10,True)Repeat Surface = GetSurface(Mesh,1) VerticesCount = VerticesCount + 1 V0I% = VerticesCount-1 AddVertex( Surface, Rnd(-1.5,+1.5), Rnd(+1,+4), Rnd(-1,+1) ) VerticesCount = VerticesCount + 1 V1I% = VerticesCount-1 AddVertex( Surface, Rnd(+4,+1), Rnd(-1,-4), Rnd(-1,+1) ) VerticesCount = VerticesCount + 1 V2I% = VerticesCount-1 AddVertex( Surface, Rnd(-1,-4), Rnd(-1,-4), Rnd(-1,+1) ) TrianglesCount = TrianglesCount + 1 TI% = TrianglesCount-1 AddTriangle( Surface, V0I, V1I, V2I ) ;UpdateNormals(Mesh) WireFrame(True) SetBuffer(BackBuffer()) RenderWorld() Text(0,0,"VerticesCount = "+VerticesCount) Text(0,10,"TrianglesCount = "+TrianglesCount) Flip(1)Until( MAV = True )End()

(with Blitz3d, it would be around 32000 vertices / 32000 triangles per surface)

which means 65535 vertices in Blitz3D should be fine

Quotewhich means 65535 vertices in Blitz3D should be finein theory, maybe, but in practice, no, the MAV happens with less than 32000 triangles (depending on the computer), this is weird (and annoying)tested on 3 different computers :MAV when the surface has 54615 vertices and 18205 triangles...

so for folks such as yourself who is building quite neat procedural cave system, down to triangle, I believe, B3D is bad choice of tool..

// Project: maxverts // Created: 2018-03-08#insert "mesh.agc"// show all errorsSetErrorMode(2)// set window propertiesSetWindowTitle( "maxverts" )SetWindowSize( 1024, 768, 0 )SetWindowAllowResize( 1 ) // allow the user to resize the window// set display propertiesSetVirtualResolution( 1024, 768 ) // doesn't have to match the windowSetOrientationAllowed( 1, 1, 1, 1 ) // allow both portrait and landscape on mobile devicesSetSyncRate( 0, 0 ) // 30fps instead of 60 to save batterySetScissor( 0,0,0,0 ) // use the maximum available screen space, no black bordersUseNewDefaultFonts( 1 ) // since version 2.0.22 we can use nicer default fontsSetcameraposition(1,0,0,0)SetCameraRotation(1,0,0,0)grid as Meshfor y = 0 to 1000 for x = 0 to 1000 AddVertex(grid,x-500,y-500,999,0,0,-1,mod(x,2),mod(y,2),0xFFFFFFFF) next x if mod(y,100) = 0 Print (y) sync() endifnext yfor y = 0 to 999 for x = 0 to 999 v1 = x+y*1001 v2 = x+y*1001+1 v3 = x+(y+1)*1001 v4 = x+(y+1)*1001+1 AddTriangle(grid,v1,v2,v3) AddTriangle(grid,v2,v4,v3) next if mod(y,100) = 0 print (y) sync() endifnextgridObject = CreateObjectFromMesh(grid)image = LoadImage("mesh3-1.jpg")SetObjectImage(gridObject,image,0)do Print( ScreenFPS() ) print("Vertex = "+str(grid.VertexList.Length+1)) Print("Triangle = "+str(grid.TriangleList.Length+1)) Sync()loop