Project

General

Profile

Download (4.96 KB) Statistics
| Branch: | Tag: | Revision:

magiccube / src / main / java / org / distorted / effect / sizechange / SizeChangeEffectTransparency.java @ 5ba13c05

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.effect.sizechange;
21

    
22
import org.distorted.library.effect.Effect;
23
import org.distorted.library.effect.FragmentEffectAlpha;
24
import org.distorted.library.effect.VertexEffectWave;
25
import org.distorted.library.type.Dynamic1D;
26
import org.distorted.library.type.Dynamic5D;
27
import org.distorted.library.type.Static1D;
28
import org.distorted.library.type.Static3D;
29
import org.distorted.library.type.Static5D;
30

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

    
33
class SizeChangeEffectTransparency extends SizeChangeEffect
34
  {
35
  public int createEffectsPhase0(int duration)
36
    {
37
    mCubeEffectPosition[0] = new int[] {-1};
38
    mCubeEffects[0]        = new Effect[mCubeEffectPosition[0].length];
39

    
40
    Dynamic1D d0 = new Dynamic1D(duration/2, 0.5f);
41
    d0.add(new Static1D(1.0f));
42
    d0.add(new Static1D(0.0f));
43
    mCubeEffects[0][0] = new FragmentEffectAlpha(d0);
44

    
45
    mNodeEffectPosition[0] = new int[] {-1};
46
    mNodeEffects[0]        = new Effect[mNodeEffectPosition[0].length];
47

    
48
    int w = mScreen.getWidth();
49
    int h = mScreen.getHeight();
50
    int min = w<h ? w:h;
51

    
52
    float init_amplitude = 0.0f;
53
    float end_amplitude  = min/15.0f;
54
    float length         = min/15.0f;
55
    float init_phase     = 360.0f;
56
    float end_phase      = 0.0f;
57
    float alpha          = 30.0f;
58
    float beta           = 90.0f;
59

    
60
    Dynamic5D d1 = new Dynamic5D(duration/2, 0.5f);
61
    d1.add(new Static5D( init_amplitude, length, init_phase, alpha, beta) );
62
    d1.add(new Static5D( end_amplitude , length, end_phase , alpha, beta) );
63
    Static3D center = new Static3D(0,0,0);
64
    mNodeEffects[0][0] = new VertexEffectWave(d1, center, null);
65

    
66
    return 2;
67
    }
68

    
69
///////////////////////////////////////////////////////////////////////////////////////////////////
70

    
71
  public int createEffectsPhase1(int duration)
72
    {
73
    mCubeEffectPosition[1] = new int[] {-1};
74
    mCubeEffects[1]        = new Effect[mCubeEffectPosition[1].length];
75

    
76
    Dynamic1D d0 = new Dynamic1D(duration/2, 0.5f);
77
    d0.add(new Static1D(0.0f));
78
    d0.add(new Static1D(1.0f));
79
    mCubeEffects[1][0] = new FragmentEffectAlpha(d0);
80

    
81
    mNodeEffectPosition[1] = new int[] {-1};
82
    mNodeEffects[1]        = new Effect[mNodeEffectPosition[1].length];
83

    
84
    int w = mScreen.getWidth();
85
    int h = mScreen.getHeight();
86
    int min = w<h ? w:h;
87

    
88
    float init_amplitude = min/15.0f;
89
    float end_amplitude  = 0.0f;
90
    float length         = min/15.0f;
91
    float init_phase     = 0.0f;
92
    float end_phase      = 360.0f;
93
    float alpha          = 30.0f;
94
    float beta           = 90.0f;
95

    
96
    Dynamic5D d1 = new Dynamic5D(duration/2, 0.5f);
97
    d1.add(new Static5D( init_amplitude, length, init_phase, alpha, beta) );
98
    d1.add(new Static5D( end_amplitude , length, end_phase , alpha, beta) );
99
    Static3D center = new Static3D(0,0,0);
100
    mNodeEffects[1][0] = new VertexEffectWave(d1, center, null);
101

    
102
    return 2;
103
    }
104

    
105
///////////////////////////////////////////////////////////////////////////////////////////////////
106
// Enable all effects used in this Effect. Called by reflection from the parent class.
107

    
108
  @SuppressWarnings("unused")
109
  static void enable()
110
    {
111
    FragmentEffectAlpha.enable();
112
    VertexEffectWave.enable();
113
    }
114
  }
(6-6/6)