2019-10-21 21:11:11 +02:00
|
|
|
#ifndef TEXTURE_PACKER_H
|
|
|
|
#define TEXTURE_PACKER_H
|
2019-10-20 21:19:00 +02:00
|
|
|
|
2019-10-21 18:33:12 +02:00
|
|
|
#include "core/reference.h"
|
2019-10-21 23:42:53 +02:00
|
|
|
#include "core/image.h"
|
|
|
|
#include "core/color.h"
|
2019-10-20 21:46:36 +02:00
|
|
|
#include "core/ustring.h"
|
2019-10-21 00:06:09 +02:00
|
|
|
#include "core/vector.h"
|
2019-10-21 18:33:12 +02:00
|
|
|
#include "scene/resources/texture.h"
|
|
|
|
#include <vector>
|
2019-10-20 21:46:36 +02:00
|
|
|
|
|
|
|
#include "rectpack2D/pack.h"
|
2019-10-20 21:19:00 +02:00
|
|
|
|
2019-10-21 21:11:11 +02:00
|
|
|
class TexturePacker : public Reference {
|
|
|
|
GDCLASS(TexturePacker, Reference);
|
2019-10-20 21:19:00 +02:00
|
|
|
|
|
|
|
public:
|
2019-10-21 21:29:42 +02:00
|
|
|
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);
|
|
|
|
|
2019-10-21 23:42:53 +02:00
|
|
|
Color get_background_color() const;
|
|
|
|
void set_background_color(const Color color);
|
|
|
|
|
2019-10-22 00:03:04 +02:00
|
|
|
int get_margin() const;
|
|
|
|
void set_margin(const int margin);
|
|
|
|
|
2019-10-21 18:33:12 +02:00
|
|
|
Ref<AtlasTexture> add_texture(Ref<Texture> texture);
|
|
|
|
Ref<AtlasTexture> get_texture(int index);
|
|
|
|
Ref<Texture> get_original_texture(int index);
|
2019-10-22 00:52:59 +02:00
|
|
|
bool contains_texture(Ref<Texture> texture);
|
2019-10-21 23:18:06 +02:00
|
|
|
|
2019-10-23 16:30:41 +02:00
|
|
|
bool unref_texture_index(int index);
|
|
|
|
bool unref_texture(Ref<Texture> texture);
|
2019-10-21 18:33:12 +02:00
|
|
|
void remove_texture_index(int index);
|
|
|
|
void remove_texture(Ref<Texture> texture);
|
2019-10-21 23:18:06 +02:00
|
|
|
|
2019-10-21 12:18:31 +02:00
|
|
|
int get_texture_count();
|
2019-10-21 23:04:11 +02:00
|
|
|
void clear();
|
2019-10-21 18:33:12 +02:00
|
|
|
|
2019-10-21 20:57:39 +02:00
|
|
|
Ref<ImageTexture> get_generated_texture(int index);
|
|
|
|
int get_generated_texture_count();
|
|
|
|
|
2019-10-21 00:06:09 +02:00
|
|
|
void merge();
|
|
|
|
|
2019-10-26 18:19:28 +02:00
|
|
|
int get_offset_for_format(Image::Format format);
|
|
|
|
|
2019-10-21 21:11:11 +02:00
|
|
|
TexturePacker();
|
|
|
|
~TexturePacker();
|
2019-10-20 21:19:00 +02:00
|
|
|
|
|
|
|
protected:
|
|
|
|
static void _bind_methods();
|
2019-10-21 00:06:09 +02:00
|
|
|
|
|
|
|
private:
|
2019-10-21 21:29:42 +02:00
|
|
|
int _texture_flags;
|
|
|
|
int _max_atlas_size;
|
2019-10-21 12:18:31 +02:00
|
|
|
bool _keep_original_atlases;
|
2019-10-21 23:42:53 +02:00
|
|
|
Color _background_color;
|
2019-10-22 00:03:04 +02:00
|
|
|
int _margin;
|
2019-10-21 18:33:12 +02:00
|
|
|
|
|
|
|
Vector<rect_xywhf *> _rects;
|
|
|
|
Vector<Ref<ImageTexture> > _generated_textures;
|
2019-10-20 21:19:00 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|