paint: import psd layers
This commit is contained in:
+39
-3
@@ -1,19 +1,26 @@
|
||||
|
||||
#ifdef WITH_PLUGINS
|
||||
|
||||
#include "engine.h"
|
||||
#include "iron_array.h"
|
||||
#include "iron_map.h"
|
||||
#include "iron_ui.h"
|
||||
#include "engine.h"
|
||||
|
||||
void *io_svg_parse(char *buf);
|
||||
void *io_exr_parse(char *buf, size_t len);
|
||||
void *io_psd_parse(uint8_t *buf, size_t len, const char *filename);
|
||||
void *io_tiff_parse(uint8_t *buf, size_t len);
|
||||
void *io_gltf_parse(char *buf, size_t size, const char *path);
|
||||
void *io_gltf_parse_skinned(char *buf, size_t size, const char *path, int frame);
|
||||
void *io_fbx_parse(char *buf, size_t size);
|
||||
void *io_fbx_parse_skinned(char *buf, size_t size, int frame);
|
||||
void proc_uv_unwrap(void *mesh);
|
||||
void proc_uv_unwrap(void *mesh);
|
||||
|
||||
typedef struct asset {
|
||||
i32 id;
|
||||
char *name;
|
||||
char *file;
|
||||
} asset_t;
|
||||
|
||||
extern any_map_t *import_mesh_importers;
|
||||
extern string_array_t *_path_mesh_formats;
|
||||
@@ -21,16 +28,43 @@ string_array_t *path_mesh_formats(void);
|
||||
extern any_map_t *import_texture_importers;
|
||||
extern string_array_t *_path_texture_formats;
|
||||
string_array_t *path_texture_formats(void);
|
||||
extern any_map_t *util_mesh_unwrappers;
|
||||
extern any_map_t *util_mesh_unwrappers;
|
||||
extern any_map_t *data_cached_images;
|
||||
void import_texture_run(char *path, bool hdr_as_envmap);
|
||||
extern any_array_t *project_assets;
|
||||
void tab_textures_delete_texture(asset_t *asset);
|
||||
|
||||
int plugins_skinning_frame = -1;
|
||||
|
||||
void io_psd_import_layer(char *file_name, char *layer_name, void *tex) {
|
||||
char *path = string("%s.%s.png", file_name, layer_name);
|
||||
any_map_set(data_cached_images, path, tex);
|
||||
import_texture_run(path, false);
|
||||
}
|
||||
|
||||
static void *import_exr(char *path) {
|
||||
buffer_t *b = data_get_blob(path);
|
||||
data_delete_blob(path);
|
||||
return io_exr_parse((char *)b->buffer, b->length);
|
||||
}
|
||||
|
||||
static void *import_psd(char *path) {
|
||||
char *filename = substring(path, string_last_index_of(path, PATH_SEP) + 1, string_length(path));
|
||||
|
||||
// Delete existing layers so they can be re-imported
|
||||
char *prefix = string("%s.", filename);
|
||||
for (int i = project_assets->length - 1; i >= 0; --i) {
|
||||
asset_t *a = project_assets->buffer[i];
|
||||
if (starts_with(a->name, prefix)) {
|
||||
tab_textures_delete_texture(a);
|
||||
}
|
||||
}
|
||||
|
||||
buffer_t *b = data_get_blob(path);
|
||||
data_delete_blob(path);
|
||||
return io_psd_parse((uint8_t *)b->buffer, b->length, filename);
|
||||
}
|
||||
|
||||
static void *import_tiff(char *path) {
|
||||
buffer_t *b = data_get_blob(path);
|
||||
data_delete_blob(path);
|
||||
@@ -69,6 +103,8 @@ void plugins_init() {
|
||||
path_texture_formats(); // Init array
|
||||
any_map_set(import_texture_importers, "exr", import_exr);
|
||||
any_array_push(_path_texture_formats, "exr");
|
||||
any_map_set(import_texture_importers, "psd", import_psd);
|
||||
any_array_push(_path_texture_formats, "psd");
|
||||
any_map_set(import_texture_importers, "svg", import_svg);
|
||||
any_array_push(_path_texture_formats, "svg");
|
||||
any_map_set(import_texture_importers, "tiff", import_tiff);
|
||||
|
||||
Reference in New Issue
Block a user