コード例 #1
0
        public AdornerSet3DContainer(Viewport3DElement adornedViewport)
        {
            if (adornedViewport == null)
            {
                throw new ArgumentNullException("adornedViewport");
            }
            this.adornedViewport = adornedViewport;
            Rect computedTightBounds = adornedViewport.GetComputedTightBounds();

            this.shadowAdorningContainer = new Viewport3DVisual();
            this.shadowAdorningContainer.Children.Add((Visual3D)this.CreateContainerWorld());
            this.shadowAdorningContainer.Viewport = computedTightBounds;
            this.orthographicAdorningContainer    = new Viewport3DVisual();
            this.orthographicAdorningContainer.Children.Add((Visual3D)this.CreateContainerWorld());
            this.orthographicAdorningContainer.Viewport = computedTightBounds;
            ProjectionCamera projectionCamera1 = this.adornedViewport.Camera.ViewObject.PlatformSpecificObject as ProjectionCamera;
            ProjectionCamera projectionCamera2;

            if (projectionCamera1 != null)
            {
                projectionCamera2           = projectionCamera1.Clone();
                projectionCamera2.Transform = Transform3D.Identity;
            }
            else
            {
                projectionCamera2 = (ProjectionCamera) new PerspectiveCamera(new Point3D(0.0, 0.0, 10.0), new Vector3D(0.0, 0.0, 1.0), new Vector3D(0.0, 1.0, 0.0), 35.0);
            }
            this.shadowAdorningContainer.Camera = (Camera)projectionCamera2;
            OrthographicCamera orthographicCamera = new OrthographicCamera(projectionCamera2.Position, projectionCamera2.LookDirection, projectionCamera2.UpDirection, 3.0);

            orthographicCamera.NearPlaneDistance      = 0.01;
            orthographicCamera.FarPlaneDistance       = 1000000.0;
            this.orthographicAdorningContainer.Camera = (Camera)orthographicCamera;
            this.Children.Add((Visual)this.shadowAdorningContainer);
            this.Children.Add((Visual)this.orthographicAdorningContainer);
        }
コード例 #2
0
        protected virtual IList <SceneElement> AddToDocumentInternal(string importedFilePath, SceneElement element, ISceneInsertionPoint insertionPoint, SceneViewModel sceneViewModel, SceneEditTransaction undoTransaction)
        {
            List <SceneElement> list              = new List <SceneElement>();
            SceneElement        sceneElement      = insertionPoint.SceneElement;
            Viewport3DElement   viewport3Delement = sceneElement as Viewport3DElement;

            if (viewport3Delement != null || sceneElement is Base3DElement)
            {
                if (element.TargetType == typeof(Image))
                {
                    string[] strArray = importedFilePath.Split('.');
                    string   newName  = strArray.Length <= 1 || strArray[0] == null ? "Image" : strArray[0];
                    element = (SceneElement)GeometryCreationHelper3D.ConvertImageTo3D(sceneViewModel, (BaseFrameworkElement)element, newName);
                }
                IChildContainer3D childContainer3D = sceneElement as IChildContainer3D;
                if (ModelVisual3DElement.ContentProperty.Equals((object)insertionPoint.Property))
                {
                    element = (SceneElement)BaseElement3DCoercionHelper.CoerceToModel3D(sceneViewModel, element);
                    if (element != null)
                    {
                        list.Add(element);
                        insertionPoint.Insert((SceneNode)element);
                    }
                }
                else if (childContainer3D != null)
                {
                    Base3DElement child = (Base3DElement)element;
                    list.Add(childContainer3D.AddChild(sceneViewModel, child));
                    if (viewport3Delement != null && viewport3Delement.Camera == null)
                    {
                        ModelVisual3DElement modelVisual3Delement = element as ModelVisual3DElement;
                        Camera camera;
                        if (modelVisual3Delement != null)
                        {
                            Rect computedTightBounds = viewport3Delement.GetComputedTightBounds();
                            camera = Helper3D.CreateEnclosingPerspectiveCamera(45.0, computedTightBounds.Width / computedTightBounds.Height, modelVisual3Delement.DesignTimeBounds, 0.8);
                        }
                        else
                        {
                            camera = (Camera) new PerspectiveCamera(new Point3D(0.0, 0.0, -5.0), new Vector3D(0.0, 0.0, 1.0), new Vector3D(0.0, 1.0, 0.0), 45.0);
                        }
                        viewport3Delement.Camera = (CameraElement)sceneViewModel.CreateSceneNode((object)camera);
                    }
                }
            }
            else
            {
                ModelVisual3DElement modelVisual3D = element as ModelVisual3DElement;
                if (modelVisual3D != null)
                {
                    Viewport3DElement forModelVisual3D = GeometryCreationHelper3D.GetEnclosingViewportForModelVisual3D(sceneViewModel, modelVisual3D);
                    list.Add((SceneElement)forModelVisual3D);
                    insertionPoint.Insert((SceneNode)forModelVisual3D);
                }
                else if (insertionPoint.CanInsert((ITypeId)element.Type))
                {
                    list.Add(element);
                    insertionPoint.Insert((SceneNode)element);
                }
            }
            return((IList <SceneElement>)list);
        }