|
1 | 1 | package cleargl; |
2 | 2 |
|
| 3 | +import static java.lang.Math.*; |
| 4 | +import java.io.Serializable; |
| 5 | +import java.nio.ByteBuffer; |
3 | 6 | import com.jogamp.opengl.math.FloatUtil; |
4 | 7 | import com.jogamp.opengl.math.Quaternion; |
5 | 8 | import com.jogamp.opengl.math.VectorUtil; |
6 | 9 |
|
7 | | -import java.io.Serializable; |
8 | | -import java.nio.ByteBuffer; |
9 | | - |
10 | | -import static java.lang.Math.*; |
11 | | - |
12 | 10 | public class GLMatrix implements Serializable { |
13 | 11 |
|
14 | 12 | private final float[] mMatrix; |
@@ -96,7 +94,8 @@ public void multinv(final GLMatrix pGLMatrix) { |
96 | 94 | mult(pGLMatrix); |
97 | 95 | } |
98 | 96 |
|
99 | | - public GLMatrix setFrustumMatrix(final float left, final float right, final float bottom, final float top, final float near, final float far) { |
| 97 | + public GLMatrix setFrustumMatrix(final float left, final float right, final float bottom, final float top, |
| 98 | + final float near, final float far) { |
100 | 99 | FloatUtil.makeFrustum(mMatrix, 0, true, left, right, bottom, top, near, far); |
101 | 100 |
|
102 | 101 | return this; |
@@ -178,18 +177,19 @@ public GLMatrix setGeneralizedPerspectiveProjectionMatrix(final GLVector lowerLe |
178 | 177 | float top = Math.abs(lowerLeft.minus(upperLeft).y()) - res.y(); |
179 | 178 | float n = -res.z(); |
180 | 179 |
|
181 | | - float s = 0.1f/n; |
| 180 | + float s = 0.1f / n; |
182 | 181 |
|
183 | | - System.err.println(eye + ", " + (right + res.x()) + "/" + (top + res.y()) + " => " + distance + "/" + n + " -> " + left + "/" + right + "/"+bottom+"/"+top + ", s=" + s); |
184 | | - FloatUtil.makeFrustum(mMatrix, 0, true, left*s, right*s, bottom*s, top*s, n*s, far); |
| 182 | + System.err.println(eye + ", " + (right + res.x()) + "/" + (top + res.y()) + " => " + distance + "/" + n + " -> " |
| 183 | + + left + "/" + right + "/" + bottom + "/" + top + ", s=" + s); |
| 184 | + FloatUtil.makeFrustum(mMatrix, 0, true, left * s, right * s, bottom * s, top * s, n * s, far); |
185 | 185 |
|
186 | | - final GLMatrix flip = new GLMatrix(new float[] { |
| 186 | + final GLMatrix flip = new GLMatrix(new float[]{ |
187 | 187 | 1.0f, 0.0f, 0.0f, 0.0f, |
188 | 188 | 0.0f, 1.0f, 0.0f, 0.0f, |
189 | 189 | 0.0f, 0.0f, -1.0f, 0.0f, |
190 | 190 | 0.0f, 0.0f, 1.0f, 1.0f}); |
191 | 191 |
|
192 | | -// this.mult(flip); |
| 192 | + // this.mult(flip); |
193 | 193 | return this; |
194 | 194 | } |
195 | 195 |
|
@@ -604,12 +604,12 @@ public ByteBuffer put(ByteBuffer buffer) { |
604 | 604 | } |
605 | 605 |
|
606 | 606 | public ByteBuffer toBuffer() { |
607 | | - ByteBuffer b = ByteBuffer.allocateDirect(16*4); |
608 | | - b.asFloatBuffer().put(mMatrix); |
609 | | - b.position(0); |
610 | | - b.limit(16*4); |
| 607 | + ByteBuffer b = ByteBuffer.allocateDirect(16 * 4); |
| 608 | + b.asFloatBuffer().put(mMatrix); |
| 609 | + b.position(0); |
| 610 | + b.limit(16 * 4); |
611 | 611 |
|
612 | | - return b; |
| 612 | + return b; |
613 | 613 | } |
614 | 614 |
|
615 | 615 | } |
0 commit comments