1
0
mirror of https://github.com/XProger/OpenLara.git synced 2025-08-15 09:34:18 +02:00

#8 cutscene animation sequence

This commit is contained in:
XProger
2016-12-29 13:56:57 +03:00
parent 5df5ec8a60
commit 97b8898cb2
5 changed files with 122 additions and 82 deletions

View File

@@ -19,6 +19,7 @@ struct Camera : Controller {
float timer;
int actTargetEntity, actCamera;
bool cutscene;
Camera(TR::Level *level, Lara *owner) : Controller(level, owner ? owner->entity : 0), owner(owner), frustum(new Frustum()), timer(0.0f), actTargetEntity(-1), actCamera(-1) {
fov = 65.0f;
@@ -31,6 +32,8 @@ struct Camera : Controller {
pos = pos - owner->getDir() * 1024.0f;
target = owner->getViewPoint();
}
cutscene = owner->getEntity().type != TR::Entity::LARA && level->cameraFrames;
}
virtual ~Camera() {
@@ -56,6 +59,42 @@ struct Camera : Controller {
}
virtual void update() {
#ifndef LEVEL_EDITOR
if (cutscene) { // cutscene
vec3 orig = owner->pos;
float rotY = 0.0f;
switch (level->cameraFramesCount) {
case 1600 : // CUT1
orig.x = 36668;
orig.z = 63180;
rotY = -23312.0f / float(0x4000) * PI * 0.5f;
break;
case 1000 : // CUT2
orig.x = 51962;
orig.z = 53760;
rotY = 16380.0f / float(0x4000) * PI * 0.5f;
break;
case 400 : // CUT3
rotY = PI * 0.5f;
break;
case 1890 : // CUT4
rotY = PI * 0.5f;
break;
}
timer += Core::deltaTime * 30;
int indexA = int(timer) % level->cameraFramesCount;
TR::CameraFrame *frame = &level->cameraFrames[indexA];
pos = orig + vec3(frame->pos).rotateY(-rotY);
target = orig + vec3(frame->target).rotateY(-rotY);
//fov = float(frame->fov) / 32767.0f * 120.0f;
// TODO: frame->roll
} else
#endif
{
if (Input::down[ikMouseR]) {
vec2 delta = Input::mouse.pos - Input::mouse.start.R;
angleAdv.x -= delta.y * 0.01f;
@@ -141,8 +180,8 @@ struct Camera : Controller {
}
room = destRoom;
}
pos = pos.lerp(destPos, Core::deltaTime * lerpFactor);
}
if (actCamera <= -1) {
TR::Level::FloorInfo info;

View File

@@ -630,14 +630,10 @@ namespace TR {
};
struct CameraFrame {
int16 rotY;
int16 rotZ;
int16 unused1;
int16 posZ;
int16 posY;
int16 posX;
int16 unknown;
int16 rotX;
Vertex target;
Vertex pos;
int16 fov;
int16 roll;
};
struct SoundSource {

View File

@@ -33,7 +33,7 @@ namespace Game {
//lstartLevel("LEVEL2_DEMO.PHD", true, false);
//lstartLevel("GYM.PSX", false, true);
//lstartLevel("LEVEL3A.PHD", false, false);
startLevel("LEVEL2.PSX", false, false);
startLevel("CUT1.PHD", false, false);
}
void free() {

View File

@@ -1601,7 +1601,7 @@ struct Lara : Character {
if (velocity.length() >= 0.001f)
move();
/*
if (getEntity().type != TR::Entity::LARA) {
TR::Entity &e = getEntity();
vec3 &p = getPos();
@@ -1611,6 +1611,7 @@ struct Lara : Character {
checkRoom();
updateEntity();
}
*/
}
virtual vec3& getPos() {

View File

@@ -749,7 +749,11 @@ struct Level {
for (int i = 0; i < level.roomsCount; i++)
renderRoom(i);
#else
if (!camera->cutscene)
renderRoom(roomIndex);
else // TODO: use brain
for (int i = 0; i < level.roomsCount; i++)
renderRoom(i);
#endif
}