Divide Framework 0.1
A free and open-source 3D Framework under heavy development
Loading...
Searching...
No Matches
Character.h
Go to the documentation of this file.
1/*
2 Copyright (c) 2018 DIVIDE-Studio
3 Copyright (c) 2009 Ionut Cava
4
5 This file is part of DIVIDE Framework.
6
7 Permission is hereby granted, free of charge, to any person obtaining a copy
8 of this software
9 and associated documentation files (the "Software"), to deal in the Software
10 without restriction,
11 including without limitation the rights to use, copy, modify, merge, publish,
12 distribute, sublicense,
13 and/or sell copies of the Software, and to permit persons to whom the
14 Software is furnished to do so,
15 subject to the following conditions:
16
17 The above copyright notice and this permission notice shall be included in
18 all copies or substantial portions of the Software.
19
20 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21 IMPLIED,
22 INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
23 PARTICULAR PURPOSE AND NONINFRINGEMENT.
24 IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
25 DAMAGES OR OTHER LIABILITY,
26 WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
27 IN CONNECTION WITH THE SOFTWARE
28 OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29
30 */
31/*
32 OgreCrowd
33 ---------
34
35 Copyright (c) 2012 Jonas Hauquier
36
37 Additional contributions by:
38
39 - mkultra333
40 - Paul Wilson
41
42 Sincere thanks and to:
43
44 - Mikko Mononen (developer of Recast navigation libraries)
45
46 Permission is hereby granted, free of charge, to any person obtaining a copy
47 of this software and associated documentation files (the "Software"), to
48 deal
49 in the Software without restriction, including without limitation the rights
50 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
51 copies of the Software, and to permit persons to whom the Software is
52 furnished to do so, subject to the following conditions:
53
54 The above copyright notice and this permission notice shall be included in
55 all copies or substantial portions of the Software.
56
57 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
58 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
59 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
60 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
61 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
62 FROM,
63 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
64 THE SOFTWARE.
65
66*/
67
68#pragma once
69#ifndef DVD_CHARACTER_H_
70#define DVD_CHARACTER_H_
71
72#include "Unit.h"
73
74namespace Divide {
75
79class Character : public Unit {
80 public:
82 enum class CharacterType : U8 {
88 COUNT
89 };
90
91 explicit Character(CharacterType type);
92
107 virtual void update(U64 deltaTimeUS);
109 virtual void setPosition(const vec3<F32>& newPosition);
111 virtual void setVelocity(const vec3<F32>& newVelocity);
113 [[nodiscard]] virtual vec3<F32> getPosition() const;
115 [[nodiscard]] virtual vec3<F32> getLookingDirection();
117 virtual void lookAt(const vec3<F32>& targetPos);
118
119 [[nodiscard]] const vec3<F32>& getRelativeLookingDirection() const noexcept { return _lookingDirection; }
120 void setRelativeLookingDirection(const vec3<F32>& direction) noexcept { _lookingDirection = direction; }
121
122 void playAnimation(U32 index) const;
123 void playNextAnimation() const;
124 void playPreviousAnimation() const;
125 void pauseAnimation(bool state) const;
126
128
129 protected:
130 void setParentNode(SceneGraphNode* node) override;
131
132 private:
136 std::atomic_bool _positionDirty;
137 std::atomic_bool _velocityDirty;
138};
139
140} // namespace Divide
141
142#endif //DVD_CHARACTER_H_
void setRelativeLookingDirection(const vec3< F32 > &direction) noexcept
Definition: Character.h:120
vec3< F32 > _curPosition
Definition: Character.h:134
virtual vec3< F32 > getPosition() const
The current position of this character.
Definition: Character.cpp:72
void playAnimation(U32 index) const
Definition: Character.cpp:97
void setParentNode(SceneGraphNode *node) override
Definition: Character.cpp:22
vec3< F32 > _lookingDirection
Definition: Character.h:133
std::atomic_bool _positionDirty
Definition: Character.h:136
vec3< F32 > _oldPosition
Definition: Character.h:134
virtual void lookAt(const vec3< F32 > &targetPos)
Rotate the character to look at another character.
Definition: Character.cpp:86
virtual void update(U64 deltaTimeUS)
Definition: Character.cpp:33
virtual void setVelocity(const vec3< F32 > &newVelocity)
Update character velocity.
Definition: Character.cpp:67
virtual void setPosition(const vec3< F32 > &newPosition)
Set the current position of this charater.
Definition: Character.cpp:62
vec3< F32 > _newPosition
Definition: Character.h:134
std::atomic_bool _velocityDirty
Definition: Character.h:137
void playNextAnimation() const
Definition: Character.cpp:124
CharacterType
Currently supported character types.
Definition: Character.h:82
@ CHARACTER_TYPE_PLAYER
user controlled character
@ CHARACTER_TYPE_NPC
non-user(player) character
void playPreviousAnimation() const
Definition: Character.cpp:143
PROPERTY_RW(CharacterType, characterType, CharacterType::COUNT)
vec3< F32 > _newVelocity
Definition: Character.h:135
virtual vec3< F32 > getLookingDirection()
The direction in which the character is currently looking.
Definition: Character.cpp:76
void pauseAnimation(bool state) const
Definition: Character.cpp:162
vec3< F32 > _curVelocity
Definition: Character.h:135
const vec3< F32 > & getRelativeLookingDirection() const noexcept
Definition: Character.h:119
Unit interface.
Definition: Unit.h:68
Handle console commands that start with a forward slash.
Definition: AIProcessor.cpp:7
uint8_t U8
uint32_t U32
uint64_t U64