/
TexDef.h
56 lines (43 loc) · 1.55 KB
/
TexDef.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
44
45
46
47
48
49
50
51
52
53
54
55
56
#pragma once
#include <iostream>
#include "ibrush.h"
class TexDef final
{
private:
double _shift[2];
double _rotate;
double _scale[2];
public:
// Constructor
TexDef();
// Constructs a TexDef out of the given transformation matrix plus width/height
TexDef(double width, double height, const Matrix4& transform);
// Destructor
virtual ~TexDef() {}
Vector2 getShift() const;
void setShift(const Vector2& shift);
Vector2 getScale() const;
void setScale(const Vector2& scale);
double getRotation() const;
void setRotation(double rotation);
void shift(double s, double t);
void scale(double s, double t);
void rotate(double angle);
// Checks the TexDef for insanely large values
bool isSane() const;
// All texture-projection translation (shift) values are congruent modulo the dimensions of the texture.
// This function normalises shift values to the smallest positive congruent values.
void normalise(double width, double height);
// Converts this instance's values to a ShiftScaleRotation structure
// Since TexDef is using the same format to store its values internally
// this is equivalent to a few simple assignment or copy operations.
ShiftScaleRotation toShiftScaleRotation() const;
static TexDef CreateFromShiftScaleRotation(const ShiftScaleRotation& scr);
friend std::ostream& operator<<(std::ostream& st, const TexDef& texdef);
};
inline std::ostream& operator<<(std::ostream& st, const TexDef& texdef)
{
st << "Scale: <" << texdef._scale[0] << ", " << texdef._scale[1] << ">, ";
st << "Rotation: <" << texdef._rotate << ">";
return st;
}