From John Kelso, add support for default frame time for children of a Sequence node

This commit is contained in:
Robert Osfield 2006-11-10 15:25:04 +00:00
parent 8983544a86
commit c3f3093ecc
2 changed files with 11 additions and 1 deletions

View File

@ -44,6 +44,12 @@ public :
/** Get time for child. */ /** Get time for child. */
float getTime(int frame) const; float getTime(int frame) const;
/** Set default time in seconds for new child. */
void setDefaultTime(float t) {_defaultTime = t;}
/** Get default time in seconds for new child. */
float getDefaultTime(void) const {return _defaultTime;};
/** Get number of frames */ /** Get number of frames */
inline unsigned int getNumFrames() const { return _frameTime.size(); } inline unsigned int getNumFrames() const { return _frameTime.size(); }
@ -107,6 +113,8 @@ protected :
float _speed; float _speed;
int _nreps, _nrepsremain; int _nreps, _nrepsremain;
float _defaultTime ;
SequenceMode _mode; SequenceMode _mode;
}; };

View File

@ -30,6 +30,7 @@ Sequence::Sequence() :
_speed(0), _speed(0),
_nreps(0), _nreps(0),
_nrepsremain(0), _nrepsremain(0),
_defaultTime(1.f),
_mode(STOP) _mode(STOP)
{ {
setNumChildrenRequiringUpdateTraversal(1); setNumChildrenRequiringUpdateTraversal(1);
@ -47,6 +48,7 @@ Sequence::Sequence(const Sequence& seq, const CopyOp& copyop) :
_speed(seq._speed), _speed(seq._speed),
_nreps(seq._nreps), _nreps(seq._nreps),
_nrepsremain(seq._nrepsremain), _nrepsremain(seq._nrepsremain),
_defaultTime(seq._defaultTime),
_mode(seq._mode) _mode(seq._mode)
{ {
setNumChildrenRequiringUpdateTraversal(getNumChildrenRequiringUpdateTraversal()+1); setNumChildrenRequiringUpdateTraversal(getNumChildrenRequiringUpdateTraversal()+1);
@ -144,7 +146,7 @@ void Sequence::traverse(NodeVisitor& nv)
// default timeout for unset values // default timeout for unset values
if (sw >= (int) _frameTime.size()) if (sw >= (int) _frameTime.size())
{ {
setTime(sw, 1.0f); setTime(sw, _defaultTime);
} }
// frame time-out? // frame time-out?