Project

General

Profile

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

magiccube / src / main / java / org / distorted / object / RubikObjectList.java @ a10ada2a

1 27a70eae Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
2
// Copyright 2020 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.object;
21
22
import org.distorted.library.main.DistortedEffects;
23
import org.distorted.library.main.DistortedTexture;
24 97c012ae Leszek Koltunski
import org.distorted.library.mesh.MeshRectangles;
25 a10ada2a Leszek Koltunski
import org.distorted.library.type.Static3D;
26 27a70eae Leszek Koltunski
import org.distorted.library.type.Static4D;
27
import org.distorted.magic.R;
28
29 74686c71 Leszek Koltunski
import static org.distorted.magic.RubikRenderer.TEXTURE_SIZE;
30
31 27a70eae Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
32
33
public enum RubikObjectList
34
  {
35
  CUBE2 ( 2, R.drawable.button2 , RubikCube.class, RubikCubeMovement.class),
36
  CUBE3 ( 3, R.drawable.button3 , RubikCube.class, RubikCubeMovement.class),
37
  CUBE4 ( 4, R.drawable.button4 , RubikCube.class, RubikCubeMovement.class),
38
  CUBE5 ( 5, R.drawable.button5 , RubikCube.class, RubikCubeMovement.class),
39
  ;
40
41
  public static final int VECTX = 0;  //
42
  public static final int VECTY = 1;  // don't change this
43
  public static final int VECTZ = 2;  //
44 a10ada2a Leszek Koltunski
  static final Static3D VectX = new Static3D(1,0,0);
45
  static final Static3D VectY = new Static3D(0,1,0);
46
  static final Static3D VectZ = new Static3D(0,0,1);
47 27a70eae Leszek Koltunski
48
  public static final int LENGTH = values().length;
49
  private final int mObjectSize, mIconID;
50
  final Class<? extends RubikObject> mObjectClass;
51
  final Class<? extends RubikObjectMovement> mObjectMovementClass;
52
  private static final RubikObjectList[] objects;
53
54
  static
55
    {
56
    int i = 0;
57
    objects = new RubikObjectList[LENGTH];
58
59
    for(RubikObjectList size: RubikObjectList.values())
60
      {
61
      objects[i] = size;
62
      i++;
63
      }
64
    }
65
66
///////////////////////////////////////////////////////////////////////////////////////////////////
67
68
  public static RubikObjectList getObject(int ordinal)
69
    {
70
    return objects[ordinal];
71
    }
72
73
///////////////////////////////////////////////////////////////////////////////////////////////////
74
75
  RubikObjectList(int size, int iconID, Class<? extends RubikObject > object, Class<? extends RubikObjectMovement> movement)
76
    {
77
    mObjectSize = size;
78
    mIconID     = iconID;
79
    mObjectClass= object;
80
    mObjectMovementClass = movement;
81
    }
82
83
///////////////////////////////////////////////////////////////////////////////////////////////////
84
85
  public int getIconID()
86
    {
87
    return mIconID;
88
    }
89
90
///////////////////////////////////////////////////////////////////////////////////////////////////
91 74686c71 Leszek Koltunski
// TODO - currently all objects in the list are RubikCubes of various sizes
92 27a70eae Leszek Koltunski
93 74686c71 Leszek Koltunski
  public RubikObject create(Static4D quatCur, Static4D quatAcc)
94 27a70eae Leszek Koltunski
    {
95 74686c71 Leszek Koltunski
    DistortedTexture texture = new DistortedTexture(TEXTURE_SIZE,TEXTURE_SIZE);
96
    DistortedEffects effects = new DistortedEffects();
97 97c012ae Leszek Koltunski
    MeshRectangles mesh      = new MeshRectangles(20,20);
98 74686c71 Leszek Koltunski
99 27a70eae Leszek Koltunski
    return new RubikCube(mObjectSize, quatCur, quatAcc, texture, mesh, effects);
100
    }
101
102
///////////////////////////////////////////////////////////////////////////////////////////////////
103 74686c71 Leszek Koltunski
// TODO - currently all objects in the list are RubikCubes of various sizes
104 27a70eae Leszek Koltunski
105
  public RubikObjectMovement getObjectMovementClass()
106
    {
107
    return new RubikCubeMovement();
108
    }
109
  }