Project

General

Profile

« Previous | Next » 

Revision 6d62a900

Added by Leszek Koltunski over 7 years ago

Beginnings of support for Effect classes.

View differences:

src/main/java/org/distorted/library/effect/Effect.java
25 25
  {
26 26
  private final long mID;
27 27
  private final int mType;
28
  private final int mName;
28 29
  private final float[] mUnity;
29 30
  private final int mDimension;
30 31
  private final boolean mSupportsR;
......
64 65
    return mType;
65 66
    }
66 67

  
68
///////////////////////////////////////////////////////////////////////////////////////////////////
69

  
70
  public int getName()
71
    {
72
    return mName;
73
    }
74

  
67 75
///////////////////////////////////////////////////////////////////////////////////////////////////
68 76

  
69 77
  public long getID()
......
94 102

  
95 103
///////////////////////////////////////////////////////////////////////////////////////////////////
96 104

  
97
  Effect(int type, float[] unity, int dimension, boolean center, boolean region)
105
  Effect(int type, int name, float[] unity, int dimension, boolean center, boolean region)
98 106
    {
99 107
    mID        = mNextID++;
108

  
109
    mName      = name;
100 110
    mType      = type;
101 111
    mUnity     = unity;
102 112
    mDimension = dimension;
src/main/java/org/distorted/library/effect/FragmentEffect.java
19 19

  
20 20
package org.distorted.library.effect;
21 21

  
22
import org.distorted.library.type.Data4D;
23

  
22 24
///////////////////////////////////////////////////////////////////////////////////////////////////
23 25

  
24 26
public abstract class FragmentEffect extends Effect
25 27
  {
26 28
  static final int MAX = 5;
27 29

  
30
  public static int CHROMA            = 0;
31
  public static int SMOOTH_CHROMA     = 1;
32
  public static int ALPHA             = 2;
33
  public static int SMOOTH_ALPHA      = 3;
34
  public static int BRIGHTNESS        = 4;
35
  public static int SMOOTH_BRIGHTNESS = 5;
36
  public static int CONTRAST          = 6;
37
  public static int SMOOTH_CONTRAST   = 7;
38
  public static int SATURATION        = 8;
39
  public static int SMOOTH_SATURATION = 9;
40

  
41

  
42
  Data4D mRegion;
43

  
28 44
///////////////////////////////////////////////////////////////////////////////////////////////////
29 45

  
30
  public FragmentEffect(float[] unity, int dimension, boolean center, boolean region)
46
  public FragmentEffect(int name,float[] unity, int dimension, boolean center, boolean region)
31 47
    {
32
    super(FRAGMENT,unity,dimension,center,region);
48
    super(FRAGMENT,name,unity,dimension,center,region);
33 49
    }
34 50
  }
src/main/java/org/distorted/library/effect/MatrixEffect.java
19 19

  
20 20
package org.distorted.library.effect;
21 21

  
22
import org.distorted.library.type.*;
23

  
22 24
///////////////////////////////////////////////////////////////////////////////////////////////////
23 25

  
24 26
public abstract class MatrixEffect extends Effect
25 27
  {
26 28
  static final int MAX = 10;
27 29

  
30
  public static final int MOVE       = 0;
31
  public static final int SCALE      = 1;
32
  public static final int ROTATE     = 2;
33
  public static final int QUATERNION = 3;
34
  public static final int SHEAR      = 4;
35

  
36
  Dynamic mDynamic0;
37
  Static  mStatic0, mStatic1;
38
  Data3D mCenter;
39

  
28 40
///////////////////////////////////////////////////////////////////////////////////////////////////
29 41

  
30
  public MatrixEffect(float[] unity, int dimension, boolean center, boolean region)
42
  public MatrixEffect(int name, float[] unity, int dimension, boolean center, boolean region)
31 43
    {
32
    super(MATRIX,unity,dimension,center,region);
44
    super(MATRIX,name,unity,dimension,center,region);
33 45
    }
34 46
  }
src/main/java/org/distorted/library/effect/MatrixEffectMove.java
19 19

  
20 20
package org.distorted.library.effect;
21 21

  
22
import org.distorted.library.type.Data3D;
23
import org.distorted.library.type.Dynamic3D;
24
import org.distorted.library.type.Static3D;
25

  
22 26
///////////////////////////////////////////////////////////////////////////////////////////////////
23 27

  
24 28
public class MatrixEffectMove extends MatrixEffect
......
30 34

  
31 35
///////////////////////////////////////////////////////////////////////////////////////////////////
32 36

  
33
  public MatrixEffectMove()
37
  public MatrixEffectMove(Data3D vector)
34 38
    {
35
    super(UNITIES,DIMENSION,SUPPORTS_CENTER,SUPPORTS_REGION);
39
    super(MOVE,UNITIES,DIMENSION,SUPPORTS_CENTER,SUPPORTS_REGION);
40

  
41
    if( vector instanceof Static3D)
42
      {
43
      mStatic0 = (Static3D)vector;
44
      }
45
    else if ( vector instanceof Dynamic3D )
46
      {
47
      mDynamic0 = (Dynamic3D)vector;
48
      }
36 49
    }
37 50
  }
