@Test public void yz() { ElementType type = new ElementType( "vertex", new Property("x", DataType.DOUBLE), new Property("y", DataType.DOUBLE), new Property("z", DataType.DOUBLE), new Property("u", DataType.DOUBLE), new Property("v", DataType.DOUBLE)); Element element = new Element(type); element.setDouble("x", 12); element.setDouble("y", 130); element.setDouble("z", 1400); Element expected = new Element(type); expected.setDouble("x", 12); expected.setDouble("y", 130); expected.setDouble("z", 1400); expected.setDouble("u", 0.3); expected.setDouble("v", 0.4); RectBounds bounds = new RectBounds(10, 20, 100, 200, 1000, 2000); PlanarTexGenStrategy target = new PlanarTexGenStrategy(Axis.Y, Axis.Z); target.generateCoordinates(element, bounds); assertEquals(expected, element); }
@Override public void generateCoordinates(final Element element, final RectBounds bounds) { if (element == null || bounds == null) { throw new NullPointerException(); } double x = element.getDouble("x"); double y = element.getDouble("y"); double z = element.getDouble("z"); x = ( x - bounds.getMinX() ) / ( bounds.getMaxX() - bounds.getMinX() ); y = ( y - bounds.getMinY() ) / ( bounds.getMaxY() - bounds.getMinY() ); z = ( z - bounds.getMinZ() ) / ( bounds.getMaxZ() - bounds.getMinZ() ); double u = 0.0; switch (uAxis) { case X: u = x; break; case Y: u = y; break; case Z: u = z; break; default: throw new IllegalStateException("Invalid axis."); } double v = 0.0; switch (vAxis) { case X: v = x; break; case Y: v = y; break; case Z: v = z; break; default: throw new IllegalStateException("Invalid axis."); } element.setDouble("u", u); element.setDouble("v", v); }
PlanarTexGenStrategy implements TexGenStrategy { @Override public void generateCoordinates(final Element element, final RectBounds bounds) { if (element == null || bounds == null) { throw new NullPointerException(); } double x = element.getDouble("x"); double y = element.getDouble("y"); double z = element.getDouble("z"); x = ( x - bounds.getMinX() ) / ( bounds.getMaxX() - bounds.getMinX() ); y = ( y - bounds.getMinY() ) / ( bounds.getMaxY() - bounds.getMinY() ); z = ( z - bounds.getMinZ() ) / ( bounds.getMaxZ() - bounds.getMinZ() ); double u = 0.0; switch (uAxis) { case X: u = x; break; case Y: u = y; break; case Z: u = z; break; default: throw new IllegalStateException("Invalid axis."); } double v = 0.0; switch (vAxis) { case X: v = x; break; case Y: v = y; break; case Z: v = z; break; default: throw new IllegalStateException("Invalid axis."); } element.setDouble("u", u); element.setDouble("v", v); } }
PlanarTexGenStrategy implements TexGenStrategy { @Override public void generateCoordinates(final Element element, final RectBounds bounds) { if (element == null || bounds == null) { throw new NullPointerException(); } double x = element.getDouble("x"); double y = element.getDouble("y"); double z = element.getDouble("z"); x = ( x - bounds.getMinX() ) / ( bounds.getMaxX() - bounds.getMinX() ); y = ( y - bounds.getMinY() ) / ( bounds.getMaxY() - bounds.getMinY() ); z = ( z - bounds.getMinZ() ) / ( bounds.getMaxZ() - bounds.getMinZ() ); double u = 0.0; switch (uAxis) { case X: u = x; break; case Y: u = y; break; case Z: u = z; break; default: throw new IllegalStateException("Invalid axis."); } double v = 0.0; switch (vAxis) { case X: v = x; break; case Y: v = y; break; case Z: v = z; break; default: throw new IllegalStateException("Invalid axis."); } element.setDouble("u", u); element.setDouble("v", v); } PlanarTexGenStrategy(final Axis uAxis, final Axis vAxis); }
PlanarTexGenStrategy implements TexGenStrategy { @Override public void generateCoordinates(final Element element, final RectBounds bounds) { if (element == null || bounds == null) { throw new NullPointerException(); } double x = element.getDouble("x"); double y = element.getDouble("y"); double z = element.getDouble("z"); x = ( x - bounds.getMinX() ) / ( bounds.getMaxX() - bounds.getMinX() ); y = ( y - bounds.getMinY() ) / ( bounds.getMaxY() - bounds.getMinY() ); z = ( z - bounds.getMinZ() ) / ( bounds.getMaxZ() - bounds.getMinZ() ); double u = 0.0; switch (uAxis) { case X: u = x; break; case Y: u = y; break; case Z: u = z; break; default: throw new IllegalStateException("Invalid axis."); } double v = 0.0; switch (vAxis) { case X: v = x; break; case Y: v = y; break; case Z: v = z; break; default: throw new IllegalStateException("Invalid axis."); } element.setDouble("u", u); element.setDouble("v", v); } PlanarTexGenStrategy(final Axis uAxis, final Axis vAxis); @Override void generateCoordinates(final Element element,
            final RectBounds bounds); }
PlanarTexGenStrategy implements TexGenStrategy { @Override public void generateCoordinates(final Element element, final RectBounds bounds) { if (element == null || bounds == null) { throw new NullPointerException(); } double x = element.getDouble("x"); double y = element.getDouble("y"); double z = element.getDouble("z"); x = ( x - bounds.getMinX() ) / ( bounds.getMaxX() - bounds.getMinX() ); y = ( y - bounds.getMinY() ) / ( bounds.getMaxY() - bounds.getMinY() ); z = ( z - bounds.getMinZ() ) / ( bounds.getMaxZ() - bounds.getMinZ() ); double u = 0.0; switch (uAxis) { case X: u = x; break; case Y: u = y; break; case Z: u = z; break; default: throw new IllegalStateException("Invalid axis."); } double v = 0.0; switch (vAxis) { case X: v = x; break; case Y: v = y; break; case Z: v = z; break; default: throw new IllegalStateException("Invalid axis."); } element.setDouble("u", u); element.setDouble("v", v); } PlanarTexGenStrategy(final Axis uAxis, final Axis vAxis); @Override void generateCoordinates(final Element element,
            final RectBounds bounds);  }