Project

General

Profile

« Previous | Next » 

Revision 4282d39a

Added by Leszek Koltunski about 4 years ago

Add the first two VERTEX 'pseudo-matrix' effects: VERTEX_MOVE & VERTEX_QUATERNION i.e. implementations of those two MATRIX effects in VERTEX queue.

The point(s):

1) preparation for the upcoming MeshBase.preApply(VertexEffect effect) API that's going to supersede the current much more limited MeshBase.apply(MatrixEffect effect)
2) those can be put in any position in the VERTEX queue, whereas the Matrix effects always have to come last

View differences:

src/main/java/org/distorted/examples/generic/GenericEffect.java
41 41
import org.distorted.library.effect.PostprocessEffectGlow;
42 42
import org.distorted.library.effect.VertexEffectDeform;
43 43
import org.distorted.library.effect.VertexEffectDistort;
44
import org.distorted.library.effect.VertexEffectMove;
44 45
import org.distorted.library.effect.VertexEffectPinch;
46
import org.distorted.library.effect.VertexEffectQuaternion;
45 47
import org.distorted.library.effect.VertexEffectSink;
46 48
import org.distorted.library.effect.VertexEffectSwirl;
47 49
import org.distorted.library.effect.VertexEffectWave;
......
99 101
  private long mId;
100 102

  
101 103
///////////////////////////////////////////////////////////////////////////////////////////////////
102
// requires knowledge dialog_about effect nature
104
// requires knowledge about effect nature
103 105

  
104 106
  void apply(DistortedEffects effects)
105 107
    {
......
119 121
      case PINCH            : effect = new VertexEffectPinch       (mDyn3, mCenterDyn, mRegion4Dyn); break;
120 122
      case SWIRL            : effect = new VertexEffectSwirl       (mDyn1, mCenterDyn, mRegion4Dyn); break;
121 123
      case WAVE             : effect = new VertexEffectWave        (mDyn5, mCenterDyn, mRegion4Dyn); break;
124
      case VERTEX_MOVE      : effect = new VertexEffectMove        (mDyn3)                         ; break;
125
      case VERTEX_QUATERNION: effect = new VertexEffectQuaternion  (mDyn4, mCenterDyn)             ; break;
122 126

  
123 127
      case ALPHA            : effect = new FragmentEffectAlpha     (mDyn1,        mCenterDyn, mRegion3Dyn, false); break;
124 128
      case SMOOTH_ALPHA     : effect = new FragmentEffectAlpha     (mDyn1,        mCenterDyn, mRegion3Dyn, true ); break;
......
143 147
    }
144 148

  
145 149
///////////////////////////////////////////////////////////////////////////////////////////////////
146
// requires knowledge dialog_about effect nature
150
// requires knowledge about effect nature
147 151

  
148 152
  private void fillStatics()
149 153
    {
150 154
    switch(mName)
151 155
      {
152 156
      ///////////////////////////////////////////////////////////////////////////////////////
153
      // MATRIX
157
      // MATRIX (and VERTEX-pseudo-matrix)
154 158
      ///////////////////////////////////////////////////////////////////////////////////////
155 159

  
156 160
      case ROTATE           : float an = (mInter[0]-50)*180/50.0f;
......
160 164
                              mSta1.set(an);
161 165
                              mSta3.set(rx,ry,rz);
162 166
                              break;
167
      case VERTEX_QUATERNION:
163 168
      case QUATERNION       : float qx = (mInter[0]-50)/ 50.0f;
164 169
                              float qy = (mInter[1]-50)/ 50.0f;
165 170
                              float qz = (mInter[2]-50)/ 50.0f;
166
                              float qa = (mInter[3]-50)*3.1415f/50;
167
                              float cosA = (float)Math.cos(qa/2);
171
                              float qw = (mInter[3]-50)*3.1415f/50;
172
                              float cosA = (float)Math.cos(qw/2);
168 173
                              float len = (float)Math.sqrt(qx*qx+qy*qy+qz*qz);
169
                              float sinAnorm = (float)Math.sin(qa/2)/len;
174
                              float sinAnorm = (float)Math.sin(qw/2)/len;
170 175
                              mSta4.set(sinAnorm*qx,sinAnorm*qy,sinAnorm*qz, cosA);
171 176
                              break;
172 177
      case MOVE             : float scr= mAct.get().getScreenWidth();
......
192 197
      // VERTEX
193 198
      ///////////////////////////////////////////////////////////////////////////////////////
194 199

  
200
      case VERTEX_MOVE      :
195 201
      case DISTORT          :
196 202
      case DEFORM           : float ld = mAct.get().getWidth()/50.0f;
197 203
                              float xd = (mInter[0]-50)*ld;
......
266 272
      case 1: mInter[0] = 50;
267 273
      }
268 274

  
269
    if( mName==EffectName.ROTATE || mName==EffectName.QUATERNION ) mInter[1]= 100;
275
    if( mName==EffectName.ROTATE         ||
276
        mName==EffectName.QUATERNION     ||
277
        mName==EffectName.VERTEX_QUATERNION )
278
      {
279
      mInter[0]= 100;
280
      }
270 281
    }