src/main/java/org/distorted/library/effect/MatrixEffectQuaternion.java
19 19

  
20 20
package org.distorted.library.effect;
21 21

  
22
import org.distorted.library.type.Data3D;
23
import org.distorted.library.type.Data4D;
24
import org.distorted.library.type.Dynamic4D;
25
import org.distorted.library.type.Static4D;
26

  
22 27
///////////////////////////////////////////////////////////////////////////////////////////////////
23 28

  
24 29
public class MatrixEffectQuaternion extends MatrixEffect
......
30 35

  
31 36
///////////////////////////////////////////////////////////////////////////////////////////////////
32 37

  
33
  public MatrixEffectQuaternion()
38
  public MatrixEffectQuaternion(Data4D quaternion, Data3D center )
34 39
    {
35
    super(UNITIES,DIMENSION,SUPPORTS_CENTER,SUPPORTS_REGION);
40
    super(QUATERNION,UNITIES,DIMENSION,SUPPORTS_CENTER,SUPPORTS_REGION);
41

  
42
    if( quaternion instanceof Static4D)
43
      {
44
      mStatic0 = (Static4D)quaternion;
45
      }
46
    else if( quaternion instanceof Dynamic4D)
47
      {
48
      mDynamic0 = (Dynamic4D)quaternion;
49
      }
50

  
51
    mCenter = center;
36 52
    }
37 53
  }
src/main/java/org/distorted/library/effect/MatrixEffectRotate.java
19 19

  
20 20
package org.distorted.library.effect;
21 21

  
22
import org.distorted.library.type.Data1D;
23
import org.distorted.library.type.Data3D;
24
import org.distorted.library.type.Data4D;
25
import org.distorted.library.type.Dynamic1D;
26
import org.distorted.library.type.Dynamic4D;
27
import org.distorted.library.type.Static1D;
28
import org.distorted.library.type.Static3D;
29
import org.distorted.library.type.Static4D;
30

  
22 31
///////////////////////////////////////////////////////////////////////////////////////////////////
23 32

  
24 33
public class MatrixEffectRotate extends MatrixEffect
......
30 39

  
31 40
///////////////////////////////////////////////////////////////////////////////////////////////////
32 41

  
33
  public MatrixEffectRotate()
42
  public MatrixEffectRotate(Data1D angle, Static3D axis, Data3D center)
34 43
    {
35
    super(UNITIES,DIMENSION,SUPPORTS_CENTER,SUPPORTS_REGION);
44
    super(ROTATE,UNITIES,DIMENSION,SUPPORTS_CENTER,SUPPORTS_REGION);
45

  
46
    if( angle instanceof Static1D )
47
      {
48
      mStatic0 = (Static1D)angle;
49
      }
50
    else if( angle instanceof Dynamic1D )
51
      {
52
      mDynamic0 = (Dynamic1D)angle;
53
      }
54

  
55
    mStatic1 = axis;
56
    mCenter = center;
36 57
    }
58

  
59
///////////////////////////////////////////////////////////////////////////////////////////////////
60

  
61
  public MatrixEffectRotate(Data4D angleaxis, Data3D center)
62
    {
63
    super(ROTATE,UNITIES,DIMENSION,SUPPORTS_CENTER,SUPPORTS_REGION);
64

  
65
    if( angleaxis instanceof Static4D)
66
      {
67
      mStatic0 = (Static4D)angleaxis;
68
      }
69
    else if( angleaxis instanceof Dynamic4D)
70
      {
71
      mDynamic0 = (Dynamic4D)angleaxis;
72
      }
73

  
74
    mCenter = center;
75
    }
