import java.awt.*;
import static eu.svjatoslav.sixth.e3d.geometry.Polygon.pointWithinPolygon;
+import static java.util.Arrays.sort;
+
+/**
+ * Textured polygon.
+ * <p>
+ *
+ * <pre>
+ * This is how perspective-correct texture rendering is implemented:
+ * If polygon is sufficiently small, it is rendered without perspective correction.
+ * Otherwise, it is sliced into smaller polygons.
+ * </pre>
+ */
public class TexturedPolygon extends AbstractCoordinateShape {
public final Texture texture;
- final PolygonBorderInterpolator[] is = new PolygonBorderInterpolator[]{
- new PolygonBorderInterpolator(), new PolygonBorderInterpolator(),
- new PolygonBorderInterpolator()};
/**
* Polygon texture coordinates.
*/
yBottom = renderBuffer.height - 1;
// paint
- double totalVisibleDistance = projectedPoint1
- .getDistanceTo(projectedPoint2);
+ double totalVisibleDistance = projectedPoint1.getDistanceTo(projectedPoint2);
totalVisibleDistance += projectedPoint1.getDistanceTo(projectedPoint3);
totalVisibleDistance += projectedPoint2.getDistanceTo(projectedPoint3);
final TextureBitmap zoomedBitmap = texture.getZoomedBitmap(scaleFactor);
+ final PolygonBorderInterpolator[] is = new PolygonBorderInterpolator[]{
+ new PolygonBorderInterpolator(), new PolygonBorderInterpolator(),
+ new PolygonBorderInterpolator()};
+
is[0].setPoints(projectedPoint1, projectedPoint2, texturePoint1,
texturePoint2);
is[1].setPoints(projectedPoint1, projectedPoint3, texturePoint1,
is[2].setPoints(projectedPoint2, projectedPoint3, texturePoint2,
texturePoint3);
- java.util.Arrays.sort(is);
+ sort(is);
for (int y = yTop; y < yBottom; y++)
if (is[0].containsY(y)) {