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/image.h"
|
|
|
|
#include "core/reference.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 18:33:12 +02:00
|
|
|
//Rename to TexturePacker
|
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 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);
|
|
|
|
void remove_texture_index(int index);
|
|
|
|
void remove_texture(Ref<Texture> texture);
|
2019-10-21 12:18:31 +02:00
|
|
|
int get_texture_count();
|
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-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 12:18:31 +02:00
|
|
|
bool _keep_original_atlases;
|
2019-10-21 18:33:12 +02:00
|
|
|
|
2019-10-21 00:06:09 +02:00
|
|
|
std::vector<bin> _bins;
|
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
|