mirror of
https://github.com/XProger/OpenLara.git
synced 2025-08-12 08:04:09 +02:00
13
src/camera.h
13
src/camera.h
@@ -25,7 +25,7 @@ struct Camera : ICamera {
|
|||||||
Frustum *frustum;
|
Frustum *frustum;
|
||||||
|
|
||||||
float fov, znear, zfar;
|
float fov, znear, zfar;
|
||||||
vec3 target, pos, destPos, lastDest, angle, advAngle;
|
vec3 target, destPos, lastDest, angle, advAngle;
|
||||||
float advTimer;
|
float advTimer;
|
||||||
mat4 mViewInv;
|
mat4 mViewInv;
|
||||||
int room;
|
int room;
|
||||||
@@ -138,9 +138,14 @@ struct Camera : ICamera {
|
|||||||
TR::CameraFrame *frameB = &level->cameraFrames[indexB];
|
TR::CameraFrame *frameB = &level->cameraFrames[indexB];
|
||||||
|
|
||||||
if (indexB < indexA) {
|
if (indexB < indexA) {
|
||||||
level->initCutscene();
|
indexB = indexA;
|
||||||
game->playTrack(0, true);
|
timer = 0.0f;
|
||||||
timer = 0.0f;
|
if (level->cutEntity != -1) {
|
||||||
|
// TODO: level end
|
||||||
|
level->initCutscene();
|
||||||
|
game->playTrack(0, true);
|
||||||
|
} else
|
||||||
|
state = STATE_FOLLOW;
|
||||||
}
|
}
|
||||||
|
|
||||||
const int eps = 512;
|
const int eps = 512;
|
||||||
|
@@ -18,6 +18,7 @@ struct Controller;
|
|||||||
|
|
||||||
struct ICamera {
|
struct ICamera {
|
||||||
vec4 *reflectPlane;
|
vec4 *reflectPlane;
|
||||||
|
vec3 pos;
|
||||||
|
|
||||||
ICamera() : reflectPlane(NULL) {}
|
ICamera() : reflectPlane(NULL) {}
|
||||||
|
|
||||||
@@ -489,7 +490,7 @@ struct Controller {
|
|||||||
if (cmd == TR::ANIM_CMD_EFFECT) {
|
if (cmd == TR::ANIM_CMD_EFFECT) {
|
||||||
switch (fx) {
|
switch (fx) {
|
||||||
case TR::Effect::ROTATE_180 : angle.y = angle.y + PI; break;
|
case TR::Effect::ROTATE_180 : angle.y = angle.y + PI; break;
|
||||||
case TR::Effect::FLOOR_SHAKE : game->setEffect(TR::Effect(fx), 0.5f * max(0.0f, 1.0f - (pos - ((Controller*)level->cameraController)->pos).length2() / (15 * 1024 * 15 * 1024) )); break;
|
case TR::Effect::FLOOR_SHAKE : game->setEffect(TR::Effect(fx), 0.5f * max(0.0f, 1.0f - (pos - ((ICamera*)level->cameraController)->pos).length2() / (15 * 1024 * 15 * 1024) )); break;
|
||||||
case TR::Effect::FLIP_MAP : level->isFlipped = !level->isFlipped; break;
|
case TR::Effect::FLIP_MAP : level->isFlipped = !level->isFlipped; break;
|
||||||
default : cmdEffect(fx); break;
|
default : cmdEffect(fx); break;
|
||||||
}
|
}
|
||||||
|
@@ -354,7 +354,7 @@ namespace TR {
|
|||||||
};
|
};
|
||||||
|
|
||||||
Limit SCION = {
|
Limit SCION = {
|
||||||
640, 310, 30, {{-256, 540, -350}, {256, 740, -200}}, true, false
|
640, -202, 30, {{-256, 540, -350}, {256, 740, -200}}, false, false
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1282,6 +1282,7 @@ struct Lara : Character {
|
|||||||
|
|
||||||
virtual void cmdEffect(int fx) {
|
virtual void cmdEffect(int fx) {
|
||||||
switch (fx) {
|
switch (fx) {
|
||||||
|
case TR::Effect::LARA_NORMAL : animation.setAnim(ANIM_STAND); break;
|
||||||
case TR::Effect::LARA_BUBBLES : doBubbles(); break;
|
case TR::Effect::LARA_BUBBLES : doBubbles(); break;
|
||||||
case TR::Effect::LARA_HANDSFREE : break;//meshSwap(1, level->extra.weapons[wpnCurrent], BODY_LEG_L1 | BODY_LEG_R1); break;
|
case TR::Effect::LARA_HANDSFREE : break;//meshSwap(1, level->extra.weapons[wpnCurrent], BODY_LEG_L1 | BODY_LEG_R1); break;
|
||||||
case TR::Effect::DRAW_RIGHTGUN : drawGun(true); break;
|
case TR::Effect::DRAW_RIGHTGUN : drawGun(true); break;
|
||||||
@@ -1401,9 +1402,10 @@ struct Lara : Character {
|
|||||||
pickupEntity = &item;
|
pickupEntity = &item;
|
||||||
|
|
||||||
if (item.type == TR::Entity::SCION_1) {
|
if (item.type == TR::Entity::SCION_1) {
|
||||||
animation.setAnim(level->models[level->entities[TR::MODEL_LARA_SPEC].modelIndex].animation);
|
animation.setAnim(level->models[TR::MODEL_LARA_SPEC].animation);
|
||||||
((Controller*)level->cameraController)->state = Camera::STATE_CUTSCENE;
|
((Camera*)level->cameraController)->state = Camera::STATE_CUTSCENE;
|
||||||
level->cutMatrix.identity();
|
level->cutMatrix.identity();
|
||||||
|
level->cutMatrix.rotateY(angle.y);
|
||||||
level->cutMatrix.setPos(pos);
|
level->cutMatrix.setPos(pos);
|
||||||
} else
|
} else
|
||||||
state = STATE_PICK_UP;
|
state = STATE_PICK_UP;
|
||||||
|
@@ -276,6 +276,7 @@ struct MovingBlock : Controller {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
struct Door : Controller {
|
struct Door : Controller {
|
||||||
enum {
|
enum {
|
||||||
STATE_CLOSE,
|
STATE_CLOSE,
|
||||||
@@ -402,9 +403,9 @@ struct TrapFloor : Controller {
|
|||||||
STATE_FALL,
|
STATE_FALL,
|
||||||
STATE_DOWN,
|
STATE_DOWN,
|
||||||
};
|
};
|
||||||
float velocity;
|
float speed;
|
||||||
|
|
||||||
TrapFloor(IGame *game, int entity) : Controller(game, entity), velocity(0) {
|
TrapFloor(IGame *game, int entity) : Controller(game, entity), speed(0) {
|
||||||
getEntity().flags.collision = true;
|
getEntity().flags.collision = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -422,16 +423,15 @@ struct TrapFloor : Controller {
|
|||||||
virtual void update() {
|
virtual void update() {
|
||||||
updateAnimation(true);
|
updateAnimation(true);
|
||||||
if (state == STATE_FALL) {
|
if (state == STATE_FALL) {
|
||||||
TR::Entity &e = getEntity();
|
getEntity().flags.collision = false;
|
||||||
e.flags.collision = false;
|
speed += GRAVITY * 30 * Core::deltaTime;
|
||||||
velocity += GRAVITY * 30 * Core::deltaTime;
|
pos.y += speed * Core::deltaTime;
|
||||||
pos.y += velocity * Core::deltaTime;
|
|
||||||
|
|
||||||
TR::Level::FloorInfo info;
|
TR::Level::FloorInfo info;
|
||||||
level->getFloorInfo(e.room, e.x, (int)pos.y, e.z, info);
|
level->getFloorInfo(getRoomIndex(), int(pos.x), int(pos.y), int(pos.z), info);
|
||||||
|
|
||||||
if (pos.y > info.roomFloor && info.roomBelow != 0xFF)
|
if (pos.y > info.roomFloor && info.roomBelow != 0xFF)
|
||||||
e.room = info.roomBelow;
|
getEntity().room = info.roomBelow;
|
||||||
|
|
||||||
if (pos.y > info.floor) {
|
if (pos.y > info.floor) {
|
||||||
pos.y = (float)info.floor;
|
pos.y = (float)info.floor;
|
||||||
@@ -489,13 +489,46 @@ struct TrapSpikes : Controller {
|
|||||||
};
|
};
|
||||||
|
|
||||||
struct FallingCeiling : Controller {
|
struct FallingCeiling : Controller {
|
||||||
FallingCeiling(IGame *game, int entity) : Controller(game, entity) {}
|
enum {
|
||||||
|
STATE_STATIC,
|
||||||
|
STATE_FALL,
|
||||||
|
STATE_DOWN,
|
||||||
|
};
|
||||||
|
|
||||||
|
float speed;
|
||||||
|
|
||||||
|
FallingCeiling(IGame *game, int entity) : Controller(game, entity), speed(0) {}
|
||||||
|
|
||||||
virtual void update() {
|
virtual void update() {
|
||||||
updateAnimation(true);
|
updateAnimation(true);
|
||||||
|
|
||||||
|
if (state == STATE_STATIC)
|
||||||
|
animation.setState(STATE_FALL);
|
||||||
|
|
||||||
|
if (state == STATE_FALL) {
|
||||||
|
speed += GRAVITY * 30 * Core::deltaTime;
|
||||||
|
pos.y += speed * Core::deltaTime;
|
||||||
|
|
||||||
|
TR::Level::FloorInfo info;
|
||||||
|
level->getFloorInfo(getRoomIndex(), int(pos.x), int(pos.y), int(pos.z), info);
|
||||||
|
|
||||||
|
if (pos.y > info.roomFloor && info.roomBelow != 0xFF)
|
||||||
|
getEntity().room = info.roomBelow;
|
||||||
|
|
||||||
|
if (pos.y > info.floor) {
|
||||||
|
pos.y = (float)info.floor;
|
||||||
|
animation.setState(STATE_DOWN);
|
||||||
|
}
|
||||||
|
updateEntity();
|
||||||
|
|
||||||
|
Controller *lara = (Controller*)level->laraController;
|
||||||
|
if (collide(lara))
|
||||||
|
lara->hit(1000);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
struct FallingSword : Controller {
|
struct FallingSword : Controller {
|
||||||
FallingSword(IGame *game, int entity) : Controller(game, entity) {}
|
FallingSword(IGame *game, int entity) : Controller(game, entity) {}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user