public static TexturedPolygon newTexturedPolygon(Texture texture, Vector... vectors) { TexturedPolygon texturedPolygon = TexturedPolygonImpl.newInstance(texture, vectors); if (vectors.length >= 2) { if (texture instanceof ShadedTexture) { ShadedTexture shadedTexture = ShadedTexture.class.cast(texture); List<PointLight> pointLights = new ArrayList<>(); Vector normal = texturedPolygon.getNormal(); Vector location = null; double x = normal.getX(); double y = normal.getY() + 500.0D; double z = normal.getZ(); double distanceFalloff = 2500.0D; Color intensity = Color.white(); location = Vector.newInstance(x, y, z); PointLight pointLight = PointLight.newInstance(); pointLight.setLocation(location); pointLight.setIntensity(intensity); pointLight.setDistanceFalloff(distanceFalloff); pointLights.add(pointLight); Color ambientLightIntensity = Color.valueOf(0xFF333333); ShadedSurfaceTexture.createShadedSurfaceTexture( texturedPolygon, shadedTexture, pointLights, new ArrayList<Polygon>(), ambientLightIntensity); } else { Vector origin = vectors[0]; Vector v = vectors[1].copy(); Vector normal = texturedPolygon.getNormal(); v.subtract(origin); Vector u = Vector.toCrossProduct(normal, v); BoundingBox boundingBox = texturedPolygon.getTextureBounds(); boundingBox.setOrigin(origin); boundingBox.setU(u); boundingBox.setV(v); } } return texturedPolygon; }
public static TexturedPolygon newTexturedPolygon(Texture texture, List<Vector> vectors) { TexturedPolygon texturedPolygon = TexturedPolygonImpl.newInstance(texture, vectors); return texturedPolygon; }