QuadColumnDrawer

Draws a perspective-textured quad as projected texture columns: one DrawTransformedObject per 1-texel column, perspective correct, with no scratch bitmaps. Textured triangles (model faces) draw the same way with drawTriangleTo().

Corners are given in camera space and projected once; column ends are lerped in camera space then divided (or, with an orthographic projection, just scaled). Columns run along whichever texture axis changes depth least, so each is near constant depth. How many is set by render quality (quadColumnsPerTexel, quadMinPixelsPerColumn), and a per-frame budget keeps a bitmap under Roku's limit on queued draws. Call beginFrame() once per frame (Renderer.render() does).

Properties

  • maxColumnsPerFrame (integer) — Most columns drawn per frame, across every quad (Roku drops all draws into a bitmap
  • nearZ (float) — Camera-space z a point must be at or below to be in front of the camera. setProjection()
  • columnsThisFrame (integer) — Columns drawn this frame
  • lastColumnCount (integer) — Of the last drawTo(): columns it worked out, and whether they were texture rows
  • lastUsedRows (boolean)

Constructor

new QuadColumnDrawer(): QuadColumnDrawer

Instance Methods

beginFrame(settings: BGE.RenderQualitySettings): void

Starts a frame: resets the column budget and reads the column density.

Parameters

Returns

  • void

setProjection( focal: float, canvasWidth: float, canvasHeight: float, ): void

Sets the projection: screen x = centerX + focal * x / -z, screen y = centerY - focal * y / -z.

Parameters

  • focal (float) — focal length in pixels
  • canvasWidth (float)
  • canvasHeight (float)

Returns

  • void

setOrthographicProjection( scaleX: float, scaleY: float, canvasWidth: float, canvasHeight: float, ): void

Sets an orthographic projection (a Camera2d): screen x = centerX + scaleX * x, screen y = centerY - scaleY * y. In front is still z < 0.

Parameters

  • scaleX (float) — pixels per camera-space unit across
  • scaleY (float) — pixels per camera-space unit up
  • canvasWidth (float)
  • canvasHeight (float)

Returns

  • void

setProjectionCenter(centerX: float, centerY: float): void

Moves where the view axis lands on the target, for a bitmap placed elsewhere on the canvas (may be negative or past its edges). Call after setProjection().

Parameters

  • centerX (float)
  • centerY (float)

Returns

  • void

drawTo( target: ifDraw2D, corners: Array.<float>, texture: BGE.QuadColumnTexture, colors: Array.<integer>, ): integer

Draws a textured quad into target.

Parameters

  • target (ifDraw2D) — an roBitmap or roScreen
  • corners (Array.<float>) — 12 floats: camera-space x, y, z (in front is -z) of the texture's top-left, top-right, bottom-left and bottom-right
  • texture (BGE.QuadColumnTexture)
  • colors (Array.<integer>) — one RGBA tint (with fade alpha), or one per corner in the same order, blended across the columns (e.g. lighting)

Returns

  • integer — how many columns were drawn

drawTiledTo( target: ifDraw2D, corners: Array.<float>, texture: BGE.QuadColumnTexture, colors: Array.<integer>, repeatU: float, repeatV: float, ): integer

drawTo(), repeating the texture repeatU times across and repeatV times down instead of stretching it once. Tiles start at the texture's left and bottom edges (a wall's foot), so a partial tile is on the right or top. Columns wrap the texture across them in one pass; along their length the quad is drawn in bands, one per repeat.

Parameters

  • target (ifDraw2D) — an roBitmap or roScreen
  • corners (Array.<float>) — as drawTo()
  • texture (BGE.QuadColumnTexture)
  • colors (Array.<integer>) — as drawTo()
  • repeatU (float) — times the texture repeats across (u)
  • repeatV (float) — times the texture repeats down (v)

Returns

  • integer — how many columns were drawn

drawTriangleTo( target: ifDraw2D, vertices: Array.<float>, cuts: BGE.TriangleColumnCuts, color: integer, ): integer

Draws a textured triangle (a model face) into target as strips cut to the triangle (see BGE.TriangleColumnCuts), a power of two texels wide, sized like drawTo()'s columns.

Parameters

  • target (ifDraw2D) — an roBitmap or roScreen
  • vertices (Array.<float>) — 9 floats: camera-space x, y, z of the face's 3 vertices, in the order of the texture points cuts was made from
  • cuts (BGE.TriangleColumnCuts)
  • color (integer) — RGBA tint

Returns

  • integer — how many strips were drawn: 0 if it's wholly behind the camera, or -1 if it can't be drawn this way (no UV area, or this frame's budget is spent)