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: 2.0.8956+4c7684e186ca1be74e7a284fbe739d9a1b843d3c
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