Beispiel #1
0
        public void Snap()
        {
            float offsetFromSurface = SourcePrefab.OffsetFromGridSurface;

            if (ObjectSnapping.Get().SnapSurfaceType != SnapSurfaceType.GridCell)
            {
                offsetFromSurface = SourcePrefab.OffsetFromObjectSurface;
            }

            if (AllShortcutCombos.Instance.PlaceGuideBehindSurfacePlane.IsActive())
            {
                offsetFromSurface *= -1.0f;
            }

            if (AllShortcutCombos.Instance.SnapCenterToCenter.IsActive())
            {
                ObjectSnapping.Get().SnapObjectHierarchyToCenterOfSnapSurface(gameObject, ObjectPlacement.Get().CenterProjectedGuidePivotPoint, ObjectPlacement.Get().ProjectedGuidePivotPoints, offsetFromSurface);
            }
            else
            {
                ObjectSnapping.Get().SnapObjectHierarchy(gameObject, ObjectPlacement.Get().ProjectedGuidePivotPoints, offsetFromSurface);
            }

            PersistentObjectPlacementGuideData.Get().LastUsedWorldPosition = _transform.position;
        }
        public override void Render()
        {
            ObjectSnapping.Get().Settings.View.Render();
            ObjectSnapping.Get().XZSnapGrid.CellSizeSettings.View.Render();

            EditorGUILayout.Separator();
            ObjectSnapping.Get().ObjectSnapMask.View.Render();

            EditorGUILayout.Separator();
            _objectSnappingLookAndFeelSettingsView.Render();
        }
Beispiel #3
0
        public void HandleMouseButtonDownEvent(Event e)
        {
            if (_object2ObjectSnapSession.IsActive && AllShortcutCombos.Instance.EndSelectionObject2ObjectSnap.IsActive())
            {
                e.DisableInSceneView();
                _object2ObjectSnapSession.End();
                return;
            }

            if (_selectionGridSnapSession.IsActive || _selectionGrabSession.IsActive || _object2ObjectSnapSession.IsActive || _objectVertexSnapSession.IsActive)
            {
                return;
            }
            if (AllShortcutCombos.Instance.SnapXZGridToCursorPickPointOnLeftClick_Selection.IsActive() && e.InvolvesLeftMouseButton())
            {
                e.DisableInSceneView();

                ObjectSnapping.Get().SnapXZGridToCursorPickPoint(e.clickCount == 2);
                return;
            }

            if (Mirror.IsInteractionSessionActive && e.InvolvesLeftMouseButton())
            {
                e.DisableInSceneView();
                Mirror.EndInteractionSession();
                return;
            }

            if (e.InvolvesLeftMouseButton() && NumberOfSelectedObjects != 0 &&
                !SelectionShape.IsVisible() && AllShortcutCombos.Instance.ReplacePrefabsForSelectedObjects_Scene.IsActive() &&
                !Mirror.IsInteractionSessionActive)
            {
                e.DisableInSceneView();
                UndoEx.RecordForToolAction(this);
                List <GameObject> newObjects = ObjectSelectionActions.ReplaceSelectedObjectsPrefabOnMouseClick();
                if (newObjects.Count != 0)
                {
                    AddGameObjectCollectionToSelection(newObjects);
                }

                return;
            }

            SelectionShape.HandleMouseButtonDownEvent(e);
            if (CanPerformClickSelectionUpdateOperation())
            {
                var clickSelectionUpdateOperation = ObjectSelectionUpdateOperationFactory.Create(ObjectSelectionUpdateOperationType.Click);
                clickSelectionUpdateOperation.Perform();

                SceneView.RepaintAll();
            }
        }
Beispiel #4
0
        public static GameObject GetSurfaceObject()
        {
            ObjectPlacementSettings objectPlacementSettings = ObjectPlacementSettings.Get();

            if (objectPlacementSettings.ObjectPlacementMode == ObjectPlacementMode.DecorPaint)
            {
                return(ObjectPlacement.Get().DecorPaintObjectPlacement.DecorPaintSurfaceObject);
            }
            else
            {
                return(ObjectSnapping.Get().ObjectSnapSurfaceObject);
            }
        }
