Project

General

Profile

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

magiccube / src / main / java / org / distorted / object / RubikObjectList.java @ 869a4528

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 27a70eae Leszek Koltunski
import org.distorted.library.type.Static4D;
26
import org.distorted.magic.R;
27
28
///////////////////////////////////////////////////////////////////////////////////////////////////
29
30
public enum RubikObjectList
31
  {
32 49f67f9b Leszek Koltunski
  CUBE2 ( 1, R.drawable.cube2, RubikCube.class, RubikCubeMovement.class),
33
  CUBE3 ( 2, R.drawable.cube3, RubikCube.class, RubikCubeMovement.class),
34
  CUBE4 ( 3, R.drawable.cube4, RubikCube.class, RubikCubeMovement.class),
35
  CUBE5 ( 4, R.drawable.cube5, RubikCube.class, RubikCubeMovement.class),
36 27a70eae Leszek Koltunski
  ;
37
38
  public static final int LENGTH = values().length;
39
  private final int mObjectSize, mIconID;
40
  final Class<? extends RubikObject> mObjectClass;
41
  final Class<? extends RubikObjectMovement> mObjectMovementClass;
42
  private static final RubikObjectList[] objects;
43
44
  static
45
    {
46
    int i = 0;
47
    objects = new RubikObjectList[LENGTH];
48
49
    for(RubikObjectList size: RubikObjectList.values())
50
      {
51
      objects[i] = size;
52
      i++;
53
      }
54
    }
55
56
///////////////////////////////////////////////////////////////////////////////////////////////////
57
58
  public static RubikObjectList getObject(int ordinal)
59
    {
60
    return objects[ordinal];
61
    }
62
63
///////////////////////////////////////////////////////////////////////////////////////////////////
64
65
  RubikObjectList(int size, int iconID, Class<? extends RubikObject > object, Class<? extends RubikObjectMovement> movement)
66
    {
67
    mObjectSize = size;
68
    mIconID     = iconID;
69
    mObjectClass= object;
70
    mObjectMovementClass = movement;
71
    }
72
73
///////////////////////////////////////////////////////////////////////////////////////////////////
74
75
  public int getIconID()
76
    {
77
    return mIconID;
78
    }
79
80
///////////////////////////////////////////////////////////////////////////////////////////////////
81 74686c71 Leszek Koltunski
// TODO - currently all objects in the list are RubikCubes of various sizes
82 27a70eae Leszek Koltunski
83 74686c71 Leszek Koltunski
  public RubikObject create(Static4D quatCur, Static4D quatAcc)
84 27a70eae Leszek Koltunski
    {
85 5974d2ae Leszek Koltunski
    DistortedTexture texture = new DistortedTexture();
86 36273130 Leszek Koltunski
    DistortedEffects effects = new DistortedEffects();
87 b32444ee Leszek Koltunski
    MeshRectangles mesh      = new MeshRectangles(20,20);   // mesh of the node, not of the cubits
88 74686c71 Leszek Koltunski
89 869a4528 Leszek Koltunski
    return new RubikCube(mObjectSize, quatCur, quatAcc, texture, mesh, effects);
90 27a70eae Leszek Koltunski
    }
91
92
///////////////////////////////////////////////////////////////////////////////////////////////////
93 74686c71 Leszek Koltunski
// TODO - currently all objects in the list are RubikCubes of various sizes
94 27a70eae Leszek Koltunski
95
  public RubikObjectMovement getObjectMovementClass()
96
    {
97 869a4528 Leszek Koltunski
    return new RubikCubeMovement();
98 27a70eae Leszek Koltunski
    }
99
  }