Project

General

Profile

« Previous | Next » 

Revision 0e1d3d2e

Added by Leszek Koltunski almost 3 years ago

Extra API for QuatHelper.

View differences:

src/main/java/org/distorted/library/effect/FragmentEffectAlpha.java
29 29
 */
30 30
public class FragmentEffectAlpha extends FragmentEffect
31 31
  {
32
  private Data1D mAlpha;
33
  private Data3D mCenter;
34
  private Data3D mRegion;
32
  private final Data1D mAlpha;
33
  private final Data3D mCenter;
34
  private final Data3D mRegion;
35 35

  
36 36
///////////////////////////////////////////////////////////////////////////////////////////////////
37 37
/**
src/main/java/org/distorted/library/effect/FragmentEffectBrightness.java
29 29
 */
30 30
public class FragmentEffectBrightness extends FragmentEffect
31 31
  {
32
  private Data1D mBrightness;
33
  private Data3D mCenter;
34
  private Data3D mRegion;
32
  private final Data1D mBrightness;
33
  private final Data3D mCenter;
34
  private final Data3D mRegion;
35 35

  
36 36
///////////////////////////////////////////////////////////////////////////////////////////////////
37 37
/**
src/main/java/org/distorted/library/effect/FragmentEffectChroma.java
29 29
 */
30 30
public class FragmentEffectChroma extends FragmentEffect
31 31
  {
32
  private Data1D mBlend;
33
  private Data3D mColor;
34
  private Data3D mCenter;
35
  private Data3D mRegion;
32
  private final Data1D mBlend;
33
  private final Data3D mColor;
34
  private final Data3D mCenter;
35
  private final Data3D mRegion;
36 36

  
37 37
///////////////////////////////////////////////////////////////////////////////////////////////////
38 38
/**
src/main/java/org/distorted/library/effect/FragmentEffectContrast.java
29 29
 */
30 30
public class FragmentEffectContrast extends FragmentEffect
31 31
  {
32
  private Data1D mContrast;
33
  private Data3D mCenter;
34
  private Data3D mRegion;
32
  private final Data1D mContrast;
33
  private final Data3D mCenter;
34
  private final Data3D mRegion;
35 35

  
36 36
///////////////////////////////////////////////////////////////////////////////////////////////////
37 37
/**
src/main/java/org/distorted/library/effect/FragmentEffectSaturation.java
29 29
 */
30 30
public class FragmentEffectSaturation extends FragmentEffect
31 31
  {
32
  private Data1D mSaturation;
33
  private Data3D mCenter;
34
  private Data3D mRegion;
32
  private final Data1D mSaturation;
33
  private final Data3D mCenter;
34
  private final Data3D mRegion;
35 35

  
36 36
///////////////////////////////////////////////////////////////////////////////////////////////////
37 37
/**
src/main/java/org/distorted/library/effect/MatrixEffectMove.java
29 29
 */
30 30
public class MatrixEffectMove extends MatrixEffect
31 31
  {
32
  private Data3D mVector;
32
  private final Data3D mVector;
33 33

  
34 34
///////////////////////////////////////////////////////////////////////////////////////////////////
35 35
/**
src/main/java/org/distorted/library/effect/MatrixEffectRotate.java
30 30
 */
31 31
public class MatrixEffectRotate extends MatrixEffect
32 32
  {
33
  private Data1D mAngle;
34
  private Data3D mAxis, mCenter;
33
  private final Data1D mAngle;
34
  private final Data3D mAxis, mCenter;
35 35

  
36 36
///////////////////////////////////////////////////////////////////////////////////////////////////
37 37
/**
src/main/java/org/distorted/library/effect/VertexEffectDeform.java
31 31
  {
32 32
  private static final EffectName NAME = EffectName.DEFORM;
33 33

  
34
  private Data3D mVector, mCenter;
35
  private Data1D mRadius;
36
  private Data4D mRegion;
34
  private final Data3D mVector, mCenter;
35
  private final Data1D mRadius;
36
  private final Data4D mRegion;
37 37

  
38 38
///////////////////////////////////////////////////////////////////////////////////////////////////
39 39
/**
src/main/java/org/distorted/library/effect/VertexEffectDistort.java
30 30
  {
31 31
  private static final EffectName NAME = EffectName.DISTORT;
32 32

  
33
  private Data3D mVector, mCenter;
34
  private Data4D mRegion;
33
  private final Data3D mVector, mCenter;
34
  private final Data4D mRegion;
35 35

  
36 36
///////////////////////////////////////////////////////////////////////////////////////////////////
37 37
/**
src/main/java/org/distorted/library/effect/VertexEffectMove.java
30 30
  {
31 31
  private static final EffectName NAME = EffectName.VERTEX_MOVE;
32 32

  
33
  private Data3D mVector;
33
  private final Data3D mVector;
34 34

  
35 35
///////////////////////////////////////////////////////////////////////////////////////////////////
36 36
/**
src/main/java/org/distorted/library/effect/VertexEffectPinch.java
36 36
  {
37 37
  private static final EffectName NAME = EffectName.PINCH;
38 38

  
39
  private Data3D mPinch;
40
  private Data3D mCenter;
41
  private Data4D mRegion;
39
  private final Data3D mPinch;
40
  private final Data3D mCenter;
41
  private final Data4D mRegion;
42 42

  
43 43
///////////////////////////////////////////////////////////////////////////////////////////////////
44 44
/**
src/main/java/org/distorted/library/effect/VertexEffectQuaternion.java
31 31
  {
32 32
  private static final EffectName NAME = EffectName.VERTEX_QUATERNION;
33 33

  
34
  private Data4D mQuaternion;
35
  private Data3D mCenter;
34
  private final Data4D mQuaternion;
35
  private final Data3D mCenter;
36 36

  
37 37
///////////////////////////////////////////////////////////////////////////////////////////////////
38 38
/**
src/main/java/org/distorted/library/effect/VertexEffectScale.java
30 30
  {
31 31
  private static final EffectName NAME = EffectName.VERTEX_SCALE;
32 32

  
33
  private Data3D mScale;
33
  private final Data3D mScale;
34 34

  
35 35
///////////////////////////////////////////////////////////////////////////////////////////////////
36 36
/**
src/main/java/org/distorted/library/effect/VertexEffectSink.java
32 32
  {
33 33
  private static final EffectName NAME = EffectName.SINK;
34 34

  
35
  private Data1D mSink;
36
  private Data3D mCenter;
37
  private Data4D mRegion;
35
  private final Data1D mSink;
36
  private final Data3D mCenter;
37
  private final Data4D mRegion;
38 38

  
39 39
///////////////////////////////////////////////////////////////////////////////////////////////////
40 40
/**
src/main/java/org/distorted/library/effect/VertexEffectSwirl.java
36 36
  {
37 37
  private static final EffectName NAME = EffectName.SWIRL;
38 38

  
39
  private Data1D mSwirl;
40
  private Data3D mCenter;
41
  private Data4D mRegion;
39
  private final Data1D mSwirl;
40
  private final Data3D mCenter;
41
  private final Data4D mRegion;
42 42

  
43 43
///////////////////////////////////////////////////////////////////////////////////////////////////
44 44
/**
src/main/java/org/distorted/library/effect/VertexEffectWave.java
35 35
  {
36 36
  private static final EffectName NAME = EffectName.WAVE;
37 37

  
38
  private Data5D mWave;
39
  private Data3D mCenter;
40
  private Data4D mRegion;
38
  private final Data5D mWave;
39
  private final Data3D mCenter;
40
  private final Data4D mRegion;
41 41

  
42 42
///////////////////////////////////////////////////////////////////////////////////////////////////
43 43
/**
src/main/java/org/distorted/library/main/QuatHelper.java
108 108
    ret[3] = r[3]*q[3] - r[2]*q[2] - r[1]*q[1] - r[0]*q[0];
109 109
    }
110 110

  
111
///////////////////////////////////////////////////////////////////////////////////////////////////
112
// ret = (qx,qy,qz,qw)*(rx,ry,rz,rw)
113

  
114
  public static void quatMultiply( float[] ret, float qx, float qy, float qz, float qw, float rx, float ry, float rz, float rw )
115
    {
116
    ret[0] = rw*qx - rz*qy + ry*qz + rx*qw;
117
    ret[1] = rw*qy + rz*qx + ry*qw - rx*qz;
118
    ret[2] = rw*qz + rz*qw - ry*qx + rx*qy;
119
    ret[3] = rw*qw - rz*qz - ry*qy - rx*qx;
120
    }
121

  
111 122
///////////////////////////////////////////////////////////////////////////////////////////////////
112 123
// rotate 'vector' by quat  ( i.e. return quat*vector*(quat^-1) )
113 124

  
......
138 149
    return quatMultiply(tmp,-qx,-qy,-qz,qw);
139 150
    }
140 151

  
152
///////////////////////////////////////////////////////////////////////////////////////////////////
153
// rotate (x1,x2,x3,x4) by quat  ( i.e. return quat*vector*(quat^-1) )
154

  
155
  public static void rotateVectorByQuat(float[] output, float x, float y, float z, float w, Static4D quat)
156
    {
157
    float[] tmp = new float[4];
158

  
159
    float qx = quat.get0();
160
    float qy = quat.get1();
161
    float qz = quat.get2();
162
    float qw = quat.get3();
163

  
164
    quatMultiply(tmp,qx,qy,qz,qw,x,y,z,w);
165
    quatMultiply(output,tmp[0],tmp[1],tmp[2],tmp[3],-qx,-qy,-qz,qw);
166
    }
167

  
141 168
///////////////////////////////////////////////////////////////////////////////////////////////////
142 169
// rotate vec by quat ( i.e. return quat*vector*(quat^-1) )
143 170

  

Also available in: Unified diff