Table of Contents

Class ViewportExtensions

Namespace
HelixToolkit.Wpf.SharpDX
Assembly
HelixToolkit.Wpf.SharpDX.dll

Provides extension methods for Viewport3DX.

public static class ViewportExtensions
Inheritance
ViewportExtensions
Inherited Members

Fields

EmptyHits

public static readonly HitTestResult[] EmptyHits

Field Value

HitTestResult[]

Methods

Copy(Viewport3DX)

Copies the specified viewport to the clipboard.

public static void Copy(this Viewport3DX view)

Parameters

view Viewport3DX

FindBounds3D(Viewport3DX)

Finds the bounding box of the viewport.

public static Rect3D FindBounds3D(this Viewport3DX viewport)

Parameters

viewport Viewport3DX

The viewport.

Returns

Rect3D

The bounding box.

FindHits(Viewport3DX, Point)

Finds the hits for a given 2D viewport position.

public static IList<HitTestResult> FindHits(this Viewport3DX viewport, Point position)

Parameters

viewport Viewport3DX

The viewport.

position Point

The position.

Returns

IList<HitTestResult>

List of hits, sorted with the nearest hit first.

FindNearest(Viewport3DX, Point, out Point3D, out Vector3D, out Element3D?, out SceneNode?)

Finds the nearest point and its normal.

public static bool FindNearest(this Viewport3DX viewport, Point position, out Point3D point, out Vector3D normal, out Element3D? model, out SceneNode? node)

Parameters

viewport Viewport3DX

The viewport.

position Point

The position.

point Point3D

The point.

normal Vector3D

The normal.

model Element3D

The model.

node SceneNode

Returns

bool

The find nearest.

FindNearestPoint(Viewport3DX, Point)

Find the coordinates of the nearest point given a 2D position in the viewport

public static Point3D? FindNearestPoint(this Viewport3DX viewport, Point position)

Parameters

viewport Viewport3DX

The viewport.

position Point

The position.

Returns

Point3D?

The nearest point, or null if no point was found.

GetScreenViewProjectionMatrix3D(Viewport3DX)

Gets the total transform for a Viewport3DX. Old name of this function: GetTotalTransform New name of the function: GetScreenViewProjectionTransform

public static Matrix3D GetScreenViewProjectionMatrix3D(this Viewport3DX viewport)

Parameters

viewport Viewport3DX

The viewport.

Returns

Matrix3D

The total transform.

GetTotalNumberOfTriangles(Viewport3DX)

Gets the total number of triangles in the viewport.

public static int GetTotalNumberOfTriangles(this Viewport3DX viewport)

Parameters

viewport Viewport3DX

The viewport.

Returns

int

The total number of triangles

GetViewProjectionMatrix3D(Viewport3DX)

Gets the camera transform.

public static Matrix3D GetViewProjectionMatrix3D(this Viewport3DX viewport)

Parameters

viewport Viewport3DX

The viewport.

Returns

Matrix3D

The camera transform.

GetViewportMatrix3D(Viewport3DX)

Gets the viewport transform aka the screen-space transform.

public static Matrix3D GetViewportMatrix3D(this Viewport3DX viewport)

Parameters

viewport Viewport3DX

The viewport.

Returns

Matrix3D

The transform.

Print(Viewport3DX, string)

Prints the specified viewport.

public static void Print(this Viewport3DX vp, string description)

Parameters

vp Viewport3DX

The viewport.

description string

The description.

Project(Viewport3DX, Point3D)

Projects the specified 3D point to a 2D screen point.

public static Point Project(this Viewport3DX viewport, Point3D point)

Parameters

viewport Viewport3DX

The viewport.

point Point3D

The 3D point.

Returns

Point

The point.

RenderBitmap(Viewport3DX)

Renders the viewport to a bitmap.

public static BitmapSource? RenderBitmap(this Viewport3DX view)

Parameters

view Viewport3DX

The viewport.

Returns

BitmapSource

A bitmap.

RenderBitmap(Viewport3DX, int, int)

Renders the viewport to a bitmap.

public static BitmapSource? RenderBitmap(this Viewport3DX view, int width, int height)

Parameters

view Viewport3DX

The viewport.

width int

The width.

height int

The height.

Returns

BitmapSource

A bitmap.

ResizeAndArrange(Viewport3DX, int, int)

Resizes and arranges the viewport.

public static void ResizeAndArrange(this Viewport3DX view, int width, int height)

Parameters

view Viewport3DX

The view.

width int

The width.

height int

The height.

SaveScreen(Viewport3DX, string)

Saves the bitmap.

public static void SaveScreen(this Viewport3DX view, string fileName)

Parameters

view Viewport3DX

The view.

