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
Methods
Copy(Viewport3DX)
Copies the specified viewport to the clipboard.
public static void Copy(this Viewport3DX view)
Parameters
viewViewport3DX
FindBounds3D(Viewport3DX)
Finds the bounding box of the viewport.
public static Rect3D FindBounds3D(this Viewport3DX viewport)
Parameters
viewportViewport3DXThe 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
viewportViewport3DXThe viewport.
positionPointThe 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
viewportViewport3DXThe viewport.
positionPointThe position.
pointPoint3DThe point.
normalVector3DThe normal.
modelElement3DThe model.
nodeSceneNode
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
viewportViewport3DXThe viewport.
positionPointThe 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
viewportViewport3DXThe 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
viewportViewport3DXThe viewport.
Returns
- int
The total number of triangles
GetViewProjectionMatrix3D(Viewport3DX)
Gets the camera transform.
public static Matrix3D GetViewProjectionMatrix3D(this Viewport3DX viewport)
Parameters
viewportViewport3DXThe 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
viewportViewport3DXThe viewport.
Returns
- Matrix3D
The transform.
Print(Viewport3DX, string)
Prints the specified viewport.
public static void Print(this Viewport3DX vp, string description)
Parameters
vpViewport3DXThe viewport.
descriptionstringThe description.
Project(Viewport3DX, Point3D)
Projects the specified 3D point to a 2D screen point.
public static Point Project(this Viewport3DX viewport, Point3D point)
Parameters
viewportViewport3DXThe viewport.
pointPoint3DThe 3D point.
Returns
- Point
The point.
RenderBitmap(Viewport3DX)
Renders the viewport to a bitmap.
public static BitmapSource? RenderBitmap(this Viewport3DX view)
Parameters
viewViewport3DXThe 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
viewViewport3DXThe viewport.
widthintThe width.
heightintThe 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
viewViewport3DXThe view.
widthintThe width.
heightintThe height.
SaveScreen(Viewport3DX, string)
Saves the bitmap.
public static void SaveScreen(this Viewport3DX view, string fileName)
Parameters
viewViewport3DXThe view.
fileNamestringName of the file.
SaveScreen(Viewport3DX, string, Direct2DImageFormat)
Saves the bitmap.
public static void SaveScreen(this Viewport3DX view, string fileName, Direct2DImageFormat format)
Parameters
viewViewport3DXThe view.
fileNamestringName of the file.
formatDirect2DImageFormatThe 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
elementElement3DThe element.
actionAction<T, Transform3D>The action.
Type Parameters
TThe 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
viewportViewport3DXThe viewport.
actionAction<T, Transform3D>The action.
Type Parameters
TThe 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
viewportViewport3DXThe viewport.
functionFunc<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
viewportViewport3DXThe viewport.
point2dVector2The 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
viewportViewport3DXThe viewport.
point2dPointThe input point.
Returns
- Ray
The ray.
UnProjectOnPlane(Viewport3DX, Vector2, Plane)
public static Vector3? UnProjectOnPlane(this Viewport3DX viewport, Vector2 p, Plane plane)
Parameters
viewportViewport3DXpVector2planePlane
Returns
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
viewportViewport3DXThe viewport.
pPointThe 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
viewportViewport3DXThe viewport.
pPointThe 2D point.
positionPoint3Dplane position
normalVector3Dplane 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
viewportViewport3DXThe viewport.
deltadoubleThe 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
viewportViewport3DXThe viewport.
animationTimedoubleThe 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
viewportViewport3DXThe viewport.
centerPoint3DThe center of the sphere.
radiusdoubleThe radius of the sphere.
animationTimedoubleThe 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
viewportViewport3DXThe viewport.
boundsRect3DThe bounding rectangle.
animationTimedoubleThe animation time.
ZoomToRectangle(Viewport3DX, Rect)
Zooms the viewport to the specified rectangle.
public static void ZoomToRectangle(this Viewport3DX viewport, Rect rectangle)
Parameters
viewportViewport3DXThe viewport.
rectangleRectThe rectangle.