SceneObjectBillboard

Extends: SceneObject

Properties

  • worldPoints (BGE.Math.CornerPoints)
  • canvasPoints (BGE.Math.CornerPoints)
  • canvasPosition (BGE.Math.Vector)
  • useTempBitmapMap (dynamic)

Constructor

new SceneObjectBillboard( name: string, drawableObj: Drawable, objType: SceneObjectType, ): SceneObjectBillboard

Parameters


Instance Methods

performDraw( rendererObj: BGE.Renderer, drawMode: SceneObjectDrawMode, ): boolean

protected

Parameters

Returns

  • boolean

isRedrawToCanvasRequired( rendererObj: BGE.Renderer, drawMode: SceneObjectDrawMode, ): boolean

protected

Determine if we need to redraw directly to the canvas, instead of use previous temp bitmap

Parameters

Returns

  • boolean

usesTempBitmap(drawMode: SceneObjectDrawMode): boolean

protected

Whether this object caches its drawing into a temp bitmap in the given draw mode, so that later frames can blit (or just re-transform) that bitmap instead of rasterizing the object from scratch again. Worth it for anything whose draw involves triangle rasterization; not worth it for a draw that's already a single cheap call.

Override to make the decision depend on more than the draw mode.

Parameters

Returns

  • boolean

createTempBitmap( canvasBounds: Array.<BGE.Math.Vector>, rendererObj: Renderer, drawMode: SceneObjectDrawMode, allowFastDraw?: boolean, ): roBitmap

protected

Create a Temporary bitmap with a the image of the scene object in relation to the current camera viewport

Parameters

  • canvasBounds (Array.<BGE.Math.Vector>) — where in the final render will the bitmap be drawn [TL, BR]
  • rendererObj (Renderer)
  • drawMode (SceneObjectDrawMode)
  • allowFastDraw (boolean, optional, default: false)

Returns

  • roBitmap — the bitmap with the current perspective of the object or invalid if it failed

drawToCanvas( rendererObj: BGE.Renderer, drawMode: SceneObjectDrawMode, ): boolean

protected

Draw this SceneObject directly to the final canvas Override this function in subclasses to provide specific behavior

Parameters

Returns

  • boolean

drawOutlineToCanvas( rendererObj: BGE.Renderer, drawMode: SceneObjectDrawMode, ): boolean

protected

Strokes this object's outline onto the final canvas, on top of whatever has already been drawn for it. Only called when Drawable.hasOutline() is true and the draw mode isn't already outline-only.

Parameters

Returns

  • boolean — true if the outline was drawn

getOutlineCanvasPoints(): dynamic

protected

The canvas points this object's outline is stroked along, in perimeter order - note that this is not the order getAllCanvasPoints() returns, which is bounds order (topLeft, topRight, bottomLeft, bottomRight) and traces a bowtie if stroked directly. Return invalid to opt out of outline drawing entirely, which is what a SceneObject whose shape isn't a single quad (e.g. SceneObjectModel) should do.

Returns

  • dynamic — points to stroke along, or invalid for no outline

getCanvasBounds(): dynamic

protected

Get the AA bounds of all points to be drawn on the final canvas

Returns

  • dynamic — the bounds of the canvas points

getAllCanvasPoints(): dynamic

protected

Get all canvas points

Returns

  • dynamic

getRegionWithIdToDraw(): BGE.RendererHelpers.RegionWithId

protected

Returns

  • BGE.RendererHelpers.RegionWithId

drawToTempBitmap( rendererObj: BGE.Renderer, tempBitmap: ifDraw2d, canvasPointsTopLeftBound: BGE.Math.Vector, drawMode: SceneObjectDrawMode, allowFastDraw?: boolean, ): TempBitmapDrawResult

protected

Parameters

  • rendererObj (BGE.Renderer)
  • tempBitmap (ifDraw2d)
  • canvasPointsTopLeftBound (BGE.Math.Vector)
  • drawMode (SceneObjectDrawMode)
  • allowFastDraw (boolean, optional, default: false)

Returns

getPinnedCornersOptions(): DrawPinnedCornersOptions

protected

Returns

didRegionToDrawChange(): boolean

protected

Returns

  • boolean

getDrawColorRGBA( rendererObj: BGE.Renderer, ignoreColor?: boolean, ): integer

protected

Parameters

  • rendererObj (BGE.Renderer)
  • ignoreColor (boolean, optional, default: false)

Returns

  • integer

getOutlineDrawColorRGBA( rendererObj: BGE.Renderer, ignoreColor?: boolean, ): integer

protected

