Пример #1
0
void
Clock::Begin (TimeSpan parentTime)
{
	//printf ("clock %p (%s) begin\n", this, GetName ());
	emit_completed = false;
	has_completed = false;
	was_stopped = false;

	/* we're starting.  initialize our current_time field */
	SetCurrentTime ((parentTime - root_parent_time - timeline->GetBeginTime ()) * timeline->GetSpeedRatio());

	Duration d = GetNaturalDuration ();
	if (d.HasTimeSpan ()) {
		if (d.GetTimeSpan() == 0) {
			progress = 1.0;
		}
		else {
			progress = (double)current_time / d.GetTimeSpan();
			if (progress > 1.0)
				progress = 1.0;
		}
	}
	else
		progress = 0.0;

	CalculateFillTime ();

	SetClockState (Clock::Active);

	// force the time manager to tick the clock hierarchy to wake it up
	time_manager->NeedClockTick ();
}
Пример #2
0
//-----------------------------------------------------------------------------
// Purpose: 
// Input  : *scene - 
//			*event - 
//-----------------------------------------------------------------------------
void C_SceneEntity::DispatchProcessLoop( CChoreoScene *scene, CChoreoEvent *event )
{
	Assert( event->GetType() == CChoreoEvent::LOOP );

	float backtime = (float)atof( event->GetParameters() );

	bool process = true;
	int counter = event->GetLoopCount();
	if ( counter != -1 )
	{
		int remaining = event->GetNumLoopsRemaining();
		if ( remaining <= 0 )
		{
			process = false;
		}
		else
		{
			event->SetNumLoopsRemaining( --remaining );
		}
	}

	if ( !process )
		return;

	scene->LoopToTime( backtime );
	SetCurrentTime( backtime, true );
}
Пример #3
0
void RarTime::SetAgeText(char *TimeText)
{
  uint Seconds=0,Value=0;
  for (int I=0;TimeText[I]!=0;I++)
  {
    int Ch=TimeText[I];
    if (IsDigit(Ch))
      Value=Value*10+Ch-'0';
    else
    {
      switch(etoupper(Ch))
      {
        case 'D':
          Seconds+=Value*24*3600;
          break;
        case 'H':
          Seconds+=Value*3600;
          break;
        case 'M':
          Seconds+=Value*60;
          break;
        case 'S':
          Seconds+=Value;
          break;
      }
      Value=0;
    }
  }
  SetCurrentTime();
  int64 RawTime=GetRaw();
  SetRaw(RawTime-INT32TO64(0,Seconds)*10000000);
}
Пример #4
0
// https://w3c.github.io/web-animations/#set-the-animation-playback-rate
void
Animation::SetPlaybackRate(double aPlaybackRate)
{
  if (aPlaybackRate == mPlaybackRate) {
    return;
  }

  AutoMutationBatchForAnimation mb(*this);

  Nullable<TimeDuration> previousTime = GetCurrentTime();
  mPlaybackRate = aPlaybackRate;
  if (!previousTime.IsNull()) {
    SetCurrentTime(previousTime.Value());
  }

  // In the case where GetCurrentTime() returns the same result before and
  // after updating mPlaybackRate, SetCurrentTime will return early since,
  // as far as it can tell, nothing has changed.
  // As a result, we need to perform the following updates here:
  // - update timing (since, if the sign of the playback rate has changed, our
  //   finished state may have changed),
  // - dispatch a change notification for the changed playback rate, and
  // - update the playback rate on animations on layers.
  UpdateTiming(SeekFlag::DidSeek, SyncNotifyFlag::Async);
  if (IsRelevant()) {
    nsNodeUtils::AnimationChanged(this);
  }
  PostUpdate();
}
Пример #5
0
void CModelGTF::UpdateModel()
{
	// Grab a pointer to the model
	t3DModel *pModel = &m_Model;

	// Make sure there are objects and animation speed in the model
	if(!pModel->pObject.size() || pModel->animSpeed <= 0) return;

	// Initialize a start and end frame.  In this tutorial we don't add a way
	// to keep track of each animation, so we just play all of the animations
	// in a sequence.  If we wanted to only play certain animations the start
	// frame and end frame would need to be changed for each animation.
	int startFrame = 0;
	int endFrame   = pModel->pObject[0].numFrames;
	
	// This gives us the next frame we are going to.  We mod the current frame plus
	// 1 by the current animations end frame to make sure the next frame is valid.
	pModel->nextFrame = (pModel->currentFrame + 1) % endFrame;

	// If the next frame is zero, that means that we need to start the animation over.
	// To do this, we set nextFrame to the starting frame of this animation.
	if(pModel->nextFrame == 0) 
		pModel->nextFrame =  startFrame;

	// Next, we want to get the current time that we are interpolating by.  Remember,
	// if t = 0 then we are at the beginning of the animation, where if t = 1 we are at the end.
	// Anything from 0 to 1 can be thought of as a percentage from 0 to 100 percent complete.
	SetCurrentTime();
}
AbstractTimelineMarker::AbstractTimelineMarker(const char* aName,
                                               MarkerTracingType aTracingType)
  : mName(aName)
  , mTracingType(aTracingType)
{
  MOZ_COUNT_CTOR(AbstractTimelineMarker);
  SetCurrentTime();
}
Пример #7
0
bool wxSVGDocument::Load(const wxString& filename, const wxString& encoding) {
	bool result = wxSvgXmlDocument::Load(filename, encoding);
	if (result) {
		m_path =  wxPathOnly(filename);
	}
	SetCurrentTime(0);
	return result;
}
Пример #8
0
void
Animation::SetPlaybackRate(double aPlaybackRate)
{
  Nullable<TimeDuration> previousTime = GetCurrentTime();
  mPlaybackRate = aPlaybackRate;
  if (!previousTime.IsNull()) {
    SetCurrentTime(previousTime.Value());
  }
}
Пример #9
0
void Widget::SetConnect()
{
    //每秒显示时间
    connect(m_timer,SIGNAL(timeout()),this,SLOT(SetCurrentTime()));
    //返回今天
    connect(m_TotodayButton,SIGNAL(clicked()),this,SLOT(ReturnToday()));

    connect(m_Calendar,SIGNAL(selectionChanged()),this,SLOT(DateChanged()));
    connect(m_NextDayButton,SIGNAL(clicked()),this,SLOT(ToNextDay()));
    connect(m_ToPreDayButton,SIGNAL(clicked()),this,SLOT(ToPreDay()));

    connect(m_YearComboBox,SIGNAL(currentIndexChanged(int)),this,SLOT(ToCertainDate()));
    connect(m_MonthComboBox,SIGNAL(currentIndexChanged(int)),this,SLOT(ToCertainDate()));
    connect(m_DayComboBox,SIGNAL(currentIndexChanged(int)),this,SLOT(ToCertainDate()));
    connect(m_YearComboBox,SIGNAL(currentIndexChanged(int)),this,SLOT(SetCBDay()));
    connect(m_MonthComboBox,SIGNAL(currentIndexChanged(int)),this,SLOT(SetCBDay()));

    QTimer::singleShot(0,this,SLOT(SetCurrentTime()));
    QTimer::singleShot(0,this,SLOT(DateChanged()));
}
Пример #10
0
void
Animation::SetPlaybackRate(double aPlaybackRate)
{
  Nullable<TimeDuration> previousTime = GetCurrentTime();
  mPlaybackRate = aPlaybackRate;
  if (!previousTime.IsNull()) {
    ErrorResult rv;
    SetCurrentTime(previousTime.Value());
    MOZ_ASSERT(!rv.Failed(), "Should not assert for non-null time");
  }
}
Пример #11
0
CGameTimer::CGameTimer( double dCurrentime )
{
	m_nSec = 0;
	m_nMin = 0;
	m_nHour = 0;
	m_nDay = 0;
	m_dBeginTime = 0;
	m_dCurrentTime = 0;
	SetCurrentTime( dCurrentime );
	m_bFixed = FALSE;
}
Пример #12
0
CGameTimer::CGameTimer()
{
	m_nSec = 0;
	m_nMin = 0;
	m_nHour = 0;
	m_nDay = 0;
	m_dBeginTime = 0;
	m_dCurrentTime = 0;
	SetCurrentTime( 3, 15 );
	m_bFixed = FALSE;
}
Пример #13
0
void
Animation::SetCurrentTimeAsDouble(const Nullable<double>& aCurrentTime,
                                        ErrorResult& aRv)
{
  if (aCurrentTime.IsNull()) {
    if (!GetCurrentTime().IsNull()) {
      aRv.Throw(NS_ERROR_DOM_TYPE_ERR);
    }
    return;
  }

  return SetCurrentTime(TimeDuration::FromMilliseconds(aCurrentTime.Value()));
}
Пример #14
0
/*
	Output command with controlmode
*/
void OutputCmdType002( char *cmdPtr, long cmdLen, short isSetTime )
{
	int n;
	long len;
	char buf[CMD_BUF_MAX_SIZE];
	char *p = buf;

	n = SetBJLStart(p); p += n;
	n = SetControlMode(p); p += n;

	if ( isSetTime ) {
		n = SetCurrentTime(p); p+=n; 
	}

	memcpy( p, cmdPtr, cmdLen ); p += cmdLen;
	n = SetBJLEnd(p); p += n;
	*p = 0x00; p++;

	len = (long)(p - buf);
	PutPrintData( buf, len );
}
Пример #15
0
/*
	Output command
*/
void OutputCmdType001( char *cmdPtr, long cmdLen )
{
	int n;
	long len;
	char buf[CMD_BUF_MAX_SIZE];
	char *p = buf;

	/* Output SetTime */
	n = SetBJLStart(p); p += n;
	n = SetControlMode(p); p += n;
	n = SetCurrentTime(p); p+=n; 
	n = SetBJLEnd(p); p += n;

	/* Output Command */
	n = SetBJLStart(p); p += n;
	memcpy( p, cmdPtr, cmdLen ); p += cmdLen;
	n = SetBJLEnd(p); p += n;
	*p = 0x00; p++;

	len = (long)(p - buf);
	PutPrintData( buf, len );
}
Пример #16
0
// https://w3c.github.io/web-animations/#finish-an-animation
void
Animation::Finish(ErrorResult& aRv)
{
  if (mPlaybackRate == 0 ||
      (mPlaybackRate > 0 && EffectEnd() == TimeDuration::Forever())) {
    aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
    return;
  }

  TimeDuration limit =
    mPlaybackRate > 0 ? TimeDuration(EffectEnd()) : TimeDuration(0);

  SetCurrentTime(limit);

  if (mPendingState == PendingState::PlayPending) {
    CancelPendingTasks();
    if (mReady) {
      mReady->MaybeResolve(this);
    }
  }
  UpdateFinishedState(true);
  PostUpdate();
}
Пример #17
0
bool CModelMD3::UpdateModel(t3DModel *pModel,bool loop)
{
	int startFrame = 0;
	int endFrame   = 1;

	tAnimationInfo *pAnim = &(pModel->pAnimations[pModel->currentAnim]);

	if(pModel->numOfAnimations)
	{
		startFrame = pAnim->startFrame;
		endFrame   = pAnim->endFrame;
	}
	
	pModel->nextFrame = (pModel->currentFrame + 1) % endFrame;

	if(pModel->nextFrame == 0)
	{
		pModel->nextFrame =  startFrame;
		if(!loop)
			return true;
	}
	SetCurrentTime(pModel);
	return false;
}
Пример #18
0
void CAnimBlendAssociation::Start(float fStartTime)
{
    usFlags |= 0x01;
    SetCurrentTime(fStartTime);
}
Пример #19
0
void CGameTimer::SetCurrentTime( int nDay, int nHour )
{
	int nSec = ( ( nDay * 24 ) + nHour ) * 60 * 60;
	SetCurrentTime( nSec * TIMESPEED );
}
Пример #20
0
bool
Clock::UpdateFromParentTime (TimeSpan parentTime)
{
#define CLAMP_NORMALIZED_TIME do {			\
	if (normalizedTime < 0.0) normalizedTime = 0.0; \
	if (normalizedTime > 1.0) normalizedTime = 1.0; \
} while (0)

	//
	// The idea behind this method is that it is possible (and
	// easier, and clearer) to apply a simple function to our
	// parent clock's time to calculate our own time.
	//
	// We also calculate our progress (MS uses the term
	// "normalized time"), a value in the range [0-1] at the same
	// time.
	//
	// This clock's localTime runs from the range
	// [0-natural_duration] for natural_durations with timespans,
	// and [0-$forever] for Forever durations.  Automatic
	// durations are translated into timespans.

	if (timeline == NULL) {
		// printf ("timeline is null!?  f**k yeah! (clock = %s)\n", name);
		Stop ();
		return false;
	}
		
	if (!GetHasStarted() && !GetWasStopped() && (GetBeginOnTick() || timeline->GetBeginTime () <= parentTime)) {
		if (GetBeginOnTick())
			BeginOnTick (false);
		Begin (parentTime);
	}

	// root_parent_time is the time we were added to our parent clock.
	// timeline->GetBeginTime() is expressed in the time-space of the parent clock.
	//
	// subtracting those two translates our start time to 0
	//
	// we then have to account for our accumulated pause time, and
	// scale the whole thing by our speed ratio.
	//
	// the result is a timespan unaffected by repeatbehavior or
	// autoreverse.  it is simple the timespan our clock has been
	// running.
	TimeSpan localTime = (parentTime - root_parent_time - timeline->GetBeginTime() - accumulated_pause_time) * timeline->GetSpeedRatio();

	bool seek_completed = false;

	if (is_seeking) {
		// if we're seeking, we need to arrange for the above
		// localTime formula to keep time correctly.  we clear
		// accumulated_pause_time, and adjust root_parent_time
		// such that we can re-evaluate localTime and have
		// localTime = seek_time.

		begin_pause_time = 0;
		accumulated_pause_time = 0;

		/* seek_time = localTime

		   seek_time = (parentTime - root_parent_time - timeline->BeginTime() - 0) * timeline->GetSpeedRatio ()

		          seek_time
  		   ------------------------- = parentTime - root_parent_time - timeline->BeginTime();
		   timeline->GetSpeedRatio()
                                                                                  seek_time         
		   root_parent_time = parentTime - timeline->BeginTime() - -------------------------
									   timeline->GetSpeedRatio()
		*/
		root_parent_time = parentTime - (timeline->GetBeginTime () - seek_time) / timeline->GetSpeedRatio ();
		localTime = (seek_time - timeline->GetBeginTime()) * timeline->GetSpeedRatio();
		is_seeking = false;
		seek_completed = true;

		if (!GetHasStarted())
			CalculateFillTime ();
	}
	else if (is_paused) {
		// if we're paused and not seeking, we don't update
		// anything.
		return false;
	}

	// the clock doesn't update and we don't progress if the
	// translated local time is before our begin time.  Keep in
	// mind that this can happen *after* a clock has started,
	// since parentTime isn't strictly increasing.  It can
	// decrease and represent a time before our start time.
	if (localTime < 0)
		return true;

	if (GetClockState () == Clock::Stopped) {
		if (!seek_completed)
			return false;

		// even for stopped clocks we update their position if they're seeked.
	}

	double normalizedTime = 0.0;


	// we only do the bulk of the work if the duration has a
	// timespan.  if we're automatic/forever, our normalizedTime
	// stays pegged at 0.0, and our localTime progresses
	// undisturbed.  i.e. a RepeatBehavior="2x" means nothing if
	// the Duration of the animation is forever.
	if (GetNaturalDuration().HasTimeSpan()) {
		TimeSpan natural_duration_timespan = GetNaturalDuration().GetTimeSpan();
		
		if (natural_duration_timespan <= 0) {
			// for clocks with instantaneous begin times/durations, expressable like so:
			//     <DoubleAnimation Storyboard.TargetProperty="Opacity" To="1" BeginTime="00:00:00" Duration="00:00:00" />
			// we keep our localtime pegged at 0 (FIXME:
			// without filling?) and our normalizedTime at
			// 1.  The latter makes sure that value is applied in full.
 			localTime = 0;
 			normalizedTime = 1.0;
			if (GetClockState () == Clock::Active) {
				FillOnNextTick ();
				Completed ();

				SetCurrentTime (localTime);
				progress = normalizedTime;

				return false;
			}
		}
		else if (natural_duration_timespan > 0) {
			RepeatBehavior *repeat = timeline->GetRepeatBehavior ();

			if (!repeat->IsForever() && localTime >= fillTime) {
				// fillTime represents the local time
				// at which the number of repeats
				// (expressed either as a timespan or
				// e.g. "2x") and autoreverses have
				// completed.  i.e. it's the
				// $natural_duration * $repeat_count
				// for repeat behaviors with counts,
				// and $repeat_duration for repeat
				// behaviors with timespans.

				// if the timeline is auto-reversible,
				// we always end at localTime = 0.
				// Otherwise we know it's fillTime.
				localTime = timeline->GetAutoReverse () ? 0 : fillTime;
				normalizedTime = (double)localTime / natural_duration_timespan;
				CLAMP_NORMALIZED_TIME;
				if (GetClockState () == Clock::Active) {
					FillOnNextTick ();
					Completed ();
				}
				else if ((moonlight_flags & RUNTIME_INIT_USE_IDLE_HINT) && GetClockState () == Clock::Filling) {
					return false;
				}
			}
			else {
				if (GetClockState () != Clock::Active)
					SetClockState (Clock::Active);

				if (localTime > 0) {
					double t = (double)localTime / natural_duration_timespan;
					int ti = (int)t;
					double fract = t - ti;

					// This block of code is the first time where localTime is translated
					// into per-repeat/per-autoreverse segments.  We do it here because it
					// allows us to use a cute hack for determining if we're ascending or
					// descending.
					//
					// for instance:

					// <storyboard duration="00:00:12">
					//   <doubleanimation begintime="00:00:00" repeatbehavior="2x" autoreverse="<below>" duration="00:00:03" />
					// </storyboard>
					//
					//  autoreverse = true                       autoreverse = false
					// 0  / 3 = 0        = 0                  0 / 3 = 0           = 0
					// 1  / 3 = .333     > 0.333              1 / 3 = .333        > 0.333
					// 2  / 3 = .666     > 0.666              2 / 3 = .666        > 0.666
					// 3  / 3 = 1        = 1                  3 / 3 = 1           = 1
					// 4  / 3 = 1.33     < 0.666              4 / 3 = 1.33        > 0.333
					// 5  / 3 = 1.66     < 0.333              5 / 3 = 1.66        > 0.666
					// 6  / 3 = 2        = 0                  6 / 3 = 2           = 1
					// 7  / 3 = 2.33     > 0.333
					// 8  / 3 = 2.66     > 0.666
					// 9  / 3 = 3        = 1
					// 10 / 3 = 3.33     < 0.666
					// 11 / 3 = 3.66     < 0.333
					// 12 / 3 = 4        = 0


					// a little explanation:  the $localtime / $natural_duration = $foo is done
					// to factor out the repeat count.  we know that the time within a given repeated
					// run is just the fractional part of that (if the result has a fraction), or 0 or 1.

					// the >,<,= column above represents whether we're increasing, decreasing, or at an
					// end-point, respectively.

					if (timeline->GetAutoReverse()) {
						// left column above
						if (ti & 1) {
							// e.g:
							// 3  / 3 = 1        = 1    
							// 4  / 3 = 1.33     < 0.666
							// 5  / 3 = 1.66     < 0.333

							// we know we're either at normalized time 1 (at our duration), or we're descending,
							// based on if there's a fractional component.
							if (ti == t) {
								normalizedTime = 1.0;
								localTime = natural_duration_timespan;
							}
							else {
								/* we're descending */
								normalizedTime = 1.0 - fract;
								CLAMP_NORMALIZED_TIME;
								localTime = normalizedTime * natural_duration_timespan;
							}
						}
						else {
							// e.g:
							// 6  / 3 = 2        = 0    
							// 7  / 3 = 2.33     > 0.333
							// 8  / 3 = 2.66     > 0.666

							// we know we're either at normalizd time 0 (at our start time), or we're ascending,
							// based on if there's a fractional component.
							if (ti == t) {
								normalizedTime = 0.0;
								localTime = 0;
							}
							else {
								/* we're ascending */
								normalizedTime = fract;
								CLAMP_NORMALIZED_TIME;
								localTime = normalizedTime * natural_duration_timespan;
							}
						}
					}
					else {
						// e.g.:
						// 0 / 3 = 0           = 0
						// 1 / 3 = .333        > 0.333
						// 2 / 3 = .666        > 0.666
						// 3 / 3 = 1           = 1
						// 4 / 3 = 1.33        > 0.333
						// 5 / 3 = 1.66        > 0.666
						// 6 / 3 = 2           = 1

						// we're always ascending here (since autoreverse is off), and we know we're > 0,
						// so we don't need to concern ourselves with that case.  At the integer points we're
						// at our duration, and otherwise we're at the fractional value.
						if (ti == t) {
							normalizedTime = 1.0;
							localTime = natural_duration_timespan;
						}
						else {
							/* we're ascending */
							normalizedTime = fract;
							CLAMP_NORMALIZED_TIME;
							localTime = normalizedTime * natural_duration_timespan;
						}
					}
				}
			}
		}
	}

	SetCurrentTime (localTime);
	progress = normalizedTime;

	// we check to see if there's a clockgroup in our hierarchy
	// that's Filling.  if there is, we return false here, since
	// we won't be updated beyond our current time anyway.
	if (moonlight_flags & RUNTIME_INIT_USE_IDLE_HINT) {
		Clock *cg = this;
		while ((cg = cg->GetParentClock())) {
			if (cg->GetClockState () == Clock::Active && !((ClockGroup*)cg)->IsTimeManagerClockGroup())
				return true;
		}

		return false;
	}

	return true;
}
Пример #21
0
void CAnimBlendAssociation::SyncAnimation(CAnimBlendAssociation *pOtherAssoc)
{
    SetCurrentTime(pOtherAssoc->fCurrentTime / pOtherAssoc->fTotalTime * m_pAnimHierarchy->fTotalTime);
}
Пример #22
0
CAnimBlendAssociation::CAnimBlendAssociation(CAnimBlendAssociation& assoc)
{
    SetCurrentTime(assoc.m_assoc.currentTime / assoc.m_assoc.fTotalTime * m_assoc.animHierarchy->m_totalTime);
}