forked from floft/sprouts
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathtexture_descriptor.h
43 lines (39 loc) · 1.16 KB
/
texture_descriptor.h
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
#ifndef TEXTURE_DESCRIPTOR_H_INCLUDED
#define TEXTURE_DESCRIPTOR_H_INCLUDED
#include "image.h"
#include "util.h"
/**************
*Description:
*Input:
*Output:
**************/
struct TextureDescriptor
{
Image image;
float minU, maxU, minV, maxV;
TextureDescriptor(Image image = Image())
: image(image), minU(0), maxU(1), minV(0), maxV(1)
{
}
TextureDescriptor(Image image, float minU, float maxU, float minV, float maxV)
: image(image), minU(minU), maxU(maxU), minV(minV), maxV(maxV)
{
}
operator bool() const
{
return (bool)image;
}
bool operator !() const
{
return !image;
}
TextureDescriptor subTexture(const float minU, const float maxU, const float minV, const float maxV) const
{
return TextureDescriptor(image,
interpolate(minU, this->minU, this->maxU),
interpolate(maxU, this->minU, this->maxU),
interpolate(minV, this->minV, this->maxV),
interpolate(maxV, this->minV, this->maxV));
}
};
#endif // TEXTURE_DESCRIPTOR_H_INCLUDED