Project

General

Profile

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

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

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 org.distorted.library.type.Data3D;
24

    
25
///////////////////////////////////////////////////////////////////////////////////////////////////
26

    
27
/**
28
 * Move the Mesh with a given vector.
29
 */
30
public class VertexEffectMove extends VertexEffect
31
  {
32
  private static final EffectName NAME = EffectName.VERTEX_MOVE;
33

    
34
  private final Data3D mVector;
35

    
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
    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
    }
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
    addEffect( NAME, code() );
63
    }
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
    super(NAME);
74
    mVector = vector;
75
    }
76
  }
(26-26/34)