1
0
mirror of https://github.com/XProger/OpenLara.git synced 2025-08-16 10:04:28 +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; float timer;
int actTargetEntity, actCamera; 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) { 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; fov = 65.0f;
@@ -31,6 +32,8 @@ struct Camera : Controller {
pos = pos - owner->getDir() * 1024.0f; pos = pos - owner->getDir() * 1024.0f;
target = owner->getViewPoint(); target = owner->getViewPoint();
} }
cutscene = owner->getEntity().type != TR::Entity::LARA && level->cameraFrames;
} }
virtual ~Camera() { virtual ~Camera() {
@@ -56,6 +59,42 @@ struct Camera : Controller {
} }
virtual void update() { 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]) { if (Input::down[ikMouseR]) {
vec2 delta = Input::mouse.pos - Input::mouse.start.R; vec2 delta = Input::mouse.pos - Input::mouse.start.R;
angleAdv.x -= delta.y * 0.01f; angleAdv.x -= delta.y * 0.01f;
@@ -141,8 +180,8 @@ struct Camera : Controller {
} }
room = destRoom; room = destRoom;
} }
pos = pos.lerp(destPos, Core::deltaTime * lerpFactor); pos = pos.lerp(destPos, Core::deltaTime * lerpFactor);
}
if (actCamera <= -1) { if (actCamera <= -1) {
TR::Level::FloorInfo info; TR::Level::FloorInfo info;

View File

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

View File

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

View File

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

View File

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