-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathbasic_character_controller.h
More file actions
103 lines (85 loc) · 2.43 KB
/
Copy pathbasic_character_controller.h
File metadata and controls
103 lines (85 loc) · 2.43 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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
////////////////////////////////////////////////////////////////////////////////
// Distributed under the Boost Software License, Version 1.0. //
// (See accompanying file LICENSE or copy at //
// https://www.boost.org/LICENSE_1_0.txt) //
////////////////////////////////////////////////////////////////////////////////
#pragma once
#include <chrono>
#include "core/quaternion.h"
#include "core/vector3.h"
#include "physics/character_controller.h"
#include "physics/physics_system.h"
#include "physics/rigid_body.h"
namespace iris
{
class PhysicsSystem;
/**
* Implementation of CharacterController for a basic walking character controller.
* Uses a capsule shape for character.
*/
class BasicCharacterController : public CharacterController
{
public:
/**
* Create a BasicCharacterController.
*
* @param physics_system
* Pointer to physics_system that owns this controller.
*/
BasicCharacterController(PhysicsSystem *physics_system, float speed, float width, float height, float float_height);
/**
* Set the direction the character is walking. Should be a normalised
* vector.
*
* @param direction
* Direction character is moving.
*/
void set_movement_direction(const Vector3 &direction) override;
/**
* Get position of character in the world.
*
* @returns
* World coordinates of character.
*/
Vector3 position() const override;
/**
* Get orientation of character.
*
* @returns
* Orientation of character
*/
Quaternion orientation() const override;
/**
* Set speed of character.
*
* @param speed
* New speed.
*/
void set_speed(float speed) override;
/**
* Reposition character.
*
* @param position
* New position.
*
* @param orientation
* New orientation.
*/
void reposition(const Vector3 &position, const Quaternion &orientation) override;
/**
* Get the underlying RigidBody.
*
* @returns
* Underlying RigidBody.
*/
RigidBody *rigid_body() const override;
void update(PhysicsSystem *ps, std::chrono::milliseconds delta) override;
protected:
Vector3 movement_direction_;
/** Speed of character. */
float speed_;
float float_height_;
/** Underlying rigid body, */
RigidBody *body_;
};
}