Revision fa6c352d
Added by Leszek Koltunski about 9 years ago
| src/main/java/org/distorted/library/DistortedObject.java | ||
|---|---|---|
| 723 | 723 |
* |
| 724 | 724 |
* @param vector 3-dimensional Vector which represents the force the Center of the Effect is |
| 725 | 725 |
* currently being dragged with. |
| 726 |
* @param center 2-dimensional Data that, at any given time, returns the Center of the Effect.
|
|
| 726 |
* @param center 3-dimensional Data that, at any given time, returns the Center of the Effect.
|
|
| 727 | 727 |
* @param region Region that masks the Effect. |
| 728 | 728 |
* @return ID of the effect added, or -1 if we failed to add one. |
| 729 | 729 |
*/ |
| 730 |
public long distort(Data3D vector, Data2D center, Data4D region)
|
|
| 730 |
public long distort(Data3D vector, Data3D center, Data4D region)
|
|
| 731 | 731 |
{
|
| 732 | 732 |
return mV.add(EffectNames.DISTORT, vector, center, region); |
| 733 | 733 |
} |
| ... | ... | |
| 738 | 738 |
* |
| 739 | 739 |
* @param vector 3-dimensional Vector which represents the force the Center of the Effect is |
| 740 | 740 |
* currently being dragged with. |
| 741 |
* @param center 2-dimensional Data that, at any given time, returns the Center of the Effect.
|
|
| 741 |
* @param center 3-dimensional Data that, at any given time, returns the Center of the Effect.
|
|
| 742 | 742 |
* @return ID of the effect added, or -1 if we failed to add one. |
| 743 | 743 |
*/ |
| 744 |
public long distort(Data3D vector, Data2D center)
|
|
| 744 |
public long distort(Data3D vector, Data3D center)
|
|
| 745 | 745 |
{
|
| 746 | 746 |
return mV.add(EffectNames.DISTORT, vector, center, null); |
| 747 | 747 |
} |
| ... | ... | |
| 752 | 752 |
* a (possibly changing in time) point on the Object. |
| 753 | 753 |
* |
| 754 | 754 |
* @param vector Vector of force that deforms the shape of the whole Object. |
| 755 |
* @param center 2-dimensional Data that, at any given time, returns the Center of the Effect.
|
|
| 755 |
* @param center 3-dimensional Data that, at any given time, returns the Center of the Effect.
|
|
| 756 | 756 |
* @return ID of the effect added, or -1 if we failed to add one. |
| 757 | 757 |
*/ |
| 758 |
public long deform(Data3D vector, Data2D center)
|
|
| 758 |
public long deform(Data3D vector, Data3D center)
|
|
| 759 | 759 |
{
|
| 760 | 760 |
return mV.add(EffectNames.DEFORM, vector, center, null); |
| 761 | 761 |
} |
| ... | ... | |
| 766 | 766 |
* away from the center (degree<=1) |
| 767 | 767 |
* |
| 768 | 768 |
* @param sink The current degree of the Effect. |
| 769 |
* @param center 2-dimensional Data that, at any given time, returns the Center of the Effect.
|
|
| 769 |
* @param center 3-dimensional Data that, at any given time, returns the Center of the Effect.
|
|
| 770 | 770 |
* @param region Region that masks the Effect. |
| 771 | 771 |
* @return ID of the effect added, or -1 if we failed to add one. |
| 772 | 772 |
*/ |
| 773 |
public long sink(Data1D sink, Data2D center, Data4D region)
|
|
| 773 |
public long sink(Data1D sink, Data3D center, Data4D region)
|
|
| 774 | 774 |
{
|
| 775 | 775 |
return mV.add(EffectNames.SINK, sink, center, region); |
| 776 | 776 |
} |
| ... | ... | |
| 781 | 781 |
* away from the center (degree<=1) |
| 782 | 782 |
* |
| 783 | 783 |
* @param sink The current degree of the Effect. |
| 784 |
* @param center 2-dimensional Data that, at any given time, returns the Center of the Effect.
|
|
| 784 |
* @param center 3-dimensional Data that, at any given time, returns the Center of the Effect.
|
|
| 785 | 785 |
* @return ID of the effect added, or -1 if we failed to add one. |
| 786 | 786 |
*/ |
| 787 |
public long sink(Data1D sink, Data2D center)
|
|
| 787 |
public long sink(Data1D sink, Data3D center)
|
|
| 788 | 788 |
{
|
| 789 | 789 |
return mV.add(EffectNames.SINK, sink, center); |
| 790 | 790 |
} |
| ... | ... | |
| 794 | 794 |
* Rotate part of the Object around the Center of the Effect by a certain angle. |
| 795 | 795 |
* |
| 796 | 796 |
* @param swirl The angle of Swirl (in degrees). Positive values swirl clockwise. |
| 797 |
* @param center 2-dimensional Data that, at any given time, returns the Center of the Effect.
|
|
| 797 |
* @param center 3-dimensional Data that, at any given time, returns the Center of the Effect.
|
|
| 798 | 798 |
* @param region Region that masks the Effect. |
| 799 | 799 |
* @return ID of the effect added, or -1 if we failed to add one. |
| 800 | 800 |
*/ |
| 801 |
public long swirl(Data1D swirl, Data2D center, Data4D region)
|
|
| 801 |
public long swirl(Data1D swirl, Data3D center, Data4D region)
|
|
| 802 | 802 |
{
|
| 803 | 803 |
return mV.add(EffectNames.SWIRL, swirl, center, region); |
| 804 | 804 |
} |
| ... | ... | |
| 808 | 808 |
* Rotate the whole Object around the Center of the Effect by a certain angle. |
| 809 | 809 |
* |
| 810 | 810 |
* @param swirl The angle of Swirl (in degrees). Positive values swirl clockwise. |
| 811 |
* @param center 2-dimensional Data that, at any given time, returns the Center of the Effect.
|
|
| 811 |
* @param center 3-dimensional Data that, at any given time, returns the Center of the Effect.
|
|
| 812 | 812 |
* @return ID of the effect added, or -1 if we failed to add one. |
| 813 | 813 |
*/ |
| 814 |
public long swirl(Data1D swirl, Data2D center)
|
|
| 814 |
public long swirl(Data1D swirl, Data3D center)
|
|
| 815 | 815 |
{
|
| 816 | 816 |
return mV.add(EffectNames.SWIRL, swirl, center); |
| 817 | 817 |
} |
| ... | ... | |
| 842 | 842 |
* Example3: if Alpha = 0 and Beta = 45, then V=(sqrt(2)/2, -sqrt(2)/2, 0) and the wave |
| 843 | 843 |
* is entirely 'horizontal' and moves point (x,y,0) in direction V by whatever is the |
| 844 | 844 |
* value if sin at this point. |
| 845 |
* @param center 2-dimensional Data that, at any given time, returns the Center of the Effect.
|
|
| 845 |
* @param center 3-dimensional Data that, at any given time, returns the Center of the Effect.
|
|
| 846 | 846 |
* @return ID of the effect added, or -1 if we failed to add one. |
| 847 | 847 |
*/ |
| 848 |
public long wave(Data5D wave, Data2D center)
|
|
| 848 |
public long wave(Data5D wave, Data3D center)
|
|
| 849 | 849 |
{
|
| 850 | 850 |
return mV.add(EffectNames.WAVE, wave, center, null); |
| 851 | 851 |
} |
| ... | ... | |
| 855 | 855 |
* Directional, sinusoidal wave effect. |
| 856 | 856 |
* |
| 857 | 857 |
* @param wave see {@link DistortedObject#wave(Data5D,Data2D)}
|
| 858 |
* @param center see {@link DistortedObject#wave(Data5D,Data2D)}
|
|
| 858 |
* @param center 3-dimensional Data that, at any given time, returns the Center of the Effect.
|
|
| 859 | 859 |
* @param region Region that masks the Effect. |
| 860 | 860 |
* @return ID of the effect added, or -1 if we failed to add one. |
| 861 | 861 |
*/ |
| 862 |
public long wave(Data5D wave, Data2D center, Data4D region)
|
|
| 862 |
public long wave(Data5D wave, Data3D center, Data4D region)
|
|
| 863 | 863 |
{
|
| 864 | 864 |
return mV.add(EffectNames.WAVE, wave, center, region); |
| 865 | 865 |
} |
| src/main/java/org/distorted/library/EffectNames.java | ||
|---|---|---|
| 53 | 53 |
* <p> |
| 54 | 54 |
* Unity: angle==0 |
| 55 | 55 |
*/ |
| 56 |
ROTATE ( EffectTypes.MATRIX , new float[] {0.0f} , 1, false, true ),
|
|
| 56 |
ROTATE ( EffectTypes.MATRIX , new float[] {0.0f} , 4, false, true ),
|
|
| 57 | 57 |
/** |
| 58 | 58 |
* Rotate the whole Object around a center point (in quaternion notation). |
| 59 | 59 |
* <p> |
| src/main/java/org/distorted/library/EffectQueueVertex.java | ||
|---|---|---|
| 23 | 23 |
|
| 24 | 24 |
import org.distorted.library.message.EffectMessage; |
| 25 | 25 |
import org.distorted.library.type.Data1D; |
| 26 |
import org.distorted.library.type.Data2D; |
|
| 27 | 26 |
import org.distorted.library.type.Data3D; |
| 28 | 27 |
import org.distorted.library.type.Data4D; |
| 29 | 28 |
import org.distorted.library.type.Data5D; |
| 30 | 29 |
import org.distorted.library.type.Dynamic1D; |
| 31 |
import org.distorted.library.type.Dynamic2D; |
|
| 32 | 30 |
import org.distorted.library.type.Dynamic3D; |
| 33 | 31 |
import org.distorted.library.type.Dynamic4D; |
| 34 | 32 |
import org.distorted.library.type.Dynamic5D; |
| 35 | 33 |
import org.distorted.library.type.Static1D; |
| 36 |
import org.distorted.library.type.Static2D; |
|
| 37 | 34 |
import org.distorted.library.type.Static3D; |
| 38 | 35 |
import org.distorted.library.type.Static4D; |
| 39 | 36 |
import org.distorted.library.type.Static5D; |
| ... | ... | |
| 109 | 106 |
|
| 110 | 107 |
if( mInter[2][i]!=null ) // center |
| 111 | 108 |
{
|
| 112 |
mInter[2][i].interpolateMain(mUniforms, NUM_UNIFORMS*i+6, mCurrentDuration[i], step);
|
|
| 109 |
mInter[2][i].interpolateMain(mUniforms, NUM_UNIFORMS*i+5, mCurrentDuration[i], step);
|
|
| 113 | 110 |
|
| 114 |
mUniforms[NUM_UNIFORMS*i+6] = mUniforms[NUM_UNIFORMS*i+6]-mObjHalfX; |
|
| 115 |
mUniforms[NUM_UNIFORMS*i+7] =-mUniforms[NUM_UNIFORMS*i+7]+mObjHalfY; |
|
| 111 |
mUniforms[NUM_UNIFORMS*i+5] = mUniforms[NUM_UNIFORMS*i+5]-mObjHalfX; |
|
| 112 |
mUniforms[NUM_UNIFORMS*i+6] =-mUniforms[NUM_UNIFORMS*i+6]+mObjHalfY; |
|
| 113 |
mUniforms[NUM_UNIFORMS*i+7] = mUniforms[NUM_UNIFORMS*i+7]-mObjHalfZ; |
|
| 116 | 114 |
} |
| 117 | 115 |
|
| 118 | 116 |
mCurrentDuration[i] += step; |
| ... | ... | |
| 187 | 185 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 188 | 186 |
// wave |
| 189 | 187 |
|
| 190 |
synchronized long add(EffectNames eln, Data5D data, Data2D center, Data4D region)
|
|
| 188 |
synchronized long add(EffectNames eln, Data5D data, Data3D center, Data4D region)
|
|
| 191 | 189 |
{
|
| 192 | 190 |
if( mMax[INDEX]>mNumEffects ) |
| 193 | 191 |
{
|
| ... | ... | |
| 218 | 216 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 219 | 217 |
// deform,distort |
| 220 | 218 |
|
| 221 |
synchronized long add(EffectNames eln, Data3D data, Data2D center, Data4D region)
|
|
| 219 |
synchronized long add(EffectNames eln, Data3D data, Data3D center, Data4D region)
|
|
| 222 | 220 |
{
|
| 223 | 221 |
if( mMax[INDEX]>mNumEffects ) |
| 224 | 222 |
{
|
| ... | ... | |
| 247 | 245 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 248 | 246 |
// sink, swirl |
| 249 | 247 |
|
| 250 |
synchronized long add(EffectNames eln, Data1D data, Data2D center, Data4D region)
|
|
| 248 |
synchronized long add(EffectNames eln, Data1D data, Data3D center, Data4D region)
|
|
| 251 | 249 |
{
|
| 252 | 250 |
if( mMax[INDEX]>mNumEffects ) |
| 253 | 251 |
{
|
| ... | ... | |
| 272 | 270 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 273 | 271 |
// sink, swirl |
| 274 | 272 |
|
| 275 |
synchronized long add(EffectNames eln, Data1D data, Data2D center)
|
|
| 273 |
synchronized long add(EffectNames eln, Data1D data, Data3D center)
|
|
| 276 | 274 |
{
|
| 277 | 275 |
if( mMax[INDEX]>mNumEffects ) |
| 278 | 276 |
{
|
| ... | ... | |
| 296 | 294 |
|
| 297 | 295 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 298 | 296 |
|
| 299 |
private long addPriv(EffectNames eln, Data2D center, Data4D region)
|
|
| 297 |
private long addPriv(EffectNames eln, Data3D center, Data4D region)
|
|
| 300 | 298 |
{
|
| 301 | 299 |
if( region!=null ) |
| 302 | 300 |
{
|
| ... | ... | |
| 327 | 325 |
mInter[1][mNumEffects] = null; |
| 328 | 326 |
} |
| 329 | 327 |
|
| 330 |
if( center instanceof Dynamic2D)
|
|
| 328 |
if( center instanceof Dynamic3D)
|
|
| 331 | 329 |
{
|
| 332 |
mInter[2][mNumEffects] = (Dynamic2D)center;
|
|
| 330 |
mInter[2][mNumEffects] = (Dynamic3D)center;
|
|
| 333 | 331 |
} |
| 334 |
else if( center instanceof Static2D)
|
|
| 332 |
else if( center instanceof Static3D)
|
|
| 335 | 333 |
{
|
| 336 | 334 |
mInter[2][mNumEffects] = null; |
| 337 |
mUniforms[NUM_UNIFORMS*mNumEffects+6] = ((Static2D)center).getX()-mObjHalfX; |
|
| 338 |
mUniforms[NUM_UNIFORMS*mNumEffects+7] =-((Static2D)center).getY()+mObjHalfY; |
|
| 335 |
mUniforms[NUM_UNIFORMS*mNumEffects+5] = ((Static3D)center).getX()-mObjHalfX; |
|
| 336 |
mUniforms[NUM_UNIFORMS*mNumEffects+6] =-((Static3D)center).getY()+mObjHalfY; |
|
| 337 |
mUniforms[NUM_UNIFORMS*mNumEffects+7] = ((Static3D)center).getZ()-mObjHalfZ; |
|
| 339 | 338 |
} |
| 340 | 339 |
|
| 341 | 340 |
long ret= addBase(eln); |
| src/main/res/raw/main_vertex_shader.glsl | ||
|---|---|---|
| 208 | 208 |
|
| 209 | 209 |
void deform(in int effect, inout vec4 v) |
| 210 | 210 |
{
|
| 211 |
vec2 center = vUniforms[effect+1].zw;
|
|
| 211 |
vec2 center = vUniforms[effect+1].yz;
|
|
| 212 | 212 |
vec2 force = vUniforms[effect].xy; // force = vec(MM') |
| 213 | 213 |
vec2 vert_vec, horz_vec; |
| 214 | 214 |
vec2 signXY = sign(center-v.xy); |
| ... | ... | |
| 286 | 286 |
|
| 287 | 287 |
void distort(in int effect, inout vec4 v, inout vec4 n) |
| 288 | 288 |
{
|
| 289 |
vec2 center = vUniforms[effect+1].zw;
|
|
| 289 |
vec2 center = vUniforms[effect+1].yz;
|
|
| 290 | 290 |
vec2 ps = center-v.xy; |
| 291 | 291 |
vec3 force = vUniforms[effect].xyz; |
| 292 | 292 |
float d = degree(vUniforms[effect+2],center,ps); |
| ... | ... | |
| 314 | 314 |
|
| 315 | 315 |
void sink(in int effect,inout vec4 v) |
| 316 | 316 |
{
|
| 317 |
vec2 center = vUniforms[effect+1].zw;
|
|
| 317 |
vec2 center = vUniforms[effect+1].yz;
|
|
| 318 | 318 |
vec2 ps = center-v.xy; |
| 319 | 319 |
float h = vUniforms[effect].x; |
| 320 | 320 |
float t = degree(vUniforms[effect+2],center,ps) * (1.0-h)/max(1.0,h); |
| ... | ... | |
| 331 | 331 |
|
| 332 | 332 |
void swirl(in int effect, inout vec4 v) |
| 333 | 333 |
{
|
| 334 |
vec2 center = vUniforms[effect+1].zw;
|
|
| 334 |
vec2 center = vUniforms[effect+1].yz;
|
|
| 335 | 335 |
vec2 PS = center-v.xy; |
| 336 | 336 |
vec4 SO = vUniforms[effect+2]; |
| 337 | 337 |
float d1_circle = degree_region(SO,PS); |
| ... | ... | |
| 416 | 416 |
|
| 417 | 417 |
void wave(in int effect, inout vec4 v, inout vec4 n) |
| 418 | 418 |
{
|
| 419 |
vec2 center = vUniforms[effect+1].zw;
|
|
| 419 |
vec2 center = vUniforms[effect+1].yz;
|
|
| 420 | 420 |
float amplitude = vUniforms[effect ].x; |
| 421 | 421 |
float length = vUniforms[effect ].y; |
| 422 | 422 |
|
Also available in: Unified diff
Complete moving center to 3D.