Pyrogenesis HEAD
Pyrogenesis, a RTS Engine
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
21#include <cstring>
22
24{
25public:
27 BlendShape4(int a,int b,int c,int d) {
28 m_Data[0]=a; m_Data[1]=b; m_Data[2]=c; m_Data[3]=d;
29 }
30
31 int& operator[](int index) { return m_Data[index]; }
32 const int& operator[](int index) const { return m_Data[index]; }
33
34 bool operator==(const BlendShape4& lhs) const {
35 return memcmp(m_Data,lhs.m_Data,sizeof(BlendShape4))==0;
36 }
37
38 void Rotate90(BlendShape4& dst) const {
39 dst[0]=m_Data[3];
40 dst[1]=m_Data[0];
41 dst[2]=m_Data[1];
42 dst[3]=m_Data[2];
43 }
44
45 void Rotate180(BlendShape4& dst) const {
46 dst[0]=m_Data[2];
47 dst[1]=m_Data[3];
48 dst[2]=m_Data[0];
49 dst[3]=m_Data[1];
50 }
51
52 void Rotate270(BlendShape4& dst) const {
53 dst[0]=m_Data[1];
54 dst[1]=m_Data[2];
55 dst[2]=m_Data[3];
56 dst[3]=m_Data[0];
57 }
58
59 void FlipU(BlendShape4& dst) const {
60 dst[0]=m_Data[2];
61 dst[1]=m_Data[1];
62 dst[2]=m_Data[0];
63 dst[3]=m_Data[3];
64 }
65
66 void FlipV(BlendShape4& dst) const {
67 dst[0]=m_Data[0];
68 dst[1]=m_Data[3];
69 dst[2]=m_Data[2];
70 dst[3]=m_Data[1];
71 }
72
73private:
74 int m_Data[4];
75};
76
77
79{
80public:
82 BlendShape8(int a,int b,int c,int d,int e,int f,int g,int h) {
83 m_Data[0]=a; m_Data[1]=b; m_Data[2]=c; m_Data[3]=d;
84 m_Data[4]=e; m_Data[5]=f; m_Data[6]=g; m_Data[7]=h;
85 }
86
87 int& operator[](size_t index) { return m_Data[index]; }
88 const int& operator[](size_t index) const { return m_Data[index]; }
89
90 bool operator==(const BlendShape8& lhs) const {
91 return memcmp(m_Data,lhs.m_Data,sizeof(BlendShape8))==0;
92 }
93
94 void Rotate90(BlendShape8& dst) const {
95 dst[0]=m_Data[6];
96 dst[1]=m_Data[7];
97 dst[2]=m_Data[0];
98 dst[3]=m_Data[1];
99 dst[4]=m_Data[2];
100 dst[5]=m_Data[3];
101 dst[6]=m_Data[4];
102 dst[7]=m_Data[5];
103 }
104
105 void Rotate180(BlendShape8& dst) const {
106 dst[0]=m_Data[4];
107 dst[1]=m_Data[5];
108 dst[2]=m_Data[6];
109 dst[3]=m_Data[7];
110 dst[4]=m_Data[0];
111 dst[5]=m_Data[1];
112 dst[6]=m_Data[2];
113 dst[7]=m_Data[3];
114 }
115
116 void Rotate270(BlendShape8& dst) const {
117 dst[0]=m_Data[2];
118 dst[1]=m_Data[3];
119 dst[2]=m_Data[4];
120 dst[3]=m_Data[5];
121 dst[4]=m_Data[6];
122 dst[5]=m_Data[7];
123 dst[6]=m_Data[0];
124 dst[7]=m_Data[1];
125 }
126
127 void FlipU(BlendShape8& dst) const {
128 dst[0]=m_Data[4];
129 dst[1]=m_Data[3];
130 dst[2]=m_Data[2];
131 dst[3]=m_Data[1];
132 dst[4]=m_Data[0];
133 dst[5]=m_Data[7];
134 dst[6]=m_Data[6];
135 dst[7]=m_Data[5];
136 }
137
138 void FlipV(BlendShape8& dst) const {
139 dst[0]=m_Data[0];
140 dst[1]=m_Data[7];
141 dst[2]=m_Data[6];
142 dst[3]=m_Data[5];
143 dst[4]=m_Data[4];
144 dst[5]=m_Data[3];
145 dst[6]=m_Data[2];
146 dst[7]=m_Data[1];
147 }
148
149private:
150 int m_Data[8];
151};
152
153#endif
Definition: BlendShapes.h:24
void Rotate90(BlendShape4 &dst) const
Definition: BlendShapes.h:38
int m_Data[4]
Definition: BlendShapes.h:74
void FlipV(BlendShape4 &dst) const
Definition: BlendShapes.h:66
void Rotate270(BlendShape4 &dst) const
Definition: BlendShapes.h:52
void FlipU(BlendShape4 &dst) const
Definition: BlendShapes.h:59
BlendShape4()
Definition: BlendShapes.h:26
const int & operator[](int index) const
Definition: BlendShapes.h:32
BlendShape4(int a, int b, int c, int d)
Definition: BlendShapes.h:27
bool operator==(const BlendShape4 &lhs) const
Definition: BlendShapes.h:34
int & operator[](int index)
Definition: BlendShapes.h:31
void Rotate180(BlendShape4 &dst) const
Definition: BlendShapes.h:45
Definition: BlendShapes.h:79
int & operator[](size_t index)
Definition: BlendShapes.h:87
const int & operator[](size_t index) const
Definition: BlendShapes.h:88
void FlipU(BlendShape8 &dst) const
Definition: BlendShapes.h:127
BlendShape8()
Definition: BlendShapes.h:81
void Rotate270(BlendShape8 &dst) const
Definition: BlendShapes.h:116
BlendShape8(int a, int b, int c, int d, int e, int f, int g, int h)
Definition: BlendShapes.h:82
bool operator==(const BlendShape8 &lhs) const
Definition: BlendShapes.h:90
void FlipV(BlendShape8 &dst) const
Definition: BlendShapes.h:138
int m_Data[8]
Definition: BlendShapes.h:150
void Rotate90(BlendShape8 &dst) const
Definition: BlendShapes.h:94
void Rotate180(BlendShape8 &dst) const
Definition: BlendShapes.h:105