Saga3D API Documentation  1.0-RC4
ISceneNodeAnimator.h
Go to the documentation of this file.
1 // Copyright (C) 2002-2012 Nikolaus Gebhardt
2 // This file is part of the "Irrlicht Engine".
3 // For conditions of distribution and use, see copyright notice in irrlicht.h
4 
5 #ifndef __I_SCENE_NODE_ANIMATOR_H_INCLUDED__
6 #define __I_SCENE_NODE_ANIMATOR_H_INCLUDED__
7 
9 #include "IEventReceiver.h"
10 #include <cstdint>
11 
12 namespace saga
13 {
14 namespace scene
15 {
16  class ISceneNode;
17  class ISceneManager;
18 
20 
25  {
26  public:
28  {
29  }
30 
32 
34  virtual void animateNode(ISceneNode& node, const float time) = 0;
35 
37 
39  // virtual ISceneNodeAnimator* createClone(ISceneNode* node,
40  // ISceneManager* newManager= 0) = 0;
41 
43  virtual void onEvent(const SDL_Event& event) override
44  {
45 
46  }
47 
50  {
52  }
53 
55 
57  virtual bool hasFinished(void) const
58  {
59  return false;
60  }
61 
63 
69  virtual void setStartTime(std::uint32_t time, bool resetPauseTime = true)
70  {
71  StartTime = time;
72  if (resetPauseTime)
73  {
74  PauseTimeStart = 0;
75  PauseTimeSum = 0;
76  }
77  }
78 
80 
81  virtual std::uint32_t getStartTime() const
82  {
83  return StartTime;
84  }
85 
87 
95  virtual void setEnabled(bool enabled, std::uint32_t timeNow = 0)
96  {
97  if (enabled == IsEnabled)
98  return;
99  IsEnabled = enabled;
100  if (enabled)
101  {
102  if (timeNow > 0 && PauseTimeStart > 0)
103  PauseTimeSum += timeNow-PauseTimeStart;
104  }
105  else
106  {
107  PauseTimeStart = timeNow;
108  }
109  }
110 
111  virtual bool isEnabled() const
112  {
113  return IsEnabled;
114  }
115 
116  protected:
117 
121  // void cloneMembers(const ISceneNodeAnimator* toCopyFrom)
122  // {
123  // IsEnabled = toCopyFrom->IsEnabled;
124  // PauseTimeSum = toCopyFrom->IsEnabled;
125  // PauseTimeStart = toCopyFrom->PauseTimeStart;
126  // StartTime = toCopyFrom->StartTime;
127  // }
128 
129  bool IsEnabled;
130  std::uint32_t PauseTimeSum;
131  std::uint32_t PauseTimeStart;
132  std::uint32_t StartTime;
133  };
134 
135 } // namespace scene
136 } // namespace saga
137 
138 #endif // __I_SCENE_NODE_ANIMATOR_H_INCLUDED__
saga::scene::ISceneNodeAnimator
Animates a scene node. Can animate position, rotation, material, and so on.
Definition: ISceneNodeAnimator.h:24
saga::scene::ISceneNodeAnimator::getStartTime
virtual std::uint32_t getStartTime() const
Get the starttime.
Definition: ISceneNodeAnimator.h:81
saga::scene::ISceneNode
Type for list of scene node animators.
Definition: ISceneNode.h:41
saga::scene::E_SCENE_NODE_ANIMATOR_TYPE::UNKNOWN
@ UNKNOWN
Unknown scene node animator.
saga::scene::ISceneNodeAnimator::hasFinished
virtual bool hasFinished(void) const
Returns if the animator has finished.
Definition: ISceneNodeAnimator.h:57
saga::scene::ISceneNodeAnimator::animateNode
virtual void animateNode(ISceneNode &node, const float time)=0
Animates a scene node.
saga::scene::ISceneNodeAnimator::StartTime
std::uint32_t StartTime
Last time setEnabled(false) was called with a timer > 0.
Definition: ISceneNodeAnimator.h:132
saga::scene::ISceneNodeAnimator::setStartTime
virtual void setStartTime(std::uint32_t time, bool resetPauseTime=true)
Reset a time-based movement by changing the starttime.
Definition: ISceneNodeAnimator.h:69
saga::scene::ISceneNodeAnimator::ISceneNodeAnimator
ISceneNodeAnimator()
Definition: ISceneNodeAnimator.h:27
saga::scene::ISceneNodeAnimator::PauseTimeSum
std::uint32_t PauseTimeSum
Only enabled animators are updated.
Definition: ISceneNodeAnimator.h:130
saga::scene::ISceneNodeAnimator::PauseTimeStart
std::uint32_t PauseTimeStart
Sum up time which the animator was disabled.
Definition: ISceneNodeAnimator.h:131
saga::IEventReceiver
Interface of an object which can receive events (SDL_Event*)
Definition: IEventReceiver.h:17
saga::scene::ISceneNodeAnimator::onEvent
virtual void onEvent(const SDL_Event &event) override
Creates a clone of this animator.
Definition: ISceneNodeAnimator.h:43
ESceneNodeAnimatorTypes.h
IEventReceiver.h
saga::scene::ISceneNodeAnimator::getType
virtual E_SCENE_NODE_ANIMATOR_TYPE getType() const
Returns type of the scene node animator.
Definition: ISceneNodeAnimator.h:49
saga::scene::ISceneNodeAnimator::setEnabled
virtual void setEnabled(bool enabled, std::uint32_t timeNow=0)
Sets the enabled state of this element.
Definition: ISceneNodeAnimator.h:95
saga::scene::E_SCENE_NODE_ANIMATOR_TYPE
E_SCENE_NODE_ANIMATOR_TYPE
An enumeration for all types of built-in scene node animators.
Definition: ESceneNodeAnimatorTypes.h:14
saga::scene::ISceneNodeAnimator::IsEnabled
bool IsEnabled
Definition: ISceneNodeAnimator.h:129
saga::scene::ISceneNodeAnimator::isEnabled
virtual bool isEnabled() const
Definition: ISceneNodeAnimator.h:111
saga
Definition: aabbox3d.h:11