Пример #1
0
        public SceneElement AddChild(SceneViewModel sceneView, Base3DElement child)
        {
            Model3DElement model3Delement = BaseElement3DCoercionHelper.CoerceToModel3D(sceneView, (SceneElement)child);

            if (model3Delement != null)
            {
                this.Children.Add(model3Delement);
            }
            return((SceneElement)model3Delement);
        }
        public static Model3DElement CoerceToModel3D(SceneViewModel viewModel, SceneElement sceneElement)
        {
            Model3DElement model3Delement = sceneElement as Model3DElement;

            if (model3Delement != null)
            {
                return(model3Delement);
            }
            ModelVisual3DElement modelVisual3Delement1;

            if ((modelVisual3Delement1 = sceneElement as ModelVisual3DElement) != null)
            {
                Model3DGroupElement model3DgroupElement = (Model3DGroupElement)viewModel.CreateSceneNode(typeof(Model3DGroup));
                SceneNode           valueAsSceneNode1   = modelVisual3Delement1.GetLocalValueAsSceneNode(ModelVisual3DElement.TransformProperty);
                if (valueAsSceneNode1 != null)
                {
                    valueAsSceneNode1.Remove();
                    model3DgroupElement.SetValueAsSceneNode(ModelVisual3DElement.TransformProperty, valueAsSceneNode1);
                }
                model3DgroupElement.Name = modelVisual3Delement1.Name;
                SceneNode valueAsSceneNode2 = modelVisual3Delement1.GetLocalValueAsSceneNode(ModelVisual3DElement.ContentProperty);
                if (valueAsSceneNode2 != null)
                {
                    valueAsSceneNode2.Remove();
                    if (valueAsSceneNode2 is Model3DElement)
                    {
                        model3DgroupElement.GetCollectionForProperty(Model3DGroupElement.ChildrenProperty).Add(valueAsSceneNode2);
                    }
                }
                foreach (ModelVisual3DElement modelVisual3Delement2 in (IEnumerable <Visual3DElement>)modelVisual3Delement1.Children)
                {
                    model3DgroupElement.Children.Add(BaseElement3DCoercionHelper.CoerceToModel3D(viewModel, (SceneElement)modelVisual3Delement2));
                }
                return((Model3DElement)model3DgroupElement);
            }
            if (sceneElement is Viewport2DVisual3DElement)
            {
                return((Model3DElement)null);
            }
            Viewport3DElement viewport3Delement = sceneElement as Viewport3DElement;

            return((Model3DElement)null);
        }