aboutsummaryrefslogtreecommitdiff
path: root/addons/voxel-core/classes/readers
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/readers
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/readers')
-rw-r--r--addons/voxel-core/classes/readers/gpl.gd48
-rw-r--r--addons/voxel-core/classes/readers/image.gd40
-rw-r--r--addons/voxel-core/classes/readers/vox.gd86
3 files changed, 0 insertions, 174 deletions
diff --git a/addons/voxel-core/classes/readers/gpl.gd b/addons/voxel-core/classes/readers/gpl.gd
deleted file mode 100644
index 4a6b943..0000000
--- a/addons/voxel-core/classes/readers/gpl.gd
+++ /dev/null
@@ -1,48 +0,0 @@
-class_name GPLReader
-extends Reference
-# GIMP palette file reader
-
-
-
-# Public Methods
-# Reads GPL file, and returns voxel palette
-static func read(gpl_file : File) -> Dictionary:
- var result := {
- "error": OK,
- "voxels": {},
- "palette": [],
- }
-
- if gpl_file.get_line() == "GIMP Palette":
- while not gpl_file.eof_reached():
- var line = gpl_file.get_line()
- if typeof(line) == TYPE_STRING and not line.empty() and (line[0].is_valid_integer() or line[0] == " "):
- var tokens = line.split("\t")
- var name = ""
- var color = tokens[0].split_floats(" ")
- color = Color(color[0] / 255, color[1] / 255, color[2] / 255)
- if tokens.size() > 1:
- name = tokens[1]
- var end = name.find("(")
- name = name.substr(0, end)
-
- if not result["palette"].has(color):
- var voxel := Voxel.colored(color)
- result["palette"].append(voxel)
- if not name.empty():
- Voxel.set_name(voxel, name.strip_edges())
- else:
- result["error"] = ERR_FILE_UNRECOGNIZED
-
- return result
-
-
-static func read_file(gpl_path : String) -> Dictionary:
- var result := { "error": OK }
- var file := File.new()
- var error = file.open(gpl_path, File.READ)
- if error == OK:
- result = read(file)
- if file.is_open():
- file.close()
- return result
diff --git a/addons/voxel-core/classes/readers/image.gd b/addons/voxel-core/classes/readers/image.gd
deleted file mode 100644
index 3c19d2f..0000000
--- a/addons/voxel-core/classes/readers/image.gd
+++ /dev/null
@@ -1,40 +0,0 @@
-class_name ImageReader, "res://addons/voxel-core/assets/logos/MagicaVoxel.png"
-extends Reference
-# Image file reader
-
-
-
-## Public Methods
-# Reads images pixels, returns voxel content and voxel palette
-static func read(image : Image) -> Dictionary:
- var result := {
- "error": OK,
- "voxels": {},
- "palette": [],
- }
-
- image.lock()
- for x in range(image.get_width()):
- for y in range(image.get_height()):
- if image.get_pixel(x, y).a > 0:
- var color := image.get_pixel(x, y)
- color.a = 1.0
- var index = result["palette"].find(color)
- if index == -1:
- index = result["palette"].size()
- result["palette"].append(color)
- result["voxels"][Vector3(x, -y, 0).round()] = index
- image.unlock()
-
- for index in range(result["palette"].size()):
- result["palette"][index] = Voxel.colored(result["palette"][index])
-
- return result
-
-
-static func read_file(image_path : String) -> Dictionary:
- var image := Image.new()
- var err = image.load(image_path)
- if err == OK:
- return read(image)
- return { "error": err }
diff --git a/addons/voxel-core/classes/readers/vox.gd b/addons/voxel-core/classes/readers/vox.gd
deleted file mode 100644
index 51dfa86..0000000
--- a/addons/voxel-core/classes/readers/vox.gd
+++ /dev/null
@@ -1,86 +0,0 @@
-class_name VoxReader, "res://addons/voxel-core/assets/logos/MagicaVoxel.png"
-extends Reference
-# MagicaVoxel file reader
-
-
-
-# Constants
-const magicavoxel_default_palette := [
- Color("00000000"), Color("ffffffff"), Color("ffccffff"), Color("ff99ffff"), Color("ff66ffff"), Color("ff33ffff"), Color("ff00ffff"), Color("ffffccff"), Color("ffccccff"), Color("ff99ccff"), Color("ff66ccff"), Color("ff33ccff"), Color("ff00ccff"), Color("ffff99ff"), Color("ffcc99ff"), Color("ff9999ff"),
- Color("ff6699ff"), Color("ff3399ff"), Color("ff0099ff"), Color("ffff66ff"), Color("ffcc66ff"), Color("ff9966ff"), Color("ff6666ff"), Color("ff3366ff"), Color("ff0066ff"), Color("ffff33ff"), Color("ffcc33ff"), Color("ff9933ff"), Color("ff6633ff"), Color("ff3333ff"), Color("ff0033ff"), Color("ffff00ff"),
- Color("ffcc00ff"), Color("ff9900ff"), Color("ff6600ff"), Color("ff3300ff"), Color("ff0000ff"), Color("ffffffcc"), Color("ffccffcc"), Color("ff99ffcc"), Color("ff66ffcc"), Color("ff33ffcc"), Color("ff00ffcc"), Color("ffffcccc"), Color("ffcccccc"), Color("ff99cccc"), Color("ff66cccc"), Color("ff33cccc"),
- Color("ff00cccc"), Color("ffff99cc"), Color("ffcc99cc"), Color("ff9999cc"), Color("ff6699cc"), Color("ff3399cc"), Color("ff0099cc"), Color("ffff66cc"), Color("ffcc66cc"), Color("ff9966cc"), Color("ff6666cc"), Color("ff3366cc"), Color("ff0066cc"), Color("ffff33cc"), Color("ffcc33cc"), Color("ff9933cc"),
- Color("ff6633cc"), Color("ff3333cc"), Color("ff0033cc"), Color("ffff00cc"), Color("ffcc00cc"), Color("ff9900cc"), Color("ff6600cc"), Color("ff3300cc"), Color("ff0000cc"), Color("ffffff99"), Color("ffccff99"), Color("ff99ff99"), Color("ff66ff99"), Color("ff33ff99"), Color("ff00ff99"), Color("ffffcc99"),
- Color("ffcccc99"), Color("ff99cc99"), Color("ff66cc99"), Color("ff33cc99"), Color("ff00cc99"), Color("ffff9999"), Color("ffcc9999"), Color("ff999999"), Color("ff669999"), Color("ff339999"), Color("ff009999"), Color("ffff6699"), Color("ffcc6699"), Color("ff996699"), Color("ff666699"), Color("ff336699"),
- Color("ff006699"), Color("ffff3399"), Color("ffcc3399"), Color("ff993399"), Color("ff663399"), Color("ff333399"), Color("ff003399"), Color("ffff0099"), Color("ffcc0099"), Color("ff990099"), Color("ff660099"), Color("ff330099"), Color("ff000099"), Color("ffffff66"), Color("ffccff66"), Color("ff99ff66"),
- Color("ff66ff66"), Color("ff33ff66"), Color("ff00ff66"), Color("ffffcc66"), Color("ffcccc66"), Color("ff99cc66"), Color("ff66cc66"), Color("ff33cc66"), Color("ff00cc66"), Color("ffff9966"), Color("ffcc9966"), Color("ff999966"), Color("ff669966"), Color("ff339966"), Color("ff009966"), Color("ffff6666"),
- Color("ffcc6666"), Color("ff996666"), Color("ff666666"), Color("ff336666"), Color("ff006666"), Color("ffff3366"), Color("ffcc3366"), Color("ff993366"), Color("ff663366"), Color("ff333366"), Color("ff003366"), Color("ffff0066"), Color("ffcc0066"), Color("ff990066"), Color("ff660066"), Color("ff330066"),
- Color("ff000066"), Color("ffffff33"), Color("ffccff33"), Color("ff99ff33"), Color("ff66ff33"), Color("ff33ff33"), Color("ff00ff33"), Color("ffffcc33"), Color("ffcccc33"), Color("ff99cc33"), Color("ff66cc33"), Color("ff33cc33"), Color("ff00cc33"), Color("ffff9933"), Color("ffcc9933"), Color("ff999933"),
- Color("ff669933"), Color("ff339933"), Color("ff009933"), Color("ffff6633"), Color("ffcc6633"), Color("ff996633"), Color("ff666633"), Color("ff336633"), Color("ff006633"), Color("ffff3333"), Color("ffcc3333"), Color("ff993333"), Color("ff663333"), Color("ff333333"), Color("ff003333"), Color("ffff0033"),
- Color("ffcc0033"), Color("ff990033"), Color("ff660033"), Color("ff330033"), Color("ff000033"), Color("ffffff00"), Color("ffccff00"), Color("ff99ff00"), Color("ff66ff00"), Color("ff33ff00"), Color("ff00ff00"), Color("ffffcc00"), Color("ffcccc00"), Color("ff99cc00"), Color("ff66cc00"), Color("ff33cc00"),
- Color("ff00cc00"), Color("ffff9900"), Color("ffcc9900"), Color("ff999900"), Color("ff669900"), Color("ff339900"), Color("ff009900"), Color("ffff6600"), Color("ffcc6600"), Color("ff996600"), Color("ff666600"), Color("ff336600"), Color("ff006600"), Color("ffff3300"), Color("ffcc3300"), Color("ff993300"),
- Color("ff663300"), Color("ff333300"), Color("ff003300"), Color("ffff0000"), Color("ffcc0000"), Color("ff990000"), Color("ff660000"), Color("ff330000"), Color("ff0000ee"), Color("ff0000dd"), Color("ff0000bb"), Color("ff0000aa"), Color("ff000088"), Color("ff000077"), Color("ff000055"), Color("ff000044"),
- Color("ff000022"), Color("ff000011"), Color("ff00ee00"), Color("ff00dd00"), Color("ff00bb00"), Color("ff00aa00"), Color("ff008800"), Color("ff007700"), Color("ff005500"), Color("ff004400"), Color("ff002200"), Color("ff001100"), Color("ffee0000"), Color("ffdd0000"), Color("ffbb0000"), Color("ffaa0000"),
- Color("ff880000"), Color("ff770000"), Color("ff550000"), Color("ff440000"), Color("ff220000"), Color("ff110000"), Color("ffeeeeee"), Color("ffdddddd"), Color("ffbbbbbb"), Color("ffaaaaaa"), Color("ff888888"), Color("ff777777"), Color("ff555555"), Color("ff444444"), Color("ff222222"), Color("ff111111")
-]
-
-
-
-# Public Methods
-# Reads vox file, returns voxel content and voxel palette
-static func read(vox_file : File) -> Dictionary:
- var result := {
- "error": OK,
- "voxels": {},
- "palette": [],
- }
-
- var magic := vox_file.get_buffer(4).get_string_from_ascii()
- var magic_version := vox_file.get_32()
- if magic == "VOX " and magic_version == 150:
- var nodes := {}
- while vox_file.get_position() < vox_file.get_len():
- var chunk_name = vox_file.get_buffer(4).get_string_from_ascii()
- var chunk_size = vox_file.get_32()
- var chunk_children = vox_file.get_32()
-
- match chunk_name:
- "XYZI":
- for i in range(0, vox_file.get_32()):
- var x := vox_file.get_8()
- var z := -vox_file.get_8()
- var y := vox_file.get_8()
- result["voxels"][Vector3(
- x, y, z).floor()] = vox_file.get_8() - 1
- "RGBA":
- for i in range(0,256):
- var color := Color(
- float(vox_file.get_8() / 255.0),
- float(vox_file.get_8() / 255.0),
- float(vox_file.get_8() / 255.0),
- float(vox_file.get_8() / 255.0))
- color.a = 1.0
- result["palette"].append(color)
- _:
- vox_file.get_buffer(chunk_size)
-
- if result["palette"].empty():
- result["palette"] = magicavoxel_default_palette.duplicate()
- else:
- result["error"] = ERR_FILE_UNRECOGNIZED
-
- for index in range(result["palette"].size()):
- result["palette"][index] = Voxel.colored(result["palette"][index])
-
- return result
-
-
-static func read_file(vox_path : String) -> Dictionary:
- var result := { "error": OK }
- var vox_file := File.new()
- var error = vox_file.open(vox_path, File.READ)
- if error == OK:
- result = read(vox_file)
- if vox_file.is_open():
- vox_file.close()
- return result