fileName string

Name of the file.

SaveScreen(Viewport3DX, string, Direct2DImageFormat)

Saves the bitmap.

public static void SaveScreen(this Viewport3DX view, string fileName, Direct2DImageFormat format)

Parameters

view Viewport3DX

The view.

fileName string

Name of the file.

format Direct2DImageFormat

The format.

Traverse<T>(Element3D, Action<T, Transform3D>)

Traverses the Visual3D/Element3D tree and invokes the specified action on each Element3D of the specified type.

public static void Traverse<T>(this Element3D element, Action<T, Transform3D> action) where T : Element3D

Parameters

element Element3D

The element.

action Action<T, Transform3D>

The action.

Type Parameters

T

The type filter.

Traverse<T>(Viewport3DX, Action<T, Transform3D>)

Traverses the Visual3D/Element3D tree and invokes the specified action on each Element3D of the specified type.

public static void Traverse<T>(this Viewport3DX viewport, Action<T, Transform3D> action) where T : Element3D

Parameters

viewport Viewport3DX

The viewport.

action Action<T, Transform3D>

The action.

Type Parameters

T

The type filter.

Traverse<T>(Viewport3DX, Func<T, bool>)

Traverses the specified action.

public static void Traverse<T>(this Viewport3DX viewport, Func<T, bool> function) where T : Element3D

Parameters

viewport Viewport3DX

The viewport.

function Func<T, bool>

The function. Return true to continue traverse, otherwise stop at current node

Type Parameters

T

UnProject(Viewport3DX, Vector2)

Un-projects a 2D screen point.

public static Ray UnProject(this Viewport3DX viewport, Vector2 point2d)

Parameters

viewport Viewport3DX

The viewport.

point2d Vector2

The input point.

Returns

Ray

The ray.

UnProject(Viewport3DX, Point)

Un-projects a 2D screen point.

public static Ray UnProject(this Viewport3DX viewport, Point point2d)

Parameters

viewport Viewport3DX

The viewport.

point2d Point

The input point.

Returns

Ray

The ray.

UnProjectOnPlane(Viewport3DX, Vector2, Plane)

public static Vector3? UnProjectOnPlane(this Viewport3DX viewport, Vector2 p, Plane plane)

Parameters

viewport Viewport3DX
p Vector2
plane Plane

Returns

Vector3?

UnProjectOnPlane(Viewport3DX, Point)

Un-projects a point from the screen (2D) to a point on the plane trough the camera target point.

public static Point3D? UnProjectOnPlane(this Viewport3DX viewport, Point p)

Parameters

viewport Viewport3DX

The viewport.

p Point

The 2D point.

Returns

Point3D?

A 3D point.

UnProjectOnPlane(Viewport3DX, Point, Point3D, Vector3D)

Un-project a point from the screen (2D) to a point on plane (3D)

public static Point3D? UnProjectOnPlane(this Viewport3DX viewport, Point p, Point3D position, Vector3D normal)

Parameters

viewport Viewport3DX

The viewport.

p Point

The 2D point.

position Point3D

plane position

normal Vector3D

plane normal

Returns

Point3D?

A 3D point.

ZoomByChangingFieldOfView(Viewport3DX, double)

Changes the field of view and tries to keep the scale fixed.

public static void ZoomByChangingFieldOfView(this Viewport3DX viewport, double delta)

Parameters

viewport Viewport3DX

The viewport.

delta double

The relative change in fov.

ZoomExtents(Viewport3DX, double)

Zooms to the extents of the specified viewport.

public static void ZoomExtents(this Viewport3DX viewport, double animationTime = 0)

Parameters

viewport Viewport3DX

The viewport.

animationTime double

The animation time.

ZoomExtents(Viewport3DX, Point3D, double, double)

Zooms to the extents of the specified bounding sphere.

public static void ZoomExtents(this Viewport3DX viewport, Point3D center, double radius, double animationTime = 0)

Parameters

viewport Viewport3DX

The viewport.

center Point3D

The center of the sphere.

radius double

The radius of the sphere.

animationTime double

The animation time.

ZoomExtents(Viewport3DX, Rect3D, double)

Zooms to the extents of the specified bounding box.

public static void ZoomExtents(this Viewport3DX viewport, Rect3D bounds, double animationTime = 0)

Parameters

viewport Viewport3DX

The viewport.

bounds Rect3D

The bounding rectangle.

animationTime double

The animation time.

ZoomToRectangle(Viewport3DX, Rect)

Zooms the viewport to the specified rectangle.

public static void ZoomToRectangle(this Viewport3DX viewport, Rect rectangle)

Parameters

viewport Viewport3DX

The viewport.

rectangle Rect

The rectangle.