public void AddKeyframedMotion(KeyframeAnimation animation, KeyframeAnimation.Commands command) { if (command == KeyframeAnimation.Commands.Play) { if (animation != null)//This will happen if just the play command is being set m_rootPart.KeyframeAnimation = animation; //Only have one at a time m_scene.EventManager.OnFrame -= moveKeyframeMotion; m_scene.EventManager.OnFrame += moveKeyframeMotion; } else { m_scene.EventManager.OnFrame -= moveKeyframeMotion; if(m_rootPart.KeyframeAnimation != null) { m_rootPart.KeyframeAnimation.TimeLastTick = 0; if (command == KeyframeAnimation.Commands.Stop) { //Stop will reset the transformations while Pause does not m_rootPart.KeyframeAnimation.CurrentAnimationPosition = 0; //Reset the time elapsed too so that we don't start in the middle of a move m_rootPart.KeyframeAnimation.TimeElapsed = 0; } } } if (m_rootPart.KeyframeAnimation != null) m_rootPart.KeyframeAnimation.CurrentCommand = command; HasGroupChanged = true; }
public void TestKeyframeAnimationSerialization() { KeyframeAnimation anim = new KeyframeAnimation() { CurrentAnimationPosition = 5, CurrentCommand = KeyframeAnimation.Commands.Stop, CurrentMode = KeyframeAnimation.Modes.PingPong, InitialPosition = new Vector3(128,128,128), InitialRotation = new Quaternion(0.25f, 0.5f, 0.75f, 1.0f), PingPongForwardMotion = true, PositionList = new Vector3[3] { new Vector3(10,0,0), new Vector3(-10,0,0), new Vector3(0,0,10) }, RotationList = new Quaternion[3] { new Quaternion(0.4f, 0.6f, 0.8f, 1), new Quaternion(0.2f, 0.5f, 0.8f, 1), new Quaternion(0.1f, 0.5f, 0.9f, 1) }, TimeElapsed = 678, TimeLastTick = Environment.TickCount, TimeList = new TimeSpan[3] { TimeSpan.FromSeconds(1), TimeSpan.FromSeconds(2), TimeSpan.FromSeconds(3) } }; byte[] byteFormat = serEngine.MiscObjectSerializer.SerializeKeyframeAnimationToBytes(anim); KeyframeAnimation deserializedAnim = serEngine.MiscObjectSerializer.DeserializeKeyframeAnimationFromBytes(byteFormat); CompareObjects comp = new CompareObjects(); comp.CompareStaticFields = false; comp.CompareStaticProperties = false; comp.ElementsToIgnore = PrimCompareIgnoreList; Assert.IsTrue(comp.Compare(anim, deserializedAnim), comp.DifferencesString); }