private void RenderPathUnderManualConstructionWhenNotUsingTileConnections(ObjectPlacementPath path)
        {
            List <ObjectPlacementBoxStackSegment> allPathSegments = path.GetAllSegments();
            ObjectPlacementPathManualConstructionRenderSettings renderSettings = path.RenderSettings.ManualConstructionRenderSettings;
            Vector3 boxYOffsetvector = path.Settings.ManualConstructionSettings.OffsetAlongGrowDirection * path.ExtensionPlane.normal;

            foreach (ObjectPlacementBoxStackSegment segment in allPathSegments)
            {
                for (int stackIndex = 0; stackIndex < segment.NumberOfStacks; ++stackIndex)
                {
                    ObjectPlacementBoxStack stack = segment.GetStackByIndex(stackIndex);
                    if (stack.IsOverlappedByAnotherStack)
                    {
                        continue;
                    }

                    for (int boxIndex = 0; boxIndex < stack.NumberOfBoxes; ++boxIndex)
                    {
                        ObjectPlacementBox placementBox = stack.GetBoxByIndex(boxIndex);
                        if (placementBox.IsHidden)
                        {
                            continue;
                        }

                        OrientedBox orientedBox = placementBox.OrientedBox;
                        orientedBox.Center += boxYOffsetvector;
                        GizmosEx.RenderOrientedBoxEdges(orientedBox, renderSettings.BoxBorderLineColor);
                    }
                }
            }
        }
        public void RenderMirroredEntityOrientedBox(Plane mirrorPlane, OrientedBox entityBox, bool mirrorRotation, Color boxColor, Color boxBorderLineColor)
        {
            if (!entityBox.IsValid())
            {
                return;
            }

            OrientedBox mirroredEntityBox = Mirroring.MirrorOrientedBox(mirrorPlane, entityBox, mirrorRotation);

            GizmosEx.RenderOrientedBox(mirroredEntityBox, boxColor);
            GizmosEx.RenderOrientedBoxEdges(mirroredEntityBox, boxBorderLineColor);
        }
Ejemplo n.º 3
0
        public void RenderGizmos()
        {
            if (_state != State.Inactive && _isPivotAvailable)
            {
                Circle2D circle = new Circle2D(SceneViewCamera.Camera.WorldToScreenPoint(_pivot), 6.0f);
                GizmosEx.Render2DCircleBorderLines(circle, Color.black);
                GizmosEx.Render2DFilledCircle(circle, Color.green);

                foreach (var parent in _selectedParents)
                {
                    OrientedBox worldOOBB = parent.GetHierarchyWorldOrientedBox();
                    GizmosEx.RenderOrientedBoxEdges(worldOOBB, Color.yellow);
                }
            }
        }
        private void RenderPathUnderManualConstructionWhenUsingTileConnections(ObjectPlacementPath path, ObjectPlacementPathTileConnectionSettings tileConnectionSettings)
        {
            List <ObjectPlacementPathTileConnectionGridCell>    tileConnectionGridCells = path.TileConnectionGridCells;
            ObjectPlacementPathManualConstructionRenderSettings renderSettings          = path.RenderSettings.ManualConstructionRenderSettings;
            var tileConnectionYOffsetVectorCalculator = new ObjectPlacementPathTileConnectionYOffsetVectorCalculator();

            // Loop through all tile connection grid cells. Each cell will give us access to all the information
            // that we need to perform the rendering operation.
            foreach (ObjectPlacementPathTileConnectionGridCell tileConnectionGridCell in tileConnectionGridCells)
            {
                // Use the cell to access the tile connection stack. If the stack is overlapped by another stack
                // or if no boxes exist in the stack, we can move on to the next cell.
                ObjectPlacementBoxStack tileConnectionStack = tileConnectionGridCell.TileConnectionStack;
                if (tileConnectionStack.IsOverlappedByAnotherStack || tileConnectionStack.NumberOfBoxes == 0)
                {
                    continue;
                }

                // Calculate the Y offset vector which applies to all tiles in the current stack and then render each
                // box which resides inside the stack.
                Vector3 tileConnectionYOffsetVector = tileConnectionYOffsetVectorCalculator.Calculate(tileConnectionSettings.GetSettingsForTileConnectionType(tileConnectionGridCell.TileConnectionType), path);
                for (int boxIndex = 0; boxIndex < tileConnectionStack.NumberOfBoxes; ++boxIndex)
                {
                    // If the box is hidden, we can move on to the next box
                    ObjectPlacementBox placementBox = tileConnectionStack.GetBoxByIndex(boxIndex);
                    if (placementBox.IsHidden)
                    {
                        continue;
                    }

                    // Retrieve the box and apply the Y offset vector. The render the box.
                    OrientedBox orientedBox = placementBox.OrientedBox;
                    orientedBox.Center += tileConnectionYOffsetVector;
                    GizmosEx.RenderOrientedBoxEdges(orientedBox, renderSettings.BoxBorderLineColor);
                }

                // We have to take tile connection extrusion into account, so we will need to retrieve the extrusion
                // boxes and render those too.
                List <OrientedBox> extrusionOrientedBoxes = ObjectPlacementPathTileConnectionExtrusion.GetTileConnectionExtrusionOrientedBoxes(tileConnectionGridCell);
                foreach (OrientedBox extrusionBox in extrusionOrientedBoxes)
                {
                    GizmosEx.RenderOrientedBoxEdges(extrusionBox, renderSettings.BoxBorderLineColor);
                }
            }
        }
