2002-08-04 02:11:21 +08:00
|
|
|
// -*-c++-*-
|
|
|
|
|
|
|
|
//C++ header - Open Scene Graph - Copyright (C) 1998-2002 Robert Osfield
|
|
|
|
//Distributed under the terms of the GNU Library General Public License (LGPL)
|
|
|
|
//as published by the Free Software Foundation.
|
|
|
|
|
|
|
|
#ifndef OSG_SEQUENCE
|
|
|
|
#define OSG_SEQUENCE 1
|
|
|
|
|
|
|
|
#include <osg/Switch>
|
|
|
|
|
|
|
|
namespace osg {
|
|
|
|
|
|
|
|
/** Sequence is a Group node which allows automatic, time based
|
|
|
|
switching between children.
|
|
|
|
*/
|
|
|
|
class SG_EXPORT Sequence : public Switch
|
|
|
|
{
|
|
|
|
public :
|
|
|
|
|
|
|
|
Sequence();
|
|
|
|
|
|
|
|
/** Copy constructor using CopyOp to manage deep vs shallow copy.*/
|
|
|
|
Sequence(const Sequence&, const CopyOp& copyop=CopyOp::SHALLOW_COPY);
|
|
|
|
|
|
|
|
META_Node(osg, Sequence);
|
|
|
|
|
|
|
|
virtual void traverse(NodeVisitor& nv);
|
|
|
|
|
|
|
|
/** Set time in seconds for child */
|
|
|
|
void setTime(int frame, float t);
|
|
|
|
|
|
|
|
/** Get time for child */
|
2002-09-02 20:31:35 +08:00
|
|
|
float getTime(int frame) const;
|
2002-08-04 02:11:21 +08:00
|
|
|
|
|
|
|
/** Interval modes */
|
2002-08-29 05:40:38 +08:00
|
|
|
enum LoopMode
|
|
|
|
{
|
2002-08-04 02:11:21 +08:00
|
|
|
LOOP,
|
|
|
|
SWING
|
|
|
|
};
|
|
|
|
|
|
|
|
/** Set sequence mode & interval. */
|
|
|
|
void setInterval(LoopMode mode, int begin, int end);
|
|
|
|
|
|
|
|
/** Get sequence mode & interval. */
|
2002-08-29 05:40:38 +08:00
|
|
|
inline void getInterval(LoopMode& mode, int& begin, int& end) const
|
|
|
|
{
|
2002-08-04 02:11:21 +08:00
|
|
|
mode = _loopMode;
|
|
|
|
begin = _begin;
|
|
|
|
end = _end;
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Set duration: speed-up & number of repeats */
|
|
|
|
void setDuration(float speed, int nreps = -1);
|
|
|
|
|
|
|
|
/** Get duration */
|
2002-08-29 05:40:38 +08:00
|
|
|
inline void getDuration(float& speed, int& nreps) const
|
|
|
|
{
|
2002-08-04 02:11:21 +08:00
|
|
|
speed = _speed;
|
|
|
|
nreps = _nreps;
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Sequence modes */
|
2002-08-29 05:40:38 +08:00
|
|
|
enum SequenceMode
|
|
|
|
{
|
2002-08-04 02:11:21 +08:00
|
|
|
START,
|
|
|
|
STOP,
|
|
|
|
PAUSE,
|
|
|
|
RESUME
|
|
|
|
};
|
|
|
|
|
|
|
|
/** Set sequence mode. Start/stop & pause/resume. */
|
|
|
|
void setMode(SequenceMode mode);
|
|
|
|
|
|
|
|
/** Get sequence mode. */
|
|
|
|
inline SequenceMode getMode() const { return _mode; }
|
|
|
|
|
|
|
|
protected :
|
|
|
|
|
|
|
|
virtual ~Sequence() {}
|
|
|
|
|
|
|
|
float _last;
|
|
|
|
std::vector<float> _frameTime;
|
|
|
|
|
|
|
|
int _step;
|
|
|
|
|
|
|
|
LoopMode _loopMode;
|
|
|
|
int _begin, _end;
|
|
|
|
|
|
|
|
float _speed;
|
|
|
|
int _nreps, _nrepsremain;
|
|
|
|
|
|
|
|
SequenceMode _mode;
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|