public MatrixCache() { this(new ProjectionMatrix()); }
/** * iplementierung der alten gl.perspectiv(...) funktion */ public void perspective(double fovy, double aspect, double znear, double zfar) { double top = tan(fovy * PI / 360.) * znear; double bottom = -top; double left = aspect * bottom; double right = aspect * top; frustum(left, right, bottom, top, znear, zfar); }
public void ortho(double left, double bottom, double near, double rigth, double top, double far) { float rl = (float) (rigth - left); float tb = (float) (top - bottom); float fn = (float) (far - near); loadIdentity(); float[] mat = getArray(); mat[0] = 2f / rl; mat[5] = 2f / tb; mat[10] = 2f / fn; mat[12] = (float) (-(rigth + left) / rl); mat[13] = (float) (-(top + bottom) / tb); mat[14] = (float) (-(far + near) / fn); mat[15] = 1f; } }
ProjectionMatrix lightp = new ProjectionMatrix(); lightp.ortho(mi[0], mi[1], mi[2], ma[0], ma[1], ma[2]); lightp.mult(light);
public Matrix4 getViewProjection() { if (pv == null) { pv = projektion.clone().mult(view); } return pv; // return normal ? pv : getShadowProjection(); }
@Override public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) { final float ratio = (float) height / Math.min(1, width); matrices.getProjektion().perspective(50, ratio, 0.001, 1000); matrices.fireChange(MatType.PROJECTION); }
@Override public void set() { if (p) { uni.setData(matricen.getProjektion(). getFloatBuffer()); } } });
@Inject public BasicScene(GraphicContext gc) { this.gc = gc; matrices = new MatrixCache(new ProjectionMatrix()); half = new LinkedList<>(); lightdir = new LinkedList<>(); animated = new LinkedList<>(); }
"top,bottom and left,right must not be equal"; loadIdentity(); float[] mat = getArray();