271 282

  
272 283
///////////////////////////////////////////////////////////////////////////////////////////////////
......
452 463
               mSta3 = new Static3D(0,0,0);
453 464
               mDyn3.add(mSta3);
454 465
               break;
455
      case 4 : if( mName == EffectName.QUATERNION )
466
      case 4 : if( mName == EffectName.QUATERNION || mName == EffectName.VERTEX_QUATERNION )
456 467
                 {
457 468
                 mDyn4 = new Dynamic4D();
458 469
                 mSta4 = new Static4D(0,0,0,0);
......
692 703

  
693 704
  public void onProgressChanged(SeekBar bar, int progress, boolean fromUser)
694 705
    {
695
    if ( mDimension>=1 && bar.getId()==mSeekID[0] )
696
      {
697
      mInter[0] = progress;
698
      fillStatics();
699
      setText();
700
      }
701
    if ( mDimension>=2 && bar.getId()==mSeekID[1] )
702
      {
703
      mInter[1] = progress;
704
      fillStatics();
705
      setText();
706
      }
707
    if ( mDimension>=3 && bar.getId()==mSeekID[2] )
708
      {
709
      mInter[2] = progress;
710
      fillStatics();
711
      setText();
712
      }
713
    if ( mDimension>=4 && bar.getId()==mSeekID[3] )
706
    boolean vectorChanged=false;
707
    boolean regionChanged=false;
708
    boolean centerChanged=false;
709

  
710
    for(int dim=0; dim<5; dim++)
714 711
      {
715
      mInter[3] = progress;
716
      fillStatics();
717
      setText();
712
      if ( mDimension>dim && bar.getId()==mSeekID[dim] )
713
        {
714
        mInter[dim] = progress;
715
        vectorChanged = true;
716
        }
718 717
      }
719
    if ( mDimension>=5 && bar.getId()==mSeekID[4] )
718

  
719
    if( vectorChanged )
720 720
      {
721
      mInter[4] = progress;
722 721
      fillStatics();
723 722
      setText();
724 723
      }
725 724

  
726
    if( mRegionDimension>=1 && bar.getId() == mSeekRegionID[0] )
727
      {
728
      mInterRegion[0] = progress;
729
      fillRegionStatics();
730
      setRegionText();
731
      }
732
    if( mRegionDimension>=2 && bar.getId() == mSeekRegionID[1] )
725
    for(int reg=0; reg<4; reg++)
733 726
      {
734
      mInterRegion[1] = progress;
735
      fillRegionStatics();
736
      setRegionText();
737
      }
738
    if( mRegionDimension>=3 && bar.getId() == mSeekRegionID[2] )
739
      {
740
      mInterRegion[2] = progress;
741
      fillRegionStatics();
742
      setRegionText();
727
      if( mRegionDimension>reg && bar.getId() == mSeekRegionID[reg] )
728
        {
729
        mInterRegion[reg] = progress;
730
        regionChanged = true;
731
        }
743 732
      }
744
    if( mRegionDimension>=4 && bar.getId() == mSeekRegionID[3] )
733

  
734
    if( regionChanged )
745 735
      {
746
      mInterRegion[3] = progress;
747 736
      fillRegionStatics();
748 737
      setRegionText();
749 738
      }
750 739

  
751
    if( bar.getId() == mSeekCenterID[0] )
752
      {
753
      mInterCenter[0] = progress;
754
      fillCenterStatics();
755
      setCenterText();
756
      }
757
    if( bar.getId() == mSeekCenterID[1] )
740
    for(int cen=0; cen<3; cen++)
758 741
      {
759
      mInterCenter[1] = progress;
760
      fillCenterStatics();
761
      setCenterText();
742
      if( bar.getId() == mSeekCenterID[cen] )
743
        {
744
        mInterCenter[cen] = progress;
745
        centerChanged = true;
746
        }
762 747
      }
763
    if( bar.getId() == mSeekCenterID[2] )
748

  
749
    if( centerChanged )
764 750
      {
765
      mInterCenter[2] = progress;
766 751
      fillCenterStatics();
767 752
      setCenterText();
768 753
      }

Also available in: Unified diff