BGE/FogSilhouettes

Alias: BGE.FogSilhouettes


Static Methods

modelParts(faces: Array.<BGE.Model3dFace>): Array.<float>

static

Splits a model into a few boxes by height, where its footprint shrinks sharply (a tower on a nave), for its fog silhouette. Each box covers every face reaching into its height range, so the boxes never cut into the model.

Parameters

Returns

  • Array.<float> — [loX, loY, loZ, hiX, hiY, hiZ] per part, bottom first; empty for no faces

boundsOf( fx0: Array.<float>, fx1: Array.<float>, fz0: Array.<float>, fz1: Array.<float>, y0: float, y1: float, ): Array.<float>

static

Parameters

  • fx0 (Array.<float>)
  • fx1 (Array.<float>)
  • fz0 (Array.<float>)
  • fz1 (Array.<float>)
  • y0 (float)
  • y1 (float)

Returns

  • Array.<float>

mergeRects(boxes: Array.<float>, out: Array.<float>): void

static

Turns screen boxes into rects covering the same pixels with none overlapping, so a translucent fill doesn't darken where the boxes overlap.

Parameters

  • boxes (Array.<float>) — [x0, y0, x1, y1] per box, each with x1 > x0 and y1 > y0
  • out (Array.<float>) — [x, y, w, h] per rect is appended

Returns

  • void

emitBand( spans: Array.<float>, top: float, bottom: float, prevSpans: Array.<float>, prevRects: Array.<integer>, out: Array.<float>, ): Array.<integer>

static

Appends a band's pieces to out: a piece the same as one in the band above carries that rect on down, the rest start new rects.

Parameters

  • spans (Array.<float>)
  • top (float)
  • bottom (float)
  • prevSpans (Array.<float>)
  • prevRects (Array.<integer>)
  • out (Array.<float>)

Returns

  • Array.<integer> — each piece's rect index in out

modelPartPoints( faces: Array.<BGE.Model3dFace>, parts: Array.<float>, ): roArray

static

Each part's points for its outline (see Fog.silhouetteHulls) - the faces' vertices inside the part's height range and where their edges cross its top and bottom, deduped.

Parameters

  • faces (Array.<BGE.Model3dFace>) — in model space
  • parts (Array.<float>) — from modelParts()

Returns

  • roArray — per part, [x, y, z, ...] in model space

extremePoints(pts: Array.<float>): Array.<float>

static

The points furthest along each of a fixed set of directions (the 26 of a cube's faces, edges and corners, and 16 round the horizon), so a detailed part costs at most MAX_HULL_POINTS a frame. Its outline can then sit a little inside the true one.

Parameters

  • pts (Array.<float>)

Returns

  • Array.<float>

addPoint( pts: Array.<float>, seen: roAssociativeArray, x: float, y: float, z: float, ): void

static

Parameters

  • pts (Array.<float>)
  • seen (roAssociativeArray)
  • x (float)
  • y (float)
  • z (float)

Returns

  • void

convexHull(pts: Array.<float>, stride?: integer): Array.<float>

static

The convex hull of points (monotone chain), as [x, y, ...] in order

Parameters

  • pts (Array.<float>) — x, y first in each stride values (2 for [x, y, ...])
  • stride (integer, optional, default: 2)

Returns

  • Array.<float>

hullRects( polys: roArray, band: float, w: float, h: float, out: Array.<float>, ): void

static

Fills the union of convex polygons with rects, none overlapping, clamped to the frame. Bands break at the polygons' corners and step down each leaning edge in stairs at most band px tall and across, on one grid so the sides' steps line up. A band covers each polygon's widest extent within it, so nothing is left uncovered.

Parameters

  • polys (roArray) — [x, y, ...] each, from convexHull()
  • band (float)
  • w (float)
  • h (float)
  • out (Array.<float>)

Returns

  • void

insertSpan( spans: Array.<float>, k: integer, x0: float, x1: float, ): void

static

Inserts [x0, x1] at pair index k of sorted spans, merging any it touches

Parameters

  • spans (Array.<float>)
  • k (integer)
  • x0 (float)
  • x1 (float)

Returns

  • void

Other

SLICES

staticreadonly

Height slices a model is cut into when looking for its parts

Default: 8

SHRINK

staticreadonly

A slice whose footprint is under this fraction of the one below starts a new part

Default: 0.5

MAX_PARTS

staticreadonly

Default: 3

MAX_HULL_POINTS

staticreadonly

Most points a part is outlined by: more are cut down to the extremes (see extremePoints())

Default: 42