Project

General

Profile

« Previous | Next » 

Revision a918bba1

Added by Leszek Koltunski about 4 years ago

new VertexEffectScale

View differences:

src/main/java/org/distorted/library/effect/EffectName.java
58 58
  VERTEX_MOVE      ( EffectType.VERTEX  ,   new float[] {0.0f,0.0f,0.0f} , 3, 0,     0    , VertexEffectMove.class         ),
59 59
  VERTEX_QUATERNION( EffectType.VERTEX  ,   new float[] {0.0f,0.0f,0.0f} , 4, 0,     3    , VertexEffectQuaternion.class   ),
60 60
  VERTEX_ROTATE    ( EffectType.VERTEX  ,   new float[] {0.0f}           , 4, 0,     3    , VertexEffectRotate.class       ),
61
  VERTEX_SCALE     ( EffectType.VERTEX  ,   new float[] {1.0f,1.0f,1.0f} , 3, 0,     0    , VertexEffectScale.class        ),
61 62

  
62 63
  ALPHA            ( EffectType.FRAGMENT,   new float[] {1.0f}           , 1, 3,     3    , FragmentEffectAlpha.class      ),
63 64
  SMOOTH_ALPHA     ( EffectType.FRAGMENT,   new float[] {1.0f}           , 1, 3,     3    , FragmentEffectAlpha.class      ),
src/main/java/org/distorted/library/effect/VertexEffectScale.java
1
///////////////////////////////////////////////////////////////////////////////////////////////////
2
// Copyright 2020 Leszek Koltunski                                                               //
3
//                                                                                               //
4
// This file is part of Distorted.                                                               //
5
//                                                                                               //
6
// Distorted 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
// Distorted 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 Distorted.  If not, see <http://www.gnu.org/licenses/>.                            //
18
///////////////////////////////////////////////////////////////////////////////////////////////////
19

  
20
package org.distorted.library.effect;
21

  
22
import org.distorted.library.type.Data3D;
23
import org.distorted.library.type.Static3D;
24

  
25
///////////////////////////////////////////////////////////////////////////////////////////////////
26
/**
27
 * Scale the Mesh by 3D scale factors.
28
 */
29
public class VertexEffectScale extends VertexEffect
30
  {
31
  private Data3D mScale;
32

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

  
44
///////////////////////////////////////////////////////////////////////////////////////////////////
45
// PUBLIC API
46
///////////////////////////////////////////////////////////////////////////////////////////////////
47
/**
48
 * Have to call this before the shaders get compiled (i.e before DistortedLibrary.onCreate()) for the Effect to work.
49
 */
50
  public static void enable()
51
    {
52
    addEffect( EffectName.VERTEX_SCALE, "v *= vUniforms[effect].xyz;" );
53
    }
54

  
55
///////////////////////////////////////////////////////////////////////////////////////////////////
56
/**
57
 * Scale the Mesh by 3D scale factors.
58
 *
59
 * @param scale current x- , y- and z- scale factors.
60
 */
61
  public VertexEffectScale(Data3D scale)
62
    {
63
    super(EffectName.VERTEX_SCALE);
64
    mScale = scale;
65
    }
66

  
67
///////////////////////////////////////////////////////////////////////////////////////////////////
68
/**
69
 * Scale the Mesh by 3D scale factors.
70
 *
71
 * @param scale Common x,y, and z scale factor.
72
 */
73
  public VertexEffectScale(float scale)
74
    {
75
    super(EffectName.VERTEX_SCALE);
76
    mScale = new Static3D(scale,scale,scale);
77
    }
78
  }

Also available in: Unified diff