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
/*
Copyright (c) 2017 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.

*/

#ifndef _ANIMATION_COMPONENT_H_
#define _ANIMATION_COMPONENT_H_

#include "SGNComponent.h"
#include "Core/Math/Headers/Line.h"
#include "Core/Math/Headers/MathMatrices.h"
#include "Core/Math/BoundingVolumes/Headers/BoundingBox.h"

namespace Divide {

class Bone;
class ShaderBuffer;
class AnimEvaluator;
class SceneAnimator;
class SceneGraphNode;
class AnimationComponent : public SGNComponent {
   public:
    inline void updateAnimator(const std::shared_ptr<SceneAnimator>& animator) {
        _animator = animator;
    }

    bool onRender(const RenderStagePass& renderStagePass) override;

    void update(const U64 deltaTime) override;

    /// Select an animation by name
    bool playAnimation(const stringImpl& name);
    /// Select an animation by index
    bool playAnimation(I32 pAnimIndex);
    /// Select next available animation
    bool playNextAnimation();
    /// Select previous available animation
    bool playPreviousAnimation();

    inline U64 animationTimeStamp() const { return _currentTimeStamp;  }
    inline U32 frameIndex() const { return _previousFrameIndex; }
    inline I32 frameCount() const { return frameCount(_currentAnimIndex); }
    I32 frameCount(U32 animationID) const;

    inline const vectorImplBest<mat4<F32> >& transformsByIndex(U32 index) const {
        return transformsByIndex(_currentAnimIndex, index);
    }

    const vectorImplBest<mat4<F32> >& transformsByIndex(U32 animationID, U32 index) const;

    U32 boneCount() const;
    Bone* getBoneByName(const stringImpl& bname) const;

    const mat4<F32>& getBoneTransform(U32 animationID,
                                      const D64 timeStamp,
                                      const stringImpl& name);

    inline bool playAnimations() const { return _playAnimations; }
    inline void playAnimations(bool state) { _playAnimations = state; }

    inline I32 animationIndex() const { return _currentAnimIndex; }

    AnimEvaluator& getAnimationByIndex(I32 animationID) const;

    inline AnimEvaluator& getCurrentAnimation() const {
        return getAnimationByIndex(animationIndex());
    }

    void resetTimers();
    void incParentTimeStamp(const U64 timestamp);

    const vectorImpl<Line>& skeletonLines() const;
   protected:
    friend class SceneGraphNode;
    AnimationComponent(SceneGraphNode& parentSGN);
    ~AnimationComponent();

   protected:
    /// Pointer to the mesh's animator. Owned by the mesh!
    std::shared_ptr<SceneAnimator> _animator;
    /// Current animation index for the current SGN
    I32 _currentAnimIndex;
    /// Current animation timestamp for the current SGN
    U64 _currentTimeStamp;
    /// Previous frame index. Gets reset to -1 when animation changes
    U32 _previousFrameIndex;
    /// Previous animation index
    I32 _previousAnimationIndex;
    /// Parent time stamp (e.g. Mesh). 
    /// Should be identical for all nodes of the same level with the same parent
    U64 _parentTimeStamp;
    /// Animation playback toggle
    bool _playAnimations;
};

};  // namespace Divide
#endif

Commits for Divide-Framework/trunk/Source Code/Graphs/Components/Headers/AnimationComponent.h

Diff revisions: vs.
Revision Author Commited Message
851 Diff Diff IonutCava picture IonutCava Mon 06 Feb, 2017 23:38:14 +0000

[IonutCava]
- Replaced most RenderStage params with RenderStagePass types
- More work on water rendering

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

[IonutCava]
- Update copyright notice

833 Diff Diff IonutCava picture IonutCava Thu 26 Jan, 2017 22:04:33 +0000

[IonutCava]
- Fix most build errors. Divide-Server does not build for now.

773 Diff Diff IonutCava picture IonutCava Tue 04 Oct, 2016 15:53:18 +0000

[IonutCava]
- Split GenericDrawCommand gathering system into Init/Update to facilitate future threading support
- Fix drawCount() == 0 case in submitRenderCommand
- Make _cameraPool (more) threadsafe

720 Diff Diff IonutCava picture IonutCava Mon 06 Jun, 2016 15:51:06 +0000

[IonutCava]
- PVS-Studio guided static analysis fixes and optimizations
- Added a flag to SceneState to bypass the Save/Load system not needed for certain types of scenes (menus, cinematics, etc)

684 Diff Diff IonutCava picture IonutCava Wed 20 Apr, 2016 16:27:05 +0000

[IonutCava]
- More math template code cleanup

680 Diff Diff IonutCava picture IonutCava Thu 14 Apr, 2016 16:15:38 +0000

[IonutCava]
- Added a mat2 class (untested)
- Added static asserts to matrices, vectors and quaternions to allow only arithmetic (sans bool) data types
- Added more vector unit tests
- Added unit tests for matrices
- D32 finally renamed to D64 as the VC++ compiler is considered as the reference compiler

671 Diff Diff IonutCava picture IonutCava Fri 08 Apr, 2016 16:26:49 +0000

[Ionut]
- Custom memory allocation system part 1:
— Add http://www.codeproject.com/Articles/1089905/A-Custom-STL-std-allocator-Replacement-Improves-Pe
— Add custom allocators to strings and vectors
— Add custom allocators to a few test classes
— No support for aligned memory yet, so vec4<F32> and mat4<F32> vectors use the old allocation system
- Replace more std::async call with our custom task system

650 Diff Diff IonutCava picture IonutCava Tue 23 Feb, 2016 16:54:54 +0000

[IonutCava]
- Fix decoupling between PhysicsComponent and BoundsComponent
— SceneNodes now keep references to all owning SGNs and informs them when the bounds change
- AnimationComponent does not need a SceneAnimator on creation but most functionality will assert if one is not specified
— This was needed for the new component configuration system
- Added placeholder classes for an Inverse Kinematic component and a Ragdoll component
- SNG component configuration is now an upfront requirement: pass a component type mask when adding a node the the scenegraph
- SGN SpatialPartitionFlag is now an update flag that is set and cleared. More flags can be added in a similar fashion to nodes

648 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