Pyrogenesis  trunk
BlendShapes.h
Go to the documentation of this file.
1 /* Copyright (C) 2009 Wildfire Games.
2  * This file is part of 0 A.D.
3  *
4  * 0 A.D. is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, either version 2 of the License, or
7  * (at your option) any later version.
8  *
9  * 0 A.D. is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with 0 A.D. If not, see <http://www.gnu.org/licenses/>.
16  */
17 
18 #ifndef INCLUDED_BLENDSHAPES
19 #define INCLUDED_BLENDSHAPES
20 
22 {
23 public:
25  BlendShape4(int a,int b,int c,int d) {
26  m_Data[0]=a; m_Data[1]=b; m_Data[2]=c; m_Data[3]=d;
27  }
28 
29  int& operator[](int index) { return m_Data[index]; }
30  const int& operator[](int index) const { return m_Data[index]; }
31 
32  bool operator==(const BlendShape4& lhs) const {
33  return memcmp(m_Data,lhs.m_Data,sizeof(BlendShape4))==0;
34  }
35 
36  void Rotate90(BlendShape4& dst) const {
37  dst[0]=m_Data[3];
38  dst[1]=m_Data[0];
39  dst[2]=m_Data[1];
40  dst[3]=m_Data[2];
41  }
42 
43  void Rotate180(BlendShape4& dst) const {
44  dst[0]=m_Data[2];
45  dst[1]=m_Data[3];
46  dst[2]=m_Data[0];
47  dst[3]=m_Data[1];
48  }
49 
50  void Rotate270(BlendShape4& dst) const {
51  dst[0]=m_Data[1];
52  dst[1]=m_Data[2];
53  dst[2]=m_Data[3];
54  dst[3]=m_Data[0];
55  }
56 
57  void FlipU(BlendShape4& dst) const {
58  dst[0]=m_Data[2];
59  dst[1]=m_Data[1];
60  dst[2]=m_Data[0];
61  dst[3]=m_Data[3];
62  }
63 
64  void FlipV(BlendShape4& dst) const {
65  dst[0]=m_Data[0];
66  dst[1]=m_Data[3];
67  dst[2]=m_Data[2];
68  dst[3]=m_Data[1];
69  }
70 
71 private:
72  int m_Data[4];
73 };
74 
75 
77 {
78 public:
80  BlendShape8(int a,int b,int c,int d,int e,int f,int g,int h) {
81  m_Data[0]=a; m_Data[1]=b; m_Data[2]=c; m_Data[3]=d;
82  m_Data[4]=e; m_Data[5]=f; m_Data[6]=g; m_Data[7]=h;
83  }
84 
85  int& operator[](size_t index) { return m_Data[index]; }
86  const int& operator[](size_t index) const { return m_Data[index]; }
87 
88  bool operator==(const BlendShape8& lhs) const {
89  return memcmp(m_Data,lhs.m_Data,sizeof(BlendShape8))==0;
90  }
91 
92  void Rotate90(BlendShape8& dst) const {
93  dst[0]=m_Data[6];
94  dst[1]=m_Data[7];
95  dst[2]=m_Data[0];
96  dst[3]=m_Data[1];
97  dst[4]=m_Data[2];
98  dst[5]=m_Data[3];
99  dst[6]=m_Data[4];
100  dst[7]=m_Data[5];
101  }
102 
103  void Rotate180(BlendShape8& dst) const {
104  dst[0]=m_Data[4];
105  dst[1]=m_Data[5];
106  dst[2]=m_Data[6];
107  dst[3]=m_Data[7];
108  dst[4]=m_Data[0];
109  dst[5]=m_Data[1];
110  dst[6]=m_Data[2];
111  dst[7]=m_Data[3];
112  }
113 
114  void Rotate270(BlendShape8& dst) const {
115  dst[0]=m_Data[2];
116  dst[1]=m_Data[3];
117  dst[2]=m_Data[4];
118  dst[3]=m_Data[5];
119  dst[4]=m_Data[6];
120  dst[5]=m_Data[7];
121  dst[6]=m_Data[0];
122  dst[7]=m_Data[1];
123  }
124 
125  void FlipU(BlendShape8& dst) const {
126  dst[0]=m_Data[4];
127  dst[1]=m_Data[3];
128  dst[2]=m_Data[2];
129  dst[3]=m_Data[1];
130  dst[4]=m_Data[0];
131  dst[5]=m_Data[7];
132  dst[6]=m_Data[6];
133  dst[7]=m_Data[5];
134  }
135 
136  void FlipV(BlendShape8& dst) const {
137  dst[0]=m_Data[0];
138  dst[1]=m_Data[7];
139  dst[2]=m_Data[6];
140  dst[3]=m_Data[5];
141  dst[4]=m_Data[4];
142  dst[5]=m_Data[3];
143  dst[6]=m_Data[2];
144  dst[7]=m_Data[1];
145  }
146 
147 private:
148  int m_Data[8];
149 };
150 
151 #endif
const int & operator[](size_t index) const
Definition: BlendShapes.h:86
bool operator==(const BlendShape4 &lhs) const
Definition: BlendShapes.h:32
Definition: BlendShapes.h:21
void Rotate180(BlendShape8 &dst) const
Definition: BlendShapes.h:103
int & operator[](int index)
Definition: BlendShapes.h:29
int m_Data[8]
Definition: BlendShapes.h:148
Definition: BlendShapes.h:76
void FlipU(BlendShape8 &dst) const
Definition: BlendShapes.h:125
void Rotate180(BlendShape4 &dst) const
Definition: BlendShapes.h:43
void FlipU(BlendShape4 &dst) const
Definition: BlendShapes.h:57
void Rotate90(BlendShape8 &dst) const
Definition: BlendShapes.h:92
void Rotate270(BlendShape4 &dst) const
Definition: BlendShapes.h:50
BlendShape4()
Definition: BlendShapes.h:24
void FlipV(BlendShape8 &dst) const
Definition: BlendShapes.h:136
BlendShape8()
Definition: BlendShapes.h:79
void FlipV(BlendShape4 &dst) const
Definition: BlendShapes.h:64
BlendShape8(int a, int b, int c, int d, int e, int f, int g, int h)
Definition: BlendShapes.h:80
void Rotate270(BlendShape8 &dst) const
Definition: BlendShapes.h:114
const int & operator[](int index) const
Definition: BlendShapes.h:30
int m_Data[4]
Definition: BlendShapes.h:72
int & operator[](size_t index)
Definition: BlendShapes.h:85
bool operator==(const BlendShape8 &lhs) const
Definition: BlendShapes.h:88
void Rotate90(BlendShape4 &dst) const
Definition: BlendShapes.h:36
BlendShape4(int a, int b, int c, int d)
Definition: BlendShapes.h:25