Project

General

Profile

Download (3.45 KB) Statistics
| Branch: | Revision:

library / src / main / java / org / distorted / library / effect / MatrixEffectMove.java @ c226920c

1
///////////////////////////////////////////////////////////////////////////////////////////////////
2
// Copyright 2017 Leszek Koltunski  leszek@koltunski.pl                                          //
3
//                                                                                               //
4
// This file is part of Distorted.                                                               //
5
//                                                                                               //
6
// This library is free software; you can redistribute it and/or                                 //
7
// modify it under the terms of the GNU Lesser General Public                                    //
8
// License as published by the Free Software Foundation; either                                  //
9
// version 2.1 of the License, or (at your option) any later version.                            //
10
//                                                                                               //
11
// This library 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 GNU                             //
14
// Lesser General Public License for more details.                                               //
15
//                                                                                               //
16
// You should have received a copy of the GNU Lesser General Public                              //
17
// License along with this library; if not, write to the Free Software                           //
18
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA                //
19
///////////////////////////////////////////////////////////////////////////////////////////////////
20

    
21
package org.distorted.library.effect;
22

    
23
import android.opengl.Matrix;
24

    
25
import org.distorted.library.type.Data3D;
26

    
27
///////////////////////////////////////////////////////////////////////////////////////////////////
28
/**
29
 * Move the Mesh by a 3D vector.
30
 */
31
public class MatrixEffectMove extends MatrixEffect
32
  {
33
  private final Data3D mVector;
34

    
35
///////////////////////////////////////////////////////////////////////////////////////////////////
36
/**
37
 * Only for use by the library itself.
38
 *
39
 * @y.exclude
40
 */
41
  public boolean compute(float[] uniforms, int index, long currentDuration, long step )
42
    {
43
    return mVector.get(uniforms,index,currentDuration,step);
44
    }
45

    
46
///////////////////////////////////////////////////////////////////////////////////////////////////
47
/**
48
 * Only for use by the library itself.
49
 *
50
 * @y.exclude
51
 */
52
  public void apply(float[] matrixP, float[] matrixV, float[] uniforms, int index)
53
    {
54
    float sx = uniforms[NUM_FLOAT_UNIFORMS*index  ];
55
    float sy = uniforms[NUM_FLOAT_UNIFORMS*index+1];
56
    float sz = uniforms[NUM_FLOAT_UNIFORMS*index+2];
57

    
58
    Matrix.translateM(matrixP, 0, sx, sy, sz);
59
    Matrix.translateM(matrixV, 0, sx, sy, sz);
60
    }
61

    
62
///////////////////////////////////////////////////////////////////////////////////////////////////
63
// PUBLIC API
64
///////////////////////////////////////////////////////////////////////////////////////////////////
65
/**
66
 * Move the Mesh by a 3D vector.
67
 *
68
 * @param vector current coordinates of the vector we want to move the Mesh with.
69
 */
70
  public MatrixEffectMove(Data3D vector)
71
    {
72
    super(EffectName.MOVE);
73
    mVector = vector;
74
    }
75
  }
(12-12/34)