aboutsummaryrefslogtreecommitdiff
path: root/addons/voxel-core/classes/voxel.gd
diff options
context:
space:
mode:
authorjacopograndi <jacopo.grandi@outlook.it>2022-01-14 13:06:22 +0100
committerjacopograndi <jacopo.grandi@outlook.it>2022-01-14 13:06:22 +0100
commitad8002a8aadd7f537ef1c1d6c47d48f9e13d2015 (patch)
treee07c243def4499b0d220429364d9b9a3f23c1453 /addons/voxel-core/classes/voxel.gd
parent4bfbf641dc2b8aca8de9f86a9908063f39bd6e31 (diff)
deleted: LICENSE
deleted: README.md deleted: addons/voxel-core/assets/classes/voxel.png deleted: addons/voxel-core/assets/classes/voxel.png.import deleted: addons/voxel-core/assets/classes/voxel_core.png deleted: addons/voxel-core/assets/classes/voxel_core.png.import deleted: addons/voxel-core/assets/classes/voxel_mesh.png deleted: addons/voxel-core/assets/classes/voxel_mesh.png.import deleted: addons/voxel-core/assets/classes/voxel_set.png deleted: addons/voxel-core/assets/classes/voxel_set.png.import deleted: addons/voxel-core/assets/classes/voxel_world.png deleted: addons/voxel-core/assets/classes/voxel_world.png.import deleted: addons/voxel-core/assets/controls/about.png deleted: addons/voxel-core/assets/controls/about.png.import deleted: addons/voxel-core/assets/controls/add.png deleted: addons/voxel-core/assets/controls/add.png.import deleted: addons/voxel-core/assets/controls/area.png deleted: addons/voxel-core/assets/controls/area.png.import deleted: addons/voxel-core/assets/controls/autosave.png deleted: addons/voxel-core/assets/controls/autosave.png.import deleted: addons/voxel-core/assets/controls/cancel.png deleted: addons/voxel-core/assets/controls/cancel.png.import deleted: addons/voxel-core/assets/controls/commit.png deleted: addons/voxel-core/assets/controls/commit.png.import deleted: addons/voxel-core/assets/controls/confirm.png deleted: addons/voxel-core/assets/controls/confirm.png.import deleted: addons/voxel-core/assets/controls/cursor.png deleted: addons/voxel-core/assets/controls/cursor.png.import deleted: addons/voxel-core/assets/controls/docs.png deleted: addons/voxel-core/assets/controls/docs.png.import deleted: addons/voxel-core/assets/controls/down.png deleted: addons/voxel-core/assets/controls/down.png.import deleted: addons/voxel-core/assets/controls/duplicate.png deleted: addons/voxel-core/assets/controls/duplicate.png.import deleted: addons/voxel-core/assets/controls/edit.png deleted: addons/voxel-core/assets/controls/edit.png.import deleted: addons/voxel-core/assets/controls/effects.png deleted: addons/voxel-core/assets/controls/effects.png.import deleted: addons/voxel-core/assets/controls/export.png deleted: addons/voxel-core/assets/controls/export.png.import deleted: addons/voxel-core/assets/controls/extrude.png deleted: addons/voxel-core/assets/controls/extrude.png.import deleted: addons/voxel-core/assets/controls/fill.png deleted: addons/voxel-core/assets/controls/fill.png.import deleted: addons/voxel-core/assets/controls/floor.png deleted: addons/voxel-core/assets/controls/floor.png.import deleted: addons/voxel-core/assets/controls/general.png deleted: addons/voxel-core/assets/controls/general.png.import deleted: addons/voxel-core/assets/controls/grid.png deleted: addons/voxel-core/assets/controls/grid.png.import deleted: addons/voxel-core/assets/controls/import.png deleted: addons/voxel-core/assets/controls/import.png.import deleted: addons/voxel-core/assets/controls/individual.png deleted: addons/voxel-core/assets/controls/individual.png.import deleted: addons/voxel-core/assets/controls/info.png deleted: addons/voxel-core/assets/controls/info.png.import deleted: addons/voxel-core/assets/controls/issues.png deleted: addons/voxel-core/assets/controls/issues.png.import deleted: addons/voxel-core/assets/controls/lock.png deleted: addons/voxel-core/assets/controls/lock.png.import deleted: addons/voxel-core/assets/controls/mirrorx.png deleted: addons/voxel-core/assets/controls/mirrorx.png.import deleted: addons/voxel-core/assets/controls/mirrory.png deleted: addons/voxel-core/assets/controls/mirrory.png.import deleted: addons/voxel-core/assets/controls/mirrorz.png deleted: addons/voxel-core/assets/controls/mirrorz.png.import deleted: addons/voxel-core/assets/controls/paint.png deleted: addons/voxel-core/assets/controls/paint.png.import deleted: addons/voxel-core/assets/controls/pan.png deleted: addons/voxel-core/assets/controls/pan.png.import deleted: addons/voxel-core/assets/controls/pick.png deleted: addons/voxel-core/assets/controls/pick.png.import deleted: addons/voxel-core/assets/controls/primary.png deleted: addons/voxel-core/assets/controls/primary.png.import deleted: addons/voxel-core/assets/controls/raw.png deleted: addons/voxel-core/assets/controls/raw.png.import deleted: addons/voxel-core/assets/controls/refresh.png deleted: addons/voxel-core/assets/controls/refresh.png.import deleted: addons/voxel-core/assets/controls/reset.png deleted: addons/voxel-core/assets/controls/reset.png.import deleted: addons/voxel-core/assets/controls/secondary.png deleted: addons/voxel-core/assets/controls/secondary.png.import deleted: addons/voxel-core/assets/controls/select.png deleted: addons/voxel-core/assets/controls/select.png.import deleted: addons/voxel-core/assets/controls/settings.png deleted: addons/voxel-core/assets/controls/settings.png.import deleted: addons/voxel-core/assets/controls/solid.png deleted: addons/voxel-core/assets/controls/solid.png.import deleted: addons/voxel-core/assets/controls/sub.png deleted: addons/voxel-core/assets/controls/sub.png.import deleted: addons/voxel-core/assets/controls/swap.png deleted: addons/voxel-core/assets/controls/swap.png.import deleted: addons/voxel-core/assets/controls/tools.png deleted: addons/voxel-core/assets/controls/tools.png.import deleted: addons/voxel-core/assets/controls/unlock.png deleted: addons/voxel-core/assets/controls/unlock.png.import deleted: addons/voxel-core/assets/controls/up.png deleted: addons/voxel-core/assets/controls/up.png.import deleted: addons/voxel-core/assets/controls/visible.png deleted: addons/voxel-core/assets/controls/visible.png.import deleted: addons/voxel-core/assets/controls/wired.png deleted: addons/voxel-core/assets/controls/wired.png.import deleted: addons/voxel-core/assets/logos/GitHub.png deleted: addons/voxel-core/assets/logos/GitHub.png.import deleted: addons/voxel-core/assets/logos/Godot.png deleted: addons/voxel-core/assets/logos/Godot.png.import deleted: addons/voxel-core/assets/logos/MagicaVoxel.png deleted: addons/voxel-core/assets/logos/MagicaVoxel.png.import deleted: addons/voxel-core/classes/reader.gd deleted: addons/voxel-core/classes/readers/gpl.gd deleted: addons/voxel-core/classes/readers/image.gd deleted: addons/voxel-core/classes/readers/vox.gd deleted: addons/voxel-core/classes/voxel.gd deleted: addons/voxel-core/classes/voxel_mesh.gd deleted: addons/voxel-core/classes/voxel_object.gd deleted: addons/voxel-core/classes/voxel_set.gd deleted: addons/voxel-core/classes/voxel_tool.gd deleted: addons/voxel-core/controls/tiles_viewer/tiles_viewer.gd deleted: addons/voxel-core/controls/tiles_viewer/tiles_viewer.tscn deleted: addons/voxel-core/controls/voxel_button/voxel_button.gd deleted: addons/voxel-core/controls/voxel_button/voxel_button.tscn deleted: addons/voxel-core/controls/voxel_set_viewer/voxel_set_viewer.gd deleted: addons/voxel-core/controls/voxel_set_viewer/voxel_set_viewer.tscn deleted: addons/voxel-core/controls/voxel_viewer/voxel_viewer.gd deleted: addons/voxel-core/controls/voxel_viewer/voxel_viewer.tscn deleted: addons/voxel-core/controls/voxel_viewer/voxel_viewer_env.tres deleted: addons/voxel-core/defaults/voxel_set.tres deleted: addons/voxel-core/engine/importers/meshes.gd deleted: addons/voxel-core/engine/importers/voxel_objects.gd deleted: addons/voxel-core/engine/importers/voxel_sets.gd deleted: addons/voxel-core/engine/voxel_object_editor/editor_selection/editor_selection.gd deleted: addons/voxel-core/engine/voxel_object_editor/editor_selection/editor_selections/area.gd deleted: addons/voxel-core/engine/voxel_object_editor/editor_selection/editor_selections/extrude.gd deleted: addons/voxel-core/engine/voxel_object_editor/editor_selection/editor_selections/individual.gd deleted: addons/voxel-core/engine/voxel_object_editor/editor_tool/editor_tool.gd deleted: addons/voxel-core/engine/voxel_object_editor/editor_tool/editor_tools/add.gd deleted: addons/voxel-core/engine/voxel_object_editor/editor_tool/editor_tools/fill.gd deleted: addons/voxel-core/engine/voxel_object_editor/editor_tool/editor_tools/pick.gd deleted: addons/voxel-core/engine/voxel_object_editor/editor_tool/editor_tools/sub.gd deleted: addons/voxel-core/engine/voxel_object_editor/editor_tool/editor_tools/swap.gd deleted: addons/voxel-core/engine/voxel_object_editor/voxel_cursor/voxel_cursor.gd deleted: addons/voxel-core/engine/voxel_object_editor/voxel_grid/voxel_grid.gd deleted: addons/voxel-core/engine/voxel_object_editor/voxel_object_editor.gd deleted: addons/voxel-core/engine/voxel_object_editor/voxel_object_editor.tscn deleted: addons/voxel-core/engine/voxel_set_editor/voxel_set_editor.gd deleted: addons/voxel-core/engine/voxel_set_editor/voxel_set_editor.tscn deleted: addons/voxel-core/plugin.cfg deleted: addons/voxel-core/voxel-core.gd deleted: models/attach.mtl deleted: models/attach.obj deleted: models/attach.obj.import deleted: models/cube.mtl deleted: models/cube.obj deleted: models/cube.obj.import deleted: models/pointer.mtl deleted: models/pointer.obj deleted: models/pointer.obj.import deleted: models/shapes/Enemy.material deleted: models/shapes/T.glb deleted: models/shapes/T.glb.import deleted: models/shapes/aT.glb deleted: models/shapes/aT.glb.import deleted: models/shapes/aaT.glb deleted: models/shapes/aaT.glb.import deleted: models/shapes/aaaT.glb deleted: models/shapes/aaaT.glb.import deleted: models/shapes/aasT.glb deleted: models/shapes/aasT.glb.import deleted: models/shapes/asT.glb deleted: models/shapes/asT.glb.import deleted: models/shapes/cube.mtl deleted: models/shapes/daT.glb deleted: models/shapes/daT.glb.import deleted: models/shapes/daaT.glb deleted: models/shapes/daaT.glb.import deleted: models/shapes/daaaT.glb deleted: models/shapes/daaaT.glb.import deleted: models/shapes/daasT.glb deleted: models/shapes/daasT.glb.import deleted: models/shapes/dasT.glb deleted: models/shapes/dasT.glb.import deleted: models/shapes/dkT.glb deleted: models/shapes/dkT.glb.import deleted: models/shapes/dkaT.glb deleted: models/shapes/dkaT.glb.import deleted: models/shapes/dkdaT.glb deleted: models/shapes/dkdaT.glb.import deleted: models/shapes/dkdaaT.glb deleted: models/shapes/dkdaaT.glb.import deleted: models/shapes/dkdasT.glb deleted: models/shapes/dkdasT.glb.import deleted: models/shapes/dkdsT.glb deleted: models/shapes/dkdsT.glb.import deleted: models/shapes/dksT.glb deleted: models/shapes/dksT.glb.import deleted: models/shapes/dodecahedron.mtl deleted: models/shapes/dsT.glb deleted: models/shapes/dsT.glb.import deleted: models/shapes/dsaT.glb deleted: models/shapes/dsaT.glb.import deleted: models/shapes/dssT.glb deleted: models/shapes/dssT.glb.import deleted: models/shapes/icosahedron.mtl deleted: models/shapes/kT.glb deleted: models/shapes/kT.glb.import deleted: models/shapes/kaT.glb deleted: models/shapes/kaT.glb.import deleted: models/shapes/kdaT.glb deleted: models/shapes/kdaT.glb.import deleted: models/shapes/kdaaT.glb deleted: models/shapes/kdaaT.glb.import deleted: models/shapes/kdasT.glb deleted: models/shapes/kdasT.glb.import deleted: models/shapes/kdsT.glb deleted: models/shapes/kdsT.glb.import deleted: models/shapes/ksT.glb deleted: models/shapes/ksT.glb.import deleted: models/shapes/octahedron.mtl deleted: models/shapes/sT.glb deleted: models/shapes/sT.glb.import deleted: models/shapes/saT.glb deleted: models/shapes/saT.glb.import deleted: models/shapes/sphere.mtl deleted: models/shapes/ssT.glb deleted: models/shapes/ssT.glb.import deleted: models/shapes/tetrahedron.mtl deleted: models/turrets/GunMat.material deleted: models/turrets/MountMat.material deleted: models/turrets/laser.glb deleted: models/turrets/laser.glb.import deleted: models/turrets/laser1.mtl deleted: models/turrets/plastic.glb deleted: models/turrets/plastic.glb.import deleted: models/turrets/shotgun.glb deleted: models/turrets/shotgun.glb.import deleted: models/turrets/slower.glb deleted: models/turrets/slower.glb.import deleted: models/turrets/sniper.glb deleted: models/turrets/sniper.glb.import deleted: models/turrets/structI.glb deleted: models/turrets/structI.glb.import deleted: models/turrets/structT.glb deleted: models/turrets/structT.glb.import deleted: models/turrets/structX.glb deleted: models/turrets/structX.glb.import
Diffstat (limited to 'addons/voxel-core/classes/voxel.gd')
-rw-r--r--addons/voxel-core/classes/voxel.gd330
1 files changed, 0 insertions, 330 deletions
diff --git a/addons/voxel-core/classes/voxel.gd b/addons/voxel-core/classes/voxel.gd
deleted file mode 100644
index f9bc7bb..0000000
--- a/addons/voxel-core/classes/voxel.gd
+++ /dev/null
@@ -1,330 +0,0 @@
-tool
-class_name Voxel, "res://addons/voxel-core/assets/classes/voxel.png"
-extends Object
-# Utility class containing various properties and methods to do with voxels.
-#
-# Voxel Schema:
-# Every voxel is a Dictionary, not every Dictionary is a voxel, only by following
-# the voxel scheme indicated below can wide varieties of voxels be produced.
-# Note that voxel dictionaries may have additions, but they must be done in such
-# a way as to respect the original structure so as to avoid conflicts.
-#
-# {
-# name : String ~ Used in VoxelSets, should always be lowercase
-# color : Color ~ Default color used for all voxel faces, if not present fallback is Transparent color
-# colors : Dictionary = { ~ Color used on a per face bases, if not present fallback is voxel color
-# Vector3.UP : Color
-# Vector3.DOWN : Color
-# Vector3.RIGHT : Color
-# Vector3.LEFT : Color
-# Vector3.FORWARD : Color
-# Vector3.BACK : Color
-# }
-# uv : Vector2 ~ Default uv position used for all voxel faces, if not present fallback is (-1.0, -1.0)
-# uvs : Dictionary = { ~ uv position used on a per face bases, if not present fallback to voxel uv
-# Vector3.UP : Vector2
-# Vector3.DOWN : Vector2
-# Vector3.RIGHT : Vector2
-# Vector3.LEFT : Vector2
-# Vector3.FORWARD : Vector2
-# Vector3.BACK : Vector2
-# }
-# metallic : float ~ Metallic value used for all voxel face's material, must be between 0.0 and 1.0 and if not present fallback is 0.0
-# specular : float ~ Specular value used for all voxel faces, must be between 0.0 and 1.0 and if not present fallback is 0.5
-# roughness : float ~ Roughness value used for all voxel faces, must be between 0.0 and 1.0 and if not present fallback is 1.0
-# energy : float ~ Emission energy value used for all voxel faces, must be between 0.0 and 16.0 and if not present fallback is 0.0
-# energy_color : Color ~ Emission color used for all voxel faces, if not present fallback is white
-# material : int ~ ID of the VoxelSet material used for this voxel, if not present fallback is -1
-# }
-#
-
-
-
-## Constants
-# Lists of all voxel faces, and their adjacent directions
-const Faces := {
- Vector3.RIGHT: [ Vector3.FORWARD, Vector3.BACK, Vector3.DOWN, Vector3.UP ],
- Vector3.UP: [ Vector3.LEFT, Vector3.RIGHT, Vector3.FORWARD, Vector3.BACK ],
- Vector3.FORWARD: [ Vector3.LEFT, Vector3.RIGHT, Vector3.DOWN, Vector3.UP ],
- Vector3.LEFT: [ Vector3.FORWARD, Vector3.BACK, Vector3.DOWN, Vector3.UP ],
- Vector3.DOWN: [ Vector3.LEFT, Vector3.RIGHT, Vector3.FORWARD, Vector3.BACK ],
- Vector3.BACK: [ Vector3.LEFT, Vector3.RIGHT, Vector3.DOWN, Vector3.UP ],
-}
-
-# 0.5 means that voxels will have the dimensions of 0.5 x 0.5 x 0.5
-const VoxelWorldSize := 0.5
-
-
-
-## Public Methods
-# Returns Dictionary representation of a colored voxel
-# color : Color : color to set
-# colors : Dictionary<Vector3, Color> : face colors to set
-# return : Dictionary<String, Variant> : Dictionary representing voxel
-static func colored(color : Color, colors := {}) -> Dictionary:
- var voxel = {}
- voxel["color"] = color
- if not colors.empty():
- voxel["colors"] = colors.duplicate()
- return voxel
-
-
-# Returns true if voxel has color defined
-static func has_color(voxel : Dictionary) -> bool:
- return voxel.has("color")
-
-
-# Returns the defined color within given voxel if present, otherwise returns transparent color
-static func get_color(voxel : Dictionary) -> Color:
- return voxel.get("color", Color.transparent)
-
-
-# Sets the given color to the given voxel
-static func set_color(voxel : Dictionary, color : Color) -> void:
- voxel["color"] = color
-
-
-# Returns true if voxel has specified color at given face
-static func has_face_color(voxel : Dictionary, face : Vector3) -> bool:
- return voxel.has("colors") and voxel["colors"].has(face)
-
-
-# Returns the defined color at given face if present, otherwise returns color
-static func get_face_color(voxel : Dictionary, face : Vector3) -> Color:
- return voxel["colors"].get(face, get_color(voxel)) if voxel.has("colors") else get_color(voxel)
-
-
-# Sets the given color at the given face to the given voxel
-static func set_face_color(voxel : Dictionary, face : Vector3, color : Color) -> void:
- if not voxel.has("colors"): voxel["colors"] = {}
- voxel["colors"][face] = color
-
-
-# Removes color at given face from given voxel
-static func remove_face_color(voxel : Dictionary, face : Vector3) -> void:
- if voxel.has("colors"):
- voxel["colors"].erase(face)
- if voxel["colors"].empty():
- voxel.erase("colors")
-
-
-# Returns Dictionary representation of a uvd voxel
-# uv : Vector2 : uv to set
-# uvs : Dictionary<Vector3, Vector2> : face uv to set
-# color : Color : color to set
-# colors : Dictionary<Vector3, Color> : face colors to set
-# return : Dictionary<String, Variant> : Dictionary representing voxel
-static func uvd(uv : Vector2, uvs := {}, color := Color.white, colors := {}) -> Dictionary:
- var voxel = colored(color, colors)
- voxel["uv"] = uv
- if not uvs.empty():
- voxel["uvs"] = uvs
- return voxel
-
-
-# Returns true if voxel has uv defined
-static func has_uv(voxel : Dictionary) -> bool:
- return voxel.has("uv")
-
-
-# Returns the defined uv within given voxel if present, otherwise returns a negative vector
-static func get_uv(voxel : Dictionary) -> Vector2:
- return voxel.get("uv", -Vector2.ONE)
-
-
-# Sets the given uv to the given voxel
-static func set_uv(voxel : Dictionary, uv : Vector2) -> void:
- voxel["uv"] = uv
-
-
-# Removes uv from given voxel
-static func remove_uv(voxel : Dictionary) -> void:
- voxel.erase("uv")
-
-
-# Returns true if voxel has specified uv at given face
-static func has_face_uv(voxel : Dictionary, face : Vector3) -> bool:
- return voxel.has("uvs") and voxel["uvs"].has(face)
-
-
-# Returns the defined uv at given face if present, otherwise returns uv
-static func get_face_uv(voxel : Dictionary, face : Vector3) -> Vector2:
- return voxel["uvs"].get(face, get_uv(voxel)) if voxel.has("uvs") else get_uv(voxel)
-
-
-# Sets the given uv at the given face to the given voxel
-static func set_face_uv(voxel : Dictionary, face : Vector3, uv : Vector2) -> void:
- if not voxel.has("uvs"):
- voxel["uvs"] = {}
- voxel["uvs"][face] = uv
-
-
-# Removes uv at given face from given voxel
-static func remove_face_uv(voxel : Dictionary, face : Vector3) -> void:
- if voxel.has("uvs"):
- voxel["uvs"].erase(face)
- if voxel["uvs"].empty():
- voxel.erase("uvs")
-
-
-# Returns true if given name is valid
-static func is_valid_name(name : String) -> bool:
- return not name.empty()
-
-
-# Returns the defined name within given voxel if present, otherwise returns an empty string
-static func get_name(voxel : Dictionary) -> String:
- return voxel.get("name", "")
-
-
-# Sets the given name to the given voxel
-static func set_name(voxel : Dictionary, name : String) -> void:
- voxel["name"] = name.to_lower()
-
-
-# Removes name from given voxel
-static func remove_name(voxel : Dictionary) -> void:
- voxel.erase("name")
-
-
-# Returns the defined metallic within given voxel if present, otherwise returns 0
-static func get_metallic(voxel : Dictionary) -> float:
- return voxel.get("metallic", 0.0)
-
-
-# Sets the given metallic to the given voxel
-static func set_metallic(voxel : Dictionary, metallic : float) -> void:
- voxel["metallic"] = metallic
-
-
-# Removes metallic from given voxel
-static func remove_metallic(voxel : Dictionary) -> void:
- voxel.erase("metallic")
-
-
-# Returns the defined specular within given voxel if present, otherwise returns 0.5
-static func get_specular(voxel : Dictionary) -> float:
- return voxel.get("specular", 0.5)
-
-
-# Sets the given specular to the given voxel
-static func set_specular(voxel : Dictionary, specular : float) -> void:
- voxel["specular"] = specular
-
-
-# Removes specular from given voxel
-static func remove_specular(voxel : Dictionary) -> void:
- voxel.erase("specular")
-
-
-# Returns the defined roughness within given voxel if present, otherwise returns 1
-static func get_roughness(voxel : Dictionary) -> float:
- return voxel.get("roughness", 1.0)
-
-
-# Sets the given roughness to the given voxel
-static func set_roughness(voxel : Dictionary, roughness : float) -> void:
- voxel["roughness"] = roughness
-
-
-# Removes roughness from given voxel
-static func remove_roughness(voxel : Dictionary) -> void:
- voxel.erase("roughness")
-
-
-# Returns the defined energy within given voxel if present, otherwise returns 0
-static func get_energy(voxel : Dictionary) -> float:
- return voxel.get("energy", 0.0)
-
-
-# Sets the given energy to the given voxel
-static func set_energy(voxel : Dictionary, energy : float) -> void:
- voxel["energy"] = energy
-
-
-# Removes energy from given voxel
-static func remove_energy(voxel : Dictionary) -> void:
- voxel.erase("energy")
-
-
-# Returns the defined energy_color within given voxel if present, otherwise returns Color.white
-static func get_energy_color(voxel : Dictionary) -> Color:
- return voxel.get("energy_color", Color.white)
-
-
-# Sets the given energy_color to the given voxel
-static func set_energy_color(voxel : Dictionary, energy_color : Color) -> void:
- voxel["energy_color"] = energy_color
-
-
-# Removes energy_color from given voxel
-static func remove_energy_color(voxel : Dictionary) -> void:
- voxel.erase("energy_color")
-
-
-# Returns the defined material within given voxel if present, otherwise returns -1
-static func get_material(voxel : Dictionary) -> int:
- return voxel.get("material", -1)
-
-
-# Sets the given material to the given voxel
-static func set_material(voxel : Dictionary, material : int) -> void:
- voxel["material"] = material
-
-
-# Removes material from given voxel
-static func remove_material(voxel : Dictionary) -> void:
- voxel.erase("material")
-
-
-# Removes unnecessary properties of given voxel in accordance to Voxel schema
-static func clean(voxel : Dictionary) -> void:
- if not is_valid_name(get_name(voxel)):
- remove_name(voxel)
-
- if get_uv(voxel) == get_uv({}):
- remove_uv(voxel)
-
- for face in Faces:
- if get_face_color(voxel, face) == get_color({}):
- remove_face_color(voxel, face)
- if get_face_uv(voxel, face) == get_uv({}):
- remove_face_uv(voxel, face)
-
- if get_material(voxel) == get_material({}):
- remove_material(voxel)
-
- if get_metallic(voxel) == get_metallic({}):
- remove_metallic(voxel)
-
- if get_specular(voxel) == get_specular({}):
- remove_specular(voxel)
-
- if get_roughness(voxel) == get_roughness({}):
- remove_roughness(voxel)
-
- if get_energy(voxel) == get_energy({}):
- remove_energy(voxel)
-
- if get_energy_color(voxel) == get_energy_color({}):
- remove_energy_color(voxel)
-
-
-# Returns the world position as snapped world position
-static func world_to_snapped(world : Vector3) -> Vector3:
- return (world / VoxelWorldSize).floor() * VoxelWorldSize
-
-
-# Returns the snapped world position as voxel grid position
-static func snapped_to_grid(snapped : Vector3) -> Vector3:
- return snapped / VoxelWorldSize
-
-
-# Returns world position as voxel grid position
-static func world_to_grid(world : Vector3) -> Vector3:
- return snapped_to_grid(world_to_snapped(world))
-
-
-# Returns voxel grid position as snapped world position
-static func grid_to_snapped(grid : Vector3) -> Vector3:
- return grid * VoxelWorldSize