Table of Contents

Class View

Namespace
OmegaEngine.Graphics
Assembly
OmegaEngine.dll

Controls the rendering of a Scene using a Camera.

public class View : EngineElement, IDisposable
Inheritance
View
Implements
Derived
Inherited Members
Extension Methods

Remarks

Multiple Views can share the same Scene, but they should all have separate Cameras.

Constructors

View(Scene, Camera, Rectangle)

Creates a new view for rendering

public View(Scene scene, Camera camera, Rectangle area = default)

Parameters

scene Scene

The scene containing the PositionableRenderables to be rendered. Will NOT be disposed when Dispose() is called.

camera Camera

The Camera to look at the Scene with

area Rectangle

The screen area this view should fill (leave empty for fullscreen)

View(Color)

Creates a new view for rendering a plain color fullscreen

public View(Color color)

Parameters

color Color

The plain color to render

Fields

BackgroundQuadDirty

Does the background qaud need to be recreated?

protected bool BackgroundQuadDirty

Field Value

bool

RenderTarget

An alternative surface to render onto instead of the back-buffer

protected RenderTarget? RenderTarget

Field Value

RenderTarget

Properties

Area

The screen area this view should fill (all zero for fullscreen)

public Rectangle Area { get; set; }

Property Value

Rectangle

AreaCenter

The center point of Area

[Browsable(false)]
public Point AreaCenter { get; }

Property Value

Point

BackgroundColor

The background color and fog color of this scene - Empty for no background, may use alpha-channel if FullAlpha is not set

public Color BackgroundColor { get; set; }

Property Value

Color

Camera

The camera describing how to look at the scene

[Browsable(false)]
public Camera Camera { get; set; }

Property Value

Camera

ChildViews

A list of TextureViews that are to be OmegaEngine.Graphics.View.Render()ed before this View. Usually only OmegaEngine.Graphics.View.Render()ed if a PositionableRenderable in Positionables has it listed in RequiredViews.

[Browsable(false)]
public ICollection<TextureView> ChildViews { get; }

Property Value

ICollection<TextureView>

Remarks

Will be disposed when Dispose() is called.

FloatingModels

A list of FloatingModels to be overlayed on top of the Scene. Use this for UI-like elements, e.g. axis-arrows.

[Browsable(false)]
public ICollection<FloatingModel> FloatingModels { get; }

Property Value

ICollection<FloatingModel>

Remarks

Will be disposed when Dispose() is called.

Fog

Automatically apply a fog using BackgroundColor and the Cameras clip planes

public virtual bool Fog { get; set; }

Property Value

bool

FullAlpha

The level of transparency from 0 (solid) to 255 (invisible) for the complete scene

public virtual int FullAlpha { get; set; }

Property Value

int

InvertCull

Cull clockwise instead of counter-clockwise?

public bool InvertCull { get; set; }

Property Value

bool

Lighting

Is lighting used in OmegaEngine.Graphics.View.RenderScene()?

public virtual bool Lighting { get; set; }

Property Value

bool

Name

Text value to make it easier to identify a particular view

public string Name { get; set; }

Property Value

string

PostShaders

A list of post-processing shaders to be applied after rendering the scene

[Browsable(false)]
public ICollection<PostShader> PostShaders { get; }

Property Value

ICollection<PostShader>

Remarks

Will be disposed when Dispose() is called.

RenderedInLastFrame

Was this view rendered in the this frame?

public bool RenderedInLastFrame { get; }

Property Value

bool

Remarks

Used to debug culling methods

Scene

The scene containing the PositionableRenderables to be rendered.

[Browsable(false)]
public Scene Scene { get; }

Property Value

Scene

Remarks

Will NOT be disposed when Dispose() is called.

TextureRenderTarget

Does this View render to a texture RenderTarget? Only true for TextureViews.

protected virtual bool TextureRenderTarget { get; }

Property Value

bool

Visible

Shall the scene be rendered?

public bool Visible { get; set; }

Property Value

bool

Methods

ApplyPostShaders(bool)

Applies PostShaders to the output

protected virtual void ApplyPostShaders(bool sceneOnBackBuffer)

Parameters

sceneOnBackBuffer bool

Is the scene currently on the backbuffer?
If this is false, it is in RenderTarget.

IsToRender(PositionableRenderable)

Checks if a PositionableRenderable is supposed to be rendered in this type of View

protected virtual bool IsToRender(PositionableRenderable body)

Parameters

body PositionableRenderable

The PositionableRenderable to check

Returns

bool

true if the PositionableRenderable is supposed to be rendered

OnDispose()

Hook that is called when the object needs to dispose its internal resources.

protected override void OnDispose()

OnEngineSet()

Hook that is called when Engine is set for the first time.

protected override void OnEngineSet()

Pick(Point, out DoubleVector3)

Pick an PositionableRenderable in 3D-space using the mouse

public PositionableRenderable Pick(Point location, out DoubleVector3 position)

Parameters

location Point

The screen space location to start the ray from (usually mouse coordinates)

position DoubleVector3

Returns the position of the vertex closest to the intersection in entity space

Returns

PositionableRenderable

The picked PositionableRenderable or null.

PickingRay(Point)

Generates a 3D picking ray.

public Ray PickingRay(Point location)

Parameters

location Point

The screen space location to start the ray from (usually mouse coordinates)

Returns

Ray

A ray in world space starting at the Camera position moving towards the specified location.

PrepareRenderTarget()

Prepares a RenderTarget texture if there is none yet - call as often as you want

protected void PrepareRenderTarget()

RenderBackground()

Renders the back of the Scene

protected virtual void RenderBackground()

RenderBody(PositionableRenderable)

Renders a PositionableRenderable from the Scene

protected virtual void RenderBody(PositionableRenderable body)

Parameters

body PositionableRenderable

The PositionableRenderable to render

SetupGlow(float, float)

Creates a glow-map of this view and adds it to ChildViews

public void SetupGlow(float blurStrength = 3, float glowStrength = 1.5)

Parameters

blurStrength float

How strongly to blur the glow map - values between 0 and 10

glowStrength float

A factor by which the blurred glow color is multiplied - values between 0 and 100

Remarks

Calling this method multiple times will have no effect

SetupShadow(LightSource)

Creates a shadow-map for a LightSource in the Scene

public void SetupShadow(LightSource light)

Parameters

light LightSource

The LightSource to create the shadow-map for

ShaderToRenderTarget(PostShader)

Updates the RenderTarget using a PostShader

protected void ShaderToRenderTarget(PostShader shader)

Parameters

shader PostShader

The PostShader to apply

SwingCameraTo(Camera, float)

Switches from the current camera view to a new view using a cinematic effect

public void SwingCameraTo(Camera target, float duration = 1)

Parameters

target Camera

The new camera

duration float

The complete transition time in seconds

ToString()

Returns a string that represents the current object.

public override string ToString()

Returns

string

A string that represents the current object.

Events

PreRender

Occurs immediately before the Scene begins rendering. ChildViews will have been rendered already.

public event Action<Camera> PreRender

Event Type

Action<Camera>