Project

General

Profile

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

magiccube / src / main / java / org / distorted / control / RubikControlRotate.java @ 51f51f83

1 51f51f83 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
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
45
///////////////////////////////////////////////////////////////////////////////////////////////////
46
47
  private void createEffects()
48
    {
49
    if( mEffects==null )
50
      {
51
      mEffects   = new DistortedEffects[NUM_NODE];
52
      mEffects[0]= new DistortedEffects();
53
54
      Static3D scaleStart= new Static3D(1,1,1);
55
      Static3D scaleEnd  = new Static3D(1000,1000,1000);
56
57
      mDynamic = new Dynamic3D(10000,0.5f);
58
      mDynamic.add(scaleStart);
59
      mDynamic.add(scaleEnd  );
60
      mDynamic.add(scaleStart);
61
      mDynamic.setMode(Dynamic.MODE_PATH);
62
63
      mScale = new MatrixEffectScale(mDynamic);
64
      mScale.notifyWhenFinished(mControl);
65
      mEffectID = mScale.getID();
66
      mEffects[0].apply(mScale);
67
      }
68
    else
69
      {
70
      mDynamic.resetToBeginning();
71
      mScale.notifyWhenFinished(mControl);
72
      }
73
    }
74
75
///////////////////////////////////////////////////////////////////////////////////////////////////
76
77
  private void createNodes()
78
    {
79
    if( mNodes==null )
80
      {
81
      mNodes = new DistortedNode[NUM_NODE];
82
      MeshQuad mesh = new MeshQuad();
83
      DistortedTexture texture = new DistortedTexture();
84
      texture.setColorARGB(0xff00ff00);
85
86
      mNodes[0]= new DistortedNode(texture,mEffects[0],mesh);
87
      }
88
    }
89
90
///////////////////////////////////////////////////////////////////////////////////////////////////
91
92
  long getEffectID()
93
    {
94
    return mEffectID;
95
    }
96
97
///////////////////////////////////////////////////////////////////////////////////////////////////
98
99
  DistortedNode[] getNodes()
100
    {
101
    createEffects();
102
    createNodes();
103
104
    return mNodes;
105
    }
106
107
///////////////////////////////////////////////////////////////////////////////////////////////////
108
109
  DistortedNode[] returnNodes()
110
    {
111
    return mNodes;
112
    }
113
114
///////////////////////////////////////////////////////////////////////////////////////////////////
115
116
  RubikControlRotate(RubikControl control)
117
    {
118
    mControl = control;
119
    }
120
  }