Click or drag to resize
Ab4d.SharpEngine logo

IRotatingCameraStartRotation(Single, Single, Single, FuncSingle, Single) Method

StartRotation method slowly starts the camera rotation (animating Heading and Attitude properties) and than accelerates the rotation. To immediately start rotation for this camera, use the StartRotation(Single, Single) method.

Namespace: Ab4d.SharpEngine.Cameras
Assembly: Ab4d.SharpEngine (in Ab4d.SharpEngine.dll) Version: 2.0.8956+4c7684e186ca1be74e7a284fbe739d9a1b843d3c
Syntax
C#
void StartRotation(
	float headingChangeInSecond,
	float attitudeChangeInSecond,
	float accelerationSpeed,
	Func<float, float>? easingFunction
)

Parameters

headingChangeInSecond  Single
How many degrees the heading will be changed in one second
attitudeChangeInSecond  Single
How many degrees the attitude will be changed in one second
accelerationSpeed  Single
number of degrees the velocity will change per one second
easingFunction  FuncSingle, Single
if not null the delegate will be used to ease the acceleration value
Remarks

StartRotation method slowly starts the camera rotation (animating Heading and Attitude properties) and than accelerates the rotation.

To immediately start rotation for this camera, use the StartRotation(Single, Single) method.

The animation can be stopped with StopRotation or StopRotation(Single, FuncSingle, Single) methods.

To check if the camera is currently being rotated, see the value of the IsRotating property. Note that after calling StopRotation(Single, FuncSingle, Single) method and specifying the decelerationSpeed, the IsRotating is still true until the camera rotation is stopped.

When StartRotation is called when the rotation is already animated, StopRotation will be called and than the animation will start again.

When the camera is controller by a CameraController, the CameraController can suspend animation when user is controlling the camera. After the user stops controlling the camera the animation can be resumes.

Controlling the acceleration speed

The acceleration speed is configured by accelerationSpeed and easingFunction parameters.

accelerationSpeed specifies the number of degrees the velocity will change per one second.

easingFunction can be set to null to disable easing or set to a delegate of type Func<float, float> (takes time as float as parameter and returns eased time as float) to specify the easing function.

Some of the most common easing functions are defined in the EasingFunctions class. For example the CubicEaseInOutFunction(Single) is defined by the following code:

C#
public static float CubicEaseInOutFunction(float x)
{
    t *= 2;

    if (t < 1)
        return t * t * t * 0.5f;

    t -= 2;
    return 0.5f * (t * t * t + 2);
}

See Also