Merge 'remotes/trunk'
[0ad.git] / source / renderer / BlendShapes.h
blob30be8c39b25409b0545c86c84af038814bb82412
1 /* Copyright (C) 2009 Wildfire Games.
2 * This file is part of 0 A.D.
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.
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.
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/>.
18 #ifndef INCLUDED_BLENDSHAPES
19 #define INCLUDED_BLENDSHAPES
21 struct BlendShape4
23 public:
24 BlendShape4() {}
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;
29 int& operator[](int index) { return m_Data[index]; }
30 const int& operator[](int index) const { return m_Data[index]; }
32 bool operator==(const BlendShape4& lhs) const {
33 return memcmp(m_Data,lhs.m_Data,sizeof(BlendShape4))==0;
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];
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];
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];
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];
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];
71 private:
72 int m_Data[4];
76 struct BlendShape8
78 public:
79 BlendShape8() {}
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;
85 int& operator[](size_t index) { return m_Data[index]; }
86 const int& operator[](size_t index) const { return m_Data[index]; }
88 bool operator==(const BlendShape8& lhs) const {
89 return memcmp(m_Data,lhs.m_Data,sizeof(BlendShape8))==0;
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];
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];
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];
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];
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];
147 private:
148 int m_Data[8];
151 #endif