Nirtcpp 2.1.0
Nirtcpp is a high-performance c++ graphics engine.
Loading...
Searching...
No Matches
ISceneNodeAnimator.hpp
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 nirtcpp/nirtcpp.hpp
4
5#ifndef NIRT_I_SCENE_NODE_ANIMATOR_HPP_INCLUDED
6#define NIRT_I_SCENE_NODE_ANIMATOR_HPP_INCLUDED
7
8#include <nirtcpp/core/engine/IReferenceCounted.hpp>
9#include <nirtcpp/core/engine/vector3d.hpp>
10#include <nirtcpp/core/engine/ESceneNodeAnimatorTypes.hpp>
11#include <nirtcpp/core/engine/IAttributeExchangingObject.hpp>
12#include <nirtcpp/core/engine/IAttributes.hpp>
13#include <nirtcpp/core/engine/IEventReceiver.hpp>
14
15namespace nirt
16{
17namespace io
18{
19 class IAttributes;
20} // end namespace io
21namespace scene
22{
23 class ISceneNode;
24 class ISceneManager;
25
27
32 {
33 public:
34 ISceneNodeAnimator() : IsEnabled(true), PauseTimeSum(0), PauseTimeStart(0), StartTime(0)
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) 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 {
90 PauseTimeSum = 0;
91 }
92 }
93
95
96 virtual nirt::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
132 virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options=0) const override
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 nirt
168
169#endif
Interface of an object which can receive events.
Definition IEventReceiver.hpp:484
SEvents hold information about an event. See nirt::IEventReceiver for details on event handling.
Definition IEventReceiver.hpp:282
An object which is able to serialize and deserialize its attributes into an attributes object.
Definition IAttributeExchangingObject.hpp:54
Provides a generic interface for attributes and their values and the possibility to serialize them.
Definition IAttributes.hpp:42
virtual bool getAttributeAsBool(const c8 *attributeName, bool defaultNotFound=false) const =0
virtual void addBool(const c8 *attributeName, bool value)=0
Adds an attribute as bool.
class holding data describing options
Definition IAttributeExchangingObject.hpp:35
The Scene Manager manages scene nodes, mesh resources, cameras and all the other stuff.
Definition ISceneManager.hpp:160
Animates a scene node. Can animate position, rotation, material, and so on.
Definition ISceneNodeAnimator.hpp:32
virtual void setEnabled(bool enabled, u32 timeNow=0)
Sets the enabled state of this element.
Definition ISceneNodeAnimator.hpp:110
virtual bool hasFinished(void) const
Returns if the animator has finished.
Definition ISceneNodeAnimator.hpp:72
virtual bool OnEvent(const SEvent &event) override
Event receiver, override this function for camera controlling animators.
Definition ISceneNodeAnimator.hpp:58
u32 PauseTimeSum
Only enabled animators are updated.
Definition ISceneNodeAnimator.hpp:160
virtual void setStartTime(u32 time, bool resetPauseTime=true)
Reset a time-based movement by changing the starttime.
Definition ISceneNodeAnimator.hpp:84
void cloneMembers(const ISceneNodeAnimator *toCopyFrom)
Definition ISceneNodeAnimator.hpp:151
virtual ESCENE_NODE_ANIMATOR_TYPE getType() const
Returns type of the scene node animator.
Definition ISceneNodeAnimator.hpp:64
virtual void animateNode(ISceneNode *node, u32 timeMs)=0
Animates a scene node.
virtual ISceneNodeAnimator * createClone(ISceneNode *node, ISceneManager *newManager=0)=0
Creates a clone of this animator.
virtual void deserializeAttributes(io::IAttributes *in, io::SAttributeReadWriteOptions *options=0) override
Reads attributes of the scene node animator.
Definition ISceneNodeAnimator.hpp:139
virtual nirt::u32 getStartTime() const
Get the starttime.
Definition ISceneNodeAnimator.hpp:96
virtual void serializeAttributes(io::IAttributes *out, io::SAttributeReadWriteOptions *options=0) const override
Writes attributes of the scene node animator.
Definition ISceneNodeAnimator.hpp:132
u32 PauseTimeStart
Sum up time which the animator was disabled.
Definition ISceneNodeAnimator.hpp:161
u32 StartTime
Last time setEnabled(false) was called with a timer > 0.
Definition ISceneNodeAnimator.hpp:162
virtual bool isEventReceiverEnabled() const
Returns true if this animator receives events.
Definition ISceneNodeAnimator.hpp:52
Scene node interface.
Definition ISceneNode.hpp:43
ESCENE_NODE_ANIMATOR_TYPE
An enumeration for all types of built-in scene node animators.
Definition ESceneNodeAnimatorTypes.hpp:15
@ ESNAT_UNKNOWN
Unknown scene node animator.
Definition ESceneNodeAnimatorTypes.hpp:47
As of Nirtcpp 1.6, position2d is a synonym for vector2d.
Definition vector3d.hpp:11
unsigned int u32
32 bit unsigned variable.
Definition irrTypes.hpp:64

Nirtcpp    @cppfx.xyz

Esvcpp    esv::print