aboutsummaryrefslogtreecommitdiffstats
path: root/src/ru/olamedia/geom/Frustum.java
blob: 1a9d58d078289d74f8ee29af1c1f25d5627b840e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package ru.olamedia.geom;

import java.nio.FloatBuffer;

import org.openmali.vecmath2.Matrix4f;

import com.jogamp.opengl.util.PMVMatrix;

//import org.openmali.spatial.bodies.Frustum;

public class Frustum extends org.openmali.spatial.bodies.Frustum {
	protected PMVMatrix pmvMatrix;
	protected int mvOffset;

	public Frustum() {
		super();
	}

	public Frustum(PMVMatrix matrix) {
		super();
		this.pmvMatrix = matrix;
	}

	public float[] getMatrixFloat(FloatBuffer b) {
		if (pmvMatrix.usesBackingArray()) {
			return b.array();
		} else {
			int p = b.position();
			float[] pm = new float[16];
			b.get(pm, p, 16);
			b.position(p);
			return pm;
		}
	}

	public void compute() {
		Matrix4f proj = new Matrix4f(getMatrixFloat(pmvMatrix.glGetPMatrixf()));
		// proj.transpose();
		Matrix4f modl = new Matrix4f(getMatrixFloat(pmvMatrix.glGetMviMatrixf()));
		// modl.transpose();
		compute(proj, modl);
	}
}