Project

General

Profile

« Previous | Next » 

Revision c0255951

Added by Leszek Koltunski 12 months ago

Completely kick out the android.opengl.Matrix dependency from the library.

View differences:

src/main/java/org/distorted/library/helpers/MatrixHelper.java
123 123
    }
124 124

  
125 125
///////////////////////////////////////////////////////////////////////////////////////////////////
126
// this is android.opengl.Matrix.rotateM(), but with pre-computed sin and cos of the angle
127
// and also we have to pre-allocate and pass here two temp arrays.
126 128

  
127
  public static void rotate(float[] output, float angle, float axisX, float axisY, float axisZ)
129
  public static void rotateSinCos(float[] output, float[] tmp1, float[] tmp2, float sin, float cos, float x, float y, float z)
128 130
    {
129
    android.opengl.Matrix.rotateM(output,0,angle,axisX,axisY,axisZ);
131
    tmp1[0]  = (1-cos)*x*x + cos;
132
    tmp1[1]  = (1-cos)*x*y + sin*z;
133
    tmp1[2]  = (1-cos)*x*z - sin*y;
134
    tmp1[3]  = 0;
135
    tmp1[4]  = (1-cos)*x*y - sin*z;
136
    tmp1[5]  = (1-cos)*y*y + cos;
137
    tmp1[6]  = (1-cos)*y*z + sin*x;
138
    tmp1[7]  = 0;
139
    tmp1[8]  = (1-cos)*x*z + sin*y;
140
    tmp1[9]  = (1-cos)*y*z - sin*x;
141
    tmp1[10] = (1-cos)*z*z + cos;
142
    tmp1[11] = 0;
143
    tmp1[12] = 0;
144
    tmp1[13] = 0;
145
    tmp1[14] = 0;
146
    tmp1[15] = 1;
147

  
148
    tmp2[0]  =  output[ 0];
149
    tmp2[1]  =  output[ 1];
150
    tmp2[2]  =  output[ 2];
151
    tmp2[3]  =  output[ 3];
152
    tmp2[4]  =  output[ 4];
153
    tmp2[5]  =  output[ 5];
154
    tmp2[6]  =  output[ 6];
155
    tmp2[7]  =  output[ 7];
156
    tmp2[8]  =  output[ 8];
157
    tmp2[9]  =  output[ 9];
158
    tmp2[10] =  output[10];
159
    tmp2[11] =  output[11];
160
    tmp2[12] =  output[12];
161
    tmp2[13] =  output[13];
162
    tmp2[14] =  output[14];
163
    tmp2[15] =  output[15];
164

  
165
    multiply(output,tmp2,tmp1);
130 166
    }
131 167

  
132 168
///////////////////////////////////////////////////////////////////////////////////////////////////

Also available in: Unified diff