Class PositionableRenderable
- Namespace
- OmegaEngine.Graphics.Renderables
- Assembly
- OmegaEngine.dll
An object that can be OmegaEngine.Graphics.Renderables.PositionableRenderable.Render(OmegaEngine.Graphics.RenderContext)ed at a specific Position in a Scene.
public abstract class PositionableRenderable : Renderable, IDisposable, IPositionable
- Inheritance
-
objectPositionableRenderable
- Implements
- Derived
- Inherited Members
Constructors
PositionableRenderable()
Creates a new positionable renderable.
protected PositionableRenderable()
Properties
Billboard
How this PositionableRenderable shall be rotated towards the camera
public BillboardMode Billboard { get; set; }
Property Value
BoundingBox
An axis-aligned box that completely encompasses the body (in entity space, even before apply PreTransform).
[Browsable(false)]
public BoundingBox? BoundingBox { get; protected set; }
Property Value
- BoundingBox?
BoundingSphere
A sphere that completely encompasses the body (in entity space, even before apply PreTransform).
[Browsable(false)]
public BoundingSphere? BoundingSphere { get; protected set; }
Property Value
- BoundingSphere?
Children
The PositionableRenderables placed in this one's local coordinate system.
[Browsable(false)]
public ICollection<PositionableRenderable> Children { get; }
Property Value
Remarks
A renderable lives in exactly one collection at a time: either this or Positionables. Adding it here removes it from its previous collection and keeps its local Position, Rotation, Scale and PreTransform, i.e. its world position changes.
Setting Visible to false hides the entire subtree. A View skips the entire subtree if SubtreeBoundingSphere or SubtreeBoundingBox is outside its view frustum.
Will be disposed when Dispose() is called.
DrawBoundingBox
Shall the bounding box used to cull this object be drawn/visualized? (used for debugging)
public bool DrawBoundingBox { get; set; }
Property Value
DrawBoundingSphere
Shall the bounding sphere used to cull this object be drawn/visualized? (used for debugging)
public bool DrawBoundingSphere { get; set; }
Property Value
FloatingBoundingBox
An axis-aligned box that completely encompasses the body (in floating space, with minimum screen size scaling and billboarding but without distance compression; see FloatingTransformCached).
[Browsable(false)]
public BoundingBox? FloatingBoundingBox { get; }
Property Value
- BoundingBox?
FloatingBoundingSphere
A sphere that completely encompasses the body (in floating space, with minimum screen size scaling and billboarding but without distance compression; see FloatingTransformCached).
[Browsable(false)]
public BoundingSphere? FloatingBoundingSphere { get; }
Property Value
- BoundingSphere?
FloatingTransformCached
Transforms from entity space into floating space, with minimum screen size scaling and billboarding but without distance compression.
protected Matrix FloatingTransformCached { get; }
Property Value
- Matrix
Remarks
The transform behind FloatingBoundingSphere and FloatingBoundingBox.
Distance compression scales uniformly around the camera, which leaves the view frustum, the apparent size and any ray starting at the camera unchanged. So this suffices for culling and picking against what is rendered, while keeping bodies at their true distances for lighting and shadows.
Cached value, without ensuring it is up-to-date.
MinScreenSizeDistance
The renderable never appears smaller on screen than it does at this distance from the Camera, keeping distant objects visible.
public float? MinScreenSizeDistance { get; set; }
Property Value
Remarks
While closer than this distance the renderable renders at its natural size; farther away it is scaled up to preserve its apparent size (angular diameter) at this distance.
The scaling is applied on top of Scale and is reflected in the bounding bodies used for culling. Combine with DistanceCompressionStart for very large, very distant objects.
PhysicalTransform
Transforms from entity space into floating space, composed purely from the hierarchy's transforms.
protected Matrix PhysicalTransform { get; }
Property Value
- Matrix
Remarks
Unlike FloatingTransformCached and OmegaEngine.Graphics.Renderables.PositionableRenderable.RenderTransform this carries no billboarding, distance compression or minimum screen size scaling. Its translation is relative to the floating origin.
Pickable
Shall this PositionableRenderable be pickable with the mouse?
public bool Pickable { get; set; }
Property Value
Position
The body's position: absolute world space for a root, an offset in the parent's coordinate system for an element of another body's Children.
public DoubleVector3 Position { get; set; }
Property Value
- See Also
PreCheckBounding
Controls whether intersection tests first check the bounding bodies to filter out broad misses.
protected virtual bool PreCheckBounding { get; }
Property Value
Remarks
Turn this off for bodies whose bounding bodies nearly every ray hits anyway.
PreTransform
A transformation matrix that is to be applied before the normal world transform occurs - useful for correcting off-center meshes
[Browsable(false)]
public Matrix PreTransform { get; set; }
Property Value
- Matrix
RenderIn
In what kind of Views shall this body be rendered?
public ViewType RenderIn { get; set; }
Property Value
RenderTransformCached
The cached value of OmegaEngine.Graphics.Renderables.PositionableRenderable.RenderTransform, without ensuring it is up-to-date.
protected Matrix RenderTransformCached { get; }
Property Value
- Matrix
RequiredViews
A list of Views that must be rendered before this PositionableRenderable can be rendered
[Browsable(false)]
public ICollection<View> RequiredViews { get; }
Property Value
Rotation
The body's rotation quaternion
[Browsable(false)]
public Quaternion Rotation { get; set; }
Property Value
- Quaternion
Scale
Scaling to be performed before rendering
public Vector3 Scale { get; set; }
Property Value
- Vector3
Remarks
Inherited by Children; non-uniform scaling combined with a rotated child produces shear.
ShadowCaster
Shall this PositionableRenderable cast shadows on other objects?
public bool ShadowCaster { get; set; }
Property Value
ShadowReceiver
Shall this PositionableRenderable receive shadows from other objects?
public bool ShadowReceiver { get; set; }
Property Value
SubtreeBoundingBox
An axis-aligned box that completely encompasses this body and all its Children (in floating space, used for culling whole subtrees).
[Browsable(false)]
public BoundingBox? SubtreeBoundingBox { get; }
Property Value
- BoundingBox?
Remarks
null if the subtree cannot be culled as a whole, e.g. because it contains a body without bounding bodies or with MinScreenSizeDistance.
Unlike FloatingBoundingBox this is independent of any Camera: Billboarded leaves are covered by a box enclosing every possible rotation and DistanceCompressionStart is not applied.
SubtreeBoundingSphere
A sphere that completely encompasses this body and all its Children (in floating space, used for culling whole subtrees).
[Browsable(false)]
public BoundingSphere? SubtreeBoundingSphere { get; }
Property Value
- BoundingSphere?
Remarks
null if the subtree cannot be culled as a whole, e.g. because it contains a body without bounding bodies or with MinScreenSizeDistance.
Unlike FloatingBoundingSphere this is independent of any Camera: Billboarded leaves are covered by a sphere enclosing every possible rotation and DistanceCompressionStart is not applied.
SurfaceEffect
What kinds of surface effects (e.g. lighting) to apply to this PositionableRenderable
public SurfaceEffect SurfaceEffect { get; set; }
Property Value
SurfaceShader
The SurfaceShader to apply to the surface of this PositionableRenderable
public SurfaceShader? SurfaceShader { get; set; }
Property Value
Remarks
Will NOT be disposed when Dispose() is called.
- See Also
WorldPosition
The body's absolute position in world space, resolved through the hierarchy in double precision.
[Browsable(false)]
public DoubleVector3 WorldPosition { get; }
Property Value
Remarks
Methods
EnsureRenderTransform()
Ensures OmegaEngine.Graphics.Renderables.PositionableRenderable.RenderTransform, FloatingTransformCached, the floating bounding bodies and related values are up-to-date.
protected void EnsureRenderTransform()
GetFloatingBoundingSphereOrPosition()
Returns the FloatingBoundingSphere or, if that is not available, a sphere with the floating position and zero radius.
protected BoundingSphere GetFloatingBoundingSphereOrPosition()
Returns
- BoundingSphere
Intersects(Ray, out DoubleVector3)
Determine whether this PositionableRenderable, as it is rendered, is intersected by a ray, and where on its physical body.
public bool Intersects(Ray ray, out DoubleVector3 position)
Parameters
rayRayA ray in render space (floating space, as returned by PickingRay(Point)) along which to check for intersections.
positionDoubleVector3Returns the absolute world space position of the intersection on the body's physical shape;
defaultif there is none.
Returns
- bool
trueif this PositionableRenderable was intersected by theray.
Remarks
The ray is tested against the body as it was last rendered, like Intersects(Ray, out float). The hit is then mapped back to the corresponding point on the body without distance compression, minimum screen size scaling or billboarding.
- See Also
Intersects(Ray, out float)
Determine whether this PositionableRenderable, as it is rendered, is intersected by a ray.
public bool Intersects(Ray ray, out float distance)
Parameters
rayRayA ray in render space (floating space, as returned by PickingRay(Point)) along which to check for intersections.
distancefloatReturns the distance along the
rayat which the intersection took place, in multiples of the length of its direction.
Returns
- bool
trueif this PositionableRenderable was intersected by theray.
Remarks
Tests against the body as it was last rendered, i.e. relative to its floating origin and subject to distance compression, minimum screen size scaling and billboarding.
- See Also
IntersectsGeometry(Ray, out float)
Determine whether the geometry of this PositionableRenderable is intersected by a ray in entity space.
protected virtual bool IntersectsGeometry(Ray ray, out float distance)
Parameters
rayRayA ray in entity space (the space BoundingSphere and BoundingBox live in, even before applying PreTransform) along which to check for intersections. Its direction is not normalized, so that distances keep the scale of the original ray.
distancefloatReturns the distance along the
rayat which the intersection took place.
Returns
- bool
trueif this PositionableRenderable was intersected by theray.
Remarks
Only called if the ray passes the bounding bodies, unless PreCheckBounding is off.
IntersectsWorld(DoubleVector3, Vector3, out float)
Determine whether this PositionableRenderable is intersected by a ray in absolute world space.
public bool IntersectsWorld(DoubleVector3 origin, Vector3 direction, out float distance)
Parameters
originDoubleVector3The absolute world space position the ray starts at.
directionVector3The direction the ray points in.
distancefloatReturns the distance along the ray at which the intersection took place, in multiples of the length of
direction.
Returns
- bool
trueif this PositionableRenderable was intersected by the ray.
Remarks
Tests against the body's physical shape, independent of any Camera, floating origin, distance compression, minimum screen size scaling or billboarding.
- See Also
MarkLocalTransformDirty()
Invalidates all cached transforms of this body and makes its descendants observe the change.
protected void MarkLocalTransformDirty()
Remarks
Called by every mutation of the local transform factors and by every reparenting.
OnEngineSet()
Hook that is called when Engine is set for the first time.
protected override void OnEngineSet()
RecalcRenderTransform()
Hook for recalculating renderable-specific values derived from the transformation matrices.
protected virtual void RecalcRenderTransform()
Remarks
Called by EnsureRenderTransform() after the matrices have been updated.
SetScale(float)
Scales this PositionableRenderable symmetrically
public void SetScale(float factor)
Parameters
factorfloatThe factor by which to scale
Events
PreVisibilityCheck
Triggered before checking the entity for visibility. Will be triggered multiple times if the entity is rendered in multiple views.
public event Action? PreVisibilityCheck