With that voxel world example I would want to try and insert a infinite world size and use some of my world generating code. I would like to know what kind of save and load options are best with codea for this method. At the moment I would try to create some kind of ‘text’ data fields and save and load these on the fly.
I have not spend a lot of time analyzing the voxel examples, but is there already a possibility to add and remove chunks to the edges of these scene’s? Has anyone done something like that yet?
In another project, a 2d space game, I already was able to create a infinite map size using the tables. But in 3d I would feel safer to not let the memory get that much used.
function setup()
...
-- save the terrain in serveral chunks
parameter.boolean("Save", false,function()
if Save then
scene.voxels:enableStorage("Save01")
end
end)
...
-- Assume the saved chunk is Chunk39x50
e1 = loadOrigonVolume(asset.documents.Chunk39x50,vec3(38,60,38))
end
-- load volume model or terrain's chunk
function loadOrigonVolume(entity, volumeModel, pos)
local myE = scene:entity()
myE.position = pos or vec3(0,0,0)
local myV = myE:add(craft.volume, 1, 1, 1)
myV:load(volumeModel)
return myE
end
There are two problems with this approach:
It’s just not very stable?very easy to crash.
Loading requires one by one, with a lot of chunk files, which is quite inefficient.