aboutsummaryrefslogtreecommitdiff
path: root/addons/voxel-core/classes/voxel_tool.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_tool.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_tool.gd')
-rw-r--r--addons/voxel-core/classes/voxel_tool.gd227
1 files changed, 0 insertions, 227 deletions
diff --git a/addons/voxel-core/classes/voxel_tool.gd b/addons/voxel-core/classes/voxel_tool.gd
deleted file mode 100644
index bba14aa..0000000
--- a/addons/voxel-core/classes/voxel_tool.gd
+++ /dev/null
@@ -1,227 +0,0 @@
-tool
-class_name VoxelTool
-extends Reference
-# Used to construct a Mesh with provided VoxelSet
-# and by specifying voxel faces individually.
-
-
-
-class Surface:
- ## Public Variables
- # Index of the last vertex in Mesh being constructed
- var index : int
-
- var material : SpatialMaterial
-
- # SurfaceTool used to construct Mesh
- var surface_tool : SurfaceTool
-
-
-
- ## Built-In Virtual Methods
- func _init() -> void:
- index = 0
- surface_tool = SurfaceTool.new()
- surface_tool.begin(Mesh.PRIMITIVE_TRIANGLES)
-
-
-
-## Private Variables
-# Flag indicating whether uv mapping should be applied to constructed mesh
-var _uv_voxels := false
-
-# Contains Surfaces being constructed
-var _surfaces := {}
-
-# VoxelSet used when constructing Mesh, is set on begin
-var _voxel_set : VoxelSet = null
-
-
-
-## Public Methods
-# Called before constructing mesh, takes the VoxelSet with which Mesh will be constructed
-func begin(voxel_set : VoxelSet = null, uv_voxels := false) -> void:
- clear()
- _uv_voxels = uv_voxels and voxel_set.uv_ready()
- _voxel_set = voxel_set
-
-
-# Clear all information
-func clear() -> void:
- _uv_voxels = false
- _surfaces.clear()
- _voxel_set = null
-
-
-# Returns a constructed ArrayMesh
-func commit() -> ArrayMesh:
- var mesh := ArrayMesh.new()
- for surface_id in _surfaces:
- var surface : Surface = _surfaces[surface_id]
- var submesh = surface.surface_tool.commit_to_arrays()
- mesh.add_surface_from_arrays(
- Mesh.PRIMITIVE_TRIANGLES,
- submesh)
- mesh.surface_set_name(mesh.get_surface_count() - 1, surface_id)
- mesh.surface_set_material(mesh.get_surface_count() - 1, surface.material)
- clear()
- return mesh
-
-
-# Adds a voxel face to Mesh with given vertex positions and voxel data
-# voxel : Dictioanry<String, Variant> : voxel data to use
-# face : Vector3 : face of voxel to generate
-# bottom_right : Vector3 : grid position of bottom right vertex pertaining to face
-# bottom_left : Vector3 : grid position of bottom left vertex pertaining to face, if not given botttom right is used
-# top_right : Vector3 : grid position of top right vertex pertaining to face, if not given botttom right is used
-# top_left : Vector3 : grid position of top left vertex pertaining to face, if not given botttom right is used
-func add_face(
- voxel : Dictionary,
- face : Vector3,
- bottom_right : Vector3,
- bottom_left := Vector3.INF,
- top_right := Vector3.INF,
- top_left := Vector3.INF) -> void:
- bottom_right = bottom_right
- if bottom_left == Vector3.INF: bottom_left = bottom_right
- if top_right == Vector3.INF: top_right = bottom_right
- if top_left == Vector3.INF: top_left = bottom_right
-
- var color := Voxel.get_face_color(voxel, face)
- var uv := Voxel.get_face_uv(voxel, face) if _uv_voxels else -Vector2.ONE
- var uv_surface := uv != -Vector2.ONE
-
- var material := Voxel.get_material(voxel)
-
- var metal := Voxel.get_metallic(voxel)
- var specular := Voxel.get_specular(voxel)
- var rough := Voxel.get_roughness(voxel)
- var energy := Voxel.get_energy(voxel)
- var energy_color := Voxel.get_energy_color(voxel)
-
- var surface_id := str(material) if material > -1 else (str(metal) + "," + str(specular) + "," + str(rough) + "," + str(energy) + "," + str(energy_color))
- if uv_surface:
- surface_id += "_uv"
- var surface : Surface = _surfaces.get(surface_id)
- if not is_instance_valid(surface):
- surface = Surface.new()
-
- surface.material = _voxel_set.get_material(material) if is_instance_valid(_voxel_set) else null
- if is_instance_valid(surface.material):
- surface.material = surface.material.duplicate()
- else:
- surface.material = SpatialMaterial.new()
-
- surface.material.metallic = metal
- surface.material.metallic_specular = specular
- surface.material.roughness = rough
- if energy > 0.0:
- surface.material.emission_enabled = true
- surface.material.emission = energy_color
- surface.material.emission_energy = energy
-
- if surface.material is SpatialMaterial:
- surface.material.vertex_color_use_as_albedo = true
- if uv_surface:
- surface.material.albedo_texture = _voxel_set.tiles
-
- _surfaces[surface_id] = surface
-
- surface.surface_tool.add_normal(face)
- surface.surface_tool.add_color(color)
-
- match face:
- Vector3.RIGHT:
- if uv_surface:
- surface.surface_tool.add_uv((uv + Vector2.RIGHT) * _voxel_set.uv_scale())
- surface.surface_tool.add_vertex((top_left + Vector3.RIGHT + Vector3.UP) * Voxel.VoxelWorldSize)
- if uv_surface:
- surface.surface_tool.add_uv((uv + Vector2.ONE) * _voxel_set.uv_scale())
- surface.surface_tool.add_vertex((bottom_left + Vector3.RIGHT) * Voxel.VoxelWorldSize)
- if uv_surface:
- surface.surface_tool.add_uv((uv) * _voxel_set.uv_scale())
- surface.surface_tool.add_vertex((top_right + Vector3.ONE) * Voxel.VoxelWorldSize)
- if uv_surface:
- surface.surface_tool.add_uv((uv + Vector2.DOWN) * _voxel_set.uv_scale())
- surface.surface_tool.add_vertex((bottom_right + Vector3.RIGHT + Vector3.BACK) * Voxel.VoxelWorldSize)
- Vector3.LEFT:
- if uv_surface:
- surface.surface_tool.add_uv((uv + Vector2.DOWN) * _voxel_set.uv_scale())
- surface.surface_tool.add_vertex((bottom_left) * Voxel.VoxelWorldSize)
- if uv_surface:
- surface.surface_tool.add_uv((uv) * _voxel_set.uv_scale())
- surface.surface_tool.add_vertex((top_left + Vector3.UP) * Voxel.VoxelWorldSize)
- if uv_surface:
- surface.surface_tool.add_uv((uv + Vector2.ONE) * _voxel_set.uv_scale())
- surface.surface_tool.add_vertex((bottom_right + Vector3.BACK) * Voxel.VoxelWorldSize)
- if uv_surface:
- surface.surface_tool.add_uv((uv + Vector2.RIGHT) * _voxel_set.uv_scale())
- surface.surface_tool.add_vertex((top_right + Vector3.UP + Vector3.BACK) * Voxel.VoxelWorldSize)
- Vector3.UP:
- if uv_surface:
- surface.surface_tool.add_uv((uv + Vector2.DOWN) * _voxel_set.uv_scale())
- surface.surface_tool.add_vertex((top_left + Vector3.UP + Vector3.BACK) * Voxel.VoxelWorldSize)
- if uv_surface:
- surface.surface_tool.add_uv((uv) * _voxel_set.uv_scale())
- surface.surface_tool.add_vertex((bottom_left + Vector3.UP) * Voxel.VoxelWorldSize)
- if uv_surface:
- surface.surface_tool.add_uv((uv + Vector2.ONE) * _voxel_set.uv_scale())
- surface.surface_tool.add_vertex((top_right + Vector3.ONE) * Voxel.VoxelWorldSize)
- if uv_surface:
- surface.surface_tool.add_uv((uv + Vector2.RIGHT) * _voxel_set.uv_scale())
- surface.surface_tool.add_vertex((bottom_right + Vector3.RIGHT + Vector3.UP) * Voxel.VoxelWorldSize)
- Vector3.DOWN:
- if uv_surface:
- surface.surface_tool.add_uv((uv + Vector2.DOWN) * _voxel_set.uv_scale())
- surface.surface_tool.add_vertex((top_right + Vector3.RIGHT + Vector3.BACK) * Voxel.VoxelWorldSize)
- if uv_surface:
- surface.surface_tool.add_uv((uv) * _voxel_set.uv_scale())
- surface.surface_tool.add_vertex((bottom_right + Vector3.RIGHT) * Voxel.VoxelWorldSize)
- if uv_surface:
- surface.surface_tool.add_uv((uv + Vector2.ONE) * _voxel_set.uv_scale())
- surface.surface_tool.add_vertex((top_left + Vector3.BACK) * Voxel.VoxelWorldSize)
- if uv_surface:
- surface.surface_tool.add_uv((uv + Vector2.RIGHT) * _voxel_set.uv_scale())
- surface.surface_tool.add_vertex((bottom_left) * Voxel.VoxelWorldSize)
- Vector3.FORWARD:
- if uv_surface:
- surface.surface_tool.add_uv((uv + Vector2.ONE) * _voxel_set.uv_scale())
- surface.surface_tool.add_vertex((bottom_right + Vector3.RIGHT) * Voxel.VoxelWorldSize)
- if uv_surface:
- surface.surface_tool.add_uv((uv + Vector2.RIGHT) * _voxel_set.uv_scale())
- surface.surface_tool.add_vertex((top_right + Vector3.RIGHT + Vector3.UP) * Voxel.VoxelWorldSize)
- if uv_surface:
- surface.surface_tool.add_uv((uv + Vector2.DOWN) * _voxel_set.uv_scale())
- surface.surface_tool.add_vertex((bottom_left) * Voxel.VoxelWorldSize)
- if uv_surface:
- surface.surface_tool.add_uv((uv) * _voxel_set.uv_scale())
- surface.surface_tool.add_vertex((top_left + Vector3.UP) * Voxel.VoxelWorldSize)
- Vector3.BACK:
- if uv_surface:
- surface.surface_tool.add_uv((uv + Vector2.RIGHT) * _voxel_set.uv_scale())
- surface.surface_tool.add_vertex((top_right + Vector3.ONE) * Voxel.VoxelWorldSize)
- if uv_surface:
- surface.surface_tool.add_uv((uv + Vector2.ONE) * _voxel_set.uv_scale())
- surface.surface_tool.add_vertex((bottom_right + Vector3.RIGHT + Vector3.BACK) * Voxel.VoxelWorldSize)
- if uv_surface:
- surface.surface_tool.add_uv((uv) * _voxel_set.uv_scale())
- surface.surface_tool.add_vertex((top_left + Vector3.UP + Vector3.BACK) * Voxel.VoxelWorldSize)
- if uv_surface:
- surface.surface_tool.add_uv((uv + Vector2.DOWN) * _voxel_set.uv_scale())
- surface.surface_tool.add_vertex((bottom_left + Vector3.BACK) * Voxel.VoxelWorldSize)
-
- surface.index += 4
- surface.surface_tool.add_index(surface.index - 4)
- surface.surface_tool.add_index(surface.index - 3)
- surface.surface_tool.add_index(surface.index - 2)
- surface.surface_tool.add_index(surface.index - 3)
- surface.surface_tool.add_index(surface.index - 1)
- surface.surface_tool.add_index(surface.index - 2)
-
-
-# Adds all the faces of a voxel to Mesh at given position and with voxel data
-# voxel : Dictioanry<String, Variant> : voxel data to use
-# grid : Vector3 : voxel grid position of voxel
-func add_faces(voxel : Dictionary, grid : Vector3) -> void:
- for face in Voxel.Faces:
- add_face(voxel, face, grid)