76

  
37 77
  }
src/main/java/org/distorted/library/effect/MatrixEffectScale.java
19 19

  
20 20
package org.distorted.library.effect;
21 21

  
22
import org.distorted.library.type.Data3D;
23
import org.distorted.library.type.Dynamic3D;
24
import org.distorted.library.type.Static3D;
25

  
22 26
///////////////////////////////////////////////////////////////////////////////////////////////////
23 27

  
24 28
public class MatrixEffectScale extends MatrixEffect
......
30 34

  
31 35
///////////////////////////////////////////////////////////////////////////////////////////////////
32 36

  
33
  public MatrixEffectScale()
37
  public MatrixEffectScale(Data3D scale)
38
    {
39
    super(SCALE,UNITIES,DIMENSION,SUPPORTS_CENTER,SUPPORTS_REGION);
40

  
41
    if( scale instanceof Static3D)
42
      {
43
      mStatic0 = (Static3D)scale;
44
      }
45
    else if ( scale instanceof Dynamic3D)
46
      {
47
      mDynamic0 = (Dynamic3D)scale;
48
      }
49
    }
50

  
51
///////////////////////////////////////////////////////////////////////////////////////////////////
52

  
53
  public MatrixEffectScale(float scale)
34 54
    {
35
    super(UNITIES,DIMENSION,SUPPORTS_CENTER,SUPPORTS_REGION);
55
    super(SCALE,UNITIES,DIMENSION,SUPPORTS_CENTER,SUPPORTS_REGION);
56

  
57
    mStatic0 = new Static3D(scale,scale,scale);
36 58
    }
37 59
  }
src/main/java/org/distorted/library/effect/MatrixEffectShear.java
19 19

  
20 20
package org.distorted.library.effect;
21 21

  
22
import org.distorted.library.type.Data3D;
23
import org.distorted.library.type.Dynamic3D;
24
import org.distorted.library.type.Static3D;
25

  
22 26
///////////////////////////////////////////////////////////////////////////////////////////////////
23 27

  
24 28
public class MatrixEffectShear extends MatrixEffect
......
30 34

  
31 35
///////////////////////////////////////////////////////////////////////////////////////////////////
32 36

  
33
  public MatrixEffectShear()
37
  public MatrixEffectShear(Data3D shear, Data3D center)
34 38
    {
35
    super(UNITIES,DIMENSION,SUPPORTS_CENTER,SUPPORTS_REGION);
39
    super(SHEAR,UNITIES,DIMENSION,SUPPORTS_CENTER,SUPPORTS_REGION);
40

  
41
    if( shear instanceof Static3D)
42
      {
43
      mStatic0 = (Static3D)shear;
44
      }
45
    else if ( shear instanceof Dynamic3D)
46
      {
47
      mDynamic0 = (Dynamic3D)shear;
48
      }
49

  
50
    mCenter = center;
36 51
    }
37 52
  }
src/main/java/org/distorted/library/effect/PostprocessEffect.java
25 25
  {
26 26
  static final int MAX = 5;
27 27

  
28
  public static int BLUR = 0;
29
  public static int GLOW = 1;
30

  
28 31
///////////////////////////////////////////////////////////////////////////////////////////////////
29 32

  
30
  public PostprocessEffect(float[] unity, int dimension, boolean center, boolean region)
33
  public PostprocessEffect(int name, float[] unity, int dimension, boolean center, boolean region)
31 34
    {
32
    super(POSTPROCESS,unity,dimension,center,region);
35
    super(POSTPROCESS,name,unity,dimension,center,region);
33 36
    }
34 37
  }
src/main/java/org/distorted/library/effect/VertexEffect.java
25 25
  {
26 26
  static final int MAX = 5;
27 27

  
28
  public static int DISTORT = 0;
29
  public static int DEFORM  = 1;
30
  public static int SINK    = 2;
31
  public static int PINCH   = 3;
32
  public static int SWIRL   = 4;
33
  public static int WAVE    = 5;
34

  
28 35
///////////////////////////////////////////////////////////////////////////////////////////////////
29 36

  
30
  public VertexEffect(float[] unity, int dimension, boolean center, boolean region)
37
  public VertexEffect(int name, float[] unity, int dimension, boolean center, boolean region)
31 38
    {
32
    super(VERTEX,unity,dimension,center,region);
39
    super(VERTEX,name,unity,dimension,center,region);
33 40
    }
34 41
  }
