forked from gameprogcpp/code
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFollowCamera.h
More file actions
46 lines (38 loc) · 1.31 KB
/
FollowCamera.h
File metadata and controls
46 lines (38 loc) · 1.31 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
// ----------------------------------------------------------------
// 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.
// ----------------------------------------------------------------
#pragma once
#include "CameraComponent.h"
class FollowCamera : public CameraComponent
{
public:
FollowCamera(class Actor* owner);
void Update(float deltaTime) override;
void SnapToIdeal();
void SetHorzDist(float dist) { mHorzDist = dist; }
void SetVertDist(float dist) { mVertDist = dist; }
void SetTargetDist(float dist) { mTargetDist = dist; }
void SetSpringConstant(float spring) { mSpringConstant = spring; }
TypeID GetType() const override { return TFollowCamera; }
void LoadProperties(const rapidjson::Value& inObj) override;
void SaveProperties(rapidjson::Document::AllocatorType& alloc,
rapidjson::Value& inObj) const override;
private:
Vector3 ComputeCameraPos() const;
// Actual position of camera
Vector3 mActualPos;
// Velocity of actual camera
Vector3 mVelocity;
// Horizontal follow distance
float mHorzDist;
// Vertical follow distance
float mVertDist;
// Target distance
float mTargetDist;
// Spring constant (higher is more stiff)
float mSpringConstant;
};