Project

General

Profile

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

magiccube / src / main / java / org / distorted / control / RubikControlRotate.java @ 8badfe2a

1
///////////////////////////////////////////////////////////////////////////////////////////////////
2
// Copyright 2021 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.control;
21

    
22
import org.distorted.library.effect.MatrixEffectScale;
23
import org.distorted.library.main.DistortedEffects;
24
import org.distorted.library.main.DistortedNode;
25
import org.distorted.library.main.DistortedTexture;
26
import org.distorted.library.mesh.MeshQuad;
27
import org.distorted.library.type.Dynamic;
28
import org.distorted.library.type.Dynamic3D;
29
import org.distorted.library.type.Static3D;
30

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

    
33
class RubikControlRotate
34
  {
35
  private static final int NUM_NODE = 1;
36

    
37
  private final RubikControl mControl;
38
  private DistortedEffects[] mEffects;
39
  private DistortedNode[] mNodes;
40
  private long mEffectID;
41

    
42
  private Dynamic3D mDynamic;
43
  private MatrixEffectScale mScale;
44
  private MeshQuad mQuad;
45

    
46
///////////////////////////////////////////////////////////////////////////////////////////////////
47

    
48
  private void createEffects()
49
    {
50
    if( mEffects==null )
51
      {
52
      mEffects   = new DistortedEffects[NUM_NODE];
53
      mEffects[0]= new DistortedEffects();
54

    
55
      Static3D scaleStart= new Static3D(1,1,1);
56
      Static3D scaleEnd  = new Static3D(1000,1000,1000);
57

    
58
      mDynamic = new Dynamic3D(10000,0.5f);
59
      mDynamic.add(scaleStart);
60
      mDynamic.add(scaleEnd  );
61
      mDynamic.add(scaleStart);
62
      mDynamic.setMode(Dynamic.MODE_PATH);
63

    
64
      mScale = new MatrixEffectScale(mDynamic);
65
      mScale.notifyWhenFinished(mControl);
66
      mEffectID = mScale.getID();
67
      mEffects[0].apply(mScale);
68
      }
69
    else
70
      {
71
      mDynamic.resetToBeginning();
72
      mScale.notifyWhenFinished(mControl);
73
      }
74
    }
75

    
76
///////////////////////////////////////////////////////////////////////////////////////////////////
77

    
78
  private void createNodes()
79
    {
80
    if( mNodes==null )
81
      {
82
      mNodes = new DistortedNode[NUM_NODE];
83
      mQuad = new MeshQuad();
84
      }
85

    
86
    DistortedTexture texture = new DistortedTexture();
87
    texture.setColorARGB(0xff00ff00);
88
    mNodes[0] = new DistortedNode(texture, mEffects[0], mQuad);
89
    }
90

    
91
///////////////////////////////////////////////////////////////////////////////////////////////////
92

    
93
  long getEffectID()
94
    {
95
    return mEffectID;
96
    }
97

    
98
///////////////////////////////////////////////////////////////////////////////////////////////////
99

    
100
  DistortedNode[] getNodes()
101
    {
102
    createEffects();
103
    createNodes();
104

    
105
    return mNodes;
106
    }
107

    
108
///////////////////////////////////////////////////////////////////////////////////////////////////
109

    
110
  DistortedNode[] returnNodes()
111
    {
112
    return mNodes;
113
    }
114

    
115
///////////////////////////////////////////////////////////////////////////////////////////////////
116

    
117
  RubikControlRotate(RubikControl control)
118
    {
119
    mControl = control;
120
    }
121
  }
(2-2/3)