Class TexturedRectangle
- Direct Known Subclasses:
RaytracingCamera,TextCanvas
This composite shape creates a textured rectangle in 3D space by splitting it into
two TexturedPolygon triangles that share a common Texture. The rectangle
is centered at the origin of its local coordinate system, with configurable world-space
dimensions and independent texture resolution.
The contained Texture object is accessible via getTexture(), allowing
dynamic rendering to the texture surface (e.g., drawing text, images, or procedural content)
after construction.
Usage example:
// Create a 200x100 textured rectangle at position (0, 0, 300)
Transform transform = new Transform(new Point3D(0, 0, 300));
TexturedRectangle rect = new TexturedRectangle(transform, 200, 100, 2);
// Draw onto the texture dynamically
Texture tex = rect.getTexture();
tex.graphics.setColor(java.awt.Color.RED);
tex.graphics.fillRect(0, 0, 50, 50);
// Add to the scene
shapeCollection.addShape(rect);
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionBottom-left corner position in local 3D coordinates.Bottom-right corner position in local 3D coordinates.Bottom-left corner mapping in texture coordinates (pixels).Bottom-right corner mapping in texture coordinates (pixels).Top-left corner mapping in texture coordinates (pixels).Top-right corner mapping in texture coordinates (pixels).Top-left corner position in local 3D coordinates.Top-right corner position in local 3D coordinates.Fields inherited from class eu.svjatoslav.sixth.e3d.renderer.raster.shapes.AbstractShape
mouseInteractionController -
Constructor Summary
ConstructorsConstructorDescriptionTexturedRectangle(Transform transform) Creates a textured rectangle with only a transform, without initializing geometry.TexturedRectangle(Transform transform, int width, int height, int maxTextureUpscale) Creates a textured rectangle where the texture resolution matches the world-space size.TexturedRectangle(Transform transform, int width, int height, int textureWidth, int textureHeight, int maxTextureUpscale) Creates a fully initialized textured rectangle with independent world-space size and texture resolution. -
Method Summary
Modifier and TypeMethodDescriptionReturns the backing texture for this rectangle.voidinitialize(double width, double height, int textureWidth, int textureHeight, int maxTextureUpscale) Initializes the rectangle geometry, texture, and the two constituent textured triangles.Methods inherited from class eu.svjatoslav.sixth.e3d.renderer.raster.shapes.composite.base.AbstractCompositeShape
addShape, addShape, beforeTransformHook, getGroup, getLocation, getOriginalSubShapes, getViewSpaceTracker, hideGroup, removeGroup, setBackfaceCulling, setColor, setGroupForUngrouped, setLightingManager, setMouseInteractionController, setShadingEnabled, setTransform, showGroup, transform
-
Field Details
-
topLeft
Top-left corner position in local 3D coordinates. -
topRight
Top-right corner position in local 3D coordinates. -
bottomRight
Bottom-right corner position in local 3D coordinates. -
bottomLeft
Bottom-left corner position in local 3D coordinates. -
textureTopLeft
Top-left corner mapping in texture coordinates (pixels). -
textureTopRight
Top-right corner mapping in texture coordinates (pixels). -
textureBottomRight
Bottom-right corner mapping in texture coordinates (pixels). -
textureBottomLeft
Bottom-left corner mapping in texture coordinates (pixels).
-
-
Constructor Details
-
TexturedRectangle
Creates a textured rectangle with only a transform, without initializing geometry.After construction, call
initialize(double, double, int, int, int)to set up the rectangle's dimensions, texture, and triangle geometry.- Parameters:
transform- the position and orientation of this rectangle in the scene
-
TexturedRectangle
Creates a textured rectangle where the texture resolution matches the world-space size.This is a convenience constructor equivalent to calling
TexturedRectangle(Transform, int, int, int, int, int)withtextureWidth = widthandtextureHeight = height.- Parameters:
transform- the position and orientation of this rectangle in the scenewidth- the width of the rectangle in world units (also used as texture width in pixels)height- the height of the rectangle in world units (also used as texture height in pixels)maxTextureUpscale- the maximum mipmap upscale factor for the texture
-
TexturedRectangle
public TexturedRectangle(Transform transform, int width, int height, int textureWidth, int textureHeight, int maxTextureUpscale) Creates a fully initialized textured rectangle with independent world-space size and texture resolution.- Parameters:
transform- the position and orientation of this rectangle in the scenewidth- the width of the rectangle in world unitsheight- the height of the rectangle in world unitstextureWidth- the width of the backing texture in pixelstextureHeight- the height of the backing texture in pixelsmaxTextureUpscale- the maximum mipmap upscale factor for the texture
-
-
Method Details
-
getTexture
Returns the backing texture for this rectangle.The returned
Texturecan be used to draw dynamic content onto the rectangle's surface via itsgraphicsfield (aGraphics2Dinstance).- Returns:
- the texture mapped onto this rectangle
-
initialize
public void initialize(double width, double height, int textureWidth, int textureHeight, int maxTextureUpscale) Initializes the rectangle geometry, texture, and the two constituent textured triangles.The rectangle is centered at the local origin: corners span from
(-width/2, -height/2, 0)to(width/2, height/2, 0). TwoTexturedPolygontriangles are created to cover the full rectangle, sharing a singleTextureinstance.- Parameters:
width- the width of the rectangle in world unitsheight- the height of the rectangle in world unitstextureWidth- the width of the backing texture in pixelstextureHeight- the height of the backing texture in pixelsmaxTextureUpscale- the maximum mipmap upscale factor for the texture
-