public override Pose Calculate() { Col.Calculate(); Prev.Calculate(); Enabled.Calculate(); if (!Enabled.value.value_b) { return(Prev.value); } YPRScale.Calculate(); YPROmega.Calculate(); YPRPhi.Calculate(); OffsetScale.Calculate(); OffsetOmega.Calculate(); OffsetPhi.Calculate(); Tick.Calculate(); Duration.Calculate(); Falloff.Calculate(); if (controller != null && controller.executor != null) { Pose pose = Prev.value; float t = Tick.value.value_f; float d = Mathf.Max(0.001f, Duration.value.value_f); float f = Mathf.Max(0.001f, Falloff.value.value_f); if (t < d && t >= 0) { float scale = Mathf.Pow(1f - t / d, f); pose.yaw += Mathf.Sin((YPROmega.value.value_v.x * t + YPRPhi.value.value_v.x) * 2.0f * Mathf.PI) * YPRScale.value.value_v.x * scale; pose.pitch += Mathf.Sin((YPROmega.value.value_v.y * t + YPRPhi.value.value_v.y) * 2.0f * Mathf.PI) * YPRScale.value.value_v.y * scale; pose.roll += Mathf.Sin((YPROmega.value.value_v.z * t + YPRPhi.value.value_v.z) * 2.0f * Mathf.PI) * YPRScale.value.value_v.z * scale; Vector3 right = pose.rotation * Vector3.right; Vector3 up = pose.rotation * Vector3.up; Vector3 forward = pose.rotation * Vector3.forward; Vector3 ofs = Vector3.zero; ofs += right * Mathf.Sin((OffsetOmega.value.value_v.x * t + OffsetPhi.value.value_v.x) * 2.0f * Mathf.PI) * OffsetScale.value.value_v.x * scale; ofs += up * Mathf.Sin((OffsetOmega.value.value_v.y * t + OffsetPhi.value.value_v.y) * 2.0f * Mathf.PI) * OffsetScale.value.value_v.y * scale; ofs += forward * Mathf.Sin((OffsetOmega.value.value_v.z * t + OffsetPhi.value.value_v.z) * 2.0f * Mathf.PI) * OffsetScale.value.value_v.z * scale; pose.position += ofs; return(pose); } else { return(pose); } } return(Pose.Default); }
public double QueueImage(BeeImage bi) { BeeImage.SetShowingImage(bi); if (m_imgOld != null) { GridImage.Children.Remove(m_imgOld); } m_imgOld = m_imgNew; m_imgNew = new Image { Source = bi.BitmapFrame, // Start with 0 opacity Opacity = 0, Stretch = Stretch.None }; GridImage.Children.Add(m_imgNew); DoubleAnimation animFadeIn = new DoubleAnimation(1, TimeSpan.FromSeconds(m_fadeSeconds)); ScaleTransform scaleTransform = new ScaleTransform(1, 1); m_imgNew.RenderTransformOrigin = new Point(0, 0); m_imgNew.RenderTransform = scaleTransform; OffsetScale os1 = bi.GetStartOffsetScale(new BeeRect(0, 0, GridImage.ActualWidth, GridImage.ActualHeight)); OffsetScale os2 = bi.GetEndOffsetScale(new BeeRect(0, 0, GridImage.ActualWidth, GridImage.ActualHeight)); // Let's animate a random amount of time between 0.25 and 1.0 of the configuration value. double mult = (m_rng.NextDouble() * 0.75) + 0.25; double panSeconds = mult * m_panSeconds; TimeSpan tsAnim = TimeSpan.FromSeconds(panSeconds + m_fadeSeconds); m_currentStoryboard = new Storyboard { Duration = tsAnim }; DoubleAnimation animScaleX = new DoubleAnimation(os1.Scale, os2.Scale, tsAnim); DoubleAnimation animScaleY = new DoubleAnimation(os1.Scale, os2.Scale, tsAnim); DoubleAnimation animOffsetX = new DoubleAnimation(-os1.OffsetX, -os2.OffsetX, tsAnim); DoubleAnimation animOffsetY = new DoubleAnimation(-os1.OffsetY, -os2.OffsetY, tsAnim); Storyboard.SetTarget(animScaleX, m_imgNew); Storyboard.SetTargetProperty(animScaleX, new PropertyPath("RenderTransform.ScaleX")); m_currentStoryboard.Children.Add(animScaleX); Storyboard.SetTarget(animScaleY, m_imgNew); Storyboard.SetTargetProperty(animScaleY, new PropertyPath("RenderTransform.ScaleY")); m_currentStoryboard.Children.Add(animScaleY); Storyboard.SetTarget(animOffsetX, m_imgNew); Storyboard.SetTargetProperty(animOffsetX, new PropertyPath("RenderTransform.CenterX")); m_currentStoryboard.Children.Add(animOffsetX); Storyboard.SetTarget(animOffsetY, m_imgNew); Storyboard.SetTargetProperty(animOffsetY, new PropertyPath("RenderTransform.CenterY")); m_currentStoryboard.Children.Add(animOffsetY); if (m_imgOld != null) { DoubleAnimation animFadeOut = new DoubleAnimation(0, TimeSpan.FromSeconds(m_fadeSeconds)); Storyboard.SetTarget(animFadeOut, m_imgOld); Storyboard.SetTargetProperty(animFadeOut, new PropertyPath("Opacity")); m_currentStoryboard.Children.Add(animFadeOut); } Storyboard.SetTarget(animFadeIn, m_imgNew); Storyboard.SetTargetProperty(animFadeIn, new PropertyPath("Opacity")); m_currentStoryboard.Children.Add(animFadeIn); m_currentStoryboard.Duration = new Duration(tsAnim); m_currentStoryboard.Begin(); return(panSeconds); }