CHAPTER 2 ■ SETTING UP DIFFERENT CAMERA MODES IN YOUR 3D WORLD
76
The position is calculated by the Bezier method:
private Vector3 Bezier(Vector3 startPoint, Vector3 midPoint,
➥
Vector3 endPoint, float time)
{
float invTime = 1.0f - time;
float timePow = (float)Math.Pow(time, 2);
float invTimePow = (float)Math.Pow(invTime, 2);
Vector3 result = startPoint * invTimePow;
result += 2 * midPoint * time * invTime;
result += endPoint * timePow;
return result;
}
And the rotation is found by this method:
private Vector3 Bezier(Vector3 startPoint, Vector3 midPoint,
➥
Vector3 endPoint, float time)
{
float invTime = 1.0f - time;
float timePow = (float)Math.Pow(time, 2);
float invTimePow = (float)Math.Pow(invTime, 2);
Vector3 result = startPoint * invTimePow; ...