Revision 8eed34d3
Added by Leszek Koltunski over 5 years ago
| src/main/java/org/distorted/examples/check/CheckRenderer.java | ||
|---|---|---|
| 65 | 65 |
private MeshRectangles mMesh; |
| 66 | 66 |
private DistortedScreen mScreen; |
| 67 | 67 |
private int mObjHeight, mObjWidth; |
| 68 |
private Static3D mScale, mCenter; |
|
| 69 |
private Static3D mSwirl1, mSwirl2, mDeform1, mDeform2; |
|
| 68 |
private Static3D mScale, mSwirl1, mSwirl2, mDeform1, mDeform2; |
|
| 70 | 69 |
|
| 71 | 70 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 72 | 71 |
|
| ... | ... | |
| 88 | 87 |
mDeform1= new Static3D(0,0,0); |
| 89 | 88 |
mDeform2= new Static3D(0,0,0); |
| 90 | 89 |
mScale = new Static3D(1,1,1); |
| 91 |
mCenter = new Static3D(0,0,0); |
|
| 92 | 90 |
|
| 93 | 91 |
mEffects = new DistortedEffects(); |
| 94 | 92 |
mEffects.apply(new MatrixEffectScale(mScale)); |
| ... | ... | |
| 112 | 110 |
dDeform.add(mDeform1); |
| 113 | 111 |
dDeform.add(mDeform2); |
| 114 | 112 |
|
| 115 |
if( !mEffects.apply( new VertexEffectDeform(dDeform,mCenter) ) )
|
|
| 113 |
if( !mEffects.apply( new VertexEffectDeform(dDeform,new Static3D(0,0,0)) ) )
|
|
| 116 | 114 |
{
|
| 117 | 115 |
Log.e("Check", "Failed to add Deform effect!");
|
| 118 | 116 |
} |
| ... | ... | |
| 189 | 187 |
mScreen.detachAll(); |
| 190 | 188 |
mScreen.attach(mTexture,mEffects,mMesh); |
| 191 | 189 |
|
| 192 |
mSwirl1.set ( 0, mObjHeight/2, 0); |
|
| 193 |
mSwirl2.set (mObjWidth , mObjHeight/2, 0); |
|
| 194 |
mDeform1.set( 0, 0 , 0); |
|
| 195 |
mDeform2.set( 0, mObjHeight , 0); |
|
| 196 |
mCenter.set (mObjWidth/2, 0 , 0); |
|
| 190 |
mSwirl1.set (-mObjWidth/2, 0, 0); |
|
| 191 |
mSwirl2.set ( mObjWidth/2, 0, 0); |
|
| 192 |
mDeform1.set( 0, 0, 0); |
|
| 193 |
mDeform2.set( 0, mObjHeight, 0); |
|
| 197 | 194 |
|
| 198 | 195 |
try |
| 199 | 196 |
{
|
| src/main/java/org/distorted/examples/differentbitmaps/DifferentBitmapsRenderer.java | ||
|---|---|---|
| 69 | 69 |
Dynamic3D dDistort = new Dynamic3D(3000,0.0f); |
| 70 | 70 |
dDistort.add(new Static3D( 25,0,0)); |
| 71 | 71 |
dDistort.add(new Static3D(-25,0,0)); |
| 72 |
Static3D mPoint = new Static3D(305, 220, 0);
|
|
| 72 |
Static3D mPoint = new Static3D(0,-60,0);
|
|
| 73 | 73 |
|
| 74 | 74 |
mEffects = new DistortedEffects[NUM]; |
| 75 | 75 |
mEffects[0] = new DistortedEffects(); |
| src/main/java/org/distorted/examples/differenteffects/DifferentEffectsRenderer.java | ||
|---|---|---|
| 68 | 68 |
mView = v; |
| 69 | 69 |
|
| 70 | 70 |
// mEffects[0] effects |
| 71 |
Static3D pLeft = new Static3D(214, 394, 0);
|
|
| 72 |
Static3D pRight= new Static3D(390, 388, 0);
|
|
| 71 |
Static3D pLeft = new Static3D(214 - 594/2, 394 - 600/2, 0);
|
|
| 72 |
Static3D pRight= new Static3D(390 - 594/2, 388 - 600/2, 0);
|
|
| 73 | 73 |
Static4D RegionEye = new Static4D(0,0,0,60); |
| 74 | 74 |
|
| 75 | 75 |
// mEffects[1] effects |
| 76 | 76 |
Dynamic3D dyn = new Dynamic3D(1000,0.0f); |
| 77 | 77 |
dyn.add(new Static3D( 50,0,0)); |
| 78 | 78 |
dyn.add(new Static3D(-50,0,0)); |
| 79 |
Static3D pNose1 = new Static3D(305, 260, 0);
|
|
| 79 |
Static3D pNose1 = new Static3D(305 - 594/2, 260 - 600/2, 0);
|
|
| 80 | 80 |
|
| 81 | 81 |
// we don't need to prepare anything for mEffects[2] effects |
| 82 | 82 |
|
| src/main/java/org/distorted/examples/effectqueue/EffectQueueSurfaceView.java | ||
|---|---|---|
| 38 | 38 |
import org.distorted.library.type.Static4D; |
| 39 | 39 |
import org.distorted.library.type.Dynamic3D; |
| 40 | 40 |
|
| 41 |
import static org.distorted.examples.effectqueue.EffectQueueRenderer.*; |
|
| 42 |
|
|
| 41 | 43 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 42 | 44 |
|
| 43 | 45 |
public class EffectQueueSurfaceView extends GLSurfaceView |
| ... | ... | |
| 135 | 137 |
|
| 136 | 138 |
switch(action) |
| 137 | 139 |
{
|
| 138 |
case MotionEvent.ACTION_DOWN: x = (int)event.getX()* EffectQueueRenderer.BWID/mScrW;
|
|
| 139 |
y = EffectQueueRenderer.BHEI-(int)event.getY()* EffectQueueRenderer.BHEI/mScrH;
|
|
| 140 |
case MotionEvent.ACTION_DOWN: x = (int)event.getX()*BWID/mScrW - BWID/2;
|
|
| 141 |
y = BHEI/2 - (int)event.getY()*BHEI/mScrH;
|
|
| 140 | 142 |
EffectQueueActivity act = (EffectQueueActivity)getContext(); |
| 141 | 143 |
Static3D center = new Static3D(x,y,0); |
| 142 | 144 |
|
| src/main/java/org/distorted/examples/movingeffects/MovingEffectsSurfaceView.java | ||
|---|---|---|
| 63 | 63 |
|
| 64 | 64 |
private Paint mPaint; |
| 65 | 65 |
private int moving; |
| 66 |
private int mScrHeight; |
|
| 66 |
private int mScrWidth, mScrHeight;
|
|
| 67 | 67 |
private long mTime = 0; |
| 68 | 68 |
|
| 69 | 69 |
private int mCurrEffect; |
| ... | ... | |
| 119 | 119 |
{
|
| 120 | 120 |
int max = width>height ? width:height; |
| 121 | 121 |
|
| 122 |
mScrWidth = width; |
|
| 122 | 123 |
mScrHeight = height; |
| 123 | 124 |
|
| 124 | 125 |
mSize1 = max/200; |
| ... | ... | |
| 251 | 252 |
{
|
| 252 | 253 |
mPaint.setColor( 0xffffffff ); |
| 253 | 254 |
mCenter.get( drawCoord, 0, (long)(i*step) ); |
| 254 |
c.drawCircle(drawCoord[0], mScrHeight-drawCoord[1], mSize1, mPaint );
|
|
| 255 |
c.drawCircle(drawCoord[0] + mScrWidth*0.5f, mScrHeight*0.5f - drawCoord[1], mSize1, mPaint );
|
|
| 255 | 256 |
} |
| 256 | 257 |
} |
| 257 | 258 |
|
| ... | ... | |
| 260 | 261 |
for(int curr=0; curr<len; curr++) |
| 261 | 262 |
{
|
| 262 | 263 |
cu = mCenter.getPoint(curr); |
| 263 |
c.drawCircle(cu.get0(), mScrHeight-cu.get1(), mSize2, mPaint);
|
|
| 264 |
c.drawCircle(cu.get0() + mScrWidth*0.5f, mScrHeight*0.5f - cu.get1(), mSize2, mPaint);
|
|
| 264 | 265 |
} |
| 265 | 266 |
|
| 266 | 267 |
if( time-mTime > LOOP_TIME ) mTime = time; |
| ... | ... | |
| 274 | 275 |
{
|
| 275 | 276 |
if( mCurrEffect!=EFFECT_POINTS ) return true; |
| 276 | 277 |
|
| 277 |
int xDown, yDown; |
|
| 278 |
int xDown = (int)event.getX() - mScrWidth/2; |
|
| 279 |
int yDown = mScrHeight/2 - (int)event.getY(); |
|
| 278 | 280 |
|
| 279 | 281 |
switch(event.getAction()) |
| 280 | 282 |
{
|
| 281 |
case MotionEvent.ACTION_DOWN: xDown = (int)event.getX(); |
|
| 282 |
yDown = mScrHeight - (int)event.getY(); |
|
| 283 |
|
|
| 284 |
float gx, gy; |
|
| 283 |
case MotionEvent.ACTION_DOWN: float gx, gy; |
|
| 285 | 284 |
Static3D dv; |
| 286 | 285 |
int len = mCenter.getNumPoints(); |
| 287 | 286 |
|
| ... | ... | |
| 310 | 309 |
break; |
| 311 | 310 |
case MotionEvent.ACTION_MOVE: if( moving>=0 ) |
| 312 | 311 |
{
|
| 313 |
xDown = (int)event.getX(); |
|
| 314 |
yDown = mScrHeight - (int)event.getY(); |
|
| 315 |
|
|
| 316 | 312 |
mCenter.setPoint(moving, xDown, yDown, 0); |
| 317 | 313 |
} |
| 318 | 314 |
mRenderer.setRefresh(); |
| src/main/java/org/distorted/examples/objecttree/ObjectTreeRenderer.java | ||
|---|---|---|
| 206 | 206 |
Dynamic1D sinkDyn = new Dynamic1D(3000,0.0f); |
| 207 | 207 |
sinkDyn.add(new Static1D(1.0f)); |
| 208 | 208 |
sinkDyn.add(new Static1D(0.3f)); |
| 209 |
VertexEffectSink sink = new VertexEffectSink(sinkDyn, new Static3D(gridWidth/2.0f, gridHeight/2.0f, gridDepth/2.0f) );
|
|
| 209 |
VertexEffectSink sink = new VertexEffectSink(sinkDyn, new Static3D(0,0,0) );
|
|
| 210 | 210 |
gridEffects.apply(sink); |
| 211 | 211 |
|
| 212 | 212 |
VertexEffectSink.enable(); |
Also available in: Unified diff
Moving the Vertex and Fragment centers of effect to the center of the Mesh.