Project

General

Profile

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

library / src / main / java / org / distorted / library / effect / VertexEffectMove.java @ c0255951

1 e979d285 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
2 cc62b34a Leszek Koltunski
// Copyright 2017 Leszek Koltunski  leszek@koltunski.pl                                          //
3 e979d285 Leszek Koltunski
//                                                                                               //
4
// This file is part of Distorted.                                                               //
5
//                                                                                               //
6 cc62b34a Leszek Koltunski
// 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 e979d285 Leszek Koltunski
//                                                                                               //
11 cc62b34a Leszek Koltunski
// This library is distributed in the hope that it will be useful,                               //
12 e979d285 Leszek Koltunski
// but WITHOUT ANY WARRANTY; without even the implied warranty of                                //
13 cc62b34a Leszek Koltunski
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU                             //
14
// Lesser General Public License for more details.                                               //
15 e979d285 Leszek Koltunski
//                                                                                               //
16 cc62b34a Leszek Koltunski
// 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 e979d285 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
20
21
package org.distorted.library.effect;
22
23
import org.distorted.library.type.Data3D;
24
25
///////////////////////////////////////////////////////////////////////////////////////////////////
26
27
/**
28 943b2e18 Leszek Koltunski
 * Move the Mesh with a given vector.
29 e979d285 Leszek Koltunski
 */
30
public class VertexEffectMove extends VertexEffect
31
  {
32 f046b159 Leszek Koltunski
  private static final EffectName NAME = EffectName.VERTEX_MOVE;
33
34 0e1d3d2e Leszek Koltunski
  private final Data3D mVector;
35 e979d285 Leszek Koltunski
36
///////////////////////////////////////////////////////////////////////////////////////////////////
37
/**
38
 * Only for use by the library itself.
39
 *
40
 * @y.exclude
41
 */
42
  public boolean compute(float[] uniforms, int index, long currentDuration, long step )
43
    {
44 f046b159 Leszek Koltunski
    return mVector.get(uniforms,index+VALUES_OFFSET,currentDuration,step);
45
    }
46
47
///////////////////////////////////////////////////////////////////////////////////////////////////
48
49
  static String code()
50
    {
51
    return "v += vUniforms[effect].xyz;";
52 e979d285 Leszek Koltunski
    }
53
54
///////////////////////////////////////////////////////////////////////////////////////////////////
55
// PUBLIC API
56
///////////////////////////////////////////////////////////////////////////////////////////////////
57
/**
58
 * Have to call this before the shaders get compiled (i.e before DistortedLibrary.onCreate()) for the Effect to work.
59
 */
60
  public static void enable()
61
    {
62 f046b159 Leszek Koltunski
    addEffect( NAME, code() );
63 e979d285 Leszek Koltunski
    }
64
65
///////////////////////////////////////////////////////////////////////////////////////////////////
66
/**
67
 * Move the whole Mesh with a (possibly changing in time) vector.
68
 *
69
 * @param vector Vector by which to move the Mesh.
70
 */
71
  public VertexEffectMove(Data3D vector)
72
    {
73 f046b159 Leszek Koltunski
    super(NAME);
74 e979d285 Leszek Koltunski
    mVector = vector;
75
    }
76
  }