Revision 50ec342b
Added by Leszek Koltunski over 2 years ago
src/main/java/org/distorted/bandaged/BandagedCreatorActivity.java | ||
---|---|---|
213 | 213 |
return mFirebaseAnalytics; |
214 | 214 |
} |
215 | 215 |
|
216 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
217 |
|
|
218 |
public BandagedCreatorRenderer getRenderer() |
|
219 |
{ |
|
220 |
BandagedCreatorView view = findViewById(R.id.bandagedCreatorObjectView); |
|
221 |
return view.getRenderer(); |
|
222 |
} |
|
223 |
|
|
216 | 224 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
217 | 225 |
|
218 | 226 |
public int getHeightBar() |
src/main/java/org/distorted/bandaged/BandagedCreatorRenderer.java | ||
---|---|---|
43 | 43 |
|
44 | 44 |
private final float[][] POSITIONS = new float[][] |
45 | 45 |
{ |
46 |
{-1.0f, +1.0f, +1.0f},
|
|
47 |
{-1.0f, +1.0f, +0.0f},
|
|
48 |
{-1.0f, +1.0f, -1.0f},
|
|
49 |
{-1.0f, 0.0f, +1.0f},
|
|
50 |
{-1.0f, 0.0f, +0.0f},
|
|
51 |
{-1.0f, 0.0f, -1.0f},
|
|
52 |
{-1.0f, -1.0f, +1.0f},
|
|
53 |
{-1.0f, -1.0f, +0.0f},
|
|
54 |
{-1.0f, -1.0f, -1.0f},
|
|
55 |
{ 0.0f, -1.0f, +1.0f},
|
|
56 |
{ 0.0f, -1.0f, +0.0f},
|
|
57 |
{ 0.0f, +1.0f, +1.0f},
|
|
58 |
{ 0.0f, +1.0f, +0.0f},
|
|
59 |
{ 0.0f, +1.0f, -1.0f},
|
|
60 |
{ 0.0f, 0.0f, +1.0f},
|
|
61 |
{ 0.0f, 0.0f, -1.0f},
|
|
62 |
{ 1.0f, +1.0f, +1.0f},
|
|
63 |
{ 1.0f, +1.0f, +0.0f},
|
|
64 |
{ 1.0f, +1.0f, -1.0f},
|
|
65 |
{ 1.0f, 0.0f, +1.0f},
|
|
66 |
{ 1.0f, 0.0f, +0.0f},
|
|
67 |
{ 1.0f, -1.0f, +1.0f},
|
|
68 |
{ 1.0f, 0.0f, -1.0f },
|
|
69 |
{ 1.0f, -1.0f, -1.0f },
|
|
70 |
{ 1.0f, -1.0f, +0.0f },
|
|
71 |
{ 0.0f, -1.0f, -1.0f },
|
|
46 |
{-1, 1, 1},
|
|
47 |
{-1, 1, 0},
|
|
48 |
{-1, 1, -1},
|
|
49 |
{-1, 0, 1},
|
|
50 |
{-1, 0, 0},
|
|
51 |
{-1, 0, -1},
|
|
52 |
{-1, -1, 1},
|
|
53 |
{-1, -1, 0},
|
|
54 |
{-1, -1, -1},
|
|
55 |
{ 0, -1, 1},
|
|
56 |
{ 0, -1, 0},
|
|
57 |
{ 0, 1, 1},
|
|
58 |
{ 0, 1, 0},
|
|
59 |
{ 0, 1, -1},
|
|
60 |
{ 0, 0, 1},
|
|
61 |
{ 0, 0, -1},
|
|
62 |
{ 1, 1, 1},
|
|
63 |
{ 1, 1, 0},
|
|
64 |
{ 1, 1, -1},
|
|
65 |
{ 1, 0, 1},
|
|
66 |
{ 1, 0, 0},
|
|
67 |
{ 1, -1, 1},
|
|
68 |
{ 1, 0, -1},
|
|
69 |
{ 1, -1, -1},
|
|
70 |
{ 1, -1, 0},
|
|
71 |
{ 0, -1, -1},
|
|
72 | 72 |
}; |
73 | 73 |
|
74 | 74 |
private final BandagedCreatorView mView; |
75 | 75 |
private final DistortedScreen mScreen; |
76 | 76 |
private final Static3D mScale; |
77 | 77 |
private final BandagedCubit[] mCubits; |
78 |
private final Static4D mQuat1, mQuat2;
|
|
78 |
private final Static4D mQuatT, mQuatA;
|
|
79 | 79 |
private float mScaleValue; |
80 | 80 |
|
81 | 81 |
private float mX, mY, mZ, mW; |
82 |
private boolean mResetQuats, mSetQuat1;
|
|
82 |
private boolean mResetQuats, mSetQuatT;
|
|
83 | 83 |
|
84 | 84 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
85 | 85 |
|
... | ... | |
87 | 87 |
{ |
88 | 88 |
final float BRIGHTNESS = 0.333f; |
89 | 89 |
|
90 |
mQuat1 = new Static4D(0,0,0,1);
|
|
91 |
mQuat2 = new Static4D(-0.25189602f,0.3546389f,0.009657208f,0.90038127f);
|
|
90 |
mQuatT = new Static4D(0,0,0,1);
|
|
91 |
mQuatA = new Static4D(-0.25189602f,0.3546389f,0.009657208f,0.90038127f);
|
|
92 | 92 |
|
93 | 93 |
mView = v; |
94 | 94 |
|
95 | 95 |
mResetQuats = false; |
96 |
mSetQuat1 = false;
|
|
96 |
mSetQuatT = false;
|
|
97 | 97 |
|
98 | 98 |
mScreen = new DistortedScreen(); |
99 | 99 |
mScreen.glClearColor(BRIGHTNESS, BRIGHTNESS, BRIGHTNESS, 1.0f); |
... | ... | |
110 | 110 |
|
111 | 111 |
for(int c=0; c<len; c++) |
112 | 112 |
{ |
113 |
cubits[c] = new BandagedCubit(POSITIONS[c],mQuat1,mQuat2,mScale,COLOR_DEFAULT);
|
|
113 |
cubits[c] = new BandagedCubit(POSITIONS[c],mQuatT,mQuatA,mScale,COLOR_DEFAULT);
|
|
114 | 114 |
} |
115 | 115 |
|
116 | 116 |
return cubits; |
... | ... | |
124 | 124 |
long time = System.currentTimeMillis(); |
125 | 125 |
mScreen.render(time); |
126 | 126 |
|
127 |
if( mSetQuat1 )
|
|
127 |
if( mSetQuatT )
|
|
128 | 128 |
{ |
129 |
mSetQuat1 = false;
|
|
130 |
mQuat1.set(mX,mY,mZ,mW);
|
|
129 |
mSetQuatT = false;
|
|
130 |
mQuatT.set(mX,mY,mZ,mW);
|
|
131 | 131 |
} |
132 | 132 |
|
133 | 133 |
if( mResetQuats ) |
134 | 134 |
{ |
135 | 135 |
mResetQuats = false; |
136 | 136 |
|
137 |
float qx = mQuat1.get0();
|
|
138 |
float qy = mQuat1.get1();
|
|
139 |
float qz = mQuat1.get2();
|
|
140 |
float qw = mQuat1.get3();
|
|
137 |
float qx = mQuatT.get0();
|
|
138 |
float qy = mQuatT.get1();
|
|
139 |
float qz = mQuatT.get2();
|
|
140 |
float qw = mQuatT.get3();
|
|
141 | 141 |
|
142 |
float rx = mQuat2.get0();
|
|
143 |
float ry = mQuat2.get1();
|
|
144 |
float rz = mQuat2.get2();
|
|
145 |
float rw = mQuat2.get3();
|
|
142 |
float rx = mQuatA.get0();
|
|
143 |
float ry = mQuatA.get1();
|
|
144 |
float rz = mQuatA.get2();
|
|
145 |
float rw = mQuatA.get3();
|
|
146 | 146 |
|
147 | 147 |
float tx = rw*qx - rz*qy + ry*qz + rx*qw; |
148 | 148 |
float ty = rw*qy + rz*qx + ry*qw - rx*qz; |
149 | 149 |
float tz = rw*qz + rz*qw - ry*qx + rx*qy; |
150 | 150 |
float tw = rw*qw - rz*qz - ry*qy - rx*qx; |
151 | 151 |
|
152 |
mQuat1.set(0f, 0f, 0f, 1f);
|
|
153 |
mQuat2.set(tx, ty, tz, tw);
|
|
152 |
mQuatT.set(0f, 0f, 0f, 1f);
|
|
153 |
mQuatA.set(tx, ty, tz, tw);
|
|
154 | 154 |
} |
155 | 155 |
} |
156 | 156 |
|
... | ... | |
248 | 248 |
|
249 | 249 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
250 | 250 |
|
251 |
public Static4D getQuat2()
|
|
252 |
{
|
|
253 |
return mQuat2;
|
|
254 |
}
|
|
251 |
public Static4D getQuatAccu()
|
|
252 |
{ |
|
253 |
return mQuatA;
|
|
254 |
} |
|
255 | 255 |
|
256 | 256 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
257 | 257 |
|
258 |
public void setQuat1(float x, float y, float z, float w)
|
|
259 |
{
|
|
260 |
mX = x;
|
|
261 |
mY = y;
|
|
262 |
mZ = z;
|
|
263 |
mW = w;
|
|
258 |
public void setQuatTemp(float x, float y, float z, float w)
|
|
259 |
{ |
|
260 |
mX = x; |
|
261 |
mY = y; |
|
262 |
mZ = z; |
|
263 |
mW = w; |
|
264 | 264 |
|
265 |
mSetQuat1 = true;
|
|
266 |
}
|
|
265 |
mSetQuatT = true;
|
|
266 |
} |
|
267 | 267 |
|
268 | 268 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
269 | 269 |
|
270 |
public void resetQuats() |
|
271 |
{ |
|
272 |
mResetQuats = true; |
|
273 |
} |
|
270 |
public void resetQuats() |
|
271 |
{ |
|
272 |
mResetQuats = true; |
|
273 |
} |
|
274 |
|
|
275 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
276 |
|
|
277 |
public void reset() |
|
278 |
{ |
|
279 |
|
|
280 |
} |
|
274 | 281 |
} |
src/main/java/org/distorted/bandaged/BandagedCreatorScreen.java | ||
---|---|---|
90 | 90 |
@Override |
91 | 91 |
public void onClick(View v) |
92 | 92 |
{ |
93 |
|
|
93 |
BandagedCreatorRenderer renderer = act.getRenderer(); |
|
94 |
renderer.reset(); |
|
94 | 95 |
} |
95 | 96 |
}); |
96 | 97 |
} |
src/main/java/org/distorted/bandaged/BandagedCreatorView.java | ||
---|---|---|
93 | 93 |
} |
94 | 94 |
} |
95 | 95 |
|
96 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
97 |
|
|
98 |
public BandagedCreatorRenderer getRenderer() |
|
99 |
{ |
|
100 |
return mRenderer; |
|
101 |
} |
|
102 |
|
|
96 | 103 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
97 | 104 |
|
98 | 105 |
public void setScreenSize(int width, int height) |
... | ... | |
116 | 123 |
case MotionEvent.ACTION_DOWN: float x1 = (x - mScreenWidth*0.5f)/mScreenMin; |
117 | 124 |
float y1 = (mScreenHeight*0.5f - y)/mScreenMin; |
118 | 125 |
|
119 |
int index = mTouchControl.cubitTouched(x1,y1,mRenderer.getQuat2() );
|
|
126 |
int index = mTouchControl.cubitTouched(x1,y1,mRenderer.getQuatAccu() );
|
|
120 | 127 |
|
121 | 128 |
if( index<0 ) |
122 | 129 |
{ |
... | ... | |
162 | 169 |
float cosA = (float)Math.cos(plen*3.14f/mScreenMin); |
163 | 170 |
float sinA = (float)Math.sqrt(1-cosA*cosA); |
164 | 171 |
|
165 |
mRenderer.setQuat1(px*sinA, py*sinA, pz*sinA, cosA);
|
|
172 |
mRenderer.setQuatTemp(px*sinA, py*sinA, pz*sinA, cosA);
|
|
166 | 173 |
} |
167 | 174 |
} |
168 | 175 |
if( (mX-x)*(mX-x) + (mY-y)*(mY-y) > mScreenMin*mScreenMin/(DIRECTION_SENSITIVITY*DIRECTION_SENSITIVITY) ) |
Also available in: Unified diff
Cleanups.