Click or drag to resize
Ab4d.SharpEngine logo

PlaneModelNodeAlignWithCamera Method

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

Namespace: Ab4d.SharpEngine.SceneNodes
Assembly: Ab4d.SharpEngine (in Ab4d.SharpEngine.dll) Version: 3.1.9316+94bbd23b55747f096f056a5602f7dd90558b3673
Syntax
C#
public void AlignWithCamera(
	ICamera camera
)

Parameters

camera  ICamera
camera
Remarks

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

When many PlaneModelNode 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#
camera.GetCameraPlaneOrientation(out var planeNormalVector, out _, out var heightVector);

for(int i = 0; i < planes.Count; i++) // Use for instead of foreach to prevent creating Enumerator object
{
    var onePlaneModelNode = planes[i];
    onePlaneModelNode.Normal          = planeNormalVector;
    onePlaneModelNode.HeightDirection = heightVector;
}
See Also