-
Notifications
You must be signed in to change notification settings - Fork 390
Expand file tree
/
Copy pathSplineActor.cpp
More file actions
52 lines (44 loc) · 1.21 KB
/
SplineActor.cpp
File metadata and controls
52 lines (44 loc) · 1.21 KB
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
// ----------------------------------------------------------------
// From Game Programming in C++ by Sanjay Madhav
// Copyright (C) 2017 Sanjay Madhav. All rights reserved.
//
// Released under the BSD License
// See LICENSE in root directory for full details.
// ----------------------------------------------------------------
#include "SplineActor.h"
#include "MeshComponent.h"
#include "Game.h"
#include "Renderer.h"
#include "SplineCamera.h"
#include "MoveComponent.h"
SplineActor::SplineActor(Game* game)
:Actor(game)
{
//MeshComponent* mc = new MeshComponent(this);
//mc->SetMesh(game->GetRenderer()->GetMesh("Assets/RacingCar.gpmesh"));
//SetPosition(Vector3(0.0f, 0.0f, -100.0f));
mCameraComp = new SplineCamera(this);
// Create a spline
Spline path;
path.mControlPoints.emplace_back(Vector3::Zero);
for (int i = 0; i < 5; i++)
{
if (i % 2 == 0)
{
path.mControlPoints.emplace_back(Vector3(300.0f * (i + 1), 300.0f, 300.0f));
}
else
{
path.mControlPoints.emplace_back(Vector3(300.0f * (i + 1), 0.0f, 0.0f));
}
}
mCameraComp->SetSpline(path);
mCameraComp->SetPaused(false);
}
void SplineActor::ActorInput(const uint8_t* keys)
{
}
void SplineActor::RestartSpline()
{
mCameraComp->Restart();
}