All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Go to the documentation of this file.
9 #pragma once
11 #include "inexor/engine/shader.hpp" // for SlotShaderParam
12 #include "inexor/network/legacy/buffer_types.hpp" // for ucharbuf
13 #include "inexor/shared/cube_types.hpp" // for uchar, string, uint
14 #include "inexor/shared/cube_vector.hpp" // for vector
15 #include "inexor/shared/geom.hpp" // for vec, ivec2, vec2
17 class Slot;
18 struct ImageData;
19 struct Texture;
20 struct cube;
22 enum
23 {
33 };
37 class VSlot
38 {
39  public:
44  int index, changed;
46  bool linked;
48  // The actual params this VSlot provides:
49  float scale;
50  int rotation;
53  int layer;
58  VSlot(Slot *slot = nullptr, int index = -1);
60  void reset()
61  {
62  params.shrink(0);
63  linked = false;
64  scale = 1;
65  rotation = 0;
66  offset = ivec2(0, 0);
67  scroll = vec2(0, 0);
68  layer = 0;
69  alphafront = 0.5f;
70  alphaback = 0;
71  colorscale = vec(1, 1, 1);
72  glowcolor = vec(1, 1, 1);
73  }
75  void cleanup()
76  {
77  linked = false;
78  }
79 };
81 class Slot
82 {
83  public:
84  struct Tex
85  {
86  int type;
87  Texture *t = nullptr;
88  string name;
89  int combined = -1;
90  };
92  int index;
99  bool loaded;
101  char *autograss;
108  Slot(int index = -1) : index(index), variants(nullptr), autograss(nullptr), layermaskname(nullptr), layermask(nullptr) { reset(); }
110  void reset();
112  void cleanup();
114  void addtexture(int type, const char *filename);
117  Tex *findtexture(int type);
119  void addvariant(VSlot *vs);
122  VSlot *findvariant(const VSlot &src, const VSlot &delta);
131  void combinetextures(int index, Slot::Tex &t, bool msg = true, bool forceload = false);
133  Slot &load(bool msg, bool forceload);
135  void loadlayermask();
136 };
138 struct MSlot : Slot, VSlot
139 {
140  MSlot() : VSlot(this) {}
142  void reset()
143  {
144  Slot::reset();
145  VSlot::reset();
146  }
148  void cleanup()
149  {
150  Slot::cleanup();
151  VSlot::cleanup();
152  }
153 };
155 extern void loadlayermasks();
157 extern void clearslots();
158 extern void cleanupslots();
159 extern void cleanupvslots();
160 extern void cleanupmaterialslots();
166 extern void propagatevslot(VSlot *root, int changed);
167 extern void texturereset(int first, int num = 0);
169 extern MSlot &lookupmaterialslot(int slot, bool load = true);
170 extern Slot &lookupslot(int slot, bool load = true);
171 extern VSlot &lookupvslot(int slot, bool load = true);
172 extern VSlot *emptyvslot(Slot &owner);
174 extern VSlot *editvslot(const VSlot &src, const VSlot &delta);
175 extern void mergevslot(VSlot &dst, const VSlot &src, const VSlot &delta);
177 extern bool texturedata(ImageData &d, const char *tname, Slot::Tex *tex = nullptr, bool msg = true, int *compress = nullptr); // TODO move to texture.hpp
179 extern void compactvslots(cube *c, int n = 8);
180 extern void compactvslot(int &index);
181 extern void compactvslot(VSlot &vs);
182 extern int compactvslots();
184 extern void compacteditvslots();
185 extern void compactmruvslots();
187 extern void packvslot(vector<uchar> &buf, const VSlot &src);
188 extern void packvslot(vector<uchar> &buf, int index);
189 extern void packvslot(vector<uchar> &buf, const VSlot *src);
190 extern bool unpackvslot(ucharbuf &buf, VSlot &dst, bool delta);
192 extern vector<Slot *> slots;
193 extern vector<VSlot *> vslots;
198 // make emptyvslot obsolete by providing a better cleaning algorithm
199 // remove grass thingy
200 // remove weird clonevslot stuff
201 // make vslots a list in slot
void addtexture(int type, const char *filename)
Definition: slot.cpp:653
uint texmask
Definition: slot.hpp:100
void compactvslots(cube *c, int n=8)
Loops through all n subcubes of c, (reassigning vs.index to compactvslots++ in markmode and otherwise...
Definition: slot.cpp:128
Definition: slot.hpp:31
bool unpackvslot(ucharbuf &buf, VSlot &dst, bool delta)
Unpack a virtual Slot modified by another client.
Definition: slot.cpp:408
int changed
Definition: slot.hpp:44
template implementation of buffers (networking e.g.).
Definition: buffer_types.hpp:14
Header for the internal GLSL shader organisation.
unsigned int uint
Definition: cube_types.hpp:9
vec2 scroll
Definition: slot.hpp:52
char * autograss
Definition: slot.hpp:101
Definition: slot.hpp:30
int index
Definition: slot.hpp:92
void packvslot(vector< uchar > &buf, const VSlot &src)
Pack a virtual Slot after it has been modified for broadcasting it to the other clients.
Definition: slot.cpp:340
Structure holding the Raw Pixel Data and minimum image info.
Definition: image.hpp:20
A virtual Slot.
Definition: slot.hpp:37
float layermaskscale
Definition: slot.hpp:105
void loadlayermask()
Definition: slot.cpp:849
float scale
Definition: slot.hpp:49
void cleanupvslots()
Definition: slot.cpp:896
Slot * slot
The Slot this VSlot derived from.
Definition: slot.hpp:41
vector< SlotShaderParam > params
Definition: slot.hpp:95
2-dimensional float vectors
Definition: geom.hpp:38
void cleanupslots()
Definition: slot.cpp:891
Shader * shader
Definition: slot.hpp:94
void compactmruvslots()
Definition: octaedit.cpp:2483
bool loaded
Definition: slot.hpp:99
VSlot * setvariantchain(VSlot *vs)
Sets a chain of VSlot variants for the owner slot.
Definition: slot.cpp:492
string name
Definition: slot.hpp:88
Definition: slot.hpp:27
void compacteditvslots()
Definition: octaedit.cpp:1663
void compactvslot(int &index)
compacting mode: set index to compactvslots++ = vs.index, marking mode, just set vs.index
Definition: slot.cpp:112
vector< SlotShaderParam > params
Definition: slot.hpp:45
Slot(int index=-1)
Definition: slot.hpp:108
vector< Slot * > slots
Definition: slot.cpp:39
bool texturedata(ImageData &d, const char *tname, Slot::Tex *tex=nullptr, bool msg=true, int *compress=nullptr)
Definition: texture.cpp:355
void cleanupmaterialslots()
Definition: slot.cpp:901
VSlot * findvariant(const VSlot &src, const VSlot &delta)
Definition: slot.cpp:478
void reset()
Definition: slot.cpp:859
Texture * loadthumbnail()
Generate a preview image of this slot for the texture browser.
Definition: slot.cpp:767
Definition: slot.hpp:138
int layer
Definition: slot.hpp:53
vector< VSlot * > vslots
Definition: slot.cpp:38
bool linked
Definition: slot.hpp:46
Texture * thumbnail
Definition: slot.hpp:102
Tex * findtexture(int type)
Find a texture in the sts array, depending on type (beeing one of TEX_DIFFUSE to TEX_NUM).
Definition: slot.cpp:661
void propagatevslot(VSlot *root, int changed)
Apply changes to all following neighbors of root.
Definition: slot.cpp:261
int index
Definition: slot.hpp:44
float alphaback
Definition: slot.hpp:54
vec colorscale
Definition: slot.hpp:55
GLuint index
Definition: glexts.hpp:412
GLsizei const GLuint GLenum GLint * params
Definition: glexts.hpp:396
Texture * grasstex
Definition: slot.hpp:102
vector with 3 floats and some useful methods.
Definition: geom.hpp:110
Definition: slot.hpp:84
void combinetextures(int index, Slot::Tex &t, bool msg=true, bool forceload=false)
Combine and load texture data to be ready for sending it to the gpu.
Definition: slot.cpp:668
void texturereset(int first, int num=0)
Resets all textures from the slots-stack.
Definition: slot.cpp:48
ivec2 offset
Definition: slot.hpp:51
int type
Definition: slot.hpp:86
2 dimensional integer vector.
Definition: geom.hpp:1304
Definition: slot.hpp:28
ImageData * layermask
Definition: slot.hpp:106
Texture * t
Definition: slot.hpp:87
int rotation
Definition: slot.hpp:50
VSlot(Slot *slot=nullptr, int index=-1)
Definition: slot.cpp:504
VSlot * variants
All virtual Slots deriving from this slot in a node chain.
Definition: slot.hpp:98
void reset()
Definition: slot.hpp:60
Definition: slot.hpp:29
Definition: slot.hpp:26
int d
Definition: octaedit.cpp:1749
void t(T x, const char *cmp)
Definition: utilTest.cpp:52
Definition: shader.hpp:142
Definition: slot.hpp:32
void cleanup()
Definition: slot.hpp:148
vec glowcolor
Definition: slot.hpp:56
VSlot * editvslot(const VSlot &src, const VSlot &delta)
Select a VSlot beeing src but having modifications based on delta (??)
Definition: slot.cpp:532
Slot & load(bool msg, bool forceload)
Definition: slot.cpp:744
GLintptr offset
Definition: glexts.hpp:354
void clearslots()
Definition: slot.cpp:83
Definition: slot.hpp:140
Definition: slot.hpp:81
int combined
Definition: slot.hpp:89
Definition: slot.hpp:25
vector< Tex > sts
Definition: slot.hpp:93
void compress(const chunk *str, chunk state[3])
Definition: crypto.cpp:36
void loadlayermasks()
Definition: slot.cpp:886
void changed(const block3 &sel, bool commit=true)
validates editing changes using readychanges() and calls commitchanges()
Definition: octaedit.cpp:725
float alphafront
Definition: slot.hpp:54
void mergevslot(VSlot &dst, const VSlot &src, const VSlot &delta)
Definition: slot.cpp:311
VSlot * emptyvslot(Slot &owner)
Wrapper around new VSlot to reuse unused dead vslots.
Definition: slot.cpp:512
char * layermaskname
Definition: slot.hpp:103
void cleanup()
Definition: slot.cpp:874
VSlot & lookupvslot(int slot, bool load=true)
Definition: slot.cpp:721
Definition: slot.hpp:24
mathmatics for vectors, matrices, quaterions and more
MSlot & lookupmaterialslot(int slot, bool load=true)
Definition: slot.cpp:703
void addvariant(VSlot *vs)
Definition: slot.cpp:467
void cleanup()
Definition: slot.hpp:75
int layermaskmode
Definition: slot.hpp:104
void reset()
Definition: slot.hpp:142
Definition: octree.hpp:208
VSlot * next
The next VSlot in the variant chain of the Slot.
Definition: slot.hpp:43
Slot & lookupslot(int slot, bool load=true)
Definition: slot.cpp:715
A Texture entry, holding info about a texture on the GPU.
Definition: texture.hpp:27