Beispiel #5
0
        private void RenderXZGridRotationField()
        {
            XZGrid  xzGrid          = ObjectSnapping.Get().XZSnapGrid;
            Vector3 currentRotation = xzGrid.Rotation.eulerAngles;
            Vector3 newVector       = EditorGUILayout.Vector3Field(GetContentForXZGridRotationField(), currentRotation);

            if (newVector != currentRotation)
            {
                UndoEx.RecordForToolAction(xzGrid);
                xzGrid.SetRotation(Quaternion.Euler(newVector));

                SceneView.RepaintAll();
            }
        }
Beispiel #6
0
        public GridCellRayHit GetGridCellRayHit()
        {
            Ray ray = GetWorldRay();

            float  minT;
            XZGrid closestSnapGrid = GetClosestHitSnapGridAndMinT(ObjectSnapping.Get().GetAllSnapGrids(), ray, out minT);

            if (closestSnapGrid != null)
            {
                return(GetGridCellHit(closestSnapGrid, ray, minT));
            }
            else
            {
                return(null);
            }
        }
Beispiel #7
0
 private void AdjustPositionBasedOnCursorHit()
 {
     UndoEx.RecordForToolAction(this);
     if (AllShortcutCombos.Instance.DisableMirrorSnapping.IsActive() && _cursorRayHit.WasAnythingHit)
     {
         SetPosition(GetHoverSurfaceHitPoint());
     }
     else
     {
         if (AllShortcutCombos.Instance.SnapMirrorToCenterOfSnapSurface.IsActive())
         {
             ObjectSnapping.Get().SnapObjectPositionToSnapSurfaceCenter(_sessionMirrorObject);
         }
         else
         {
             ObjectSnapping.Get().SnapObjectPosition(_sessionMirrorObject);
         }
         SetPosition(_sessionMirrorObjectTransform.position);
     }
 }
Beispiel #8
0
        protected override void HandleButtonClick(int buttonIndex)
        {
            switch (buttonIndex)
            {
            case 0:

                //UndoEx.RecordForToolAction(DecorPaintObjectPlacement.Get().DecorPaintMask.ObjectCollectionMask);
                DecorPaintObjectPlacement.Get().DecorPaintMask.ObjectCollectionMask.Mask(ObjectSelection.Get().GetAllSelectedGameObjects());
                break;

            case 1:

                //UndoEx.RecordForToolAction(DecorPaintObjectPlacement.Get().DecorPaintMask.ObjectCollectionMask);
                DecorPaintObjectPlacement.Get().DecorPaintMask.ObjectCollectionMask.Unmask(ObjectSelection.Get().GetAllSelectedGameObjects());
                break;

            case 2:

                //UndoEx.RecordForToolAction(ObjectSnapping.Get().ObjectSnapMask.ObjectCollectionMask);
                ObjectSnapping.Get().ObjectSnapMask.ObjectCollectionMask.Mask(ObjectSelection.Get().GetAllSelectedGameObjects());
                break;

            case 3:

                //UndoEx.RecordForToolAction(ObjectSnapping.Get().ObjectSnapMask.ObjectCollectionMask);
                ObjectSnapping.Get().ObjectSnapMask.ObjectCollectionMask.Unmask(ObjectSelection.Get().GetAllSelectedGameObjects());
                break;

            case 4:

                ObjectEraser.Get().EraseMask.ObjectCollectionMask.Mask(ObjectSelection.Get().GetAllSelectedGameObjects());
                break;

            case 5:

                ObjectEraser.Get().EraseMask.ObjectCollectionMask.Unmask(ObjectSelection.Get().GetAllSelectedGameObjects());
                break;
            }
        }
