Project

General

Profile

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

magiccube / src / main / java / org / distorted / control / RubikControlRotate.java @ 7a44bbc2

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.DistortedScreen;
26
import org.distorted.library.main.DistortedTexture;
27
import org.distorted.library.mesh.MeshQuad;
28
import org.distorted.library.type.Dynamic;
29
import org.distorted.library.type.Dynamic3D;
30
import org.distorted.library.type.Static3D;
31

    
32
///////////////////////////////////////////////////////////////////////////////////////////////////
33

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

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

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

    
47
///////////////////////////////////////////////////////////////////////////////////////////////////
48

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

    
56
      DistortedScreen screen = mControl.getScreen();
57
      int wid = screen.getWidth();
58

    
59
      Static3D scaleStart= new Static3D(1,1,1);
60
      Static3D scaleEnd  = new Static3D(wid,wid,wid);
61

    
62
      mDynamic = new Dynamic3D(10000,0.5f);
63
      mDynamic.add(scaleStart);
64
      mDynamic.add(scaleEnd  );
65
      mDynamic.add(scaleStart);
66
      mDynamic.setMode(Dynamic.MODE_PATH);
67

    
68
      mScale = new MatrixEffectScale(mDynamic);
69
      mScale.notifyWhenFinished(mControl);
70
      mEffectID = mScale.getID();
71
      mEffects[0].apply(mScale);
72
      }
73
    else
74
      {
75
      mDynamic.resetToBeginning();
76
      mScale.notifyWhenFinished(mControl);
77
      }
78
    }
79

    
80
///////////////////////////////////////////////////////////////////////////////////////////////////
81

    
82
  private void createNodes()
83
    {
84
    if( mNodes==null )
85
      {
86
      mNodes = new DistortedNode[NUM_NODE];
87
      mQuad = new MeshQuad();
88
      }
89

    
90
    DistortedTexture texture = new DistortedTexture();
91
    texture.setColorARGB(0xff00ff00);
92
    mNodes[0] = new DistortedNode(texture, mEffects[0], mQuad);
93
    }
94

    
95
///////////////////////////////////////////////////////////////////////////////////////////////////
96

    
97
  long getEffectID()
98
    {
99
    return mEffectID;
100
    }
101

    
102
///////////////////////////////////////////////////////////////////////////////////////////////////
103

    
104
  DistortedNode[] getNodes()
105
    {
106
    createEffects();
107
    createNodes();
108

    
109
    return mNodes;
110
    }
111

    
112
///////////////////////////////////////////////////////////////////////////////////////////////////
113

    
114
  DistortedNode[] returnNodes()
115
    {
116
    return mNodes;
117
    }
118

    
119
///////////////////////////////////////////////////////////////////////////////////////////////////
120

    
121
  RubikControlRotate(RubikControl control)
122
    {
123
    mControl = control;
124
    }
125
  }
(2-2/3)