1
|
package org.distorted.library;
|
2
|
|
3
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
4
|
|
5
|
enum EffectNames
|
6
|
{
|
7
|
// EFFECT NAME /////// EFFECT TYPE ////////////// UNITY /////////////////////////
|
8
|
|
9
|
ROTATE ( Distorted.TYPE_MATR, new float[] {0.0f} ),
|
10
|
QUATERNION ( Distorted.TYPE_MATR, new float[] {0.0f,0.0f,0.0f} ), // quaternion is a unity iff its axis (x,y,z) is (0,0,0)
|
11
|
MOVE ( Distorted.TYPE_MATR, new float[] {0.0f,0.0f,0.0f} ),
|
12
|
SCALE ( Distorted.TYPE_MATR, new float[] {1.0f,1.0f,1.0f} ),
|
13
|
SHEAR ( Distorted.TYPE_MATR, new float[] {0.0f,0.0f,0.0f} ),
|
14
|
// add new Matrix effects here...
|
15
|
|
16
|
DISTORT ( Distorted.TYPE_VERT, new float[] {0.0f,0.0f,0.0f} ), // keep this the first VERT effect (reason: getType)
|
17
|
DEFORM ( Distorted.TYPE_VERT, new float[] {0.0f,0.0f} ),
|
18
|
SINK ( Distorted.TYPE_VERT, new float[] {1.0f} ),
|
19
|
SWIRL ( Distorted.TYPE_VERT, new float[] {0.0f} ),
|
20
|
WAVE ( Distorted.TYPE_VERT, new float[] {0.0f} ),
|
21
|
// add new Vertex Effects here...
|
22
|
|
23
|
MACROBLOCK ( Distorted.TYPE_FRAG, new float[] {1.0f} ), // keep this the first FRAG effect (reason: getType)
|
24
|
ALPHA ( Distorted.TYPE_FRAG, new float[] {1.0f} ),
|
25
|
SMOOTH_ALPHA ( Distorted.TYPE_FRAG, new float[] {1.0f} ),
|
26
|
CHROMA ( Distorted.TYPE_FRAG, new float[] {0.0f} ),
|
27
|
SMOOTH_CHROMA ( Distorted.TYPE_FRAG, new float[] {0.0f} ),
|
28
|
BRIGHTNESS ( Distorted.TYPE_FRAG, new float[] {1.0f} ),
|
29
|
SMOOTH_BRIGHTNESS( Distorted.TYPE_FRAG, new float[] {1.0f} ),
|
30
|
SATURATION ( Distorted.TYPE_FRAG, new float[] {1.0f} ),
|
31
|
SMOOTH_SATURATION( Distorted.TYPE_FRAG, new float[] {1.0f} ),
|
32
|
CONTRAST ( Distorted.TYPE_FRAG, new float[] {1.0f} ),
|
33
|
SMOOTH_CONTRAST ( Distorted.TYPE_FRAG, new float[] {1.0f} ),
|
34
|
HUE ( Distorted.TYPE_FRAG, new float[] {0.0f} ),
|
35
|
SMOOTH_HUE ( Distorted.TYPE_FRAG, new float[] {0.0f} );
|
36
|
// add new Fragment effects here...
|
37
|
|
38
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
39
|
|
40
|
private static final int MAXDIM = 4; // maximum supported dimension of an effect
|
41
|
|
42
|
private int type;
|
43
|
private float[] unity;
|
44
|
|
45
|
static private float[] unities;
|
46
|
static private int[] dimensions;
|
47
|
|
48
|
static
|
49
|
{
|
50
|
int len = values().length;
|
51
|
int i=0;
|
52
|
|
53
|
dimensions = new int[len];
|
54
|
unities = new float[MAXDIM*len];
|
55
|
|
56
|
for(EffectNames name: EffectNames.values())
|
57
|
{
|
58
|
dimensions[i] = name.unity.length;
|
59
|
|
60
|
switch(dimensions[i])
|
61
|
{
|
62
|
case 4: unities[MAXDIM*i+3] = name.unity[3];
|
63
|
case 3: unities[MAXDIM*i+2] = name.unity[2];
|
64
|
case 2: unities[MAXDIM*i+1] = name.unity[1];
|
65
|
case 1: unities[MAXDIM*i+0] = name.unity[0];
|
66
|
case 0: break;
|
67
|
}
|
68
|
|
69
|
i++;
|
70
|
}
|
71
|
}
|
72
|
|
73
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
74
|
|
75
|
private EffectNames(int type, float[] unity)
|
76
|
{
|
77
|
this.type = type;
|
78
|
this.unity= unity;
|
79
|
}
|
80
|
|
81
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
82
|
|
83
|
public int getType()
|
84
|
{
|
85
|
return type;
|
86
|
}
|
87
|
|
88
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
89
|
|
90
|
static int getType(int ordinal)
|
91
|
{
|
92
|
if( ordinal<DISTORT.ordinal() ) return Distorted.TYPE_MATR;
|
93
|
if( ordinal<MACROBLOCK.ordinal() ) return Distorted.TYPE_VERT;
|
94
|
|
95
|
return Distorted.TYPE_FRAG;
|
96
|
}
|
97
|
|
98
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
99
|
|
100
|
static void fillWithUnities(int ordinal, float[] buffer, int index)
|
101
|
{
|
102
|
switch(dimensions[ordinal])
|
103
|
{
|
104
|
case 0: break;
|
105
|
case 1: buffer[index+0]=unities[MAXDIM*ordinal+0];
|
106
|
break;
|
107
|
case 2: buffer[index+0]=unities[MAXDIM*ordinal+0];
|
108
|
buffer[index+1]=unities[MAXDIM*ordinal+1];
|
109
|
break;
|
110
|
case 3: buffer[index+0]=unities[MAXDIM*ordinal+0];
|
111
|
buffer[index+1]=unities[MAXDIM*ordinal+1];
|
112
|
buffer[index+2]=unities[MAXDIM*ordinal+2];
|
113
|
break;
|
114
|
case 4: buffer[index+0]=unities[MAXDIM*ordinal+0];
|
115
|
buffer[index+1]=unities[MAXDIM*ordinal+1];
|
116
|
buffer[index+2]=unities[MAXDIM*ordinal+2];
|
117
|
buffer[index+3]=unities[MAXDIM*ordinal+3];
|
118
|
break;
|
119
|
}
|
120
|
}
|
121
|
|
122
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
123
|
|
124
|
static boolean isUnity(int ordinal, float[] buffer, int index)
|
125
|
{
|
126
|
switch(dimensions[ordinal])
|
127
|
{
|
128
|
case 0: return true;
|
129
|
case 1: return buffer[index+0]==unities[MAXDIM*ordinal+0];
|
130
|
case 2: return buffer[index+0]==unities[MAXDIM*ordinal+0] &&
|
131
|
buffer[index+1]==unities[MAXDIM*ordinal+1];
|
132
|
case 3: return buffer[index+0]==unities[MAXDIM*ordinal+0] &&
|
133
|
buffer[index+1]==unities[MAXDIM*ordinal+1] &&
|
134
|
buffer[index+2]==unities[MAXDIM*ordinal+2];
|
135
|
case 4: return buffer[index+0]==unities[MAXDIM*ordinal+0] &&
|
136
|
buffer[index+1]==unities[MAXDIM*ordinal+1] &&
|
137
|
buffer[index+2]==unities[MAXDIM*ordinal+2] &&
|
138
|
buffer[index+3]==unities[MAXDIM*ordinal+3];
|
139
|
}
|
140
|
|
141
|
return false;
|
142
|
}
|
143
|
}
|
144
|
|
145
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
146
|
|