diff options
author | jacopograndi <jacopo.grandi@outlook.it> | 2021-12-09 00:52:59 +0100 |
---|---|---|
committer | jacopograndi <jacopo.grandi@outlook.it> | 2021-12-09 00:52:59 +0100 |
commit | 0f518727c28d3204415db14c7ca0e4f7cb653677 (patch) | |
tree | a595121771b69a52f17154d8e5c61b7e4b2b8190 /addons/voxel-core/classes/reader.gd |
working
Diffstat (limited to 'addons/voxel-core/classes/reader.gd')
-rw-r--r-- | addons/voxel-core/classes/reader.gd | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/addons/voxel-core/classes/reader.gd b/addons/voxel-core/classes/reader.gd new file mode 100644 index 0000000..7c17b8a --- /dev/null +++ b/addons/voxel-core/classes/reader.gd @@ -0,0 +1,21 @@ +class_name Reader +extends Reference +# Makeshift interface class inhereted by all file readers. + + + +## Public Methods +# Calls on appropriate file reader according to file_path's extension. +# file_path : String : path to file to be read +# return : Dictionary : read results, contains: { error : int, voxels : Dictionary<Vec3, int>, palette : Dictionary<int, Dictionary<String, Variant> } +static func read_file(file_path : String) -> Dictionary: + var result = { "error": ERR_FILE_UNRECOGNIZED } + match file_path.get_extension(): + "png", "bmp", "dds", "exr", "hdr", "jpg", "jpeg", "tga", "svg", "svgz", "webp": + result = ImageReader.read_file(file_path) + "vox": result = VoxReader.read_file(file_path) + "qb": continue + "qbt": continue + "vxm": continue + "gpl": result = GPLReader.read_file(file_path) + return result |