Project

General

Profile

« Previous | Next » 

Revision 15aa7d94

Added by Leszek Koltunski almost 7 years ago

Progress with support for Effect classes.

View differences:

src/main/java/org/distorted/library/effect/VertexEffectPinch.java
19 19

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

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

  
28 32
///////////////////////////////////////////////////////////////////////////////////////////////////
29 33

  
......
36 40

  
37 41
///////////////////////////////////////////////////////////////////////////////////////////////////
38 42

  
39
  public VertexEffectPinch(Data1D pinch, Data3D center, Data4D region)
43
  public VertexEffectPinch(Data2D pinch, Data3D center, Data4D region)
40 44
    {
41 45
    super(PINCH,UNITIES,DIMENSION,SUPPORTS_CENTER,SUPPORTS_REGION);
42 46

  
43
    if( pinch instanceof Dynamic1D)
47
    if( pinch instanceof Dynamic2D)
44 48
      {
45
      mDynamic0 = (Dynamic1D)pinch;
49
      mDynamic0 = (Dynamic2D)pinch;
46 50
      }
47
    else if ( pinch instanceof Static1D )
51
    else if ( pinch instanceof Static2D )
48 52
      {
49
      mStatic0  = (Static1D)pinch;
53
      mStatic0  = (Static2D)pinch;
50 54
      }
51 55

  
52
    mCenter = center;
53
    mRegion = region;
56
    if( center instanceof Static3D)
57
      {
58
      mStaticCenter = (Static3D)center;
59
      }
60
    else if( center instanceof Dynamic3D)
61
      {
62
      mDynamicCenter = (Dynamic3D)center;
63
      }
64

  
65
    if( region instanceof Static4D)
66
      {
67
      mStaticRegion = (Static4D)region;
68
      }
69
    else if( region instanceof Dynamic4D)
70
      {
71
      mDynamicRegion = (Dynamic4D)region;
72
      }
54 73
    }
55 74

  
56 75
///////////////////////////////////////////////////////////////////////////////////////////////////
57 76

  
58
  public VertexEffectPinch(Data1D pinch, Data3D center)
77
  public VertexEffectPinch(Data2D pinch, Data3D center)
59 78
    {
60 79
    super(PINCH,UNITIES,DIMENSION,SUPPORTS_CENTER,SUPPORTS_REGION);
61 80

  
62
    if( pinch instanceof Dynamic1D)
81
    if( pinch instanceof Dynamic2D)
82
      {
83
      mDynamic0 = (Dynamic2D)pinch;
84
      }
85
    else if ( pinch instanceof Static2D )
86
      {
87
      mStatic0  = (Static2D)pinch;
88
      }
89

  
90
    if( center instanceof Static3D)
91
      {
92
      mStaticCenter = (Static3D)center;
93
      }
94
    else if( center instanceof Dynamic3D )
95
      {
96
      mDynamicCenter = (Dynamic3D)center;
97
      }
98

  
99
    mStaticRegion = new Static4D(0,0,Float.MAX_VALUE, Float.MAX_VALUE);
100
    }
101

  
102
///////////////////////////////////////////////////////////////////////////////////////////////////
103

  
104
  public boolean compute(float[] uniforms, int index, long currentDuration, long step )
105
    {
106
    boolean ret= false;
107

  
108
    if( mDynamicCenter!=null )
109
      {
110
      mDynamicCenter.interpolateMain(uniforms,index+5,currentDuration,step);
111
      }
112
    else
113
      {
114
      uniforms[index+5] = mStaticCenter.getX();
115
      uniforms[index+6] = mStaticCenter.getY();
116
      uniforms[index+7] = mStaticCenter.getZ();
117
      }
118

  
119
    if( mDynamicRegion!=null )
63 120
      {
64
      mDynamic0 = (Dynamic1D)pinch;
121
      mDynamicRegion.interpolateMain(uniforms,index+8,currentDuration,step);
65 122
      }
66
    else if ( pinch instanceof Static1D )
123
    else
67 124
      {
68
      mStatic0  = (Static1D)pinch;
125
      uniforms[index+ 8] = mStaticRegion.getX();
126
      uniforms[index+ 9] = mStaticRegion.getY();
127
      uniforms[index+10] = mStaticRegion.getZ();
128
      uniforms[index+11] = mStaticRegion.getW();
69 129
      }
70 130

  
71
    mCenter = center;
131
    if( mDynamic0!=null )
132
      {
133
      ret = mDynamic0.interpolateMain(uniforms,index,currentDuration,step);
134
      }
135
    else
136
      {
137
      uniforms[index  ] = ((Static2D)mStatic0).getX();
138
      uniforms[index+1] = ((Static2D)mStatic0).getY();
139
      }
140

  
141
    uniforms[index+1] = (float)(Math.PI*uniforms[index+1]/180);
142

  
143
    return ret;
72 144
    }
73 145
  }

Also available in: Unified diff