Ejemplo n.º 5
0
        public override void Render(List <GameObject> selectedObjects)
        {
            ObjectSelectionRenderSettings                   selectionRenderSettings                   = ObjectSelectionRenderSettings.Get();
            ObjectSelectionBoxRenderModeSettings            selectionBoxRenderModeSettings            = selectionRenderSettings.BoxRenderModeSettings;
            ObjectSelectionBoxCornerEdgesRenderModeSettings selectionBoxCornerEdgesRenderModeSettings = selectionBoxRenderModeSettings.CornerEdgesRenderModeSettings;

            Color boxColor  = selectionBoxRenderModeSettings.BoxColor;
            Color edgeColor = selectionBoxRenderModeSettings.EdgeColor;
            float boxScale  = selectionBoxRenderModeSettings.BoxScale;

            bool renderBoxes = boxColor.a != 0.0f;
            bool renderEdges = edgeColor.a != 0.0f;

            if (!renderBoxes && !renderEdges)
            {
                return;
            }

            // Note: Code duplication is intentional here in order to avoid further abstractions which may hinder performance.
            if (selectionBoxRenderModeSettings.EdgeRenderMode == ObjectSelectionBoxEdgeRenderMode.Wire)
            {
                if (renderBoxes && renderEdges)
                {
                    foreach (GameObject gameObject in selectedObjects)
                    {
                        if (!gameObject.activeInHierarchy)
                        {
                            continue;
                        }

                        OrientedBox worldOrientedBox = gameObject.GetWorldOrientedBox();
                        if (worldOrientedBox.IsValid())
                        {
                            worldOrientedBox.Scale *= boxScale;
                            GizmosEx.RenderOrientedBox(worldOrientedBox, boxColor);
                            GizmosEx.RenderOrientedBoxEdges(worldOrientedBox, edgeColor);
                        }
                    }
                }
                else
                if (renderEdges && !renderBoxes)
                {
                    foreach (GameObject gameObject in selectedObjects)
                    {
                        if (!gameObject.activeInHierarchy)
                        {
                            continue;
                        }

                        OrientedBox worldOrientedBox = gameObject.GetWorldOrientedBox();
                        if (worldOrientedBox.IsValid())
                        {
                            worldOrientedBox.Scale *= boxScale;
                            GizmosEx.RenderOrientedBoxEdges(worldOrientedBox, edgeColor);
                        }
                    }
                }
                else
                if (renderBoxes && !renderEdges)
                {
                    foreach (GameObject gameObject in selectedObjects)
                    {
                        if (!gameObject.activeInHierarchy)
                        {
                            continue;
                        }

                        OrientedBox worldOrientedBox = gameObject.GetWorldOrientedBox();
                        if (worldOrientedBox.IsValid())
                        {
                            worldOrientedBox.Scale *= boxScale;
                            GizmosEx.RenderOrientedBox(worldOrientedBox, boxColor);
                        }
                    }
                }
            }
            else
            if (selectionBoxRenderModeSettings.EdgeRenderMode == ObjectSelectionBoxEdgeRenderMode.CornerEdges)
            {
                float cornerEdgeLengthPercentage = selectionBoxCornerEdgesRenderModeSettings.CornerEdgeLengthPercentage;
                if (renderBoxes && renderEdges)
                {
                    foreach (GameObject gameObject in selectedObjects)
                    {
                        if (!gameObject.activeInHierarchy)
                        {
                            continue;
                        }

                        OrientedBox worldOrientedBox = gameObject.GetWorldOrientedBox();
                        if (worldOrientedBox.IsValid())
                        {
                            worldOrientedBox.Scale *= boxScale;
                            GizmosEx.RenderOrientedBox(worldOrientedBox, boxColor);
                            GizmosEx.RenderOrientedBoxCornerEdges(worldOrientedBox, cornerEdgeLengthPercentage, edgeColor);
                        }
                    }
                }
                else
                if (renderEdges && !renderBoxes)
                {
                    foreach (GameObject gameObject in selectedObjects)
                    {
                        if (!gameObject.activeInHierarchy)
                        {
                            continue;
                        }

                        OrientedBox worldOrientedBox = gameObject.GetWorldOrientedBox();
                        if (worldOrientedBox.IsValid())
                        {
                            worldOrientedBox.Scale *= boxScale;
                            GizmosEx.RenderOrientedBoxCornerEdges(worldOrientedBox, cornerEdgeLengthPercentage, edgeColor);
                        }
                    }
                }
                else
                if (renderBoxes && !renderEdges)
                {
                    foreach (GameObject gameObject in selectedObjects)
                    {
                        if (!gameObject.activeInHierarchy)
                        {
                            continue;
                        }

                        OrientedBox worldOrientedBox = gameObject.GetWorldOrientedBox();
                        if (worldOrientedBox.IsValid())
                        {
                            worldOrientedBox.Scale *= boxScale;
                            GizmosEx.RenderOrientedBox(worldOrientedBox, boxColor);
                        }
                    }
                }
            }
        }