SceneObjectModel

Extends: SceneObjectBillboard

Properties


Constructor

new SceneObjectModel( name: string, drawableObj: DrawableModel, ): SceneObjectModel

Parameters


Instance Methods

didRegionToDrawChange(): boolean

protected

Returns

  • boolean

getFaceStaleFrameCount(faceIndex: integer): integer

For tests/telemetry only - how many consecutive frames the face at faceIndex has reused its cached raster since its last real redraw (0 right after a redraw).

Parameters

  • faceIndex (integer)

Returns

  • integer — -1 if this face has never been drawn at all

getFaceBrightness(index: integer): float

For tests/telemetry only - the isShaded brightness (0-1, floored by Drawable.ambientBrightness - see updateCanvasPosition()) computed this frame for the face at index in front-to-back draw order.

Parameters

  • index (integer)

Returns

  • float — -1 if index is out of range

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

protected

Parameters

Returns

  • boolean

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

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

getAllCanvasPoints(): dynamic

protected

Returns

  • dynamic

getOutlineCanvasPoints(): dynamic

protected

A model is a triangle mesh, not a single quad, so there is no one perimeter to stroke - outlining a model means the wireFrame draw modes (which stroke every face), not the Drawable.outlineRGBA outline the other billboard SceneObjects support.

Returns

  • dynamic

getCanvasBounds(): dynamic

protected

Returns

  • dynamic

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

protected

Parameters

Returns

  • boolean

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

protected

The base class's reuse check (SceneObjectBillboard.attemptTransformTempBitmap) fits one rotate+scale from the whole-model silhouette - exact for a single rigid quad, but not for a model: rotating around any axis but the one facing the camera changes each face's shape/occlusion non-rigidly relative to the others even while the silhouette still fits (the cause of issue #128's rotation glitch). A pure camera-distance zoom has no such risk (every face scales identically, no rotation), so this only accepts the base class's fit when both its rotation and its scaleX/scaleY are negligible, and only when every face was freshly redrawn this frame (lastDrawWasFullyFresh) rather than reused per-face (drawFaceWithReuse()) - stretching an already-patchwork bitmap would compound each face's own staleness/drift. See #163.

Parameters

Returns

getTempBitmapThreshold(drawMode: SceneObjectDrawMode): integer

protected

Restores the wider drift tolerance the base class's 16px default is too tight for - a model's whole-silhouette reuse (see attemptTransformTempBitmap() above) only ever fires for a pure zoom, so it can safely tolerate more drift than a single quad's rotate+scale fit before falling back to per-face reuse (drawFaceWithReuse()).

Parameters

Returns

  • integer

canReuseTransformedTempBitmap( renderObj: Renderer, drawMode: SceneObjectDrawMode, ): boolean

For tests/telemetry only - exposes attemptTransformTempBitmap()'s result without needing test code to reach a protected member directly.

Parameters

Returns

  • boolean

getPrimitiveCount(): integer

Overrides the base class's "always 1" default: a model's real primitive count is its actual current face list, which m.modelCanvasFaces (rebuilt every frame by updateCanvasPosition, above) already reflects correctly for whatever draw mode is active - front-facing-only for oriented/solid/wireFrame, front+back for the DrawBackFace variants, and empty for matchCamera/directToCamera/directScaled (which this class doesn't render at all via any path). No new draw-mode-awareness is needed here - it's inherited for free from updateCanvasPosition's existing, already-correct backface-cull logic.

Returns

  • integer

getPrimitiveDepth(index: integer): float

priority (computed in updateCanvasPosition, above) is a positive value equal to the distance of the face's closest vertex to the camera - larger for a farther face. That's the OPPOSITE sign convention from the base class's negDistanceFromCamera (negative in front of the camera, more negative = farther), which is what Renderer.drawPendingClusterPrimitives()'s combined sort assumes for every primitive regardless of SceneObject subtype. Negating it here converts to that shared convention: -priority is negative, and more negative for a farther face (e.g. a face 100 units out has priority 100 -> depth -100, versus a face 10 units out with priority 10 -> depth -10; ascending sort puts -100 before -10, i.e. farthest first, matching negDistanceFromCamera and the main scene's own painter's-algorithm sort).

Fixed (issue #112): updateCanvasPosition()'s m.modelCanvasFaces.SortBy("priority", "r") now sorts descending (farthest-first), matching this method's own farthest-first convention - the solo draw loop (drawToCanvas/drawToTempBitmap, which iterate modelCanvasFaces in stored order with no reversal) and the cluster draw path (this method + drawPrimitive, which look up by index and get re-sorted by Renderer.drawPendingClusterPrimitives independently) now agree: both draw a model's self-overlapping faces farthest-first, nearest-last-on-top, regardless of whether the model draws solo or as part of a multi-member overlap cluster.

Parameters

  • index (integer)

Returns

  • float

drawPrimitive(rendererObj: Renderer, index: integer): boolean

Parameters

  • rendererObj (Renderer)
  • index (integer)

Returns

  • boolean