Voxel-Edits
Server Only
Currently voxel edits can only be done on the server side.
The Vox
API replaces the old VoxelEdit
API.
Remember to call Run()
to execute the edit.
Add a line
Vox:Add(Capsule(pos, pos2, thickness))
:Color(1,0,1)
:Run()
Remove but ignore object and all its children
Vox:Remove(Box(pos, Vec3(1)))
:Ignore(ob:WithChildren())
:Run()
Paint texture
Vox:Paint(Box(pos, Vec3(1)))
:Texture(tex, dir)
:Run()
Paint with transparency
Vox:Paint(Box(pos, Vec3(1)))
:Color(1,0,0,0.3)
:Metalicty(1)
:Roughness(0)
:StrokeHardness(1)
:Run()
Copy from ob to pos in ob
Vox:Copy(copyFromObject)
:To(targetObject, pos, rot, scale)
:Run()
All at area to ob
Vox:Copy(Box(pos, Vec3(1)))
:Ignore(target)
:To(target)
:Run()
To static
Vox:Copy(Box(pos, Vec3(1)))
:ToStatic()
:Run()
Subtract
Vox:Subtract(obs)
:UseColor()
:Run()
Subtract from static only
Vox:Subtract(gun)
:ForceStatic()
:Run()
Remove and draw the edit for debugging.
Vox:Remove(Box(pos, Vec3(1)))
:Draw()
:Run()
Remove with callback
Vox:Remove(Box(pos, Vec3(1)))
:OnFinished(function()
print("done")
end)
:Draw()
:Run()
Every scene has only one static voxel data and can have multiple dynamic voxel data. The static voxel data is used for the world and can not be moved.
However both can be edited. To choose whether to edit the static or dynamic voxel data, use the Force
and Ignore
functions.
Creating dynamic voxel data attached to an object
--create an object with voxel data and renderer
local ob = Scene:CreateObject("Voxel Sphere")
local vd = ob:AddComponent("VoxelData")
local vr = ob:AddComponent("VoxelRenderer")
local vres = VoxelDataResource() --new empty voxel data
vd.data = vres
ob.transform.pos = Vec3(0, 30, 0)
--add sphere
local col = Vec3(0,0.5,1)
local s = Sphere(ob.transform.pos, 1)
--using Force() to target the object only
Vox:Add(s)
:Force(ob)
:Color(col)
:Run()