Beispiel #9
0
        private GameObjectRayHit FindClosestHitObjectWhichCanBeUsedAsSnapSurface(MouseCursorRayHit cursorRayHit)
        {
            ObjectMask objectSnapMask = ObjectSnapping.Get().ObjectSnapMask;

            List <GameObjectRayHit> gameObjectHits = cursorRayHit.SortedObjectRayHits;

            for (int hitIndex = 0; hitIndex < gameObjectHits.Count; ++hitIndex)
            {
                GameObject hitObject = gameObjectHits[hitIndex].HitObject;

                if (!hitObject.HasMesh())
                {
                    continue;
                }
                if (objectSnapMask.IsGameObjectMasked(hitObject))
                {
                    continue;
                }

                return(gameObjectHits[hitIndex]);
            }

            return(null);
        }
        private void RemoveNullGameObjectReferences()
        {
            ObjectSelection.Get().RemoveNullGameObjectEntries();
            Octave3DWorldBuilder.ActiveInstance.PlacementObjectGroupDatabase.RemoveGroupsWithNullParents();
            ObjectSnapping.Get().ObjectSnapMask.RemoveInvalidEntries();
            DecorPaintObjectPlacement.Get().DecorPaintMask.RemoveInvalidEntries();

            if (PrefabTagDatabase.Get().ContainsNullEntries())
            {
                Debug.Log("Detected null prefab tag references. This bug has been fixed and should never happen. If you are reading this, please contact me.");

                List <PrefabCategory> allPrefabCategories = PrefabCategoryDatabase.Get().GetAllPrefabCategories();
                foreach (var category in allPrefabCategories)
                {
                    List <Prefab> allPrefabsInCategory = category.GetAllPrefabs();
                    foreach (var prefab in allPrefabsInCategory)
                    {
                        prefab.TagAssociations.RemoveNullEntries();
                    }
                }

                PrefabTagDatabase.Get().RemoveNullEntries();
            }
        }
Beispiel #11
0
 public void SnapHierarchyToNearbyObjects(GameObject hierarchyRoot, ProjectedBoxFacePivotPoints projectedBoxFacePivotPoints)
 {
     Object2ObjectSnap.SnapResult snapResult = Object2ObjectSnap.Snap(hierarchyRoot, Settings.ObjectToObjectSnapEpsilon, ObjectSnapping.Get().ObjectSnapMask.ObjectCollectionMask.GetAllMaskedGameObjects());
     if (snapResult.WasSnapped)
     {
         projectedBoxFacePivotPoints.MovePoints(snapResult.SnapDestination - snapResult.SnapPivot);
     }
 }
Beispiel #12
0
        public void UpdateOnMouseMove()
        {
            if (_isActive)
            {
                MouseCursorRayHit cursorRayHit = GetCursorRayHit();
                if (cursorRayHit == null || !cursorRayHit.WasAnythingHit)
                {
                    return;
                }

                Vector3 hitPoint  = Vector3.zero;
                Vector3 hitNormal = Vector3.zero;

                if (!cursorRayHit.WasAnObjectHit && cursorRayHit.WasACellHit)
                {
                    hitPoint  = cursorRayHit.GridCellRayHit.HitPoint;
                    hitNormal = cursorRayHit.GridCellRayHit.HitNormal;
                }
                else
                if (cursorRayHit.WasAnObjectHit && !cursorRayHit.WasACellHit)
                {
                    hitPoint  = cursorRayHit.ClosestObjectRayHit.HitPoint;
                    hitNormal = cursorRayHit.ClosestObjectRayHit.HitNormal;
                }
                else
                if (cursorRayHit.WasAnObjectHit && cursorRayHit.WasACellHit)
                {
                    if (cursorRayHit.ClosestObjectRayHit.HitEnter < cursorRayHit.GridCellRayHit.HitEnter)
                    {
                        hitPoint  = cursorRayHit.ClosestObjectRayHit.HitPoint;
                        hitNormal = cursorRayHit.ClosestObjectRayHit.HitNormal;
                    }
                    else
                    {
                        hitPoint  = cursorRayHit.GridCellRayHit.HitPoint;
                        hitNormal = cursorRayHit.GridCellRayHit.HitNormal;
                    }
                }

                Plane hitPlane           = new Plane(hitNormal, hitPoint);
                Box   selectionWorldAABB = ObjectSelection.Get().GetWorldBox();
                if (selectionWorldAABB.IsInvalid())
                {
                    return;
                }

                Vector3 oldCenter = selectionWorldAABB.Center;
                selectionWorldAABB.Center = hitPoint;
                selectionWorldAABB.MoveInFrontOfPlane(hitPlane);
                Vector3 moveVector = selectionWorldAABB.Center - oldCenter;

                float snapEps = ObjectSelection.Get().Settings.Object2ObjectSnapSettings.SnapEps;

                GameObjectExtensions.RecordObjectTransformsForUndo(_selectedParents);
                foreach (var parent in _selectedParents)
                {
                    parent.transform.position += moveVector;
                }

                var ignoreObjects = new List <GameObject>(_allSelectedObjects);
                ignoreObjects.AddRange(ObjectSnapping.Get().ObjectSnapMask.ObjectCollectionMask.GetAllMaskedGameObjects());
                Object2ObjectSnap.Snap(_selectedParents, snapEps, ignoreObjects);
            }
        }
