/// <summary> /// Start the animation /// </summary> /// <param name="SM">Skeleton build by SkeletonManager</param> /// <param name="MV">WPF Screen</param> /// public void StartAnimation(Mckineap.Models.Engine3D.Animation animation) { if (animation != null) { if (IsEventRegister == false) { animation.Tick = 0; animation.Timer.Tick += new EventHandler((sender, e) => UpdateAnimation(sender, e, animation)); IsEventRegister = true; } animation.Timer.Start(); } }
/// <summary> /// Build a bone for drawing /// </summary> /// <param name="myBone">Bone</param> /// <returns>bone created</returns> private GeometryModel3D BuildBone(Mckineap.Models.Engine3D.Bone myBone) { MeshBuilder bone = new MeshBuilder(); Point3D Point1 = joints.First(x => x.Name == myBone.FirstJointName).Point; Point3D Point2 = joints.First(x => x.Name == myBone.SecondJointName).Point; bone.AddCylinder(Point1, Point2, boneDiameter, thetaDiv); GeometryModel3D pipe = new GeometryModel3D(bone.ToMesh(), new DiffuseMaterial(new SolidColorBrush(Colors.Beige))); return (pipe); }
/// <summary> /// Loads a Model3D in the associated model3DList ands sets the currentModel3D. /// </summary> /// <param name="model3D">The Model3D that needs to be loaded.</param> private void Load(Mckineap.Models.Engine3D.Model3D model3D) { models.Add(model3D); CurrentModel3D = models[models.Count - 1]; }
/// <summary> /// Delete a Model3D /// </summary> /// <param name="model">the Model3D to delete</param> public void DeleteModel3D(Mckineap.Models.Engine3D.Model3D model) { if (model != null) { Models.Remove(model); // Removes the model from the list in the UI if (File.Exists(model.Path)) { File.Delete(model.Path); // Removes the model file in the folder File.Delete(model.SerializePath); } if (CurrentModel3D.Name == model.Name) { Session.CurrentSession.CurrentProject.CurrentModel3D = null; Session.CurrentSession.ModelVisual.Children.Clear(); Session.CurrentSession.ModelVisual.Content = null; } } }
/// <summary> /// Select a Model from the list /// </summary> /// <param name="model">The Model3D to select</param> public void SelectModel3D(Mckineap.Models.Engine3D.Model3D model) { if (CurrentModel3D != null && CurrentModel3D.HasAnimations) CurrentModel3D.Serialize(); if (model != null) { Mckineap.Models.Engine3D.Model3D deserializedModel3D = model.Deserialize(); CurrentModel3D = deserializedModel3D != null ? deserializedModel3D : model; } }
/// <summary> /// Stops the animation /// </summary> public void StopAnimation(Mckineap.Models.Engine3D.Animation animation) { if (animation != null) { animation.Timer.Stop(); animation.Tick = 0; skeletonConverter.Update(); IsEventRegister = false; IsPlaying = false; } }
/// <summary> /// Action at each animation Frame /// </summary> /// <param name="sender">Default parameter</param> /// <param name="e">Default parameter</param> /// <param name="MV">WPF Screen</param> public void UpdateAnimation(object sender, EventArgs e, Mckineap.Models.Engine3D.Animation animation) { if (animation != null) { //Update The tick number of the project skeletonConverter.Update(); animation.Tick++; animation.Timer = (DispatcherTimer)sender; if (animation.Tick > animation.DurationInTicks) StopAnimation(animation); } }
/// <summary> /// Put the animation in pause /// </summary> public void PauseAnimation(Mckineap.Models.Engine3D.Animation animation) { if (animation != null) animation.Timer.Stop(); }