Project

General

Profile

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

distorted-objectlib / src / main / java / org / distorted / objectlib / effects / objectchange / ObjectChangeEffectTransparency.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.objectchange;
11

    
12
import org.distorted.library.effect.Effect;
13
import org.distorted.library.effect.FragmentEffectAlpha;
14
import org.distorted.library.effect.VertexEffectWave;
15
import org.distorted.library.type.Dynamic1D;
16
import org.distorted.library.type.Dynamic5D;
17
import org.distorted.library.type.Static1D;
18
import org.distorted.library.type.Static3D;
19
import org.distorted.library.type.Static5D;
20

    
21
///////////////////////////////////////////////////////////////////////////////////////////////////
22

    
23
class ObjectChangeEffectTransparency extends ObjectChangeEffect
24
  {
25
  public int createEffectsPhase0(int duration)
26
    {
27
    mNodeEffectPosition[0] = new int[] {-1,-1};
28
    mNodeEffects[0]        = new Effect[mNodeEffectPosition[0].length];
29

    
30
    float init_amplitude = 0.0f;
31
    float end_amplitude  = 1/8.0f;
32
    float length         = 1/8.0f;
33
    float init_phase     = 360.0f;
34
    float end_phase      = 0.0f;
35
    float alpha          = 30.0f;
36
    float beta           = 90.0f;
37

    
38
    Dynamic5D d1 = new Dynamic5D(duration/2, 0.5f);
39
    d1.add(new Static5D( init_amplitude, length, init_phase, alpha, beta) );
40
    d1.add(new Static5D( end_amplitude , length, end_phase , alpha, beta) );
41
    Static3D center = new Static3D(0,0,0);
42
    mNodeEffects[0][0] = new VertexEffectWave(d1, center, null);
43

    
44
    Dynamic1D d0 = new Dynamic1D(duration/2, 0.5f);
45
    d0.add(new Static1D(1.0f));
46
    d0.add(new Static1D(0.0f));
47
    mNodeEffects[0][1] = new FragmentEffectAlpha(d0);
48

    
49
    return 2;
50
    }
51

    
52
///////////////////////////////////////////////////////////////////////////////////////////////////
53

    
54
  public int createEffectsPhase1(int duration)
55
    {
56
    mNodeEffectPosition[1] = new int[] {-1,-1};
57
    mNodeEffects[1]        = new Effect[mNodeEffectPosition[1].length];
58

    
59
    float init_amplitude = 1/8.0f;
60
    float end_amplitude  = 0.0f;
61
    float length         = 1/8.0f;
62
    float init_phase     = 0.0f;
63
    float end_phase      = 360.0f;
64
    float alpha          = 30.0f;
65
    float beta           = 90.0f;
66

    
67
    Dynamic5D d1 = new Dynamic5D(duration/2, 0.5f);
68
    d1.add(new Static5D( init_amplitude, length, init_phase, alpha, beta) );
69
    d1.add(new Static5D( end_amplitude , length, end_phase , alpha, beta) );
70
    Static3D center = new Static3D(0,0,0);
71
    mNodeEffects[1][0] = new VertexEffectWave(d1, center, null);
72

    
73
    Dynamic1D d0 = new Dynamic1D(duration/2, 0.5f);
74
    d0.add(new Static1D(0.0f));
75
    d0.add(new Static1D(1.0f));
76
    mNodeEffects[1][1] = new FragmentEffectAlpha(d0);
77

    
78
    return 2;
79
    }
80

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

    
84
  @SuppressWarnings("unused")
85
  static void enable()
86
    {
87
    FragmentEffectAlpha.enable();
88
    VertexEffectWave.enable();
89
    }
90
  }
(6-6/6)