Beispiel #13
0
        public void HandleMouseMoveEvent(Event e)
        {
            if (!_objectPlacementPath.IsUnderManualConstruction && ObjectPlacementGuide.ExistsInSceneAndIsActive)
            {
                ObjectPlacementGuide.Instance.Snap();
                AxisAlignment.AlignObjectAxis(ObjectPlacementGuide.SceneObject, PathObjectPlacementSettings.Get().PlacementGuideSurfaceAlignmentSettings, ObjectSnapping.Get().ObjectSnapSurfacePlane.normal);

                // Note: This is necessary just in case the placement guide has changed.
                _objectPlacementPath.SetStartObject(ObjectPlacementGuide.SceneObject);
            }
            else if (ObjectPlacementGuide.ExistsInScene)
            {
                _objectPlacementPath.UpdateForMouseMoveEvent();
            }
        }
Beispiel #14
0
 public static ObjectSnapSettings Get()
 {
     return(ObjectSnapping.Get().Settings);
 }
        private static void SaveSnapSettings(XmlTextWriter xmlWriter, Octave3DConfigSaveLoadSettings saveSettings)
        {
            if (saveSettings.SnapSettings)
            {
                ObjectSnapSettings snapSettings = ObjectSnapSettings.Get();

                xmlWriter.WriteNewLine(1);
                xmlWriter.WriteStartElement(Octave3DConfigXMLInfo.SnapSettingsNode);

                xmlWriter.WriteNewLine(2);
                xmlWriter.WriteStartElement(Octave3DConfigXMLInfo.UseOriginalPivotNode);
                xmlWriter.WriteString(snapSettings.UseOriginalPivot.ToString());
                xmlWriter.WriteEndElement();

                xmlWriter.WriteNewLine(2);
                xmlWriter.WriteStartElement(Octave3DConfigXMLInfo.IgnoreObjectsWhenSnappingNode);
                xmlWriter.WriteString(snapSettings.IgnoreObjectsWhenSnapping.ToString());
                xmlWriter.WriteEndElement();

                xmlWriter.WriteNewLine(2);
                xmlWriter.WriteStartElement(Octave3DConfigXMLInfo.SnapToCursorHitPointNode);
                xmlWriter.WriteString(snapSettings.SnapToCursorHitPoint.ToString());
                xmlWriter.WriteEndElement();

                xmlWriter.WriteNewLine(2);
                xmlWriter.WriteStartElement(Octave3DConfigXMLInfo.SnapCenterToCenterGridNode);
                xmlWriter.WriteString(snapSettings.SnapCenterToCenterForXZGrid.ToString());
                xmlWriter.WriteEndElement();

                xmlWriter.WriteNewLine(2);
                xmlWriter.WriteStartElement(Octave3DConfigXMLInfo.SnapCenterToCenterObjectSurfaceNode);
                xmlWriter.WriteString(snapSettings.SnapCenterToCenterForObjectSurface.ToString());
                xmlWriter.WriteEndElement();

                xmlWriter.WriteNewLine(2);
                xmlWriter.WriteStartElement(Octave3DConfigXMLInfo.EnableObjectToObjectSnapNode);
                xmlWriter.WriteString(snapSettings.EnableObjectToObjectSnap.ToString());
                xmlWriter.WriteEndElement();

                xmlWriter.WriteNewLine(2);
                xmlWriter.WriteStartElement(Octave3DConfigXMLInfo.ObjectToObjectSnapModeNode);
                xmlWriter.WriteString(snapSettings.ObjectToObjectSnapMode.ToString());
                xmlWriter.WriteEndElement();

                xmlWriter.WriteNewLine(2);
                xmlWriter.WriteStartElement(Octave3DConfigXMLInfo.ObjectToObjectSnapEpsilonNode);
                xmlWriter.WriteString(snapSettings.ObjectToObjectSnapEpsilon.ToString());
                xmlWriter.WriteEndElement();

                xmlWriter.WriteNewLine(2);
                xmlWriter.WriteStartElement(Octave3DConfigXMLInfo.SnapGridXOffsetNode);
                xmlWriter.WriteString(snapSettings.XZSnapGridXOffset.ToString());
                xmlWriter.WriteEndElement();

                xmlWriter.WriteNewLine(2);
                xmlWriter.WriteStartElement(Octave3DConfigXMLInfo.SnapGridYOffsetNode);
                xmlWriter.WriteString(snapSettings.XZSnapGridYOffset.ToString());
                xmlWriter.WriteEndElement();

                xmlWriter.WriteNewLine(2);
                xmlWriter.WriteStartElement(Octave3DConfigXMLInfo.SnapGridYOffsetStepNode);
                xmlWriter.WriteString(snapSettings.XZGridYOffsetStep.ToString());
                xmlWriter.WriteEndElement();

                xmlWriter.WriteNewLine(2);
                xmlWriter.WriteStartElement(Octave3DConfigXMLInfo.SnapGridZOffsetNode);
                xmlWriter.WriteString(snapSettings.XZSnapGridZOffset.ToString());
                xmlWriter.WriteEndElement();

                xmlWriter.WriteNewLine(2);
                xmlWriter.WriteStartElement(Octave3DConfigXMLInfo.ObjectSurfaceGridDesiredCellSizeNode);
                xmlWriter.WriteString(snapSettings.ObjectColliderSnapSurfaceGridSettings.DesiredCellSize.ToString());
                xmlWriter.WriteEndElement();

                xmlWriter.WriteNewLine(2);
                xmlWriter.WriteStartElement(Octave3DConfigXMLInfo.SnapGridCellSizeXNode);
                xmlWriter.WriteString(ObjectSnapping.Get().XZSnapGrid.CellSizeSettings.CellSizeX.ToString());
                xmlWriter.WriteEndElement();

                xmlWriter.WriteNewLine(2);
                xmlWriter.WriteStartElement(Octave3DConfigXMLInfo.SnapGridCellSizeZNode);
                xmlWriter.WriteString(ObjectSnapping.Get().XZSnapGrid.CellSizeSettings.CellSizeZ.ToString());
                xmlWriter.WriteEndElement();

                xmlWriter.WriteNewLine(1);
                xmlWriter.WriteEndElement();
            }
        }
 public override void RenderGizmos()
 {
     ObjectSnapping.Get().XZSnapGrid.RenderGizmos();
     ObjectEraser.Get().RenderGizmos();
 }
        private static void SaveSnapLookAndFeel(XmlTextWriter xmlWriter, Octave3DConfigSaveLoadSettings saveSettings)
        {
            if (saveSettings.SnapLookAndFeel)
            {
                XZGridRenderSettings           xzGridRenderSettings         = ObjectSnapping.Get().XZSnapGrid.RenderSettings;
                XZGridRenderSettings           objSurfaceGridRenderSettings = ObjectSnapping.Get().RenderSettingsForColliderSnapSurfaceGrid;
                CoordinateSystemRenderSettings coordSystemRenderSettings    = ObjectSnapping.Get().XZSnapGrid.RenderableCoordinateSystem.RenderSettings;

                xmlWriter.WriteNewLine(1);
                xmlWriter.WriteStartElement(Octave3DConfigXMLInfo.SnapLookAndFeelNode);

                xmlWriter.WriteNewLine(2);
                xmlWriter.WriteStartElement(Octave3DConfigXMLInfo.XZGridLookAndFeelNode);

                xmlWriter.WriteNewLine(3);
                xmlWriter.WriteStartElement(Octave3DConfigXMLInfo.IsXZGridVisibleNode);
                xmlWriter.WriteString(xzGridRenderSettings.IsVisible.ToString());
                xmlWriter.WriteEndElement();

                xmlWriter.WriteNewLine(3);
                xmlWriter.WriteStartElement(Octave3DConfigXMLInfo.XZGridCellLineColorNode);
                xmlWriter.WriteColorString(xzGridRenderSettings.CellLineColor);
                xmlWriter.WriteEndElement();

                xmlWriter.WriteNewLine(3);
                xmlWriter.WriteStartElement(Octave3DConfigXMLInfo.XZGridCellLineThicknessNode);
                xmlWriter.WriteString(xzGridRenderSettings.CellLineThickness.ToString());
                xmlWriter.WriteEndElement();

                xmlWriter.WriteNewLine(3);
                xmlWriter.WriteStartElement(Octave3DConfigXMLInfo.XZGridPlaneColorNode);
                xmlWriter.WriteColorString(xzGridRenderSettings.PlaneColor);
                xmlWriter.WriteEndElement();

                xmlWriter.WriteNewLine(2);
                xmlWriter.WriteEndElement();

                xmlWriter.WriteNewLine(2);
                xmlWriter.WriteStartElement(Octave3DConfigXMLInfo.XZGridCoordSystemLookAndFeelNode);

                xmlWriter.WriteNewLine(3);
                xmlWriter.WriteStartElement(Octave3DConfigXMLInfo.IsXZGridCoordSystemVisibleNode);
                xmlWriter.WriteString(coordSystemRenderSettings.IsVisible.ToString());
                xmlWriter.WriteEndElement();

                List <CoordinateSystemAxis> allAxes = CoordinateSystemAxes.GetAll();
                foreach (var axis in allAxes)
                {
                    xmlWriter.WriteNewLine(3);
                    xmlWriter.WriteStartElement(axis.ToString());

                    xmlWriter.WriteNewLine(4);
                    xmlWriter.WriteStartElement(Octave3DConfigXMLInfo.IsXZGridCoordSystemAxisVisibleNode);
                    xmlWriter.WriteString(coordSystemRenderSettings.IsAxisVisible(axis).ToString());
                    xmlWriter.WriteEndElement();

                    xmlWriter.WriteNewLine(4);
                    xmlWriter.WriteStartElement(Octave3DConfigXMLInfo.IsXZGridCoordSystemAxisInfiniteNode);
                    xmlWriter.WriteString(coordSystemRenderSettings.IsAxisRenderedInfinite(axis).ToString());
                    xmlWriter.WriteEndElement();

                    xmlWriter.WriteNewLine(4);
                    xmlWriter.WriteStartElement(Octave3DConfigXMLInfo.XZGridCoordSystemAxisFiniteSizeNode);
                    xmlWriter.WriteString(coordSystemRenderSettings.GetAxisFinitSize(axis).ToString());
                    xmlWriter.WriteEndElement();

                    xmlWriter.WriteNewLine(4);
                    xmlWriter.WriteStartElement(Octave3DConfigXMLInfo.XZGridCoordSystemAxisColorNode);
                    xmlWriter.WriteColorString(coordSystemRenderSettings.GetAxisColor(axis));
                    xmlWriter.WriteEndElement();

                    xmlWriter.WriteNewLine(3);
                    xmlWriter.WriteEndElement();
                }

                xmlWriter.WriteNewLine(2);
                xmlWriter.WriteEndElement();

                xmlWriter.WriteNewLine(2);
                xmlWriter.WriteStartElement(Octave3DConfigXMLInfo.ObjectSnapSurfaceGridLookAndFeelNode);

                xmlWriter.WriteNewLine(3);
                xmlWriter.WriteStartElement(Octave3DConfigXMLInfo.IsObjectSnapSurfaceGridVisibleNode);
                xmlWriter.WriteString(objSurfaceGridRenderSettings.IsVisible.ToString());
                xmlWriter.WriteEndElement();

                xmlWriter.WriteNewLine(3);
                xmlWriter.WriteStartElement(Octave3DConfigXMLInfo.ObjectSnapSurfaceGridCellLineColorNode);
                xmlWriter.WriteColorString(objSurfaceGridRenderSettings.CellLineColor);
                xmlWriter.WriteEndElement();

                xmlWriter.WriteNewLine(3);
                xmlWriter.WriteStartElement(Octave3DConfigXMLInfo.ObjectSnapSurfaceGridCellLineThicknessNode);
                xmlWriter.WriteString(objSurfaceGridRenderSettings.CellLineThickness.ToString());
                xmlWriter.WriteEndElement();

                xmlWriter.WriteNewLine(3);
                xmlWriter.WriteStartElement(Octave3DConfigXMLInfo.ObjectSnapSurfaceGridPlaneColorNode);
                xmlWriter.WriteColorString(objSurfaceGridRenderSettings.PlaneColor);
                xmlWriter.WriteEndElement();

                xmlWriter.WriteNewLine(2);
                xmlWriter.WriteEndElement();

                xmlWriter.WriteNewLine(1);
                xmlWriter.WriteEndElement();
            }
        }
