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