Revision 77efd5ad
Added by Leszek Koltunski over 2 years ago
src/main/java/org/distorted/bandaged/BandagedCreatorRenderer.java | ||
---|---|---|
19 | 19 |
|
20 | 20 |
package org.distorted.bandaged; |
21 | 21 |
|
22 |
import javax.microedition.khronos.egl.EGLConfig; |
|
23 |
import javax.microedition.khronos.opengles.GL10; |
|
24 |
|
|
22 | 25 |
import android.opengl.GLSurfaceView; |
23 | 26 |
|
24 | 27 |
import org.distorted.library.main.DistortedLibrary; |
25 | 28 |
import org.distorted.library.main.DistortedNode; |
26 | 29 |
import org.distorted.library.main.DistortedScreen; |
27 |
import org.distorted.library.type.Static4D; |
|
28 | 30 |
|
29 |
import javax.microedition.khronos.egl.EGLConfig;
|
|
30 |
import javax.microedition.khronos.opengles.GL10;
|
|
31 |
import org.distorted.library.type.Static3D;
|
|
32 |
import org.distorted.library.type.Static4D;
|
|
31 | 33 |
|
32 | 34 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
33 | 35 |
|
34 | 36 |
public class BandagedCreatorRenderer implements GLSurfaceView.Renderer, DistortedLibrary.ExceptionListener |
35 | 37 |
{ |
36 |
private final BandagedCreatorView mView;
|
|
38 |
private final GLSurfaceView mView;
|
|
37 | 39 |
private final DistortedScreen mScreen; |
40 |
private final Static3D mScale; |
|
38 | 41 |
|
39 |
private final BandagedCubit[] mCubits; |
|
40 |
|
|
41 |
private float[][] POSITIONS = new float[][] |
|
42 |
private final float[][] POSITIONS = new float[][] |
|
42 | 43 |
{ |
43 | 44 |
{-1.0f, +1.0f, +1.0f}, |
44 | 45 |
{-1.0f, +1.0f, +0.0f}, |
... | ... | |
81 | 82 |
mQuat2 = new Static4D(0,0,0,1); |
82 | 83 |
|
83 | 84 |
mView = v; |
85 |
|
|
84 | 86 |
mScreen = new DistortedScreen(); |
85 | 87 |
mScreen.glClearColor(BRIGHTNESS, BRIGHTNESS, BRIGHTNESS, 1.0f); |
88 |
mScale= new Static3D(1,1,1); |
|
86 | 89 |
|
87 |
mCubits = createCubits(); |
|
90 |
BandagedCubit cubit = new BandagedCubit(POSITIONS[0], mQuat1, mQuat2, mScale); |
|
91 |
DistortedNode node = cubit.getNode(); |
|
92 |
mScreen.attach(node); |
|
88 | 93 |
} |
89 | 94 |
|
90 | 95 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
91 |
|
|
96 |
/* |
|
92 | 97 |
private BandagedCubit[] createCubits() |
93 | 98 |
{ |
94 | 99 |
int len = POSITIONS.length; |
... | ... | |
96 | 101 |
|
97 | 102 |
for(int c=0; c<len; c++) |
98 | 103 |
{ |
99 |
cubits[c] = new BandagedCubit(POSITIONS[c],mQuat1,mQuat2,1.0f);
|
|
104 |
cubits[c] = new BandagedCubit(POSITIONS[c],mQuat1,mQuat2,mScale);
|
|
100 | 105 |
DistortedNode node = cubits[c].getNode(); |
101 | 106 |
mScreen.attach(node); |
102 | 107 |
} |
103 | 108 |
|
104 | 109 |
return cubits; |
105 | 110 |
} |
106 |
|
|
111 |
*/ |
|
107 | 112 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
108 | 113 |
|
109 | 114 |
@Override |
... | ... | |
118 | 123 |
@Override |
119 | 124 |
public void onSurfaceChanged(GL10 glUnused, int width, int height) |
120 | 125 |
{ |
126 |
final float Q = 0.3f; |
|
127 |
|
|
128 |
if( width<height ) mScale.set( Q*width, Q*width, 1 ); |
|
129 |
else mScale.set( Q*height, Q*height, 1 ); |
|
130 |
|
|
121 | 131 |
mScreenMin = Math.min(width, height); |
122 | 132 |
mScreen.resize(width,height); |
123 | 133 |
} |
src/main/java/org/distorted/bandaged/BandagedCubit.java | ||
---|---|---|
29 | 29 |
import org.distorted.library.type.Static3D; |
30 | 30 |
import org.distorted.library.type.Static4D; |
31 | 31 |
import org.distorted.objectlib.helpers.FactoryBandaged3x3Cubit; |
32 |
import org.distorted.objectlib.helpers.FactoryCubit; |
|
33 |
import org.distorted.objectlib.helpers.ObjectFaceShape; |
|
34 |
import org.distorted.objectlib.helpers.ObjectShape; |
|
35 |
|
|
36 |
import static org.distorted.objectlib.main.TwistyObject.MESH_NICE; |
|
37 | 32 |
|
38 | 33 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
39 | 34 |
|
... | ... | |
72 | 67 |
// PUBLIC API |
73 | 68 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
74 | 69 |
|
75 |
public BandagedCubit(float[] position, Static4D quat1, Static4D quat2, float scale)
|
|
70 |
public BandagedCubit(float[] position, Static4D quat1, Static4D quat2, Static3D scale)
|
|
76 | 71 |
{ |
77 | 72 |
mPosition = position; |
78 | 73 |
|
... | ... | |
80 | 75 |
mMesh = factory.createMesh(position); |
81 | 76 |
|
82 | 77 |
mTexture = new DistortedTexture(); |
83 |
mTexture.setColorARGB(0xffffffff);
|
|
78 |
mTexture.setColorARGB(0xffffff55);
|
|
84 | 79 |
|
85 | 80 |
Static3D move = computeMove(position); |
86 |
Static3D objectScale = new Static3D(scale,scale,scale); |
|
87 | 81 |
|
88 |
MatrixEffectScale scaleEffect = new MatrixEffectScale(objectScale);
|
|
89 |
MatrixEffectQuaternion quat1Effect = new MatrixEffectQuaternion(quat1, CENTER);
|
|
90 |
MatrixEffectQuaternion quat2Effect = new MatrixEffectQuaternion(quat2, CENTER);
|
|
82 |
MatrixEffectScale scaleEffect = new MatrixEffectScale(scale);
|
|
83 |
MatrixEffectQuaternion quat1Effect = new MatrixEffectQuaternion(quat2, CENTER);
|
|
84 |
MatrixEffectQuaternion quat2Effect = new MatrixEffectQuaternion(quat1, CENTER);
|
|
91 | 85 |
MatrixEffectMove moveEffect = new MatrixEffectMove(move); |
92 | 86 |
|
93 | 87 |
mEffects = new DistortedEffects(); |
Also available in: Unified diff
Progress with BandagedCreator.