I have made a possible solution for the cutscenes with rotating camera angle.
Instead of using a flag on individual layers I have added a pivot point for the camera:
| struct layered_scene
{
...
bool CameraDoPivot;
v3 CameraPivot;
...
};
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 | internal void
RenderLayeredScene(game_assets *Assets, render_group *RenderGroup, loaded_bitmap *DrawBuffer,
layered_scene *Scene, r32 tNormal)
{
...
if(Scene->CameraDoPivot)
{
Transform.OffsetP.xy = P.xy - (CameraPivot.xy + ((P.z - CameraPivot.z)/(CameraOffset.z - CameraPivot.z))*(CameraOffset.xy - CameraPivot.xy));
}
else
{
Transform.OffsetP.xy = P.xy - CameraOffset.xy;
}
...
}
|
Because the speed is impossible to get right I have added a function to layered_scene:
| struct layered_scene
{
...
r32 (*CameraMovementTiming)(r32);
};
|
I use this in the following way:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 | internal void
RenderLayeredScene(game_assets *Assets, render_group *RenderGroup, loaded_bitmap *DrawBuffer,
layered_scene *Scene, r32 tNormal)
{
...
v3 CameraOffset = Lerp(CameraStart, CameraMovementTiming ? Clamp01MapToRange(CameraMovementTiming(0.0f), CameraMovementTiming(tNormal), CameraMovementTiming(1.0f)) : tNormal, CameraEnd);
...
}
internal r32
IntroLayer3CameraMovementTiming(r32 tNormal)
{
r32 Result = ATan2((tNormal - 0.4f) * 5.0f, 1.0f);
return(Result);
}
|
The values:
| {INTRO_SHOT(3), 20.0f, {0.0f, 0.3f, 0.0f}, {0.0f, 3.0f, -2.0f}, 0.0f, true, {0.0f, 0.45f, -2.5f}, IntroLayer3CameraMovementTiming}
|
Edit:
I have now changed the calculation of the z-coordinate as well. There is no correct answer to distance from the camera to a plane at an angle to the direction of the camera. I decided to keep the distance from the plane to the pivot point constant as the feature is used to look down at the floor, which conceptually is closer than the wall:
| if(Scene->CameraDoPivot)
{
v3 CameraOffsetFromPivot = CameraOffset - CameraPivot;
Transform.OffsetP.xy = P.xy - (CameraPivot.xy + ((P.z - CameraPivot.z) / CameraOffsetFromPivot.z) * CameraOffsetFromPivot.xy);
Transform.OffsetP.z = P.z - CameraPivot.z - Length(CameraOffsetFromPivot);
}
else
{
Transform.OffsetP = P - CameraOffset;
}
|
The values:
| {INTRO_SHOT(3), 20.0f, {0.0f, 0.3f, 0.0f}, {0.0f, 3.0f, -2.0f}, 0.0f, true, {0.0f, 0.45f, -2.5f}, IntroLayer3CameraMovementTiming}
|