mirror of
https://github.com/Relintai/texture_packer.git
synced 2024-11-12 10:15:16 +01:00
Added a TextureMerger Node.
This commit is contained in:
parent
280dabf737
commit
95fbb4668b
2
SCsub
2
SCsub
@ -4,3 +4,5 @@ env.add_source_files(env.modules_sources,"register_types.cpp")
|
||||
|
||||
env.add_source_files(env.modules_sources,"texture_packer.cpp")
|
||||
env.add_source_files(env.modules_sources,"rectpack2D/pack.cpp")
|
||||
|
||||
env.add_source_files(env.modules_sources,"texture_merger.cpp")
|
||||
|
@ -1,9 +1,11 @@
|
||||
#include "register_types.h"
|
||||
|
||||
#include "texture_packer.h"
|
||||
#include "texture_merger.h"
|
||||
|
||||
void register_texture_packer_types() {
|
||||
ClassDB::register_class<TexturePacker>();
|
||||
ClassDB::register_class<TextureMerger>();
|
||||
}
|
||||
|
||||
void unregister_texture_packer_types() {
|
||||
|
138
texture_merger.cpp
Normal file
138
texture_merger.cpp
Normal file
@ -0,0 +1,138 @@
|
||||
#include "texture_merger.h"
|
||||
|
||||
int TextureMerger::get_texture_flags() const {
|
||||
return _packer->get_texture_flags();
|
||||
}
|
||||
void TextureMerger::set_texture_flags(const int flags) {
|
||||
_packer->set_texture_flags(flags);
|
||||
}
|
||||
|
||||
int TextureMerger::get_max_atlas_size() const {
|
||||
return _packer->get_max_atlas_size();
|
||||
}
|
||||
void TextureMerger::set_max_atlas_size(const int size) {
|
||||
_packer->set_max_atlas_size(size);
|
||||
}
|
||||
|
||||
bool TextureMerger::get_keep_original_atlases() const {
|
||||
return _packer->get_keep_original_atlases();
|
||||
}
|
||||
void TextureMerger::set_keep_original_atlases(const bool value) {
|
||||
_packer->set_keep_original_atlases(value);
|
||||
}
|
||||
|
||||
Color TextureMerger::get_background_color() const {
|
||||
return _packer->get_background_color();
|
||||
}
|
||||
void TextureMerger::set_background_color(const Color color) {
|
||||
_packer->set_background_color(color);
|
||||
}
|
||||
|
||||
int TextureMerger::get_margin() const {
|
||||
return _packer->get_margin();
|
||||
}
|
||||
void TextureMerger::set_margin(const int margin){
|
||||
_packer->set_margin(margin);
|
||||
}
|
||||
|
||||
Ref<TexturePacker> TextureMerger::get_packer() const {
|
||||
return _packer;
|
||||
}
|
||||
void TextureMerger::set_packer(const Ref<TexturePacker> packer) {
|
||||
_packer = packer;
|
||||
}
|
||||
|
||||
Ref<AtlasTexture> TextureMerger::add_texture(Ref<Texture> texture) {
|
||||
return _packer->add_texture(texture);
|
||||
}
|
||||
|
||||
Ref<Texture> TextureMerger::get_original_texture(int index) {
|
||||
return _packer->get_original_texture(index);
|
||||
}
|
||||
|
||||
Ref<AtlasTexture> TextureMerger::get_texture(int index) {
|
||||
return _packer->get_texture(index);
|
||||
}
|
||||
|
||||
void TextureMerger::unref_texture_index(int index) {
|
||||
_packer->unref_texture_index(index);
|
||||
}
|
||||
|
||||
void TextureMerger::unref_texture(Ref<Texture> texture) {
|
||||
_packer->unref_texture(texture);
|
||||
}
|
||||
|
||||
void TextureMerger::remove_texture_index(int index) {
|
||||
_packer->remove_texture_index(index);
|
||||
}
|
||||
|
||||
void TextureMerger::remove_texture(Ref<Texture> texture) {
|
||||
_packer->remove_texture(texture);
|
||||
}
|
||||
|
||||
int TextureMerger::get_texture_count() {
|
||||
return _packer->get_texture_count();
|
||||
}
|
||||
|
||||
void TextureMerger::clear() {
|
||||
_packer->clear();
|
||||
}
|
||||
|
||||
Ref<ImageTexture> TextureMerger::get_generated_texture(int index) {
|
||||
return _packer->get_generated_texture(index);
|
||||
}
|
||||
int TextureMerger::get_generated_texture_count() {
|
||||
return _packer->get_generated_texture_count();
|
||||
}
|
||||
|
||||
void TextureMerger::merge() {
|
||||
_packer->merge();
|
||||
}
|
||||
|
||||
TextureMerger::TextureMerger() {
|
||||
_packer.instance();
|
||||
_packer->set_keep_original_atlases(true);
|
||||
}
|
||||
|
||||
TextureMerger::~TextureMerger() {
|
||||
_packer.unref();
|
||||
}
|
||||
|
||||
void TextureMerger::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("get_texture_flags"), &TextureMerger::get_texture_flags);
|
||||
ClassDB::bind_method(D_METHOD("set_texture_flags", "flags"), &TextureMerger::set_texture_flags);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "texture_flags", PROPERTY_HINT_FLAGS, "Mipmaps,Repeat,Filter,Anisotropic Linear,Convert to Linear,Mirrored Repeat,Video Surface"), "set_texture_flags", "get_texture_flags");
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_max_atlas_size"), &TextureMerger::get_max_atlas_size);
|
||||
ClassDB::bind_method(D_METHOD("set_max_atlas_size", "size"), &TextureMerger::set_max_atlas_size);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "max_atlas_size"), "set_max_atlas_size", "get_max_atlas_size");
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_keep_original_atlases"), &TextureMerger::get_keep_original_atlases);
|
||||
ClassDB::bind_method(D_METHOD("set_keep_original_atlases", "value"), &TextureMerger::set_keep_original_atlases);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "keep_original_atlases"), "set_keep_original_atlases", "get_keep_original_atlases");
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_background_color"), &TextureMerger::get_background_color);
|
||||
ClassDB::bind_method(D_METHOD("set_background_color", "color"), &TextureMerger::set_background_color);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::COLOR, "background_color"), "set_background_color", "get_background_color");
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_margin"), &TextureMerger::get_margin);
|
||||
ClassDB::bind_method(D_METHOD("set_margin", "size"), &TextureMerger::set_margin);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "margin"), "set_margin", "get_margin");
|
||||
|
||||
ClassDB::bind_method(D_METHOD("add_texture", "texture"), &TextureMerger::add_texture);
|
||||
ClassDB::bind_method(D_METHOD("get_texture", "index"), &TextureMerger::get_texture);
|
||||
ClassDB::bind_method(D_METHOD("get_original_texture", "index"), &TextureMerger::get_original_texture);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("unref_texture_index", "index"), &TextureMerger::unref_texture_index);
|
||||
ClassDB::bind_method(D_METHOD("unref_texture", "texture"), &TextureMerger::unref_texture);
|
||||
ClassDB::bind_method(D_METHOD("remove_texture_index", "index"), &TextureMerger::remove_texture_index);
|
||||
ClassDB::bind_method(D_METHOD("remove_texture", "texture"), &TextureMerger::remove_texture);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_texture_count"), &TextureMerger::get_texture_count);
|
||||
ClassDB::bind_method(D_METHOD("clear"), &TextureMerger::clear);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_generated_texture", "index"), &TextureMerger::get_generated_texture);
|
||||
ClassDB::bind_method(D_METHOD("get_generated_texture_count"), &TextureMerger::get_generated_texture_count);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("merge"), &TextureMerger::merge);
|
||||
}
|
57
texture_merger.h
Normal file
57
texture_merger.h
Normal file
@ -0,0 +1,57 @@
|
||||
#ifndef TEXTURE_MERGER_H
|
||||
#define TEXTURE_MERGER_H
|
||||
|
||||
#include "scene/main/node.h"
|
||||
|
||||
#include "texture_packer.h"
|
||||
|
||||
class TextureMerger : public Node {
|
||||
GDCLASS(TextureMerger, Node);
|
||||
|
||||
public:
|
||||
int get_texture_flags() const;
|
||||
void set_texture_flags(const int flags);
|
||||
|
||||
int get_max_atlas_size() const;
|
||||
void set_max_atlas_size(const int size);
|
||||
|
||||
bool get_keep_original_atlases() const;
|
||||
void set_keep_original_atlases(const bool value);
|
||||
|
||||
Color get_background_color() const;
|
||||
void set_background_color(const Color color);
|
||||
|
||||
int get_margin() const;
|
||||
void set_margin(const int margin);
|
||||
|
||||
Ref<TexturePacker> get_packer() const;
|
||||
void set_packer(const Ref<TexturePacker> packer);
|
||||
|
||||
Ref<AtlasTexture> add_texture(Ref<Texture> texture);
|
||||
Ref<AtlasTexture> get_texture(int index);
|
||||
Ref<Texture> get_original_texture(int index);
|
||||
|
||||
void unref_texture_index(int index);
|
||||
void unref_texture(Ref<Texture> texture);
|
||||
void remove_texture_index(int index);
|
||||
void remove_texture(Ref<Texture> texture);
|
||||
|
||||
int get_texture_count();
|
||||
void clear();
|
||||
|
||||
Ref<ImageTexture> get_generated_texture(int index);
|
||||
int get_generated_texture_count();
|
||||
|
||||
void merge();
|
||||
|
||||
TextureMerger();
|
||||
~TextureMerger();
|
||||
|
||||
protected:
|
||||
static void _bind_methods();
|
||||
|
||||
private:
|
||||
Ref<TexturePacker> _packer;
|
||||
};
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue
Block a user