Irrlicht 3D Engine
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 
8 #include "IReferenceCounted.h"
9 #include "vector3d.h"
12 #include "IAttributes.h"
13 #include "IEventReceiver.h"
14 
15 namespace irr
16 {
17 namespace io
18 {
19  class IAttributes;
20 } // end namespace io
21 namespace scene
22 {
23  class ISceneNode;
24  class ISceneManager;
25 
27 
32  {
33  public:
35  {
36  }
37 
39 
41  virtual void animateNode(ISceneNode* node, u32 timeMs) =0;
42 
44 
47  ISceneManager* newManager=0) =0;
48 
50 
52  virtual bool isEventReceiverEnabled() const
53  {
54  return false;
55  }
56 
58  virtual bool OnEvent(const SEvent& event) _IRR_OVERRIDE_
59  {
60  return false;
61  }
62 
65  {
66  return ESNAT_UNKNOWN;
67  }
68 
70 
72  virtual bool hasFinished(void) const
73  {
74  return false;
75  }
76 
78 
84  virtual void setStartTime(u32 time, bool resetPauseTime=true)
85  {
86  StartTime = time;
87  if ( resetPauseTime )
88  {
89  PauseTimeStart = 0;
90  PauseTimeSum = 0;
91  }
92  }
93 
95 
96  virtual irr::u32 getStartTime() const
97  {
98  return StartTime;
99  }
100 
102 
110  virtual void setEnabled(bool enabled, u32 timeNow=0)
111  {
112  if ( enabled == IsEnabled )
113  return;
114  IsEnabled = enabled;
115  if ( enabled )
116  {
117  if ( timeNow > 0 && PauseTimeStart > 0 )
118  PauseTimeSum += timeNow-PauseTimeStart;
119  }
120  else
121  {
122  PauseTimeStart = timeNow;
123  }
124  }
125 
126  virtual bool isEnabled() const
127  {
128  return IsEnabled;
129  }
130 
133  {
134  out->addBool("IsEnabled", IsEnabled);
135  // timers not serialized as they usually depend on system-time which is different on each application start.
136  }
137 
140  {
141  IsEnabled = in->getAttributeAsBool("IsEnabled", IsEnabled);
142  PauseTimeSum = 0;
143  PauseTimeStart = 0;
144  }
145 
146  protected:
147 
151  void cloneMembers(const ISceneNodeAnimator* toCopyFrom)
152  {
153  IsEnabled = toCopyFrom->IsEnabled;
154  PauseTimeSum = toCopyFrom->IsEnabled;
155  PauseTimeStart = toCopyFrom->PauseTimeStart;
156  StartTime = toCopyFrom->StartTime;
157  }
158 
159  bool IsEnabled;
163  };
164 
165 
166 } // end namespace scene
167 } // end namespace irr
168 
169 #endif
170 
An object which is able to serialize and deserialize its attributes into an attributes object.
Provides a generic interface for attributes and their values and the possibility to serialize them.
Definition: IAttributes.h:41
SEvents hold information about an event. See irr::IEventReceiver for details on event handling.
virtual bool getAttributeAsBool(const c8 *attributeName, bool defaultNotFound=false) const =0
virtual void animateNode(ISceneNode *node, u32 timeMs)=0
Animates a scene node.
virtual bool hasFinished(void) const
Returns if the animator has finished.
u32 PauseTimeSum
Only enabled animators are updated.
Scene node interface.
Definition: ISceneNode.h:40
virtual void deserializeAttributes(io::IAttributes *in, io::SAttributeReadWriteOptions *options=0) _IRR_OVERRIDE_
Reads attributes of the scene node animator.
struct holding data describing options
Unknown scene node animator.
Animates a scene node. Can animate position, rotation, material, and so on.
virtual void addBool(const c8 *attributeName, bool value)=0
Adds an attribute as bool.
virtual void setStartTime(u32 time, bool resetPauseTime=true)
Reset a time-based movement by changing the starttime.
Everything in the Irrlicht Engine can be found in this namespace.
Definition: aabbox3d.h:12
ESCENE_NODE_ANIMATOR_TYPE
An enumeration for all types of built-in scene node animators.
Interface of an object which can receive events.
virtual ISceneNodeAnimator * createClone(ISceneNode *node, ISceneManager *newManager=0)=0
Creates a clone of this animator.
unsigned int u32
32 bit unsigned variable.
Definition: irrTypes.h:62
virtual void serializeAttributes(io::IAttributes *out, io::SAttributeReadWriteOptions *options=0) const _IRR_OVERRIDE_
Writes attributes of the scene node animator.
virtual bool isEventReceiverEnabled() const
Returns true if this animator receives events.
u32 StartTime
Last time setEnabled(false) was called with a timer > 0.
The Scene Manager manages scene nodes, mesh resources, cameras and all the other stuff.
#define _IRR_OVERRIDE_
Defines an override macro, to protect virtual functions from typos and other mismatches.
Definition: irrTypes.h:216
void cloneMembers(const ISceneNodeAnimator *toCopyFrom)
virtual void setEnabled(bool enabled, u32 timeNow=0)
Sets the enabled state of this element.
virtual ESCENE_NODE_ANIMATOR_TYPE getType() const
Returns type of the scene node animator.
u32 PauseTimeStart
Sum up time which the animator was disabled.
virtual irr::u32 getStartTime() const
Get the starttime.
virtual bool OnEvent(const SEvent &event) _IRR_OVERRIDE_
Event receiver, override this function for camera controlling animators.