The outline stroke color, given the same shading treatment as the fill color. Drawable.getOutlineColorRGBA falls back to the fill color when no outlineRGBA has been set, which is what keeps the wireFrame draw modes looking the way they did before outlines were supported.

Parameters

  • rendererObj (BGE.Renderer)
  • ignoreColor (boolean, optional, default: false) — ignore the drawable's own color and use white

Returns

  • integer — packed RGBA color to stroke with

getNetRotationZ(): float

protected

This object's total rotation about the z axis - its drawable's own rotation plus the rotation of the entity it's attached to. This is the only rotation component the direct (billboard) draw modes apply, since by definition they don't orient in 3D.

Returns

  • float — rotation about z, in radians

updateWorldPosition(drawMode: SceneObjectDrawMode): boolean

protected

Parameters

Returns

  • boolean

getPositionForCameraDistance( drawMode: SceneObjectDrawMode, ): BGE.Math.Vector

Parameters

Returns

  • BGE.Math.Vector

getPositionsForFrustumCheck( drawMode: SceneObjectDrawMode, ): dynamic

protected

Parameters

Returns

  • dynamic

findCanvasPosition( rendererObj: Renderer, drawMode: SceneObjectDrawMode, ): boolean

protected

Parameters

Returns

  • boolean

updateCanvasPosition( rendererObj: Renderer, drawMode: SceneObjectDrawMode, ): boolean

protected

Parameters

Returns

  • boolean

needsCanvasCornerPoints(): boolean

protected

Whether the four canvas corner points are needed in the direct (billboard) draw modes, which otherwise get by with the single canvasPosition. Computing them isn't free, so it's opt-in: outlines are stroked along those corners, so anything with an outline needs them. Override to require them for other reasons too.

Returns

  • boolean

needsManualPretranslationForDirectMode(): boolean

protected

Whether this object's plain 2D draw path (directToCamera/matchCamera) needs its anchor applied by hand here, rather than getting it for free some other way. True for anything with no native roRegion to lean on (DrawableRectangle, DrawableText) - false (the default) for anything backed by a region (SceneObjectImage), since Roku's own DrawObject/DrawScaledObject already apply the region's pretranslation natively.

Returns

  • boolean

getCanvasPosition(): BGE.Math.Vector

The top-left canvas point this billboard's screen-aligned (direct/directScaled) draw modes last positioned at, or invalid before the first successful draw.

Returns

  • BGE.Math.Vector

getWorldPoints(): BGE.Math.CornerPoints

The world-space corner points this billboard's oriented draw modes last computed.

Returns

  • BGE.Math.CornerPoints

updateCanvasPointsForDirectMode(): void

protected

Lays the four canvas corner points out around canvasPosition for the direct (billboard) draw modes, which draw a screen-aligned quad rather than projecting each world corner through the camera the way the oriented draw modes do (see updateCanvasPosition). canvasPosition is the quad's top left corner and the point any rotation pivots around, matching how drawToCanvas blits the region.

Returns

  • void

updateCanvasPointsForCameraFacingQuad( rendererObj: Renderer, ): boolean

protected

Builds this object's quad in the plane the camera is looking at, then projects it - which is what makes directScaled a Doom-style sprite: it faces the camera by construction, it shrinks purely with distance because its corners are offset by world units before being projected, and it is completely independent of the object's own rotation. (Deriving the on-screen size from the object's own projected quad instead would fold its orientation into its size, so a sprite turned edge-on would squash - never what a billboard wants.)

The quad is anchored at its top left corner, exactly as directToCamera anchors the region it blits - so an object switched between the two billboard modes stays put, and only its size changes.

Parameters

Returns

  • boolean — true if every corner projected onto the canvas

getDirectModeCanvasSize(): SizeWH

protected

The on-canvas size of this object in the direct (billboard) draw modes - its drawn size scaled by the owning entity, matching the scale drawToCanvas applies to the region it blits.

Returns

computeNormalDebugInfo(rendererObj: Renderer): void

protected

Parameters

Returns

  • void

getNormalDebugPoint(): BGE.Math.Vector

protected

Returns

  • BGE.Math.Vector

attemptTransformTempBitmap( renderObj: Renderer, drawMode: SceneObjectDrawMode, ): TransformTempBitmapDetails

protected

Determine if we can just scale and/or rotate the temp bitmap to match the required position

Parameters

Returns

doNotDrawBecauseBackFace(drawMode: SceneObjectDrawMode): boolean

protected

Is this a back and then we should not draw it?

Parameters

Returns

  • boolean — true if we should not draw

getTempBitmapThreshold(drawMode: SceneObjectDrawMode): integer

protected

Parameters

Returns

  • integer