21 |
21 |
|
22 |
22 |
import android.opengl.GLSurfaceView;
|
23 |
23 |
|
24 |
|
import org.distorted.library.effect.FragmentEffectAlpha;
|
|
24 |
import org.distorted.library.effect.EffectType;
|
|
25 |
import org.distorted.library.effect.MatrixEffectMove;
|
25 |
26 |
import org.distorted.library.effect.MatrixEffectQuaternion;
|
26 |
27 |
import org.distorted.library.effect.MatrixEffectScale;
|
|
28 |
import org.distorted.library.effect.VertexEffect;
|
|
29 |
import org.distorted.library.effect.Effect;
|
27 |
30 |
import org.distorted.library.effect.VertexEffectScale;
|
28 |
31 |
import org.distorted.library.main.DistortedEffects;
|
29 |
32 |
import org.distorted.library.main.DistortedLibrary;
|
... | ... | |
34 |
37 |
import org.distorted.library.type.Static3D;
|
35 |
38 |
import org.distorted.library.type.Static4D;
|
36 |
39 |
|
|
40 |
import java.util.ArrayList;
|
|
41 |
|
37 |
42 |
import javax.microedition.khronos.egl.EGLConfig;
|
38 |
43 |
import javax.microedition.khronos.opengles.GL10;
|
39 |
44 |
|
... | ... | |
46 |
51 |
|
47 |
52 |
private GLSurfaceView mView;
|
48 |
53 |
private DistortedTexture mTexture;
|
49 |
|
private DistortedEffects mEffects;
|
50 |
|
private MeshBase mMesh;
|
|
54 |
private DistortedEffects mEffects1, mEffects2;
|
|
55 |
private MeshBase mMesh1, mMesh2;
|
51 |
56 |
private DistortedScreen mScreen;
|
52 |
57 |
private float mObjWidth, mObjHeight, mObjDepth;
|
53 |
|
private Static3D mScale;
|
|
58 |
private Static3D mScale, mMove1, mMove2;
|
54 |
59 |
|
55 |
60 |
Static4D mQuat1, mQuat2;
|
56 |
61 |
int mScreenMin;
|
... | ... | |
62 |
67 |
mView = v;
|
63 |
68 |
|
64 |
69 |
mScale= new Static3D(1,1,1);
|
|
70 |
mMove1= new Static3D(0,0,0);
|
|
71 |
mMove2= new Static3D(0,0,0);
|
65 |
72 |
|
66 |
73 |
Static3D center=new Static3D(0,0,0);
|
67 |
74 |
|
68 |
75 |
PredeformActivity2 act = (PredeformActivity2)v.getContext();
|
69 |
76 |
|
70 |
77 |
mTexture = act.getTexture();
|
71 |
|
mMesh = act.getMesh();
|
|
78 |
mMesh1 = act.getMesh();
|
|
79 |
mMesh2 = mMesh1.deepCopy();
|
72 |
80 |
|
73 |
81 |
mObjWidth = act.getCols();
|
74 |
82 |
mObjHeight= act.getRows();
|
... | ... | |
83 |
91 |
quatInt1.add(mQuat1);
|
84 |
92 |
quatInt2.add(mQuat2);
|
85 |
93 |
|
86 |
|
mEffects = new DistortedEffects();
|
87 |
|
mEffects.apply( new VertexEffectScale(new Static3D(mObjWidth,mObjHeight,mObjDepth) ) );
|
88 |
|
mEffects.apply( new MatrixEffectScale(mScale));
|
89 |
|
mEffects.apply( new MatrixEffectQuaternion(quatInt2, center) );
|
90 |
|
mEffects.apply( new MatrixEffectQuaternion(quatInt1, center) );
|
|
94 |
ArrayList<VertexEffect> effectList = PredeformEffectList.getEffectList();
|
|
95 |
int numEffects = effectList.size();
|
|
96 |
|
|
97 |
for(int i=0; i<numEffects; i++)
|
|
98 |
{
|
|
99 |
mMesh2.apply(effectList.get(i));
|
|
100 |
}
|
|
101 |
|
|
102 |
mEffects1 = new DistortedEffects();
|
|
103 |
mEffects1.apply( new VertexEffectScale(new Static3D(mObjWidth,mObjHeight,mObjDepth) ) );
|
|
104 |
|
|
105 |
for(int i=0; i<numEffects; i++)
|
|
106 |
{
|
|
107 |
mEffects1.apply(effectList.get(i));
|
|
108 |
}
|
|
109 |
|
|
110 |
mEffects1.apply( new MatrixEffectScale(mScale));
|
|
111 |
mEffects1.apply( new MatrixEffectQuaternion(quatInt2, center) );
|
|
112 |
mEffects1.apply( new MatrixEffectQuaternion(quatInt1, center) );
|
|
113 |
mEffects1.apply( new MatrixEffectMove(mMove1));
|
|
114 |
|
|
115 |
mEffects2 = new DistortedEffects();
|
|
116 |
mEffects2.apply( new VertexEffectScale(new Static3D(mObjWidth,mObjHeight,mObjDepth) ) );
|
|
117 |
mEffects2.apply( new MatrixEffectScale(mScale));
|
|
118 |
mEffects2.apply( new MatrixEffectQuaternion(quatInt2, center) );
|
|
119 |
mEffects2.apply( new MatrixEffectQuaternion(quatInt1, center) );
|
|
120 |
mEffects2.apply( new MatrixEffectMove(mMove2));
|
91 |
121 |
|
92 |
122 |
mScreen = new DistortedScreen();
|
93 |
123 |
mScreen.glClearColor(1.0f,1.0f,1.0f,0.0f);
|
... | ... | |
105 |
135 |
|
106 |
136 |
public void onSurfaceChanged(GL10 glUnused, int width, int height)
|
107 |
137 |
{
|
108 |
|
final float SCALE = 0.75f;
|
|
138 |
final float SCALE = 0.6f;
|
|
139 |
|
|
140 |
if( width<height )
|
|
141 |
{
|
|
142 |
float factor = SCALE*(Math.min(width/mObjWidth, 0.5f*height/mObjHeight));
|
|
143 |
mScale.set(factor,factor,factor);
|
|
144 |
mMove1.set(0,+height*0.25f,0);
|
|
145 |
mMove2.set(0,-height*0.25f,0);
|
|
146 |
}
|
|
147 |
else
|
|
148 |
{
|
|
149 |
float factor = SCALE*(Math.min( 0.5f*width/mObjWidth, height/mObjHeight));
|
|
150 |
mScale.set(factor,factor,factor);
|
|
151 |
mMove1.set(+width*0.25f,0,0);
|
|
152 |
mMove2.set(-width*0.25f,0,0);
|
|
153 |
}
|
109 |
154 |
|
110 |
155 |
mScreenMin = Math.min(width, height);
|
111 |
|
float factor = ( width*mObjHeight > height*mObjWidth ) ? (SCALE*height)/mObjHeight : (SCALE*width)/mObjWidth;
|
112 |
|
mScale.set(factor,factor,factor);
|
113 |
156 |
mScreen.resize(width, height);
|
114 |
157 |
}
|
115 |
158 |
|
|
159 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
160 |
|
|
161 |
void showNormal(boolean show)
|
|
162 |
{
|
|
163 |
mMesh1.setShowNormals(show);
|
|
164 |
mMesh2.setShowNormals(show);
|
|
165 |
}
|
|
166 |
|
116 |
167 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
117 |
168 |
|
118 |
169 |
float setLevel(int level)
|
119 |
170 |
{
|
120 |
171 |
float inflateLevel = (level-50)/50.0f;
|
121 |
|
mMesh.setInflate(inflateLevel);
|
|
172 |
mMesh1.setInflate(inflateLevel);
|
|
173 |
mMesh2.setInflate(inflateLevel);
|
122 |
174 |
|
123 |
175 |
return inflateLevel;
|
124 |
176 |
}
|
... | ... | |
131 |
183 |
|
132 |
184 |
mTexture.setTexture( act.getBitmap() );
|
133 |
185 |
mScreen.detachAll();
|
134 |
|
mScreen.attach(mTexture,mEffects,mMesh);
|
|
186 |
mScreen.attach(mTexture,mEffects1,mMesh1);
|
|
187 |
mScreen.attach(mTexture,mEffects2,mMesh2);
|
135 |
188 |
|
136 |
|
VertexEffectScale.enable();
|
137 |
|
FragmentEffectAlpha.enable();
|
|
189 |
Effect.enableEffects(EffectType.VERTEX);
|
138 |
190 |
|
139 |
191 |
try
|
140 |
192 |
{
|
Progress with the Predeform app; deepCopy for the Meshes; various fixes.