Revision ec231614
Added by Leszek Koltunski over 7 years ago
src/main/java/org/distorted/library/DistortedEffects.java | ||
---|---|---|
638 | 638 |
/** |
639 | 639 |
* Moves the Object by a (possibly changing in time) vector. |
640 | 640 |
* |
641 |
* @param vector 3-dimensional Data which at any given time will return a Static3D |
|
642 |
* representing the current coordinates of the vector we want to move the Object with. |
|
641 |
* @param vector 3-dimensional Data which at any given time will return a Static3D representing |
|
642 |
* the current coordinates of the vector we want to move the Object with. |
|
643 |
* Units: to make it independent of the dimensions of the surface we are rendering to, |
|
644 |
* the vector's unit is the size of the surface in each direction; i.e. a move(0.3,0.7,0.0) |
|
645 |
* will move our object 30% of the width of the surface to the right and 70% of its height |
|
646 |
* down. |
|
643 | 647 |
* @return ID of the effect added, or -1 if we failed to add one. |
644 | 648 |
*/ |
645 | 649 |
public long move(Data3D vector) |
... | ... | |
653 | 657 |
* |
654 | 658 |
* @param scale 3-dimensional Data which at any given time returns a Static3D |
655 | 659 |
* representing the current x- , y- and z- scale factors. |
660 |
* Example: a scale(2,1,-0.5) makes the object 2 times wider, keeps the height |
|
661 |
* unchanged, and makes it twice thinner in Z-axis shifting the originally further |
|
662 |
* wall in front of the originally closer to the camera one. |
|
656 | 663 |
* @return ID of the effect added, or -1 if we failed to add one. |
657 | 664 |
*/ |
658 | 665 |
public long scale(Data3D scale) |
... | ... | |
675 | 682 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
676 | 683 |
/** |
677 | 684 |
* Rotates the Object by 'angle' degrees around the center. |
678 |
* Static axis of rotation is given by the last parameter.
|
|
685 |
* Static axis of rotation is given by the 2nd parameter.
|
|
679 | 686 |
* |
680 | 687 |
* @param angle Angle that we want to rotate the Object to. Unit: degrees |
681 | 688 |
* @param axis Axis of rotation |
... | ... | |
720 | 727 |
* |
721 | 728 |
* @param shear The 3-tuple of shear factors. The first controls level |
722 | 729 |
* of shearing in the X-axis, second - Y-axis and the third - |
723 |
* Z-axis. Each is the tangens of the shear angle, i.e 0 -
|
|
730 |
* Z-axis. Each is the tangent of the shear angle, i.e 0 -
|
|
724 | 731 |
* no shear, 1 - shear by 45 degrees (tan(45deg)=1) etc. |
725 | 732 |
* @param center Center of shearing, i.e. the point which stays unmoved. |
726 | 733 |
* @return ID of the effect added, or -1 if we failed to add one. |
src/main/java/org/distorted/library/EffectQueueMatrix.java | ||
---|---|---|
110 | 110 |
private void constructMatrices(DistortedOutputSurface projection, float halfX, float halfY) |
111 | 111 |
{ |
112 | 112 |
Matrix.setIdentityM(mViewMatrix, 0); |
113 |
Matrix.translateM(mViewMatrix, 0, -projection.mWidth/2, projection.mHeight/2, -projection.mDistance);
|
|
113 |
Matrix.translateM(mViewMatrix, 0, 0, 0, -projection.mDistance);
|
|
114 | 114 |
|
115 | 115 |
float x,y,z, sx,sy,sz; |
116 | 116 |
|
... | ... | |
118 | 118 |
{ |
119 | 119 |
if (mName[i] == EffectNames.ROTATE.ordinal() ) |
120 | 120 |
{ |
121 |
x = mUniforms[NUM_UNIFORMS*i+4]; |
|
122 |
y = mUniforms[NUM_UNIFORMS*i+5]; |
|
123 |
z = mUniforms[NUM_UNIFORMS*i+6]; |
|
121 |
x = mUniforms[NUM_UNIFORMS*i+4]*projection.mWidth;
|
|
122 |
y = mUniforms[NUM_UNIFORMS*i+5]*projection.mHeight;
|
|
123 |
z = mUniforms[NUM_UNIFORMS*i+6]*projection.mDistance;
|
|
124 | 124 |
|
125 | 125 |
Matrix.translateM(mViewMatrix, 0, x,-y, z); |
126 | 126 |
Matrix.rotateM( mViewMatrix, 0, mUniforms[NUM_UNIFORMS*i], mUniforms[NUM_UNIFORMS*i+1], mUniforms[NUM_UNIFORMS*i+2], mUniforms[NUM_UNIFORMS*i+3]); |
... | ... | |
128 | 128 |
} |
129 | 129 |
else if(mName[i] == EffectNames.QUATERNION.ordinal() ) |
130 | 130 |
{ |
131 |
x = mUniforms[NUM_UNIFORMS*i+4]; |
|
132 |
y = mUniforms[NUM_UNIFORMS*i+5]; |
|
133 |
z = mUniforms[NUM_UNIFORMS*i+6]; |
|
131 |
x = mUniforms[NUM_UNIFORMS*i+4]*projection.mWidth;
|
|
132 |
y = mUniforms[NUM_UNIFORMS*i+5]*projection.mHeight;
|
|
133 |
z = mUniforms[NUM_UNIFORMS*i+6]*projection.mDistance;
|
|
134 | 134 |
|
135 | 135 |
Matrix.translateM(mViewMatrix, 0, x,-y, z); |
136 | 136 |
multiplyByQuat(mViewMatrix, mUniforms[NUM_UNIFORMS*i], mUniforms[NUM_UNIFORMS*i+1], mUniforms[NUM_UNIFORMS*i+2], mUniforms[NUM_UNIFORMS*i+3]); |
... | ... | |
138 | 138 |
} |
139 | 139 |
else if(mName[i] == EffectNames.MOVE.ordinal() ) |
140 | 140 |
{ |
141 |
sx = mUniforms[NUM_UNIFORMS*i ]; |
|
142 |
sy = mUniforms[NUM_UNIFORMS*i+1]; |
|
143 |
sz = mUniforms[NUM_UNIFORMS*i+2]; |
|
141 |
sx = mUniforms[NUM_UNIFORMS*i ]*projection.mWidth;
|
|
142 |
sy = mUniforms[NUM_UNIFORMS*i+1]*projection.mHeight;
|
|
143 |
sz = mUniforms[NUM_UNIFORMS*i+2]*projection.mDistance;
|
|
144 | 144 |
|
145 | 145 |
Matrix.translateM(mViewMatrix, 0, sx,-sy, sz); |
146 | 146 |
} |
... | ... | |
158 | 158 |
sy = mUniforms[NUM_UNIFORMS*i+1]; |
159 | 159 |
sz = mUniforms[NUM_UNIFORMS*i+2]; |
160 | 160 |
|
161 |
x = mUniforms[NUM_UNIFORMS*i+4]; |
|
162 |
y = mUniforms[NUM_UNIFORMS*i+5]; |
|
163 |
z = mUniforms[NUM_UNIFORMS*i+6]; |
|
161 |
x = mUniforms[NUM_UNIFORMS*i+4]*projection.mWidth;
|
|
162 |
y = mUniforms[NUM_UNIFORMS*i+5]*projection.mHeight;
|
|
163 |
z = mUniforms[NUM_UNIFORMS*i+6]*projection.mDistance;
|
|
164 | 164 |
|
165 | 165 |
Matrix.translateM(mViewMatrix, 0, x,-y, z); |
166 | 166 |
|
... | ... | |
183 | 183 |
} |
184 | 184 |
} |
185 | 185 |
|
186 |
Matrix.translateM(mViewMatrix, 0, halfX,-halfY, 0);
|
|
186 |
Matrix.scaleM(mViewMatrix, 0, projection.mWidth/(2*halfX), projection.mHeight/(2*halfY), 1);
|
|
187 | 187 |
Matrix.multiplyMM(mMVPMatrix, 0, projection.mProjectionMatrix, 0, mViewMatrix, 0); |
188 | 188 |
} |
189 | 189 |
|
... | ... | |
311 | 311 |
mUniforms[NUM_UNIFORMS*mNumEffects+2] = axis.getY(); |
312 | 312 |
mUniforms[NUM_UNIFORMS*mNumEffects+3] = axis.getZ(); |
313 | 313 |
|
314 |
if( center instanceof Dynamic3D) |
|
314 |
if( center instanceof Dynamic3D )
|
|
315 | 315 |
{ |
316 | 316 |
mInter[1][mNumEffects] = (Dynamic3D)center; |
317 | 317 |
} |
... | ... | |
337 | 337 |
{ |
338 | 338 |
if( mMax[INDEX]>mNumEffects ) |
339 | 339 |
{ |
340 |
if( data instanceof Dynamic4D )
|
|
340 |
if( data instanceof Dynamic4D ) |
|
341 | 341 |
{ |
342 | 342 |
mInter[0][mNumEffects] = (Dynamic4D)data; |
343 | 343 |
} |
344 |
else if( data instanceof DynamicQuat) |
|
344 |
else if( data instanceof DynamicQuat )
|
|
345 | 345 |
{ |
346 | 346 |
mInter[0][mNumEffects] = (DynamicQuat)data; |
347 | 347 |
} |
348 |
else if( data instanceof Static4D )
|
|
348 |
else if( data instanceof Static4D ) |
|
349 | 349 |
{ |
350 | 350 |
mInter[0][mNumEffects] = null; |
351 | 351 |
mUniforms[NUM_UNIFORMS*mNumEffects ] = ((Static4D)data).getX(); |
... | ... | |
355 | 355 |
} |
356 | 356 |
else return -1; |
357 | 357 |
|
358 |
if( center instanceof Dynamic3D) |
|
358 |
if( center instanceof Dynamic3D )
|
|
359 | 359 |
{ |
360 | 360 |
mInter[1][mNumEffects] = (Dynamic3D)center; |
361 | 361 |
} |
... | ... | |
381 | 381 |
{ |
382 | 382 |
if( mMax[INDEX]>mNumEffects ) |
383 | 383 |
{ |
384 |
if( shear instanceof Dynamic3D) |
|
384 |
if( shear instanceof Dynamic3D )
|
|
385 | 385 |
{ |
386 | 386 |
mInter[0][mNumEffects] = (Dynamic3D)shear; |
387 | 387 |
} |
... | ... | |
394 | 394 |
} |
395 | 395 |
else return -1; |
396 | 396 |
|
397 |
if( center instanceof Dynamic3D) |
|
397 |
if( center instanceof Dynamic3D )
|
|
398 | 398 |
{ |
399 | 399 |
mInter[1][mNumEffects] = (Dynamic3D)center; |
400 | 400 |
} |
Also available in: Unified diff
Major refactoring: convert the Matrix Effects to be independent of the resolution of the surface we render to.
Re-write the first 15 apps to work with this.