Project

General

Profile

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

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

1
///////////////////////////////////////////////////////////////////////////////////////////////////
2
// Copyright 2019 Leszek Koltunski                                                               //
3
//                                                                                               //
4
// This file is part of Magic Cube.                                                              //
5
//                                                                                               //
6
// Magic Cube is proprietary software licensed under an EULA which you should have received      //
7
// along with the code. If not, check https://distorted.org/magic/License-Magic-Cube.html        //
8
///////////////////////////////////////////////////////////////////////////////////////////////////
9

    
10
package org.distorted.objectlib.effects.win;
11

    
12
import org.distorted.library.effect.Effect;
13
import org.distorted.library.effect.EffectQuality;
14
import org.distorted.library.effect.PostprocessEffectGlow;
15
import org.distorted.library.effect.VertexEffectSink;
16
import org.distorted.library.type.Dynamic1D;
17
import org.distorted.library.type.Dynamic2D;
18
import org.distorted.library.type.Dynamic4D;
19
import org.distorted.library.type.Static1D;
20
import org.distorted.library.type.Static2D;
21
import org.distorted.library.type.Static3D;
22
import org.distorted.library.type.Static4D;
23

    
24
///////////////////////////////////////////////////////////////////////////////////////////////////
25

    
26
public class WinEffectGlow extends WinEffect
27
  {
28
  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
29
  private static final int INDEX = 5;
30

    
31
///////////////////////////////////////////////////////////////////////////////////////////////////
32

    
33
  public void createEffects(int duration)
34
    {
35
    mNodeEffectPosition = new int[] {-1, -1};
36
    mNodeEffects        = new Effect[mNodeEffectPosition.length];
37

    
38
    Dynamic2D haloRadiusDyn = new Dynamic2D(duration,1.0f);
39
    haloRadiusDyn.add(new Static2D( 0, 0));
40
    haloRadiusDyn.add(new Static2D(15,50));
41
    haloRadiusDyn.add(new Static2D( 0, 0));
42

    
43
    Dynamic4D color= new Dynamic4D(duration,1.0f);
44
    Static4D P1    = new Static4D(colors[3*INDEX],colors[3*INDEX+1], colors[3*INDEX+2], 0.0f);
45
    Static4D P2    = new Static4D(colors[3*INDEX],colors[3*INDEX+1], colors[3*INDEX+2], 0.5f);
46
    color.add(P1);
47
    color.add(P2);
48
    color.add(P1);
49

    
50
    PostprocessEffectGlow glow = new PostprocessEffectGlow(haloRadiusDyn,color);
51
    glow.setQuality(EffectQuality.MEDIUM);
52

    
53
    mNodeEffects[0] = glow;
54

    
55
    Dynamic1D degreeDyn= new Dynamic1D(duration,1.0f);
56
    degreeDyn.add(new Static1D(1.0f));
57
    degreeDyn.add(new Static1D(1.5f));
58
    degreeDyn.add(new Static1D(1.0f));
59

    
60
    float moveX = mPre.getMoveX();
61
    float moveY = mPre.getMoveY();
62
    int width   = mObjectNode.getWidth();
63
    int height  = mObjectNode.getHeight();
64
    Static3D center = new Static3D(moveX/width, moveY/height, 0);
65
    float ratio = 0.5f*mObject.getRatio();
66

    
67
    mNodeEffects[1] = new VertexEffectSink(degreeDyn, center, new Static4D(0,0,0,ratio) );
68
    }
69

    
70
///////////////////////////////////////////////////////////////////////////////////////////////////
71
// Enable all effects used in this Effect. Called by reflection from the parent class.
72

    
73
  @SuppressWarnings("unused")
74
  static void enable()
75
    {
76
    PostprocessEffectGlow.enable();
77
    VertexEffectSink.enable();
78
    }
79
  }
(2-2/3)