Class ForwardOrientedTextBlock


public class ForwardOrientedTextBlock extends ForwardOrientedTexture
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:
  • 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 placed
      scale - the scale factor controlling the rendered size of the text
      maxUpscaleFactor - the maximum mipmap upscale factor for the backing texture
      text - the text string to render
      textColor - the color of the rendered text
  • Method Details

    • getTexture

      public static Texture getTexture(String text, int maxUpscaleFactor, Color textColor)
      Creates a Texture containing 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 using TextCanvas.FONT.

      Parameters:
      text - the text string to render into the texture
      maxUpscaleFactor - the maximum mipmap upscale factor for the texture
      textColor - the color of the rendered text
      Returns:
      a new Texture containing the rendered text