Click or drag to resize
AB4D logo

BaseCameraCreatePerspectiveMouseRay3D Method

CreatePerspectiveMouseRay3D is used for perspective camera and calculates a normalized 3D ray that goes from the mouse position into the 3D scene. The ray goes from rayOrigin in the rayDirection. If the ray cannot be calculated this method returns false. For orthographic camera use CreateOrthographicMouseRay3D(Point, Size, Point3D, Vector3D, Vector3D, Double, Double, Point3D, Vector3D) or use non-static CreateMouseRay3D(Point, Point3D, Vector3D) method.

Namespace: Ab3d.Cameras
Assembly: Ab3d.PowerToys (in Ab3d.PowerToys.dll) Version: 11.1.8864.1045
Syntax
C#
public static bool CreatePerspectiveMouseRay3D(
	Point mousePosition,
	Size viewportSize,
	ref Matrix3D viewMatrix,
	ref Matrix3D projectionMatrix,
	out Point3D rayOrigin,
	out Vector3D rayDirection
)

Parameters

mousePosition  Point
mouse position
viewportSize  Size
viewport size - usually size of Viewport3D (AvailableWidth, AvailableHeight)
viewMatrix  Matrix3D
camera's view matrix
projectionMatrix  Matrix3D
camera's projection matrix
rayOrigin  Point3D
out - ray origin
rayDirection  Vector3D
out - normalized ray direction

Return Value

Boolean
true if rayOrigin and rayDirection were set or false if ray cannot be defined (usually when the size of TargetViewport3D is not known)
See Also