forked from pioneerspacesim/pioneer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDeathView.cpp
57 lines (46 loc) · 1.44 KB
/
DeathView.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
// Copyright © 2008-2018 Pioneer Developers. See AUTHORS.txt for details
// Licensed under the terms of the GPL v3. See licenses/GPL-3.txt
#include "DeathView.h"
#include "Pi.h"
#include "Player.h"
#include "ShipCpanel.h"
#include "graphics/Graphics.h"
DeathView::DeathView(Game* game): View(), m_game(game)
{
float size[2];
GetSizeRequested(size);
SetTransparency(true);
float znear;
float zfar;
Pi::renderer->GetNearFarRange(znear, zfar);
const float fovY = Pi::config->Float("FOVVertical");
m_cameraContext.Reset(new CameraContext(Graphics::GetScreenWidth(), Graphics::GetScreenHeight(), fovY, znear, zfar));
m_camera.reset(new Camera(m_cameraContext, Pi::renderer));
}
DeathView::~DeathView() {}
void DeathView::Init()
{
m_cameraDist = Pi::player->GetClipRadius() * 5.0;
m_cameraContext->SetFrame(Pi::player->GetFrame());
m_cameraContext->SetPosition(Pi::player->GetInterpPosition() + vector3d(0, 0, m_cameraDist));
m_cameraContext->SetOrient(matrix3x3d::Identity());
}
void DeathView::OnSwitchTo()
{
m_game->GetCpan()->HideAll();
}
void DeathView::Update()
{
assert(Pi::player->IsDead());
m_cameraDist += 160.0 * Pi::GetFrameTime();
m_cameraContext->SetPosition(Pi::player->GetInterpPosition() + vector3d(0, 0, m_cameraDist));
m_cameraContext->BeginFrame();
m_camera->Update();
}
void DeathView::Draw3D()
{
PROFILE_SCOPED()
m_cameraContext->ApplyDrawTransforms(Pi::renderer);
m_camera->Draw();
m_cameraContext->EndFrame();
}