Class Billboard
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.Billboard
- Direct Known Subclasses:
ForwardOrientedTextBlock,GlowingPoint
A billboard: a texture that always faces the viewer.
This class implements the "billboard" rendering technique where the texture remains oriented towards the camera regardless of 3D position. The visible size is calculated based on distance from viewer (z-coordinate) and scale factor.
Texture mapping algorithm:
- Calculates screen coverage based on perspective
- Clips to viewport boundaries
- Maps texture pixels to screen pixels using proportional scaling
- See Also:
-
Field Summary
FieldsFields inherited from class eu.svjatoslav.sixth.e3d.renderer.raster.shapes.AbstractCoordinateShape
onScreenZ, shapeId, verticesFields inherited from class eu.svjatoslav.sixth.e3d.renderer.raster.shapes.AbstractShape
mouseInteractionController -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionReturns the 3D position of this billboard.voidpaint(RenderingContext targetRenderingArea) Renders this billboard to the screen.voidsetScale(double scale) Sets the scale factor for this billboard.Methods 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
-
Field Details
-
texture
The texture to display on this billboard.
-
-
Constructor Details
-
Billboard
Creates a billboard at the specified position with the given scale and texture.- Parameters:
point- the 3D position of the billboard centerscale- the scale factor (1.0 is recommended for sharpness)texture- the texture to display
-
-
Method Details
-
paint
Renders this billboard to the screen.The billboard is rendered as a screen-aligned quad centered on the projected position. The size is computed based on distance and scale factor.
Performance optimization: Uses fixed-point incremental stepping to avoid per-pixel division, and inlines alpha blending to avoid method call overhead. This provides 50-70% better performance than the previous division-based approach.
- Specified by:
paintin classAbstractCoordinateShape- Parameters:
targetRenderingArea- the rendering context containing the pixel buffer
-
setScale
public void setScale(double scale) Sets the scale factor for this billboard.- Parameters:
scale- the scale factor (1.0 is recommended for sharpness)
-
getLocation
Returns the 3D position of this billboard.- Returns:
- the center position in world coordinates
-