Пример #1
0
        protected virtual void CreatePolygonsForElement(ElementRuntime element)
        {
            bool createRectanglesForContainedElements = true;

            // We want to use coordinates
            // that match the coordinates of
            // whatever it is that we're viewing.
            // Graphical objects like Sprites use the
            // coordinates of the Layers that they're on,
            // or of their camera.  However Layers themselves
            // have a destination rectangle which is in pixel coordiantes
            // so the rectangles that we render need to be in the resolution
            // of the window.  Therefore for Layers we will want to MatchScreenResolution.
            LayerCoordinateType coordinateType = LayerCoordinateType.MatchCamera;


            if (element.DirectObjectReference != null)
            {
                object directObjectReference = element.DirectObjectReference;
                coordinateType = CreatePolygonsForObject(directObjectReference, coordinateType);
            }
            else if (element.AssociatedNamedObjectSave != null && element.AssociatedNamedObjectSave.GetIsScalableEntity())
            {
                // We used to not want to show contained object scales, but I think we want to now because we're not supporting scaling (yet) in GView.
                //createRectanglesForContainedElements = false;
                CreatePolygonForScalableEntity(element);
            }

            if (createRectanglesForContainedElements)
            {
                for (int i = 0; i < element.ContainedElements.Count; i++)
                {
                    ElementRuntime e = element.ContainedElements[i];

                    CreatePolygonsForElement(e);
                }

                for (int i = 0; i < element.ElementsInList.Count; i++)
                {
                    ElementRuntime e = element.ElementsInList[i];

                    CreatePolygonsForElement(e);
                }
            }

            SpriteManager.MoveToFront(Layer);


            if (element != null && element.Layer != null && element.Layer.LayerCameraSettings != null && element.Layer.LayerCameraSettings.Orthogonal)
            {
                // shared layer camera settings?  That seems BAD!
                //Layer.LayerCameraSettings = element.Layer.LayerCameraSettings;
                // I think we want to update to prevent modifications on the GlueView
                // Layer (which can occur to render highlights) from screwing other layers.
                Layer.LayerCameraSettings = element.Layer.LayerCameraSettings.Clone();
            }
            else
            {
                if (coordinateType == LayerCoordinateType.MatchScreenResolution)
                {
                    Layer.UsePixelCoordinates();

                    Layer.LayerCameraSettings.LeftDestination   = Camera.Main.LeftDestination;
                    Layer.LayerCameraSettings.RightDestination  = Camera.Main.RightDestination;
                    Layer.LayerCameraSettings.TopDestination    = Camera.Main.TopDestination;
                    Layer.LayerCameraSettings.BottomDestination = Camera.Main.BottomDestination;
                }
                else
                {
                    Layer.LayerCameraSettings = null;
                }
            }
        }
Пример #2
0
        private LayerCoordinateType CreatePolygonsForObject(object directObjectReference, LayerCoordinateType coordinateType)
        {
            if (directObjectReference is Scene)
            {
                CreatePolygonsForSceneElement(directObjectReference as Scene);
            }
            else if (directObjectReference is ShapeCollection)
            {
                CreatePolygonsForShapeCollectionElement(directObjectReference as ShapeCollection);
            }
            else if (directObjectReference is PositionedObject)
            {
                // Check the specifics before the general IReadOnlyScalable
                if (directObjectReference is Text)
                {
                    CreatePolygonForText((Text)directObjectReference);
                }
                else if (directObjectReference is Circle)
                {
                    CreatePolygonForCircle((Circle)directObjectReference);
                }
                else if (directObjectReference is AxisAlignedRectangle)
                {
                    CreatePolygonForAxisAlignedRectangle((AxisAlignedRectangle)directObjectReference);
                }
                else if(directObjectReference is Polygon)
                {
                    CreatePolygonForPolygon((Polygon)directObjectReference);

                }
                else if (directObjectReference is IReadOnlyScalable)
                {
                    CreatePolygonForIScalable(directObjectReference);
                }

            }
            else if (directObjectReference is Layer)
            {
                CreatePolygonForLayer((Layer)directObjectReference);
                coordinateType = LayerCoordinateType.MatchScreenResolution;
            }
            else if (directObjectReference is IEnumerable)
            {
                IEnumerable asEnumerable = directObjectReference as IEnumerable;

                foreach (var item in asEnumerable)
                {
                    CreatePolygonsForObject(item, coordinateType);
                }
            }
            return coordinateType;
        }
Пример #3
0
        private LayerCoordinateType CreatePolygonsForObject(object directObjectReference, LayerCoordinateType coordinateType)
        {
            if (directObjectReference is Scene)
            {
                CreatePolygonsForSceneElement(directObjectReference as Scene);
            }
            else if (directObjectReference is ShapeCollection)
            {
                CreatePolygonsForShapeCollectionElement(directObjectReference as ShapeCollection);
            }
            else if (directObjectReference is PositionedObject)
            {
                // Check the specifics before the general IReadOnlyScalable
                if (directObjectReference is Text)
                {
                    CreatePolygonForText((Text)directObjectReference);
                }
                else if (directObjectReference is Circle)
                {
                    CreatePolygonForCircle((Circle)directObjectReference);
                }
                else if (directObjectReference is AxisAlignedRectangle)
                {
                    CreatePolygonForAxisAlignedRectangle((AxisAlignedRectangle)directObjectReference);
                }
                else if (directObjectReference is Polygon)
                {
                    CreatePolygonForPolygon((Polygon)directObjectReference);
                }
                else if (directObjectReference is IReadOnlyScalable)
                {
                    CreatePolygonForIScalable(directObjectReference);
                }
            }
            else if (directObjectReference is Layer)
            {
                CreatePolygonForLayer((Layer)directObjectReference);
                coordinateType = LayerCoordinateType.MatchScreenResolution;
            }
            else if (directObjectReference is IEnumerable)
            {
                IEnumerable asEnumerable = directObjectReference as IEnumerable;

                foreach (var item in asEnumerable)
                {
                    CreatePolygonsForObject(item, coordinateType);
                }
            }
            return(coordinateType);
        }