Subversion Repository Public Repository

Divide-Framework

This repository has no backups
This repository's network speed is throttled to 100KB/sec

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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
/*
   Copyright (c) 2018 DIVIDE-Studio
   Copyright (c) 2009 Ionut Cava

   This file is part of DIVIDE Framework.

   Permission is hereby granted, free of charge, to any person obtaining a copy
   of this software
   and associated documentation files (the "Software"), to deal in the Software
   without restriction,
   including without limitation the rights to use, copy, modify, merge, publish,
   distribute, sublicense,
   and/or sell copies of the Software, and to permit persons to whom the
   Software is furnished to do so,
   subject to the following conditions:

   The above copyright notice and this permission notice shall be included in
   all copies or substantial portions of the Software.

   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
   IMPLIED,
   INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
   PARTICULAR PURPOSE AND NONINFRINGEMENT.
   IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
   DAMAGES OR OTHER LIABILITY,
   WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
   IN CONNECTION WITH THE SOFTWARE
   OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

 */
/*
    OgreCrowd
    ---------

    Copyright (c) 2012 Jonas Hauquier

    Additional contributions by:

    - mkultra333
    - Paul Wilson

    Sincere thanks and to:

    - Mikko Mononen (developer of Recast navigation libraries)

    Permission is hereby granted, free of charge, to any person obtaining a copy
    of this software and associated documentation files (the "Software"), to
   deal
    in the Software without restriction, including without limitation the rights
    to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
    copies of the Software, and to permit persons to whom the Software is
    furnished to do so, subject to the following conditions:

    The above copyright notice and this permission notice shall be included in
    all copies or substantial portions of the Software.

    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
    AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
    LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
   FROM,
    OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
    THE SOFTWARE.

*/

#ifndef _CHARACTER_H_
#define _CHARACTER_H_

#include "Unit.h"

namespace Divide {

/// Basic character class.
/// Use the internally calculated position to update the attached node's
/// transform!
class Character : public Unit {
   public:
    /// Currently supported character types
    enum class CharacterType : U32 {
        /// user controlled character
        CHARACTER_TYPE_PLAYER = 0,
        /// non-user(player) character
        CHARACTER_TYPE_NPC,
        /// placeholder
        COUNT
    };

    Character(CharacterType type);
    virtual ~Character();

    /// Set unit type
    inline void setCharacterType(CharacterType type) { _type = type; }
    /// Get unit type
    inline CharacterType getCharacterType() const { return _type; }
    /**
      * Update this character for drawing a new frame.
      * Updates one tick in the render loop.
      * In order for the agents to be updated, you first need to call the
      *detourCrowd
      * update function.
      * What is updated specifically is up to a specific implementation of
      *Character,
      * but at the very least the position in the scene should be updated to
      *reflect
      * the detour agent position (possibly with additional physics engine
      *clipping
      * and collision testing).
      **/
    virtual void update(const U64 deltaTimeUS);
    /// Set the curent position of this charater
    virtual void setPosition(const vec3<F32>& newPosition);
    /// Update character velocity
    virtual void setVelocity(const vec3<F32>& newVelocity);
    /// The current position of this character
    virtual vec3<F32> getPosition() const;
    /// The direction in which the character is currently looking.
    virtual vec3<F32> getLookingDirection();
    /// Rotate the character to look at another character
    virtual void lookAt(const vec3<F32>& targetPos);
    /// Just before we render the frame
    virtual bool frameRenderingQueued(const FrameEvent& evt);

    inline const vec3<F32>& getRelativeLookingDirection() const {
        return _lookingDirection;
    }
    inline const void setRelativeLookingDirection(const vec3<F32>& direction) {
        _lookingDirection = direction;
    }

    void playAnimation(I32 index);
    void playNextAnimation();
    void playPreviousAnimation();
    void pauseAnimation(bool state);

   protected:
    void setParentNode(SceneGraphNode* node) override;

   private:
    CharacterType _type;
    vec3<F32> _lookingDirection;
    vec3<F32> _newPosition, _oldPosition, _curPosition;
    vec3<F32> _newVelocity, _curVelocity;
    std::atomic_bool _positionDirty;
    std::atomic_bool _velocityDirty;
};

};  // namespace Divide

#endif

Commits for Divide-Framework/trunk/Source Code/Dynamics/Entities/Units/Headers/Character.h

Diff revisions: vs.
Revision Author Commited Message
1029 Diff Diff IonutCava picture IonutCava Tue 30 Jan, 2018 17:28:39 +0000

[Ionut]
- Update copyright notices

993 Diff Diff IonutCava picture IonutCava Sun 10 Dec, 2017 20:07:57 +0000

[Ionut]
- Finished initial port of the old scene graph system to the new ECS based system.
- Finished converting 2 components to the new ECS system: Transform and RigidBody
- Fixed the “Deploy” build error with the CEGUI OpenGL renderer.
- Compilation now needs C++14 support (it’s sufficiently wide-spread now)

968 Diff Diff IonutCava picture IonutCava Tue 07 Nov, 2017 17:32:31 +0000

[Ionut]
- Consistent naming between timing variables

836 Diff Diff IonutCava picture IonutCava Fri 27 Jan, 2017 14:59:56 +0000

[IonutCava]
- Update copyright notice

818 Diff Diff IonutCava picture IonutCava Mon 16 Jan, 2017 17:23:20 +0000

[IonutCava]
- Units get their bound node setup by the SGN UnitComponent and not during creation
- Profile guided optimizations

648 Diff Diff IonutCava picture IonutCava Sun 21 Feb, 2016 16:32:52 +0000

[IonutCava]
- Update copyright notice
- Move BoundingBox and BoundingSphere to a new BoundsComponent
— Add a temp hack in SceneGraphNode to update these

438 Diff Diff IonutCava picture IonutCava Fri 15 May, 2015 15:46:43 +0000

[Ionut]
- SceneGraphNodes are now stored as shared pointers and Units/AI entities reference them with std::weak_ptr
— ToDo: Make constructor/destructor private again. (made public as a temporary hack to make it work with std::shared_ptr)
- SceneGraphNode’s children map is now read/updated with proper locking mechanism to avoid threading issues (e.g. AI tries to delete a node and rendering thread tries to read material data from it at the same time)
- GL_API does not need to store the previous shader program, just the previous shader program handle.
— Previous responsibilities shifted to glShaderProgram

422 Diff Diff IonutCava picture IonutCava Tue 05 May, 2015 20:33:47 +0000

[Ionut]
- Bug fixes for the previous commit
- Replace most static_cast<U32/I32> with to_int / to_uint

366 Diff Diff IonutCava picture IonutCava Tue 10 Mar, 2015 16:56:30 +0000

[Ionut]
- More type safe enum replacement

354 IonutCava picture IonutCava Fri 20 Feb, 2015 17:17:37 +0000

[Ionut]
- Replaced GLEW with glbinding (requires a CEGUI recompile. It currently crashes)
- Replaced most “SceneGraphNode* const sgn” expressions with "SceneGraphNode& sgn"
- Replaced some pointers to kernel to references to kernel
- Fixed compilation issues with EASTL
- Removed NPOT -> POT texture conversion code. Modern GPUs handle NPOT textures perfectly fine