@Override public Plane clone() { return new Plane(this); }
@Override public Plane clone() { return new Plane(this); }
/** * @return An instance of Plane that is intended for temporary use in calculations and so forth. Multiple calls to * the method should return instances of this class that are not currently in use. */ public final static Plane fetchTempInstance() { if (MathConstants.useMathPools) { return Plane.PLANE_POOL.fetch(); } else { return new Plane(); } }
/** * @return An instance of Plane that is intended for temporary use in calculations and so forth. Multiple calls to * the method should return instances of this class that are not currently in use. */ public final static Plane fetchTempInstance() { if (MathConstants.useMathPools) { return Plane.PLANE_POOL.fetch(); } else { return new Plane(); } }
/** * Construct a new camera, using the given source camera's values. * * @param source */ public Camera(final Camera source) { _coeffLeft = new double[2]; _coeffRight = new double[2]; _coeffBottom = new double[2]; _coeffTop = new double[2]; _worldPlane = new Plane[MAX_WORLD_PLANES]; for (int i = 0; i < MAX_WORLD_PLANES; i++) { _worldPlane[i] = new Plane(); } set(source); _logger.fine("Camera created. W: " + getWidth() + " H: " + getHeight()); }
/** * Construct a new camera, using the given source camera's values. * * @param source */ public Camera(final Camera source) { _coeffLeft = new double[2]; _coeffRight = new double[2]; _coeffBottom = new double[2]; _coeffTop = new double[2]; _worldPlane = new Plane[MAX_WORLD_PLANES]; for (int i = 0; i < MAX_WORLD_PLANES; i++) { _worldPlane[i] = new Plane(); } set(source); _logger.fine("Camera created. W: " + getWidth() + " H: " + getHeight()); }
@Override public void write(final OutputCapsule capsule) throws IOException { super.write(capsule); capsule.write(_bounciness, "bounciness", 1.0); capsule.write(_floor, "floor", new Plane()); }
@Override public void write(final OutputCapsule capsule) throws IOException { super.write(capsule); capsule.write(_bounciness, "bounciness", 1.0); capsule.write(_floor, "floor", new Plane()); }
@Override public void read(final InputCapsule capsule) throws IOException { super.read(capsule); _bounciness = capsule.readDouble("bounciness", 1.0); _floor.set((Plane) capsule.readSavable("floor", new Plane())); }
@Override public void read(final InputCapsule capsule) throws IOException { super.read(capsule); _bounciness = capsule.readDouble("bounciness", 1.0); _floor.set((Plane) capsule.readSavable("floor", new Plane())); }
protected static double getValueFor(final SpotLight l, final BoundingVolume val) { if (val == null) { return 0; } final ReadOnlyVector3 direction = l.getDirection(); final ReadOnlyVector3 location = l.getLocation(); // direction is copied into Plane, not reused. final Plane p = new Plane(direction, direction.dot(location)); if (val.whichSide(p) != Plane.Side.Inside) { return getValueFor((PointLight) l, val); } return 0; }
protected static double getValueFor(final SpotLight l, final BoundingVolume val) { if (val == null) { return 0; } final ReadOnlyVector3 direction = l.getDirection(); final ReadOnlyVector3 location = l.getLocation(); // direction is copied into Plane, not reused. final Plane p = new Plane(direction, direction.dot(location)); if (val.whichSide(p) != Plane.Side.Inside) { return getValueFor((PointLight) l, val); } return 0; }
@Test public void testSimpleHash() { // Just a simple sanity check. final Plane plane1 = new Plane(Vector3.UNIT_Y, 2); final Plane plane2 = new Plane(Vector3.UNIT_Y, 2); final Plane plane3 = new Plane(Vector3.UNIT_Z, 2); assertTrue(plane1.hashCode() == plane2.hashCode()); assertTrue(plane1.hashCode() != plane3.hashCode()); }
/** * Resets water parameters to default values * */ public void resetParameters() { waterPlane = new Plane(new Vector3(0.0, 1.0, 0.0), 0.0); tangent = new Vector3(1.0, 0.0, 0.0); binormal = new Vector3(0.0, 0.0, 1.0); waterMaxAmplitude = 0.0; clipBias = 1.0; waterColorStart = new ColorRGBA(0.0f, 0.0f, 0.1f, 1.0f); waterColorEnd = new ColorRGBA(0.0f, 0.3f, 0.1f, 1.0f); heightFalloffStart = 400.0; heightFalloffSpeed = 500.0; speedReflection = 0.1; speedRefraction = -0.05; }
/** * Resets water parameters to default values * */ public void resetParameters() { waterPlane = new Plane(new Vector3(0.0, 1.0, 0.0), 0.0); tangent = new Vector3(1.0, 0.0, 0.0); binormal = new Vector3(0.0, 0.0, 1.0); waterMaxAmplitude = 0.0; clipBias = 1.0; waterColorStart = new ColorRGBA(0.0f, 0.0f, 0.1f, 1.0f); waterColorEnd = new ColorRGBA(0.0f, 0.3f, 0.1f, 1.0f); heightFalloffStart = 400.0; heightFalloffSpeed = 500.0; speedReflection = 0.1; speedRefraction = -0.05; setBlurSampleDistance(0.005f); }
@Test public void testClone() { final Plane plane1 = new Plane(); final Plane plane2 = plane1.clone(); assertEquals(plane1, plane2); assertNotSame(plane1, plane2); }
@Test public void testValid() { final Plane plane1 = new Plane(); final Plane plane2 = new Plane(new Vector3(Double.NaN, 0, 0), 0.5); final Plane plane3 = new Plane(Vector3.UNIT_X, Double.NaN); final Plane plane4 = new Plane(Vector3.UNIT_X, Double.POSITIVE_INFINITY); assertTrue(Plane.isValid(plane1)); assertFalse(Plane.isValid(plane2)); assertFalse(Plane.isValid(plane3)); assertFalse(Plane.isValid(plane4)); plane4.setConstant(1); assertTrue(Plane.isValid(plane4)); assertFalse(Plane.isValid(null)); }
@Test public void testEquals() { // couple of equals validity tests final Plane plane1 = new Plane(); assertEquals(plane1, plane1); assertFalse(plane1.equals(null)); assertFalse(plane1.equals(new Vector2())); // throw in a couple pool accesses for coverage final Plane plane2 = Plane.fetchTempInstance(); plane2.set(plane1); assertEquals(plane1, plane2); assertNotSame(plane1, plane2); Plane.releaseTempInstance(plane2); // cover more of equals assertFalse(plane1.equals(new Plane(Vector3.UNIT_X, 0))); }
@Test public void testDistance() { final Plane plane1 = new Plane(Vector3.UNIT_Y, 1.0); final Vector3 point = new Vector3(0, 5, 0); assertTrue(4.0 == plane1.pseudoDistance(point)); assertEquals(Side.Outside, plane1.whichSide(point)); point.set(0, -4, 0); assertTrue(-5.0 == plane1.pseudoDistance(point)); assertEquals(Side.Inside, plane1.whichSide(point)); point.set(1, 1, 1); assertTrue(0.0 == plane1.pseudoDistance(point)); assertEquals(Side.Neither, plane1.whichSide(point)); }
@Test public void testReflect() { final Plane plane1 = new Plane(Vector3.UNIT_X, 5.0); assertEquals(new Vector3(), plane1.reflectVector(new Vector3(), new Vector3())); assertEquals(new Vector3(-1, 0, 0), plane1.reflectVector(new Vector3(1, 0, 0), null)); assertEquals(new Vector3(-1, 1, 1).normalizeLocal(), plane1.reflectVector(new Vector3(1, 1, 1).normalizeLocal(), null)); assertEquals(new Vector3(-3, 2, -1).normalizeLocal(), plane1.reflectVector(new Vector3(3, 2, -1).normalizeLocal(), null)); final Plane plane2 = new Plane(Vector3.UNIT_Z, 1.0); assertEquals(new Vector3(), plane2.reflectVector(new Vector3(), new Vector3())); assertEquals(new Vector3(0, 0, -1), plane2.reflectVector(new Vector3(0, 0, 1), null)); assertEquals(new Vector3(1, 1, -1).normalizeLocal(), plane2.reflectVector(new Vector3(1, 1, 1).normalizeLocal(), null)); assertEquals(new Vector3(3, 2, 1).normalizeLocal(), plane2.reflectVector(new Vector3(3, 2, -1).normalizeLocal(), null)); } }