src/main/java/org/distorted/library/type/Dynamic.java
81 81
   */
82 82
  public static final int ACCESS_SEQUENTIAL = 1;
83 83

  
84
  protected int mDimension;
84
  protected final int mDimension;
85 85
  protected int numPoints;
86 86
  protected int mSegment;       // between which pair of points are we currently? (in case of PATH this is a bit complicated!)
87 87
  protected boolean cacheDirty; // VectorCache not up to date
......
160 160
  
161 161
  protected Dynamic()
162 162
    {
163
    mDimension = 0;
163 164
    }
164 165

  
165 166
///////////////////////////////////////////////////////////////////////////////////////////////////
......
557 558
    mDuration = duration;
558 559
    }
559 560

  
560

  
561 561
///////////////////////////////////////////////////////////////////////////////////////////////////
562 562
/**
563 563
 * Sets the access mode this Dynamic will be working in.
......
570 570
    mLastPos = -1;
571 571
    }
572 572

  
573
///////////////////////////////////////////////////////////////////////////////////////////////////
574
/**
575
 * Return the Dimension, ie number of floats in a single Point this Dynamic interpolates through.
576
 */
577
  public int getDimension()
578
    {
579
    return mDimension;
580
    }
581

  
573 582
///////////////////////////////////////////////////////////////////////////////////////////////////
574 583
/**
575 584
 * Writes the results of interpolation between the Points at time 'time' to the passed float buffer.
src/main/java/org/distorted/library/type/Static.java
1
///////////////////////////////////////////////////////////////////////////////////////////////////
2
// Copyright 2016 Leszek Koltunski                                                               //
3
//                                                                                               //
4
// This file is part of Distorted.                                                               //
5
//                                                                                               //
6
// Distorted is free software: you can redistribute it and/or modify                             //
7
// it under the terms of the GNU General Public License as published by                          //
8
// the Free Software Foundation, either version 2 of the License, or                             //
9
// (at your option) any later version.                                                           //
10
//                                                                                               //
11
// Distorted is distributed in the hope that it will be useful,                                  //
12
// but WITHOUT ANY WARRANTY; without even the implied warranty of                                //
13
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                                 //
14
// GNU General Public License for more details.                                                  //
15
//                                                                                               //
16
// You should have received a copy of the GNU General Public License                             //
17
// along with Distorted.  If not, see <http://www.gnu.org/licenses/>.                            //
18
///////////////////////////////////////////////////////////////////////////////////////////////////
19

  
20
package org.distorted.library.type;
21

  
22
///////////////////////////////////////////////////////////////////////////////////////////////////
23
/**
24
 * Any-dimensional data structure containing arbitrary number of floats. The floats have no
25
 * particular meaning; when this data structure is used in Dynamics, we can think of it as a
26
 * N-dimensional Point a few of which the Dynamic interpolates between.
27
 */
28

  
29
public class Static
30
  {
31
  private final int mDimension;
32

  
33
///////////////////////////////////////////////////////////////////////////////////////////////////
34

  
35
  Static(int dim)
36
    {
37
    mDimension = dim;
38
    }
39

  
40
///////////////////////////////////////////////////////////////////////////////////////////////////
41
/**
42
 * Return the Dimension, ie number of floats in this Static.
43
 */
44
  public int getDimension()
45
    {
46
    return mDimension;
47
    }
48
  }
src/main/java/org/distorted/library/type/Static1D.java
26 26
 * a few of which the Dynamic interpolates between.
27 27
 */
