Table of Contents

Class PivotedRenderables

Namespace
AlphaFramework.Presentation
Assembly
AlphaFramework.Presentation.dll

An ICollection<T> facade over the root renderables of a Scene that groups everything belonging to one owner under a shared transform.

public sealed class PivotedRenderables : ICollection<PositionableRenderable>, IEnumerable<PositionableRenderable>, IEnumerable
Inheritance
object
PivotedRenderables
Implements

Remarks

ModelViewSync<TModel, TView> knows nothing about render hierarchies; it only adds and removes flat representations. Create callbacks therefore call AddTo<T>(T, object, string?) to put a renderable into an owner's group. The subsequent Add(PositionableRenderable) then leaves it where it is, while Remove(PositionableRenderable) works for either case.

A group only gets a Pivot of its own once more than one thing needs to share the owner's transform. While a group holds a single renderable, that renderable carries the transform itself and its own local transform is folded into PreTransform. Adding a second renderable or attaching a light or sound promotes the group to a pivot, which takes over the owner's position, rotation and scale; it is never demoted again.

Renderables added to a group remain owned by the caller: releasing a group only disposes the Pivot itself.

Constructors

PivotedRenderables(ICollection<PositionableRenderable>)

An ICollection<T> facade over the root renderables of a Scene that groups everything belonging to one owner under a shared transform.

public PivotedRenderables(ICollection<PositionableRenderable> roots)

Parameters

roots ICollection<PositionableRenderable>

The scene's root renderables, usually Positionables.

Remarks

ModelViewSync<TModel, TView> knows nothing about render hierarchies; it only adds and removes flat representations. Create callbacks therefore call AddTo<T>(T, object, string?) to put a renderable into an owner's group. The subsequent Add(PositionableRenderable) then leaves it where it is, while Remove(PositionableRenderable) works for either case.

A group only gets a Pivot of its own once more than one thing needs to share the owner's transform. While a group holds a single renderable, that renderable carries the transform itself and its own local transform is folded into PreTransform. Adding a second renderable or attaching a light or sound promotes the group to a pivot, which takes over the owner's position, rotation and scale; it is never demoted again.

Renderables added to a group remain owned by the caller: releasing a group only disposes the Pivot itself.

Properties

Count

public int Count { get; }

Property Value

int

GroupedRenderables

All renderables that belong to some owner's group.

public IEnumerable<PositionableRenderable> GroupedRenderables { get; }

Property Value

IEnumerable<PositionableRenderable>

Remarks

Excludes the Pivots themselves, which have no geometry.

IsReadOnly

public bool IsReadOnly { get; }

Property Value

bool

Methods

Add(PositionableRenderable)

public void Add(PositionableRenderable item)

Parameters

item PositionableRenderable

AddTo<T>(T, object, string?)

Adds a renderable to an owner's group, so that it follows the owner's transform.

public T AddTo<T>(T renderable, object owner, string? name = null) where T : PositionableRenderable

Parameters

renderable T

The renderable, with its placement relative to the owner already applied to Position and friends.

owner object

An object identifying the group, usually an element of the game world.

name string

The Name to give a Pivot created for this group.

Returns

T

renderable, so that this can be used inline in create callbacks.

Type Parameters

T

AnchorFor(object)

The node that carries an owner's transform; null if nothing belongs to that owner.

public PositionableRenderable? AnchorFor(object owner)

Parameters

owner object

Returns

PositionableRenderable

Remarks

This is either the group's Pivot or, for a group holding a single renderable, that renderable.

Clear()

public void Clear()

Contains(PositionableRenderable)

public bool Contains(PositionableRenderable item)

Parameters

item PositionableRenderable

Returns

bool

CopyTo(PositionableRenderable[], int)

public void CopyTo(PositionableRenderable[] array, int arrayIndex)

Parameters

array PositionableRenderable[]
arrayIndex int

GetEnumerator()

public IEnumerator<PositionableRenderable> GetEnumerator()

Returns

IEnumerator<PositionableRenderable>

Remarks

The scene roots already cover collapsed members and pivots, so only what lives below them is added.

LocalTransformOf(PositionableRenderable)

The transform that places a grouped renderable's geometry in its owner's coordinate system.

public Matrix LocalTransformOf(PositionableRenderable renderable)

Parameters

renderable PositionableRenderable

Returns

Matrix

Remarks

Reading Position directly is not enough, because a collapsed member uses it for the owner's world position.

MovePlacements(PositionableRenderable, PositionableRenderable)

Moves all renderables currently placed underneath from over to to.

public void MovePlacements(PositionableRenderable from, PositionableRenderable to)

Parameters

from PositionableRenderable
to PositionableRenderable

Remarks

Use this when a parent renderable is replaced by a freshly built one.

PivotFor(object, string?)

Gets the Pivot of an owner's group, creating it if there is none yet.

public Pivot PivotFor(object owner, string? name = null)

Parameters

owner object

An object identifying the group, usually an element of the game world.

name string

The Name to give a newly created pivot.

Returns

Pivot

Remarks

Use this for objects that are not renderables themselves but resolve their position through one, i.e. lights and sounds. It permanently keeps the group on a pivot, because a collapsed member's transform carries its own geometry's placement, which must not leak into such attachments.

PlaceUnder<T>(T, PositionableRenderable)

Places a renderable in the local coordinate system of parent instead of at the scene root.

public T PlaceUnder<T>(T renderable, PositionableRenderable parent) where T : PositionableRenderable

Parameters

renderable T
parent PositionableRenderable

Returns

T

renderable, so that this can be used inline in create callbacks.

Type Parameters

T

Remarks

Unlike AddTo<T>(T, object, string?) this names the parent directly, for hierarchies that are not built around an owner.

Release(object)

Drops an owner's group, disposing a Pivot it may have created.

public void Release(object owner)

Parameters

owner object

Remarks

Groups that hold no renderables are dropped automatically; this is only needed for ones kept alive by PivotFor(object, string?).

ReleaseAll()

Drops all groups, disposing the Pivots they created.

public void ReleaseAll()

Remove(PositionableRenderable)

public bool Remove(PositionableRenderable item)

Parameters

item PositionableRenderable

Returns

bool