Class ForwardOrientedTextBlock
java.lang.Object
eu.svjatoslav.sixth.e3d.renderer.raster.shapes.AbstractShape
eu.svjatoslav.sixth.e3d.renderer.raster.shapes.AbstractCoordinateShape
eu.svjatoslav.sixth.e3d.renderer.raster.shapes.basic.ForwardOrientedTexture
eu.svjatoslav.sixth.e3d.renderer.raster.shapes.composite.ForwardOrientedTextBlock
A text label rendered as a billboard texture that always faces the camera.
This shape renders a single line of text onto a Texture using the font metrics
defined in TextCanvas (TextCanvas.FONT, TextCanvas.FONT_CHAR_WIDTH_TEXTURE_PIXELS,
TextCanvas.FONT_CHAR_HEIGHT_TEXTURE_PIXELS), then displays the texture as a
forward-oriented billboard via its ForwardOrientedTexture superclass. The result
is a text label that remains readable from any viewing angle.
Usage example:
// Create a red text label at position (0, -50, 300)
ForwardOrientedTextBlock label = new ForwardOrientedTextBlock(
new Point3D(0, -50, 300),
1.0,
2,
"Hello, World!",
Color.RED
);
shapeCollection.addShape(label);
- See Also:
-
Field Summary
Fields inherited from class eu.svjatoslav.sixth.e3d.renderer.raster.shapes.basic.ForwardOrientedTexture
textureFields inherited from class eu.svjatoslav.sixth.e3d.renderer.raster.shapes.AbstractCoordinateShape
coordinates, onScreenZ, shapeIdFields inherited from class eu.svjatoslav.sixth.e3d.renderer.raster.shapes.AbstractShape
mouseInteractionController -
Constructor Summary
ConstructorsConstructorDescriptionForwardOrientedTextBlock(Point3D point, double scale, int maxUpscaleFactor, String text, Color textColor) Creates a new forward-oriented text block at the given 3D position. -
Method Summary
Modifier and TypeMethodDescriptionstatic TexturegetTexture(String text, int maxUpscaleFactor, Color textColor) Creates aTexturecontaining the rendered text string.Methods inherited from class eu.svjatoslav.sixth.e3d.renderer.raster.shapes.basic.ForwardOrientedTexture
getLocation, paint, setScaleMethods inherited from class eu.svjatoslav.sixth.e3d.renderer.raster.shapes.AbstractCoordinateShape
getZ, transformMethods inherited from class eu.svjatoslav.sixth.e3d.renderer.raster.shapes.AbstractShape
setMouseInteractionController
-
Constructor Details
-
ForwardOrientedTextBlock
public ForwardOrientedTextBlock(Point3D point, double scale, int maxUpscaleFactor, String text, Color textColor) Creates a new forward-oriented text block at the given 3D position.- Parameters:
point- the 3D position where the text label is placedscale- the scale factor controlling the rendered size of the textmaxUpscaleFactor- the maximum mipmap upscale factor for the backing texturetext- the text string to rendertextColor- the color of the rendered text
-
-
Method Details
-
getTexture
Creates aTexturecontaining the rendered text string.The texture dimensions are calculated from the text length and the font metrics defined in
TextCanvas. Each character is drawn individually at the appropriate horizontal offset usingTextCanvas.FONT.- Parameters:
text- the text string to render into the texturemaxUpscaleFactor- the maximum mipmap upscale factor for the texturetextColor- the color of the rendered text- Returns:
- a new
Texturecontaining the rendered text
-