/// <summary> /// Get TranslateTransform3D from Viewport3D, since get from ObjectTree directly will takes too much time and resource /// Work around private TranslateTransform3D GetTranslateTransform3DFromViewport3D(Viewport3D Viewport3D) { if (Viewport3D != null && Viewport3D.Children.Count != 0) { foreach (Visual3D visual in Viewport3D.Children) { Transform3D transform3D = ((Visual3D)(visual)).Transform; if (transform3D != null && transform3D.GetType() == typeof(TranslateTransform3D)) { return(transform3D as TranslateTransform3D); } } } return(null); }
public static void AddTransformationAnimation(ModelVisual3D model, Transform3D value) { if (model.Transform is Transform3DGroup == false) { model.Transform = new Transform3DGroup(); } Type type = value.GetType(); Transform3DGroup transformGroup = (Transform3DGroup)model.Transform; for (int i = 0; i < transformGroup.Children.Count; i++) { if (transformGroup.Children[i].GetType() == type) { transformGroup.Children[i] = value; return; } } transformGroup.Children.Add(value); }