Project

General

Profile

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

magiccube / src / main / java / org / distorted / bandaged / BandagedCubit.java @ c279ea6d

1
///////////////////////////////////////////////////////////////////////////////////////////////////
2
// Copyright 2022 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.bandaged;
21

    
22
import org.distorted.library.effect.MatrixEffectMove;
23
import org.distorted.library.effect.MatrixEffectQuaternion;
24
import org.distorted.library.effect.MatrixEffectScale;
25
import org.distorted.library.main.DistortedEffects;
26
import org.distorted.library.main.DistortedNode;
27
import org.distorted.library.main.DistortedTexture;
28
import org.distorted.library.mesh.MeshBase;
29
import org.distorted.library.type.Static3D;
30
import org.distorted.library.type.Static4D;
31
import org.distorted.objectlib.helpers.FactoryBandaged3x3Cubit;
32

    
33
///////////////////////////////////////////////////////////////////////////////////////////////////
34

    
35
public class BandagedCubit
36
{
37
    private static final Static3D CENTER = new Static3D(0,0,0);
38

    
39
    private final DistortedNode mNode;
40
    private final DistortedTexture mTexture;
41
    private final DistortedEffects mEffects;
42
    private final MeshBase mMesh;
43
    private final float[] mPosition;
44

    
45
///////////////////////////////////////////////////////////////////////////////////////////////////
46
// PUBLIC API
47
///////////////////////////////////////////////////////////////////////////////////////////////////
48

    
49
    public BandagedCubit(float[] position, Static4D quat1, Static4D quat2, Static3D move1, Static3D move2, Static3D scale, int color)
50
      {
51
      mPosition = position;
52

    
53
      FactoryBandaged3x3Cubit factory = FactoryBandaged3x3Cubit.getInstance();
54
      mMesh = factory.createMesh(position);
55

    
56
      mTexture = new DistortedTexture();
57
      mTexture.setColorARGB(color);
58

    
59
      MatrixEffectScale scaleEffect = new MatrixEffectScale(scale);
60
      MatrixEffectQuaternion quat1Effect = new MatrixEffectQuaternion(quat1, CENTER);
61
      MatrixEffectQuaternion quat2Effect = new MatrixEffectQuaternion(quat2, CENTER);
62
      MatrixEffectMove move1Effect = new MatrixEffectMove(move1);
63
      MatrixEffectMove move2Effect = new MatrixEffectMove(move2);
64

    
65
      mEffects = new DistortedEffects();
66
      mEffects.apply(scaleEffect);
67
      mEffects.apply(move1Effect);
68
      mEffects.apply(quat2Effect);
69
      mEffects.apply(quat1Effect);
70
      mEffects.apply(move2Effect);
71

    
72
      mNode = new DistortedNode(mTexture,mEffects,mMesh);
73
      }
74

    
75
///////////////////////////////////////////////////////////////////////////////////////////////////
76

    
77
    public void setTexture(int color)
78
      {
79
      mTexture.setColorARGB(color);
80
      }
81

    
82
///////////////////////////////////////////////////////////////////////////////////////////////////
83

    
84
    public DistortedNode getNode()
85
      {
86
      return mNode;
87
      }
88
}
89

    
(5-5/10)