-
-
Notifications
You must be signed in to change notification settings - Fork 46
Expand file tree
/
Copy pathtextureconverter.h
More file actions
116 lines (81 loc) · 2.84 KB
/
textureconverter.h
File metadata and controls
116 lines (81 loc) · 2.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
#ifndef TEXTURECONVERTER_H
#define TEXTURECONVERTER_H
#include <resources/texture.h>
#include <resources/sprite.h>
#include <editor/assetconverter.h>
#include <QRect>
class TextureImportSettings : public AssetConverterSettings {
Q_OBJECT
Q_PROPERTY(AssetType Type READ assetType WRITE setAssetType DESIGNABLE true USER true)
Q_PROPERTY(WrapType Wrap READ wrap WRITE setWrap DESIGNABLE true USER true)
Q_PROPERTY(bool MIP_maping READ lod WRITE setLod DESIGNABLE true USER true)
Q_PROPERTY(FilteringType Filtering READ filtering WRITE setFiltering DESIGNABLE true USER true)
public:
enum class AssetType {
Texture2D = 1,
Sprite,
Cubemap
};
enum class FilteringType {
None = Texture::None,
Bilinear = Texture::Bilinear,
Trilinear = Texture::Trilinear
};
enum class WrapType {
Clamp,
Repeat,
Mirrored
};
Q_ENUM(WrapType)
Q_ENUM(FilteringType)
Q_ENUM(AssetType)
struct Element {
Vector2 m_min;
Vector2 m_max;
Vector2 m_saveMin;
Vector2 m_saveMax;
Vector2 m_borderMin;
Vector2 m_borderMax;
Vector2 m_saveBorderMin;
Vector2 m_saveBorderMax;
Vector2 m_pivot = Vector2(0.5f);
};
typedef std::map<std::string, Element> ElementMap;
public:
TextureImportSettings();
AssetType assetType() const;
void setAssetType(AssetType type);
FilteringType filtering() const;
void setFiltering(FilteringType type);
WrapType wrap() const;
void setWrap(WrapType wrap);
bool lod() const;
void setLod(bool lod);
ElementMap &elements();
std::string setElement(const Element &element, const std::string &key = std::string());
void removeElement(const std::string &key);
private:
QJsonObject subItemData(const QString &key) const override;
void setSubItemData(const QString &name, const QJsonObject &data) override;
std::string findFreeElementName(const std::string &name);
QStringList typeNames() const override;
QString typeName() const override;
QString defaultIcon(QString) const override;
protected:
AssetType m_assetType;
FilteringType m_filtering;
WrapType m_wrap;
ElementMap m_elements;
bool m_lod;
};
class TextureConverter : public AssetConverter {
public:
void convertTexture(Texture *texture, TextureImportSettings *settings);
void convertSprite(Sprite *sheet, TextureImportSettings *settings);
private:
QStringList suffixes() const Q_DECL_OVERRIDE { return {"bmp", "dds", "jpg", "jpeg", "png", "tga", "ico", "tif"}; }
ReturnCode convertFile(AssetConverterSettings *settings) override;
AssetConverterSettings *createSettings() override;
Actor *createActor(const AssetConverterSettings *settings, const QString &guid) const override;
};
#endif // TEXTURECONVERTER_H