@Override protected JCGLProjectionMatricesType newProjectionMatrices() { return JCGLProjectionMatrices.newMatrices(); } }
/** * @return A {@link JCGLProjectionMatricesType} instance */ public static JCGLProjectionMatricesType newMatrices() { return new JCGLProjectionMatrices(); }
final double y_max = x_max / aspect; final double y_min = -y_max; return frustumProjectionRH(x_min, x_max, y_min, y_max, z_near, z_far);
JCGLProjectionMatrices.perspectiveProjectionRH( 0.0001, 100.0,
@Override public void makePerspectiveProjection( final MatrixWritable4x4FType matrix, final double z_near, final double z_far, final double aspect, final double horizontal_fov) { NullCheck.notNull(matrix, "matrix"); final double x_max = z_near * Math.tan(horizontal_fov / 2.0); final double x_min = -x_max; final double y_max = x_max / aspect; final double y_min = -y_max; this.makeFrustumProjection( matrix, x_min, x_max, y_min, y_max, z_near, z_far); } }
final double y_max = x_max / aspect; final double y_min = -y_max; return frustumProjectionRHP(x_min, x_max, y_min, y_max, z_near, z_far);
JCGLProjectionMatrices.perspectiveProjectionRH( 0.0001, 100.0,
/** * Construct an example. */ public ExampleInstancedTrianglesView() { this.m_view = MatrixDirectM4x4F.newMatrix(); this.m_projection = MatrixDirectM4x4F.newMatrix(); this.view_matrices = JCGLViewMatrices.newMatrices(); this.proj_matrices = JCGLProjectionMatrices.newMatrices(); }
/** * Construct an example. */ public ExampleSingleTriangleView() { this.m_view = MatrixHeapArrayM4x4F.newMatrix(); this.m_model = MatrixHeapArrayM4x4F.newMatrix(); this.m_projection = MatrixDirectM4x4F.newMatrix(); this.m_modelview = MatrixDirectM4x4F.newMatrix(); this.view_matrices = JCGLViewMatrices.newMatrices(); this.proj_matrices = JCGLProjectionMatrices.newMatrices(); }
@Test public final void testMatricesObserverCalled() { final R2MatricesType m = this.newMatrices(); final JCGLProjectionMatricesType pm = JCGLProjectionMatrices.newMatrices(); final Integer r = m.withObserver( PMatrixI4x4F.identity(), R2ProjectionOrthographic.newFrustum(pm), Unit.unit(), (mm, u0) -> Integer.valueOf(23)); Assert.assertEquals(Integer.valueOf(23), r); }
@Test public void testAspectNonzero() { final JCGLProjectionMatricesType pm = JCGLProjectionMatrices.newMatrices(); final R2ProjectionFOV p = R2ProjectionFOV.newFrustumWith( pm, 1.5707963267948966f, 1.0f, 1.0f, 100.0f); this.expected.expect(RangeCheckException.class); p.setAspectRatio(0.0f); }
@Override protected final R2LightProjectiveReadableType newLight( final JCGLInterfaceGL33Type g, final R2IDPoolType pool, final JCGLTextureUnitContextType uc, final R2TextureDefaultsType td) { final R2ProjectionType p = R2ProjectionFrustum.newFrustum(JCGLProjectionMatrices.newMatrices()); final R2ProjectionMeshType pm = R2ProjectionMesh.newMesh( g, p, JCGLUsageHint.USAGE_STATIC_DRAW, JCGLUsageHint.USAGE_STATIC_DRAW); return R2LightProjectiveWithoutShadow.newLight( pm, td.texture2DProjectiveWhite(), pool); } }
@Override protected final R2LightProjectiveReadableType newLight( final JCGLInterfaceGL33Type g, final R2IDPoolType pool, final JCGLTextureUnitContextType uc, final R2TextureDefaultsType td) { final R2ProjectionType p = R2ProjectionFrustum.newFrustum(JCGLProjectionMatrices.newMatrices()); final R2ProjectionMeshType pm = R2ProjectionMesh.newMesh( g, p, JCGLUsageHint.USAGE_STATIC_DRAW, JCGLUsageHint.USAGE_STATIC_DRAW); return R2LightProjectiveWithoutShadow.newLight( pm, td.texture2DProjectiveWhite(), pool); } }
@Test public void testWatchable() { final JCGLProjectionMatricesType pm = JCGLProjectionMatrices.newMatrices(); final R2ProjectionFOV p = R2ProjectionFOV.newFrustumWith( pm, 1.5707963267948966f, 1.0f, 1.0f, 100.0f); final AtomicInteger called = new AtomicInteger(0); final R2WatchableType<R2ProjectionReadableType> w = p.projectionGetWatchable(); w.watchableAdd(ww -> called.incrementAndGet()); Assert.assertEquals(1L, (long) called.get()); p.projectionSetZFar(100.0f); p.projectionSetZNear(1.0f); p.setAspectRatio(1.0f); p.setHorizontalFOV(1.0f); Assert.assertEquals(5L, (long) called.get()); } }
@Test public void testWatchable() { final JCGLProjectionMatricesType pm = JCGLProjectionMatrices.newMatrices(); final R2ProjectionFrustum p = R2ProjectionFrustum.newFrustum(pm); final AtomicInteger called = new AtomicInteger(0); final R2WatchableType<R2ProjectionReadableType> w = p.projectionGetWatchable(); w.watchableAdd(ww -> called.incrementAndGet()); Assert.assertEquals(1L, (long) called.get()); p.projectionSetZFar(100.0f); p.projectionSetZNear(1.0f); p.projectionSetXMinimum(-1.0f); p.projectionSetXMaximum(1.0f); p.projectionSetYMinimum(-1.0f); p.projectionSetYMaximum(1.0f); Assert.assertEquals(7L, (long) called.get()); } }
@Test public void testWatchable() { final JCGLProjectionMatricesType pm = JCGLProjectionMatrices.newMatrices(); final R2ProjectionOrthographic p = R2ProjectionOrthographic.newFrustum(pm); final AtomicInteger called = new AtomicInteger(0); final R2WatchableType<R2ProjectionReadableType> w = p.projectionGetWatchable(); w.watchableAdd(ww -> called.incrementAndGet()); Assert.assertEquals(1L, (long) called.get()); p.projectionSetZFar(100.0f); p.projectionSetZNear(1.0f); p.projectionSetXMinimum(-1.0f); p.projectionSetXMaximum(1.0f); p.projectionSetYMinimum(-1.0f); p.projectionSetYMaximum(1.0f); Assert.assertEquals(7L, (long) called.get()); } }
@Test public final void testMatricesObserverTransformCalled() { final R2MatricesType m = this.newMatrices(); final JCGLProjectionMatricesType pm = JCGLProjectionMatrices.newMatrices(); final PMatrixReadable3x3FType<R2SpaceTextureType, R2SpaceTextureType> uv = PMatrixI3x3F.identity(); final R2TransformReadableType t = R2TransformSOT.newTransform(); final Integer r = m.withObserver( PMatrixI4x4F.identity(), R2ProjectionOrthographic.newFrustum(pm), Unit.unit(), (mm, u0) -> mm.withTransform(t, uv, u0, (mi, u1) -> Integer.valueOf(23)) ); Assert.assertEquals(Integer.valueOf(23), r); }
@Test public final void testMatricesObserverInactive0() { final R2MatricesType m = this.newMatrices(); final JCGLProjectionMatricesType pm = JCGLProjectionMatrices.newMatrices(); final R2MatricesObserverType r = m.withObserver( PMatrixI4x4F.identity(), R2ProjectionOrthographic.newFrustum(pm), Unit.unit(), (mm, u0) -> mm); this.expected.expect(PreconditionViolationException.class); r.matrixProjection(); }
@Test public final void testMatricesObserverInactive1() { final R2MatricesType m = this.newMatrices(); final JCGLProjectionMatricesType pm = JCGLProjectionMatrices.newMatrices(); final R2MatricesObserverType r = m.withObserver( PMatrixI4x4F.identity(), R2ProjectionOrthographic.newFrustum(pm), Unit.unit(), (mm, u0) -> mm); this.expected.expect(PreconditionViolationException.class); r.matrixView(); }
@Test public final void testMatricesObserverInactive2() { final R2MatricesType m = this.newMatrices(); final JCGLProjectionMatricesType pm = JCGLProjectionMatrices.newMatrices(); final R2MatricesObserverType r = m.withObserver( PMatrixI4x4F.identity(), R2ProjectionOrthographic.newFrustum(pm), Unit.unit(), (mm, u0) -> mm); this.expected.expect(PreconditionViolationException.class); r.matrixViewInverse(); }