28 28

  
29
public class Static1D implements Data1D
29
public class Static1D extends Static implements Data1D
30 30
  {
31 31
  float x;
32 32

  
33
///////////////////////////////////////////////////////////////////////////////////////////////////
34

  
35
  Static1D(int dim, float ox)
36
    {
37
    super(dim);
38
    x = ox;
39
    }
40

  
33 41
///////////////////////////////////////////////////////////////////////////////////////////////////
34 42
/**
35 43
 * Constructor that initialises the value of the single float to ox.   
......
38 46
 */
39 47
  public Static1D(int ox)
40 48
    {
49
    super(1);
41 50
    x = ox;
42 51
    }
43 52

  
......
49 58
 */  
50 59
  public Static1D(float ox)
51 60
    {
61
    super(1);
52 62
    x = ox;
53 63
    }
54 64
  
src/main/java/org/distorted/library/type/Static2D.java
30 30
  {
31 31
  float y;
32 32

  
33
///////////////////////////////////////////////////////////////////////////////////////////////////
34

  
35
  Static2D(int dim, float ox, float oy)
36
    {
37
    super(dim,ox);
38
    y = oy;
39
    }
40

  
33 41
///////////////////////////////////////////////////////////////////////////////////////////////////
34 42
/**
35 43
 * Constructor that initialises the value of the two floats to (ox,oy).   
......
39 47
 */  
40 48
  public Static2D(int ox, int oy)
41 49
    {
42
    super(ox);
50
    super(2,ox);
43 51
    y = oy;
44 52
    }
45 53

  
......
52 60
 */    
53 61
  public Static2D(float ox, float oy)
54 62
    {
55
    super(ox);
63
    super(2,ox);
56 64
    y = oy;
57 65
    }
58 66
  
src/main/java/org/distorted/library/type/Static3D.java
29 29
public class Static3D extends Static2D  implements Data3D
30 30
  {
31 31
  float z;
32
  
32

  
33
///////////////////////////////////////////////////////////////////////////////////////////////////
34

  
35
  Static3D(int dim, float vx, float vy, float vz)
36
    {
37
    super(dim,vx,vy);
38
    z = vz;
39
    }
40

  
33 41
///////////////////////////////////////////////////////////////////////////////////////////////////
34 42
/**
35 43
 * Constructor that initialises the value of the three floats to (vx,vy,vz).   
......
40 48
 */ 
41 49
  public Static3D(int vx, int vy, int vz)
42 50
    {
43
    super(vx,vy);
51
    super(3,vx,vy);
44 52
    z = vz;
45 53
    }
46 54

  
......
54 62
 */ 
55 63
  public Static3D(float vx, float vy, float vz)
56 64
    {
57
    super(vx,vy);
65
    super(3,vx,vy);
58 66
    z = vz;
59 67
    }
60 68

  
src/main/java/org/distorted/library/type/Static4D.java
29 29
public class Static4D extends Static3D implements Data4D
30 30
  {
31 31
  float w;
32
  
32

  
33
///////////////////////////////////////////////////////////////////////////////////////////////////
34

  
35
  Static4D(int dim, float vx, float vy, float vz, float vw)
36
    {
37
    super(dim,vx,vy,vz);
38
    w = vw;
39
    }
40

  
33 41
///////////////////////////////////////////////////////////////////////////////////////////////////
34 42
/**
35 43
 * Constructor that initialises the value of the four floats to (vx,vy,vz,vw).   
......
41 49
 */ 
42 50
  public Static4D(int vx, int vy, int vz, int vw)
43 51
    {
44
    super(vx,vy,vz);
52
    super(4,vx,vy,vz);
45 53
    w = vw;
46 54
    }
47 55

  
......
56 64
 */ 
57 65
  public Static4D(float vx, float vy, float vz, float vw)
58 66
    {
59
    super(vx,vy,vz);
67
    super(4,vx,vy,vz);
60 68
    w = vw;
61 69
    }
62 70

  
src/main/java/org/distorted/library/type/Static5D.java
29 29
public class Static5D extends Static4D implements Data5D
30 30
  {
31 31
  float v;
32
  
32

  
33 33
///////////////////////////////////////////////////////////////////////////////////////////////////
34 34
/**
35 35
 * Constructor that initialises the value of the five floats to (vx,vy,vz,vw,vv).   
......
42 42
 */ 
43 43
  public Static5D(int vx, int vy, int vz, int vw, int vv)
44 44
    {
45
    super(vx,vy,vz,vw);
45
    super(5,vx,vy,vz,vw);
46 46
    v = vv;
47 47
    }
48 48

  
......
58 58
 */ 
59 59
  public Static5D(float vx, float vy, float vz, float vw, float vv)
60 60
    {
61
    super(vx,vy,vz,vw);
61
    super(5,vx,vy,vz,vw);
62 62
    v = vv;
63 63
    }
64 64

  

Also available in: Unified diff