Revision 7c8012ee
Added by Leszek Koltunski about 8 years ago
src/main/java/org/distorted/examples/effects3d/Effects3DEffect.java | ||
---|---|---|
83 | 83 |
{ |
84 | 84 |
case ROTATE : mId = object.rotate (mDyn4, mCenterDyn); break; |
85 | 85 |
case QUATERNION : mId = object.quaternion(mDyn4, mCenterDyn); break; |
86 |
case MOVE : mId = object.move (mDyn3) ; break;
|
|
87 |
case SCALE : mId = object.scale (mDyn3) ; break;
|
|
86 |
case MOVE : mId = object.move (mDyn3) ; break; |
|
87 |
case SCALE : mId = object.scale (mDyn3) ; break; |
|
88 | 88 |
case SHEAR : mId = object.shear (mDyn3, mCenterDyn); break; |
89 | 89 |
|
90 |
case DISTORT: mId = object.distort(mDyn3, mCenterDyn, mRegionDyn); break;
|
|
91 |
case DEFORM : mId = object.deform (mDyn3, mCenterDyn ); break;
|
|
92 |
case SINK : mId = object.sink (mDyn1, mCenterDyn, mRegionDyn); break;
|
|
93 |
case PINCH : mId = object.pinch (mDyn2, mCenterDyn, mRegionDyn); break;
|
|
94 |
case SWIRL : mId = object.swirl (mDyn1, mCenterDyn, mRegionDyn); break;
|
|
95 |
case WAVE : mId = object.wave (mDyn5, mCenterDyn, mRegionDyn); break;
|
|
90 |
case DISTORT : mId = object.distort (mDyn3, mCenterDyn, mRegionDyn); break;
|
|
91 |
case DEFORM : mId = object.deform (mDyn3, mCenterDyn ); break;
|
|
92 |
case SINK : mId = object.sink (mDyn1, mCenterDyn, mRegionDyn); break;
|
|
93 |
case PINCH : mId = object.pinch (mDyn2, mCenterDyn, mRegionDyn); break;
|
|
94 |
case SWIRL : mId = object.swirl (mDyn1, mCenterDyn, mRegionDyn); break;
|
|
95 |
case WAVE : mId = object.wave (mDyn5, mCenterDyn, mRegionDyn); break;
|
|
96 | 96 |
|
97 | 97 |
case ALPHA : mId = object.alpha (mDyn1, mRegionDyn, false); break; |
98 | 98 |
case SMOOTH_ALPHA : mId = object.alpha (mDyn1, mRegionDyn, true ); break; |
... | ... | |
122 | 122 |
float rz = (mInter[3]-50)/ 50.0f; |
123 | 123 |
mSta4.set(an,rx,ry,rz); |
124 | 124 |
break; |
125 |
case QUATERNION : |
|
125 |
case QUATERNION : float qx = (mInter[0]-50)/ 50.0f; |
|
126 |
float qy = (mInter[1]-50)/ 50.0f; |
|
127 |
float qz = (mInter[2]-50)/ 50.0f; |
|
128 |
float qa = (mInter[3]-50)*3.1415f/50; |
|
129 |
float cosA = (float)Math.cos(qa/2); |
|
130 |
float len = (float)Math.sqrt(qx*qx+qy*qy+qz*qz); |
|
131 |
float sinAnorm = (float)Math.sin(qa/2)/len; |
|
132 |
mSta4.set(sinAnorm*qx,sinAnorm*qy,sinAnorm*qz, cosA); |
|
126 | 133 |
break; |
127 | 134 |
case MOVE : float sw = mAct.get().getScreenWidth()/50.0f; |
128 | 135 |
float sh = mAct.get().getScreenWidth()/50.0f; |
... | ... | |
141 | 148 |
float zsh = (mInter[2]-50)/25.0f; |
142 | 149 |
mSta3.set(xsh,ysh,zsh); |
143 | 150 |
break; |
151 |
|
|
144 | 152 |
case DISTORT : |
145 | 153 |
case DEFORM : float ld = mAct.get().getWidth()/50.0f; |
146 | 154 |
float xd = (mInter[0]-50)*ld; |
... | ... | |
197 | 205 |
case 1: mInter[0] = 50; |
198 | 206 |
} |
199 | 207 |
|
200 |
if( mName==EffectNames.ROTATE ) mInter[1]= 100; |
|
208 |
if( mName==EffectNames.ROTATE || mName==EffectNames.QUATERNION ) mInter[1]= 100;
|
|
201 | 209 |
} |
202 | 210 |
|
203 | 211 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
357 | 365 |
mSta3 = new Static3D(0,0,0); |
358 | 366 |
mDyn3.add(mSta3); |
359 | 367 |
break; |
360 |
case 4 : if( mName == EffectNames.QUATERNION || mName == EffectNames.ROTATE )
|
|
368 |
case 4 : if( mName == EffectNames.ROTATE || mName == EffectNames.QUATERNION )
|
|
361 | 369 |
{ |
362 | 370 |
mDyn4 = new Dynamic4D(); |
363 | 371 |
mSta4 = new Static4D(0,0,0,0); |
src/main/java/org/distorted/examples/matrix3d/Matrix3DEffect.java | ||
---|---|---|
83 | 83 |
{ |
84 | 84 |
case ROTATE : mId = object.rotate (mDyn4, mCenterDyn); break; |
85 | 85 |
case QUATERNION : mId = object.quaternion(mDyn4, mCenterDyn); break; |
86 |
case MOVE : mId = object.move (mDyn3) ; break;
|
|
87 |
case SCALE : mId = object.scale (mDyn3) ; break;
|
|
86 |
case MOVE : mId = object.move (mDyn3) ; break; |
|
87 |
case SCALE : mId = object.scale (mDyn3) ; break; |
|
88 | 88 |
case SHEAR : mId = object.shear (mDyn3, mCenterDyn); break; |
89 | 89 |
|
90 |
case DISTORT: mId = object.distort(mDyn3, mCenterDyn, mRegionDyn); break; |
|
91 |
case DEFORM : mId = object.deform (mDyn3, mCenterDyn ); break; |
|
92 |
case SINK : mId = object.sink (mDyn1, mCenterDyn, mRegionDyn); break; |
|
93 |
case SWIRL : mId = object.swirl (mDyn1, mCenterDyn, mRegionDyn); break; |
|
94 |
case WAVE : mId = object.wave (mDyn5, mCenterDyn, mRegionDyn); break; |
|
90 |
case DISTORT : mId = object.distort (mDyn3, mCenterDyn, mRegionDyn); break; |
|
91 |
case DEFORM : mId = object.deform (mDyn3, mCenterDyn ); break; |
|
92 |
case SINK : mId = object.sink (mDyn1, mCenterDyn, mRegionDyn); break; |
|
93 |
case PINCH : mId = object.pinch (mDyn2, mCenterDyn, mRegionDyn); break; |
|
94 |
case SWIRL : mId = object.swirl (mDyn1, mCenterDyn, mRegionDyn); break; |
|
95 |
case WAVE : mId = object.wave (mDyn5, mCenterDyn, mRegionDyn); break; |
|
95 | 96 |
|
96 | 97 |
case ALPHA : mId = object.alpha (mDyn1, mRegionDyn, false); break; |
97 | 98 |
case SMOOTH_ALPHA : mId = object.alpha (mDyn1, mRegionDyn, true ); break; |
... | ... | |
121 | 122 |
float rz = (mInter[3]-50)/ 50.0f; |
122 | 123 |
mSta4.set(an,rx,ry,rz); |
123 | 124 |
break; |
124 |
case QUATERNION : |
|
125 |
case QUATERNION : float qx = (mInter[0]-50)/ 50.0f; |
|
126 |
float qy = (mInter[1]-50)/ 50.0f; |
|
127 |
float qz = (mInter[2]-50)/ 50.0f; |
|
128 |
float qa = (mInter[3]-50)*3.1415f/50; |
|
129 |
float cosA = (float)Math.cos(qa/2); |
|
130 |
float len = (float)Math.sqrt(qx*qx+qy*qy+qz*qz); |
|
131 |
float sinAnorm = (float)Math.sin(qa/2)/len; |
|
132 |
mSta4.set(sinAnorm*qx,sinAnorm*qy,sinAnorm*qz, cosA); |
|
125 | 133 |
break; |
126 | 134 |
case MOVE : float sw = mAct.get().getScreenWidth()/50.0f; |
127 | 135 |
float sh = mAct.get().getScreenWidth()/50.0f; |
... | ... | |
140 | 148 |
float zsh = (mInter[2]-50)/25.0f; |
141 | 149 |
mSta3.set(xsh,ysh,zsh); |
142 | 150 |
break; |
151 |
|
|
143 | 152 |
case DISTORT : |
144 | 153 |
case DEFORM : float ld = mAct.get().getWidth()/50.0f; |
145 | 154 |
float xd = (mInter[0]-50)*ld; |
... | ... | |
157 | 166 |
break; |
158 | 167 |
case SWIRL : mSta1.set( 3.6f*(mInter[0]-50) ); |
159 | 168 |
break; |
169 |
case SINK : mSta1.set(mInter[0] > 50 ? 50.0f/(100.01f-mInter[0]) : mInter[0] / 50.0f); |
|
170 |
break; |
|
171 |
case PINCH : float dp = mInter[0] > 50 ? 50.0f/(100.01f-mInter[0]) : mInter[0] / 50.0f; |
|
172 |
float ap = (mInter[1]-50)*180 / 50; |
|
173 |
mSta2.set(dp,ap); |
|
174 |
break; |
|
175 |
|
|
160 | 176 |
case ALPHA : |
161 | 177 |
case SMOOTH_ALPHA : mSta1.set(mInter[0]/100.0f); |
162 | 178 |
break; |
163 |
case SINK : |
|
164 | 179 |
case SATURATION : |
165 | 180 |
case SMOOTH_SATURATION: |
166 | 181 |
case CONTRAST : |
... | ... | |
190 | 205 |
case 1: mInter[0] = 50; |
191 | 206 |
} |
192 | 207 |
|
193 |
if( mName==EffectNames.ROTATE ) mInter[1]= 100; |
|
208 |
if( mName==EffectNames.ROTATE || mName==EffectNames.QUATERNION ) mInter[1]= 100;
|
|
194 | 209 |
} |
195 | 210 |
|
196 | 211 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
350 | 365 |
mSta3 = new Static3D(0,0,0); |
351 | 366 |
mDyn3.add(mSta3); |
352 | 367 |
break; |
353 |
case 4 : if( mName == EffectNames.QUATERNION || mName == EffectNames.ROTATE )
|
|
368 |
case 4 : if( mName == EffectNames.ROTATE || mName == EffectNames.QUATERNION )
|
|
354 | 369 |
{ |
355 | 370 |
mDyn4 = new Dynamic4D(); |
356 | 371 |
mSta4 = new Static4D(0,0,0,0); |
Also available in: Unified diff
Matrix3D: implement quaternion effect