From a9faf8cefff7f5c3445743f96e7aaa888dfb6464 Mon Sep 17 00:00:00 2001 From: curt Date: Mon, 10 May 2004 20:27:30 +0000 Subject: [PATCH] Frederic Bouvier: I modified the included animation.cxx to have a randomly displaced time origin, to break the unison. And the flashing period is also random as you noticed. I also put all the flashing light of the pole in the same animation so they flash in the same rhythm. --- simgear/scene/model/animation.cxx | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/simgear/scene/model/animation.cxx b/simgear/scene/model/animation.cxx index a068d4c1..298f0691 100644 --- a/simgear/scene/model/animation.cxx +++ b/simgear/scene/model/animation.cxx @@ -420,12 +420,26 @@ SGSpinAnimation::update() SGTimedAnimation::SGTimedAnimation (SGPropertyNode_ptr props) : SGAnimation(props, new ssgSelector), _use_personality( props->getBoolValue("use-personality",false) ), - _duration_sec(props->getDoubleValue("duration-sec", 1.0)), - _last_time_sec( sim_time_sec ), _total_duration_sec( 0 ), _step( 0 ) { + SGPropertyNode_ptr dNode = props->getChild( "duration-sec" ); + if ( dNode == 0 ) { + _duration_sec = 1.0; + } else { + SGPropertyNode_ptr rNode = dNode->getChild("random"); + if ( rNode == 0 ) { + _duration_sec = dNode->getDoubleValue(); + } else { + double dmin = rNode->getDoubleValue( "min", 0.0 ), + dmax = rNode->getDoubleValue( "max", 1.0 ); + _duration_sec = dmin + sg_random() * ( dmax - dmin ); + } + } + + _last_time_sec = sim_time_sec - _duration_sec; + vector nodes = props->getChildren( "branch-duration-sec" ); size_t nb = nodes.size(); for ( size_t i = 0; i < nb; i++ ) { -- 2.39.5