Project

General

Profile

Download (4.35 KB) Statistics
| Branch: | Revision:

distorted-objectlib / src / main / java / org / distorted / objectlib / effects / win / WinEffectGlow.java @ b80e6524

1
///////////////////////////////////////////////////////////////////////////////////////////////////
2
// Copyright 2019 Leszek Koltunski                                                               //
3
//                                                                                               //
4
// This file is part of Magic Cube.                                                              //
5
//                                                                                               //
6
// Magic Cube 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
// Magic Cube 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 Magic Cube.  If not, see <http://www.gnu.org/licenses/>.                           //
18
///////////////////////////////////////////////////////////////////////////////////////////////////
19

    
20
package org.distorted.objectlib.effects.win;
21

    
22
import org.distorted.library.effect.Effect;
23
import org.distorted.library.effect.EffectQuality;
24
import org.distorted.library.effect.PostprocessEffectGlow;
25
import org.distorted.library.effect.VertexEffectSink;
26
import org.distorted.library.type.Dynamic1D;
27
import org.distorted.library.type.Dynamic2D;
28
import org.distorted.library.type.Dynamic4D;
29
import org.distorted.library.type.Static1D;
30
import org.distorted.library.type.Static2D;
31
import org.distorted.library.type.Static3D;
32
import org.distorted.library.type.Static4D;
33

    
34
///////////////////////////////////////////////////////////////////////////////////////////////////
35

    
36
public class WinEffectGlow extends WinEffect
37
  {
38
  private static final int[] colors = new int[] {0,0,1,  1,0,1,  1,0,0,  1,1,0,  0,1,0,  1,1,1}; // blue, pink, red, yellow, green, white
39
  private static final int INDEX = 5;
40

    
41
///////////////////////////////////////////////////////////////////////////////////////////////////
42

    
43
  public void createEffects(int duration)
44
    {
45
    mNodeEffectPosition = new int[] {-1, -1};
46
    mNodeEffects        = new Effect[mNodeEffectPosition.length];
47

    
48
    Dynamic2D haloRadiusDyn = new Dynamic2D(duration,1.0f);
49
    haloRadiusDyn.add(new Static2D( 0, 0));
50
    haloRadiusDyn.add(new Static2D(15,50));
51
    haloRadiusDyn.add(new Static2D( 0, 0));
52

    
53
    Dynamic4D color= new Dynamic4D(duration,1.0f);
54
    Static4D P1    = new Static4D(colors[3*INDEX],colors[3*INDEX+1], colors[3*INDEX+2], 0.0f);
55
    Static4D P2    = new Static4D(colors[3*INDEX],colors[3*INDEX+1], colors[3*INDEX+2], 0.5f);
56
    color.add(P1);
57
    color.add(P2);
58
    color.add(P1);
59

    
60
    PostprocessEffectGlow glow = new PostprocessEffectGlow(haloRadiusDyn,color);
61
    glow.setQuality(EffectQuality.MEDIUM);
62

    
63
    mNodeEffects[0] = glow;
64

    
65
    Dynamic1D degreeDyn= new Dynamic1D(duration,1.0f);
66
    degreeDyn.add(new Static1D(1.0f));
67
    degreeDyn.add(new Static1D(1.5f));
68
    degreeDyn.add(new Static1D(1.0f));
69

    
70
    float moveX = mPre.getMoveX();
71
    float moveY = mPre.getMoveY();
72
    int width   = mScreen.getWidth();
73
    int height  = mScreen.getHeight();
74
    Static3D center = new Static3D(moveX/width, moveY/height, 0);
75
    float ratio = 0.5f*mObject.getRatio();
76

    
77
    mNodeEffects[1] = new VertexEffectSink(degreeDyn, center, new Static4D(0,0,0,ratio) );
78
    }
79

    
80
///////////////////////////////////////////////////////////////////////////////////////////////////
81
// Enable all effects used in this Effect. Called by reflection from the parent class.
82

    
83
  @SuppressWarnings("unused")
84
  static void enable()
85
    {
86
    PostprocessEffectGlow.enable();
87
    VertexEffectSink.enable();
88
    }
89
  }
(2-2/3)