package eu.svjatoslav.sixth.e3d.renderer.raster.shapes.basic.texturedpolygon;
import eu.svjatoslav.sixth.e3d.geometry.Point2D;
-import eu.svjatoslav.sixth.e3d.geometry.Point3D;
import eu.svjatoslav.sixth.e3d.gui.RenderingContext;
+import eu.svjatoslav.sixth.e3d.math.Vertex;
import eu.svjatoslav.sixth.e3d.renderer.raster.shapes.AbstractCoordinateShape;
-import eu.svjatoslav.sixth.e3d.renderer.raster.slicer.PolygonCoordinate;
import eu.svjatoslav.sixth.e3d.renderer.raster.texture.Texture;
import eu.svjatoslav.sixth.e3d.renderer.raster.texture.TextureBitmap;
public class TexturedPolygon extends AbstractCoordinateShape {
public final Texture texture;
- /**
- * Polygon texture coordinates.
- */
- public Point2D texturePoint1, texturePoint2, texturePoint3;
/**
* If <code>true</code> then polygon borders will be drawn.
* It is used for debugging purposes.
*/
public boolean showBorders = false;
+
private double totalTextureDistance = -1;
- public TexturedPolygon(final Point3D p1, final Point3D p2,
- final Point3D p3, final Point2D tp1, final Point2D tp2,
- final Point2D tp3, final Texture texture) {
+ public TexturedPolygon(Vertex p1, Vertex p2, Vertex p3, final Texture texture) {
super(p1, p2, p3);
-
- texturePoint1 = tp1;
- texturePoint2 = tp2;
- texturePoint3 = tp3;
-
this.texture = texture;
}
- public TexturedPolygon(final PolygonCoordinate pc1,
- final PolygonCoordinate pc2, final PolygonCoordinate pc3,
- final Texture texture) {
-
- this(pc1.spaceCoordinate, pc2.spaceCoordinate, pc3.spaceCoordinate, pc1.textureCoordinate, pc2.textureCoordinate,
- pc3.textureCoordinate, texture);
- }
-
private void computeTotalTextureDistance() {
// compute total texture distance
- totalTextureDistance = texturePoint1.getDistanceTo(texturePoint2);
- totalTextureDistance += texturePoint1.getDistanceTo(texturePoint3);
- totalTextureDistance += texturePoint2.getDistanceTo(texturePoint3);
+ totalTextureDistance = coordinates[0].textureCoordinate.getDistanceTo(coordinates[1].textureCoordinate);
+ totalTextureDistance += coordinates[0].textureCoordinate.getDistanceTo(coordinates[2].textureCoordinate);
+ totalTextureDistance += coordinates[1].textureCoordinate.getDistanceTo(coordinates[2].textureCoordinate);
}
private void drawHorizontalLine(final PolygonBorderInterpolator line1,
new PolygonBorderInterpolator(), new PolygonBorderInterpolator(),
new PolygonBorderInterpolator()};
- is[0].setPoints(projectedPoint1, projectedPoint2, texturePoint1,
- texturePoint2);
- is[1].setPoints(projectedPoint1, projectedPoint3, texturePoint1,
- texturePoint3);
- is[2].setPoints(projectedPoint2, projectedPoint3, texturePoint2,
- texturePoint3);
+ is[0].setPoints(projectedPoint1, projectedPoint2,
+ coordinates[0].textureCoordinate,
+ coordinates[1].textureCoordinate);
+ is[1].setPoints(projectedPoint1, projectedPoint3,
+ coordinates[0].textureCoordinate,
+ coordinates[2].textureCoordinate);
+ is[2].setPoints(projectedPoint2, projectedPoint3,
+ coordinates[1].textureCoordinate,
+ coordinates[2].textureCoordinate);
sort(is);