Beispiel #18
0
 public override void RenderGizmos()
 {
     ObjectSnapping.Get().XZSnapGrid.RenderGizmos();
     ObjectSelection.Get().RenderGizmos();
 }
Beispiel #19
0
        public void ProjectSelectionOnProjectionSurface()
        {
            if (NumberOfSelectedObjects == 0)
            {
                return;
            }

            if (!ObjectOnSurfaceProjectSettings.ProjectOnGrid)
            {
                GameObject projectionSurface = ObjectOnSurfaceProjectSettings.ProjectionSurface;
                if (projectionSurface == null)
                {
                    return;
                }

                Vector3 projectionDirection = ObjectOnSurfaceProjectSettings.GetProjectionDirectionVector();
                GameObjectExtensions.EmbedAllObjectsInSurface(new List <GameObject>(_selectedObjects.HashSet), projectionDirection, projectionSurface);

                _objectSelectionGizmos.OnObjectSelectionUpdated();
            }
            else
            {
                Vector3 projectionDirection = ObjectOnSurfaceProjectSettings.GetProjectionDirectionVector();
                GameObjectExtensions.ProjectAllObjectsOnPlane(new List <GameObject>(_selectedObjects.HashSet), projectionDirection, ObjectSnapping.Get().XZSnapGrid.Plane);

                _objectSelectionGizmos.OnObjectSelectionUpdated();
            }
        }
        private void ApplyRandomizationsForPlacementGuide()
        {
            PointAndClickObjectPlacementSettings.Get().PlacementGuideRotationRandomizationSettings.CustomAxisRandomizationSettings.Axis = ObjectSnapping.Get().ObjectSnapSurfacePlane.normal;

            ObjectRotationRandomization.Randomize(ObjectPlacementGuide.SceneObject, PointAndClickObjectPlacementSettings.Get().PlacementGuideRotationRandomizationSettings);
            ObjectScaleRandomization.Randomize(ObjectPlacementGuide.SceneObject, PointAndClickObjectPlacementSettings.Get().PlacementGuideScaleRandomizationSettings);
        }
        public override void Initialize()
        {
            base.Initialize();

            _objectSnappingLookAndFeelSettingsView.IsVisible = false;

            XZGridCellSizeSettingsView xzGridCellSizeSettingsView = ObjectSnapping.Get().XZSnapGrid.CellSizeSettings.View;

            xzGridCellSizeSettingsView.ToggleVisibilityBeforeRender = true;
            xzGridCellSizeSettingsView.SurroundWithBox       = true;
            xzGridCellSizeSettingsView.VisibilityToggleLabel = xzGridCellSizeSettingsView.XAxisName + xzGridCellSizeSettingsView.ZAxisName + " Grid Cell Size Settings";

            XZGridRenderSettingsView xzGridRenderSettingsView = ObjectSnapping.Get().XZSnapGrid.RenderSettings.View;

            xzGridRenderSettingsView.IsVisible = false;
            xzGridRenderSettingsView.ToggleVisibilityBeforeRender = true;
            xzGridRenderSettingsView.VisibilityToggleIndent       = 1;
            xzGridRenderSettingsView.IndentContent         = true;
            xzGridRenderSettingsView.VisibilityToggleLabel = "XZ Grid";
            xzGridRenderSettingsView.ModifyLineThickness   = false;

            XZGridRenderSettingsView colliderSnapSurfaceGrid = ObjectSnapping.Get().RenderSettingsForColliderSnapSurfaceGrid.View;

            ObjectSnapping.Get().RenderSettingsForColliderSnapSurfaceGrid.CellLineThickness = 0.05f;
            colliderSnapSurfaceGrid.IsVisible = false;
            colliderSnapSurfaceGrid.ToggleVisibilityBeforeRender = true;
            colliderSnapSurfaceGrid.VisibilityToggleIndent       = 1;
            colliderSnapSurfaceGrid.IndentContent         = true;
            colliderSnapSurfaceGrid.VisibilityToggleLabel = "Collider Snap Surface Grid";

            CoordinateSystemRenderSettings     xzGridCoordSystemRenderSettings     = ObjectSnapping.Get().XZSnapGrid.RenderableCoordinateSystem.RenderSettings;
            CoordinateSystemRenderSettingsView xzGridCoordSystemRenderSettingsView = xzGridCoordSystemRenderSettings.View;

            xzGridCoordSystemRenderSettingsView.IsVisible = false;
            xzGridCoordSystemRenderSettingsView.ToggleVisibilityBeforeRender = true;
            xzGridCoordSystemRenderSettingsView.VisibilityToggleIndent       = 1;
            xzGridCoordSystemRenderSettingsView.IndentContent         = true;
            xzGridCoordSystemRenderSettingsView.VisibilityToggleLabel = "XZ Grid Coord System";

            CoordinateSystemAxisRenderSettings axisRenderSettings = xzGridCoordSystemRenderSettings.GetAxisRenderSettings(CoordinateSystemAxis.PositiveRight);

            axisRenderSettings.View.VisibilityToggleLabel = axisRenderSettings.Axis.ToString() + " Axis";
            axisRenderSettings = xzGridCoordSystemRenderSettings.GetAxisRenderSettings(CoordinateSystemAxis.NegativeRight);
            axisRenderSettings.View.VisibilityToggleLabel = axisRenderSettings.Axis.ToString() + " Axis";
            axisRenderSettings = xzGridCoordSystemRenderSettings.GetAxisRenderSettings(CoordinateSystemAxis.PositiveUp);
            axisRenderSettings.View.VisibilityToggleLabel = axisRenderSettings.Axis.ToString() + " Axis";
            axisRenderSettings = xzGridCoordSystemRenderSettings.GetAxisRenderSettings(CoordinateSystemAxis.NegativeUp);
            axisRenderSettings.View.VisibilityToggleLabel = axisRenderSettings.Axis.ToString() + " Axis";
            axisRenderSettings = xzGridCoordSystemRenderSettings.GetAxisRenderSettings(CoordinateSystemAxis.PositiveLook);
            axisRenderSettings.View.VisibilityToggleLabel = axisRenderSettings.Axis.ToString() + " Axis";
            axisRenderSettings = xzGridCoordSystemRenderSettings.GetAxisRenderSettings(CoordinateSystemAxis.NegativeLook);
            axisRenderSettings.View.VisibilityToggleLabel = axisRenderSettings.Axis.ToString() + " Axis";

            ObjectSnapping.Get().ObjectSnapMask.View.SurroundWithBox = true;

            ObjectLayerObjectMaskView objectLayerObjectMaskView = ObjectSnapping.Get().ObjectSnapMask.ObjectLayerObjectMask.View;

            objectLayerObjectMaskView.IsVisible = false;
            objectLayerObjectMaskView.ToggleVisibilityBeforeRender = true;
            objectLayerObjectMaskView.VisibilityToggleIndent       = 1;
            objectLayerObjectMaskView.VisibilityToggleLabel        = "Object Layer Snap Mask";

            ObjectCollectionMaskView objectCollectionMaskView = ObjectSnapping.Get().ObjectSnapMask.ObjectCollectionMask.View;

            objectCollectionMaskView.IsVisible = false;
            objectCollectionMaskView.ToggleVisibilityBeforeRender = true;
            objectCollectionMaskView.VisibilityToggleIndent       = 1;
            objectCollectionMaskView.VisibilityToggleLabel        = "Object Snap Mask";
        }
Beispiel #22
0
 public void RenderGizmos()
 {
     // Note: We will check if the surface object is null so that we don't render the surface
     //       if the object has somehow been deleted from the scene.
     if (IsValid && _type == SnapSurfaceType.ObjectCollider && _surfaceObject != null && !ObjectSnapping.Get().Settings.EnableObjectToObjectSnap)
     {
         _objectBoxSnapSurfaceGrid.RenderGizmos();
     }
 }
Beispiel #23
0
 private void AdjustGuidePositionAndRotation()
 {
     ObjectPlacementGuide.Instance.Snap();
     AxisAlignment.AlignObjectAxis(ObjectPlacementGuide.SceneObject, BlockObjectPlacementSettings.Get().PlacementGuideSurfaceAlignmentSettings, ObjectSnapping.Get().ObjectSnapSurfacePlane.normal);
 }
 protected override void RenderContent()
 {
     ObjectSnapping.Get().XZSnapGrid.RenderSettings.View.Render();
     ObjectSnapping.Get().XZSnapGrid.RenderableCoordinateSystem.RenderSettings.View.Render();
     ObjectSnapping.Get().RenderSettingsForColliderSnapSurfaceGrid.View.Render();
 }