Click or drag to resize
AB4D logo

PlaneVisual3DAlignWithCamera(ProjectionCamera) Method

AlignWithCamera method aligns the PlaneVisual3D to be oriented so that it faces the specified camera.

Namespace: Ab3d.Visuals
Assembly: Ab3d.PowerToys (in Ab3d.PowerToys.dll) Version: 11.2.9104.2045
Syntax
C#
public void AlignWithCamera(
	ProjectionCamera wpfCamera
)

Parameters

wpfCamera  ProjectionCamera
WPF's camera
Remarks

AlignWithCamera method aligns the PlaneVisual3D to be oriented so that it faces the specified camera.

When many PlaneVisual3D objects need to be aligned with the camera, then it is better to use the following code to align all the planes (this way the GetCameraPlaneOrientation method is called only once):

C#
Vector3D planeNormalVector3D, widthVector3D, heightVector3D;
Ab3d.Cameras.BaseCamera.GetCameraPlaneOrientation(wpfCamera, out planeNormalVector3D, out widthVector3D, out heightVector3D);

for(int i = 0; i < planes.Count; i++) // Use for instead of foreach to prevent creating Enumerator object
{
    var onePlaneVisual3D = planes[i];

    onePlaneVisual3D.BeginInit();
    onePlaneVisual3D.Normal          = planeNormalVector3D;
    onePlaneVisual3D.HeightDirection = heightVector3D;
    onePlaneVisual3D.EndInit();
}
See Also