2 * Sixth 3D engine. Author: Svjatoslav Agejenko.
3 * This project is released under Creative Commons Zero (CC0) license.
5 package eu.svjatoslav.sixth.e3d.renderer.raster.shapes.composite;
7 import eu.svjatoslav.sixth.e3d.geometry.Point2D;
8 import eu.svjatoslav.sixth.e3d.geometry.Point3D;
9 import eu.svjatoslav.sixth.e3d.math.Transform;
10 import eu.svjatoslav.sixth.e3d.renderer.raster.shapes.basic.texturedpolygon.TexturedPolygon;
11 import eu.svjatoslav.sixth.e3d.renderer.raster.shapes.composite.base.AbstractCompositeShape;
12 import eu.svjatoslav.sixth.e3d.renderer.raster.texture.Texture;
14 public class TexturedRectangle extends AbstractCompositeShape {
16 public Point3D topLeft;
17 public Point3D topRight;
18 public Point3D bottomRight;
19 public Point3D bottomLeft;
20 public Point2D textureTopLeft;
21 public Point2D textureTopRight;
22 public Point2D textureBottomRight;
23 public Point2D textureBottomLeft;
24 private Texture texture;
26 public TexturedRectangle(final Transform transform) {
30 public TexturedRectangle(final Transform transform, final int width,
31 final int height, final int maxTextureUpscale) {
32 this(transform, width, height, width, height, maxTextureUpscale);
35 public TexturedRectangle(final Transform transform, final int width,
36 final int height, final int textureWidth, final int textureHeight,
37 final int maxTextureUpscale) {
41 initialize(width, height, textureWidth, textureHeight,
45 public Texture getTexture() {
49 public void initialize(final double width, final double height,
50 final int textureWidth, final int textureHeight,
51 final int maxTextureUpscale) {
53 topLeft = new Point3D(-width / 2, -height / 2, 0);
54 topRight = new Point3D(width / 2, -height / 2, 0);
55 bottomRight = new Point3D(width / 2, height / 2, 0);
56 bottomLeft = new Point3D(-width / 2, height / 2, 0);
58 texture = new Texture(textureWidth, textureHeight, maxTextureUpscale);
60 textureTopRight = new Point2D(textureWidth, 0);
61 textureTopLeft = new Point2D(0, 0);
62 textureBottomRight = new Point2D(textureWidth, textureHeight);
63 textureBottomLeft = new Point2D(0, textureHeight);
65 final TexturedPolygon texturedPolygon1 = new TexturedPolygon(topLeft,
66 topRight, bottomRight, textureTopLeft, textureTopRight,
67 textureBottomRight, texture);
70 .setMouseInteractionController(mouseInteractionController);
72 final TexturedPolygon texturedPolygon2 = new TexturedPolygon(topLeft,
73 bottomLeft, bottomRight, textureTopLeft, textureBottomLeft,
74 textureBottomRight, texture);
77 .setMouseInteractionController(mouseInteractionController);
79 addShape(texturedPolygon1);
80 addShape(texturedPolygon2);
83 // public void initialize(final int width, final int height,
84 // final int maxTextureUpscale) {
85 // initialize(width, height, width, height, maxTextureUpscale);