コード例 #1
0
        internal static Vector3 GetHandlePosition()
        {
            Transform activeTransform = Selection.activeTransform;

            if (!activeTransform)
            {
                return(new Vector3(float.PositiveInfinity, float.PositiveInfinity, float.PositiveInfinity));
            }
            Vector3   b         = Tools.handleOffset + Tools.handleRotation * Tools.localHandleOffset;
            PivotMode pivotMode = Tools.get.m_PivotMode;

            if (pivotMode != PivotMode.Center)
            {
                if (pivotMode != PivotMode.Pivot)
                {
                    return(new Vector3(float.PositiveInfinity, float.PositiveInfinity, float.PositiveInfinity));
                }
                if (Tools.current == Tool.Rect && Tools.rectBlueprintMode && InternalEditorUtility.SupportsRectLayout(activeTransform))
                {
                    return(activeTransform.parent.TransformPoint(new Vector3(activeTransform.localPosition.x, activeTransform.localPosition.y, 0f)) + b);
                }
                return(activeTransform.position + b);
            }
            else
            {
                if (Tools.current == Tool.Rect)
                {
                    return(Tools.handleRotation * InternalEditorUtility.CalculateSelectionBoundsInSpace(Vector3.zero, Tools.handleRotation, Tools.rectBlueprintMode).center + b);
                }
                return(InternalEditorUtility.CalculateSelectionBounds(true, false).center + b);
            }
        }
コード例 #2
0
ファイル: TransformTool.cs プロジェクト: timkulp/EditorVR
 bool TogglePivotMode()
 {
     m_PivotMode = m_PivotMode == PivotMode.Pivot ? PivotMode.Center : PivotMode.Pivot;
     UpdatePivotModeAction();
     UpdateCurrentManipulator();
     return(true);
 }
コード例 #3
0
ファイル: CombineMesh.cs プロジェクト: sc1752/CombineMesh
    /// <summary>
    /// Draw combine mesh GUI.
    /// </summary>
    private void OnGUI()
    {
        this.maxSize = new Vector2(220, 200);
        this.minSize = new Vector2(220, 200);
        GUILayout.BeginVertical();
        GUILayout.Label("Select Meshes to Combine", EditorStyles.boldLabel);

        if (GUILayout.Button("Select All Meshes", GUILayout.Width(200)))
        {
            onSelectAllMeshes();
        }
        if (GUILayout.Button("Clear Selection", GUILayout.Width(200)))
        {
            onClearSelection();
        }

        GUILayout.Space(10);
        _pivotMode    = (PivotMode)EditorGUILayout.EnumPopup("New Mesh Pivot", _pivotMode);
        _keepOrignal  = (GUILayout.Toggle(_keepOrignal, "Keep Orignal"));
        _ignoreHidden = (GUILayout.Toggle(_ignoreHidden, "Ignore hidden Mesh"));

        if (GUILayout.Button("Combine Selected", GUILayout.Width(200)))
        {
            onCombineSelected();
        }
        GUILayout.EndVertical();
    }
コード例 #4
0
 public void ResetMoveSettings()
 {
     moveSurfaceOffset   = 0f;
     movePivotMode       = PivotMode.BoundsBottomCenter;
     moveLockUp          = false;
     moveOrientationMode = OrientationMode.SurfaceNormal;
 }
コード例 #5
0
ファイル: FaceSnap.cs プロジェクト: momoma-null/MomomaTools
 static void OnSceneGUI(SceneView sceneView)
 {
     try
     {
         Handles.BeginGUI();
         using (new EditorGUILayout.HorizontalScope())
         {
             EditorGUI.BeginChangeCheck();
             s_Enabled = GUILayout.Toggle(s_Enabled, "Face snap", GUI.skin.button);
             if (EditorGUI.EndChangeCheck())
             {
                 EditorPrefs.SetBool(k_PrefKey, s_Enabled);
             }
             EditorGUI.BeginChangeCheck();
             s_PivotMode = (PivotMode)EditorGUILayout.EnumPopup(s_PivotMode);
             if (EditorGUI.EndChangeCheck())
             {
                 EditorPrefs.SetInt(k_PrefKeyPivotMode, (int)s_PivotMode);
             }
             GUILayout.FlexibleSpace();
         }
     }
     finally
     {
         Handles.EndGUI();
     }
 }
コード例 #6
0
    void OnEnable()
    {
        temp = target as Branch_Mono;
        sim  = temp.GetSimulation;
        if (sim == null)
        {
            BinaryTree.ResetParams(temp.length);
            temp.ResetForm();
            this.sim = temp.GetSimulation;
        }
        else
        {
            //Branch.lengthExit = temp.lengthExit;
            BinaryTree.angleOffsetMax         = temp.angleOffsetMax;
            BinaryTree.angleOffsetMin         = temp.angleOffsetMin;
            BinaryTree.lengthMax1             = temp.lengthMax1;
            BinaryTree.lengthMax2             = temp.lengthMax2;
            BinaryTree.lengthMin1             = temp.lengthMin1;
            BinaryTree.lengthMin2             = temp.lengthMin2;
            BinaryTree.lengthBranchAThreshold = temp.lengthBranchAThreshold;
            BinaryTree.lengthBranchBThreshold = temp.lengthBranchBThreshold;
            //Branch.lengthExitRatio = temp.lengthExitRatio;
            //Branch.lengthExit = temp.lengthExitRatio * temp.length;
            BinaryTree.maxDepth = temp.maxDepth;
        }

        lastPMode           = Tools.pivotMode;
        lastRMode           = Tools.pivotRotation;
        Tools.pivotMode     = PivotMode.Pivot;
        Tools.pivotRotation = PivotRotation.Local;
    }
コード例 #7
0
ファイル: Tools.cs プロジェクト: twenty0ne/UnityDecompiled
        internal static Vector3 GetHandlePosition()
        {
            Transform activeTransform = Selection.activeTransform;

            if (activeTransform == null)
            {
                return(new Vector3(float.PositiveInfinity, float.PositiveInfinity, float.PositiveInfinity));
            }
            Vector3   vector2   = handleOffset + (handleRotation * localHandleOffset);
            PivotMode pivotMode = get.m_PivotMode;

            if (pivotMode != PivotMode.Center)
            {
                if (pivotMode != PivotMode.Pivot)
                {
                    return(new Vector3(float.PositiveInfinity, float.PositiveInfinity, float.PositiveInfinity));
                }
            }
            else
            {
                if (current == UnityEditor.Tool.Rect)
                {
                    return(((Vector3)(handleRotation * InternalEditorUtility.CalculateSelectionBoundsInSpace(Vector3.zero, handleRotation, rectBlueprintMode).center)) + vector2);
                }
                return(InternalEditorUtility.CalculateSelectionBounds(true, false).center + vector2);
            }
            if (((current == UnityEditor.Tool.Rect) && rectBlueprintMode) && InternalEditorUtility.SupportsRectLayout(activeTransform))
            {
                return(activeTransform.parent.TransformPoint(new Vector3(activeTransform.localPosition.x, activeTransform.localPosition.y, 0f)) + vector2);
            }
            return(activeTransform.position + vector2);
        }
コード例 #8
0
 public void ResetOrientSettings()
 {
     orientRotation      = new Vector3(0, 0, 0);
     orientLockUp        = true;
     orientPivotMode     = PivotMode.BoundsBottomCenter;
     orientSameDirection = false;
     orientFlipDirection = false;
 }
 public void Move(Vector3 mv, PivotMode pivot_mode)
 {
     if (pivot_mode == PivotMode.LOCAL)
     {
         mv = Vector3.Transform(mv, m_rotation);
     }
     SetPosition(m_position + mv);
 }
コード例 #10
0
 /// <summary>
 ///    Constructor of class.
 /// </summary>
 /// <param name="rowFields">List of columns which distinct values are used for group by as new rows.</param>
 /// <param name="columnFields">List of columns which distinct data builds new columns to group by.</param>
 /// <param name="dataFields">List of columns which contains pivoted values.</param>
 /// <param name="aggregates">List of functions to be used for aggregation.</param>
 /// <param name="columnFieldSeparator">Specifies the separator used for column names in cross table mode.</param>
 /// <param name="mode">Specifies the output format of the pivoted data.</param>
 /// <param name="dataFieldColumnName">Name of the column for datafields in flat mode.</param>
 public PivotInfo(IReadOnlyList <string> rowFields, IReadOnlyList <string> columnFields, IReadOnlyList <string> dataFields, IEnumerable <Aggregate> aggregates, char columnFieldSeparator = '.', PivotMode mode = PivotMode.CrossTable, string dataFieldColumnName = "DataField")
 {
     RowFields             = rowFields;
     DataFields            = dataFields;
     Aggregates            = aggregates;
     ColumnFields          = columnFields;
     ColumnFieldsSeparator = columnFieldSeparator;
     Mode = mode;
     DataFieldColumnName = dataFieldColumnName;
 }
コード例 #11
0
    private void SwitchPivotMode()
    {
        if (m_Mode == TransformMode.Direct)
        {
            return;
        }

        m_PivotMode = m_PivotMode == PivotMode.Pivot ? PivotMode.Center : PivotMode.Pivot;
        UpdateCurrentManipulator();
    }
コード例 #12
0
        private void SetMode(PivotMode mode)
        {
            if (_mode == mode)
            {
                return;
            }

            icons[_mode.GetHashCode()].color = Color.white;
            _mode = mode;
            InputManager.State.ActivePivotMode = _mode;
            icons[_mode.GetHashCode()].color   = activeColor;
        }
 public void CyclePivotMode(bool reverse)
 {
     if (reverse)
     {
         m_pivot_mode = (PivotMode)(((int)m_pivot_mode + (int)PivotMode.NUM - 1) % (int)PivotMode.NUM);
     }
     else
     {
         m_pivot_mode = (PivotMode)(((int)m_pivot_mode + 1) % (int)PivotMode.NUM);
     }
     UpdateOptionLabels();
 }
コード例 #14
0
        public void Repaint()
        {
            _mode = InputManager.State.ActivePivotMode;
            for (var i = 0; i < icons.Length; i++)
            {
                icons[i].color = _mode.GetHashCode() == i ? activeColor : Color.white;

                // Set mesh PivotMode.Selection interactability
                if (i == PivotMode.Selection.GetHashCode())
                {
                    icons[i].GetComponent <Button>().interactable = InputManager.State.ActiveTool != ToolType.Transform;
                }
            }
        }
コード例 #15
0
    /// <summary>
    /// Method intended to be invoked before Drawing GUI
    /// </summary>
    void CheckSelectedMode()
    {
        _selectedMode = GetCurrentMode();

        // if selected item was changed, research colliders
        if (_selectedMode != _lastSelectedMode |
            _lastPivotMode != Tools.pivotMode |
            _lastPivotRotation != Tools.pivotRotation)
        {
            _lastSelectedMode  = _selectedMode;
            _lastPivotMode     = Tools.pivotMode;
            _lastPivotRotation = Tools.pivotRotation;
        }
    }
        public void LoadPreferences()
        {
            Directory.SetCurrentDirectory(m_filepath_root);

            //m_filepath_root = UserPrefs.GetString("filepath_root", m_filepath_root);
            m_filepath_decal_textures = UserPrefs.GetString("filepath_decal_textures", m_filepath_decal_textures);
            m_filepath_level_textures = UserPrefs.GetString("filepath_level_textures", m_filepath_level_textures);
            m_filepath_decals         = UserPrefs.GetString("filepath_decals", m_filepath_decals);

            m_grid_display = (GridDisplay)UserPrefs.GetInt("grid_display", (int)m_grid_display);
            m_grid_spacing = UserPrefs.GetFloat("grid_spacing", m_grid_spacing);
            SetGridLines();
            m_grid_snap = UserPrefs.GetFloat("grid_snap", m_grid_snap);

            m_extrude_length = UserPrefs.GetFloat("extrude_length", m_extrude_length);
            m_inset_pct      = UserPrefs.GetInt("inset_pct", m_inset_pct);
            m_inset_length   = UserPrefs.GetFloat("inset_length", m_inset_length);
            m_bevel_width    = UserPrefs.GetFloat("bevel_width", m_bevel_width);

            m_coplanar_tol = UserPrefs.GetInt("coplanar_tol", m_coplanar_tol);
            m_side_select  = (SideSelect)UserPrefs.GetInt("side_select", (int)m_side_select);
            m_drag_mode    = (DragMode)UserPrefs.GetInt("drag_mode", (int)m_drag_mode);

            m_view_mode_ortho = (ViewMode)UserPrefs.GetInt("view_mode_ortho", (int)m_view_mode_ortho);
            m_view_mode_persp = (ViewMode)UserPrefs.GetInt("view_mode_persp", (int)m_view_mode_persp);
            m_view_persp_fov  = UserPrefs.GetInt("view_persp_fov", m_view_persp_fov);
            m_view_layout     = (ViewLayout)UserPrefs.GetInt("view_layout", (int)m_view_layout);
            m_bg_color        = (BGColor)UserPrefs.GetInt("bg_color", (int)m_bg_color);
            m_gimbal_display  = (GimbalDisplay)UserPrefs.GetInt("gimbal_display", (int)m_gimbal_display);
            m_lighting_type   = (LightingType)UserPrefs.GetInt("lighting_type", (int)m_lighting_type);
            m_pivot_mode      = (PivotMode)UserPrefs.GetInt("pivot_mode", (int)m_pivot_mode);

            m_low_res_force = UserPrefs.GetBool("low_res_force", m_low_res_force);
            forceLowResTexturesToolStripMenuItem.Checked = m_low_res_force;

            m_tex_list_loc       = UserPrefs.GetPoint("tex_list_loc", texture_list.Location);
            m_tex_list_sz        = UserPrefs.GetPoint("tex_list_sz", (Point)texture_list.Size);
            m_tunnel_builder_loc = UserPrefs.GetPoint("tunnel_builder_loc", tunnel_builder.Location);
            texture_list.Size    = (Size)m_tex_list_sz;

            for (int i = 0; i < RECENT_NUM; i++)
            {
                m_recent_files[i] = UserPrefs.GetString("recent" + i.ToString(), m_recent_files[i]);
            }
            UpdateRecentFileMenu();
        }
コード例 #17
0
ファイル: Tools.cs プロジェクト: simeonradivoev/Coop-Design
        internal static Vector3 GetHandlePosition()
        {
            WorldProp activeTransform = RuntimeSelection.activeProp;

            if (!activeTransform)
            {
                return(new Vector3(float.PositiveInfinity, float.PositiveInfinity, float.PositiveInfinity));
            }
            Vector3   b         = Tools.handleOffset + Tools.handleRotation * Tools.localHandleOffset;
            PivotMode pivotMode = Tools.get.m_PivotMode;

            if (pivotMode != PivotMode.Pivot)
            {
                return(new Vector3(float.PositiveInfinity, float.PositiveInfinity, float.PositiveInfinity));
            }
            return(activeTransform.Position + b);
        }
コード例 #18
0
        /// <summary>
        /// Method intended to be invoked before Drawing GUI
        /// </summary>
        void CheckSelectedMode()
        {
            bool selectionChanged =
                _lastSelectedMode != _selectedMode |
                _lastPivotMode != Tools.pivotMode |
                _lastPivotRotation != Tools.pivotRotation;

            // if selected item was changed, research colliders
            if (selectionChanged)
            {
                Tools.hidden = _selectedMode != SelectedMode.Ragdoll;

                _lastSelectedMode  = _selectedMode;
                _lastPivotMode     = Tools.pivotMode;
                _lastPivotRotation = Tools.pivotRotation;
                FindColliders();
                SceneView.RepaintAll();
            }
        }
コード例 #19
0
        private void OnGUI()
        {
            DragAndDrop.visualMode = DragAndDropVisualMode.Generic;
            if (Event.current.type == EventType.DragExited)
            {
                for (int i = 0; i < DragAndDrop.objectReferences.Length; i++)
                {
                    if (DragAndDrop.objectReferences[i].GetType() == typeof(Texture2D))
                    {
                        imageSequence.Add(DragAndDrop.objectReferences[i] as Texture2D);
                    }
                    imageSequenceChanged = true;
                }
            }
            //------------------------------------------------------------------------------
            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("Images", GUILayout.Width(60));
            int targetCount = EditorGUILayout.DelayedIntField(imageSequence.Count);

            if (targetCount != imageSequence.Count)
            {
                if (targetCount > imageSequence.Count)
                {
                    int count = targetCount - imageSequence.Count;
                    for (int i = 0; i < count; i++)
                    {
                        imageSequence.Add(null);
                    }
                }
                else
                {
                    imageSequence.RemoveRange(targetCount, imageSequence.Count - targetCount);
                }
                imageSequenceChanged = true;
            }
            string addedFilePath = "", addedFolderPath = "";

            if (GUILayout.Button("Folder", GUILayout.Width(60)))
            {
                addedFolderPath = EditorUtility.OpenFolderPanel("Add Folder to Sequence", lastOpenedPath, "opened folder");
            }

            if (addedFolderPath.Length > 1)
            {
                addedFolderPath = addedFolderPath.Substring(Application.dataPath.Length);
                lastOpenedPath  = "Assets" + addedFolderPath;
                foreach (var obj in GetAtPath <Texture2D>(addedFolderPath))
                {
                    imageSequence.Add((Texture2D)obj);
                }
                imageSequenceChanged = true;
            }

            if (GUILayout.Button("File", GUILayout.Width(60)))
            {
                addedFilePath = EditorUtility.OpenFilePanel("Add File to Sequence", lastOpenedPath, "png,jpg,jpeg");
            }
            if (addedFilePath.Length > 1)
            {
                addedFilePath  = "Assets" + addedFilePath.Substring(Application.dataPath.Length);
                lastOpenedPath = addedFilePath;
                imageSequence.Add(AssetDatabase.LoadAssetAtPath <Texture2D>(addedFilePath));
                imageSequenceChanged = true;
            }

            if (GUILayout.Button("+", GUILayout.Width(60)))
            {
                imageSequence.Add(null);
                imageSequenceChanged = true;
            }
            if (GUILayout.Button("-", GUILayout.Width(60)))
            {
                if (imageSequence.Count > 0)
                {
                    imageSequence.RemoveAt(imageSequence.Count - 1);
                }
                imageSequenceChanged = true;
            }
            EditorGUILayout.EndHorizontal();
            //------------------------------------------------------------------------------
            if (imageSequence.Count > 0)
            {
                int?toDelete = null;
                if (imageSequence.Count > 7)
                {
                    imageSequenceScroll = EditorGUILayout.BeginScrollView(imageSequenceScroll, GUILayout.Height(20 * 8));
                }
                for (int i = 0; i < imageSequence.Count; i++)
                {
                    EditorGUILayout.BeginHorizontal();
                    imageSequence[i] = (Texture2D)EditorGUILayout.ObjectField(imageSequence[i], typeof(Texture2D), false);
                    if (GUILayout.Button("-", GUILayout.Width(20)))
                    {
                        toDelete = i;
                    }
                    EditorGUILayout.EndHorizontal();
                }
                if (imageSequence.Count > 7)
                {
                    EditorGUILayout.EndScrollView();
                }
                if (toDelete != null)
                {
                    imageSequence.RemoveAt((int)toDelete);
                }

                EditorGUILayout.BeginHorizontal();
                rowsColumnsWeigth = EditorGUILayout.Slider("Rows & Columns", rowsColumnsWeigth, 0.01f, 0.99f);
                rowsColumns.x     = Mathf.CeilToInt(imageSequence.Count * rowsColumnsWeigth);
                rowsColumns.y     = Mathf.CeilToInt(imageSequence.Count / rowsColumns.x);
                EditorGUILayout.Vector2Field("", rowsColumns, GUILayout.Width(100));
                EditorGUILayout.EndHorizontal();

                if (GUI.changed || imageSequenceChanged)
                {
                    Convert();
                }

                if (targetTexture)
                {
                    EditorGUILayout.Separator();
                    EditorGUILayout.BeginHorizontal();
                    EditorGUILayout.LabelField("Zoom", GUILayout.Width(40));
                    zoom      = EditorGUILayout.Slider(zoom, 0.1f, 10f);
                    pivotMode = (PivotMode)EditorGUILayout.EnumPopup(pivotMode);
                    if (GUILayout.Button("Save SpriteSheet"))
                    {
                        SaveTexture();
                    }
                    EditorGUILayout.EndHorizontal();
                    float space = 10 + 18.5f * 5;
                    space += Mathf.Min(imageSequence.Count, 7) * 20f;
                    targetTextureScroll = EditorGUILayout.BeginScrollView(targetTextureScroll,
                                                                          GUILayout.Width(position.width),
                                                                          GUILayout.Height(Mathf.Min(position.height - space, targetTexture.height * zoom + 20)));
                    Rect rect = EditorGUILayout.GetControlRect(GUILayout.Width(targetTexture.width * zoom), GUILayout.Height(targetTexture.height * zoom));
                    EditorGUI.DrawTextureTransparent(rect, targetTexture);
                    EditorGUILayout.EndScrollView();
                }
                imageSequenceChanged = false;
            }
        }
コード例 #20
0
ファイル: SnappingModule.cs プロジェクト: xxpniu/EditorXR
        bool ManipulatorSnapConstrained(ref Vector3 position, ref Quaternion rotation, Vector3 delta, Vector3 targetPosition, Quaternion targetRotation, SnappingState state, float raycastDistance, AxisFlags constraints, PivotMode pivotMode)
        {
            var rotationOffset = Quaternion.AngleAxis(90, Vector3.right);
            var startRotation  = state.startRotation;
            var upVector       = startRotation * Vector3.back;

            var direction        = delta.normalized;
            var bounds           = state.identityBounds;
            var projectedExtents = Vector3.Project(rotation * bounds.extents, direction);
            var axisRay          = new Ray(targetPosition, direction);

            var objectCenter = Vector3.zero;
            var offset       = Vector3.zero;

            if (!pivotSnappingEnabled)
            {
                objectCenter = targetPosition;
                if (pivotMode != PivotMode.Center)
                {
                    objectCenter += targetRotation * state.identityBounds.center;
                }

                switch (constraints)
                {
                case AxisFlags.X:
                    if (Vector3.Dot(rotation * Vector3.right, direction) > 0)
                    {
                        projectedExtents *= -1;
                    }
                    break;

                case AxisFlags.Y:
                    if (Vector3.Dot(rotation * Vector3.up, direction) > 0)
                    {
                        projectedExtents *= -1;
                    }
                    break;

                case AxisFlags.Z:
                    if (Vector3.Dot(rotation * Vector3.forward, direction) > 0)
                    {
                        projectedExtents *= -1;
                    }
                    break;
                }

                axisRay.origin = objectCenter - projectedExtents;
                offset         = targetPosition - axisRay.origin;
            }

            if (state.snapping)
            {
                var breakDistance = raycastDistance;
                if (Vector3.Dot(targetPosition - position, state.snappingNormal) < 0)
                {
                    breakDistance *= k_BlockedBreakScale;
                }

                TryBreakSnap(ref position, ref rotation, targetPosition, startRotation, state, breakDistance);
                return(true);
            }

            if (surfaceSnappingEnabled && SnapToSurface(axisRay, ref position, ref rotation, state, offset, targetRotation, rotationOffset, upVector, raycastDistance, constrained: true))
            {
                return(true);
            }

            if (groundSnappingEnabled && SnapToGround(axisRay, ref position, ref rotation, targetPosition, targetRotation, state, raycastDistance, offset, true))
            {
                return(true);
            }

            // Check other direction
            axisRay.direction *= -1;
            if (!pivotSnappingEnabled)
            {
                axisRay.origin = objectCenter + projectedExtents;
                offset         = targetPosition - axisRay.origin;
            }

            if (surfaceSnappingEnabled && SnapToSurface(axisRay, ref position, ref rotation, state, offset, targetRotation, rotationOffset, upVector, raycastDistance, constrained: true))
            {
                return(true);
            }

            if (groundSnappingEnabled && SnapToGround(axisRay, ref position, ref rotation, targetPosition, targetRotation, state, raycastDistance, offset, true))
            {
                return(true);
            }

            if (TryBreakSnap(ref position, ref rotation, targetPosition, startRotation, state, raycastDistance))
            {
                return(true);
            }

            return(false);
        }
コード例 #21
0
ファイル: SnappingModule.cs プロジェクト: xxpniu/EditorXR
        public bool ManipulatorSnap(Transform rayOrigin, Transform[] transforms, ref Vector3 position, ref Quaternion rotation, Vector3 delta, AxisFlags constraints, PivotMode pivotMode)
        {
            if (transforms.Length == 0)
            {
                return(false);
            }

            if (delta == Vector3.zero)
            {
                return(false);
            }

            if (snappingEnabled && manipulatorSnappingEnabled)
            {
                var state = GetSnappingState(rayOrigin, transforms, position, rotation);

                state.currentPosition += delta;
                var targetPosition = state.currentPosition;
                var targetRotation = state.startRotation;

                AddToIgnoreList(transforms);

                var breakScale = Vector3.Distance(CameraUtils.GetMainCamera().transform.position, position);

                switch (constraints)
                {
                case 0:
                    if (limitRadius)
                    {
                        if (LocalSnapToSurface(ref position, ref rotation, targetPosition, targetRotation, state))
                        {
                            return(true);
                        }
                    }
                    else
                    {
                        var pointerRay = new Ray(rayOrigin.position, rayOrigin.forward);
                        if (surfaceSnappingEnabled)
                        {
                            var bounds           = state.identityBounds;
                            var boundsExtents    = bounds.extents;
                            var projectedExtents = Vector3.Project(boundsExtents, Vector3.down);
                            var offset           = projectedExtents - bounds.center;
                            var rotationOffset   = Quaternion.AngleAxis(90, Vector3.right);
                            var startRotation    = state.startRotation;
                            var upVector         = startRotation * Vector3.back;
                            var maxRayLength     = this.GetViewerScale() * k_SurfaceSnappingMaxRayLength;

                            if (SnapToSurface(pointerRay, ref position, ref rotation, state, offset, targetRotation, rotationOffset, upVector, maxRayLength))
                            {
                                return(true);
                            }

                            state.surfaceSnapping = false;
                        }

                        if (groundSnappingEnabled)
                        {
                            var raycastDistance = this.GetViewerScale() * k_GroundSnappingMaxRayLength;
                            if (SnapToGround(pointerRay, ref position, ref rotation, targetPosition, targetRotation, state, raycastDistance))
                            {
                                return(true);
                            }
                        }

                        if (TryBreakSnap(ref position, ref rotation, targetPosition, targetRotation, state, breakScale * k_BreakDistance))
                        {
                            return(true);
                        }
                    }

                    break;

                default:
                    if (ManipulatorSnapConstrained(ref position, ref rotation, delta, targetPosition, targetRotation, state, breakScale * k_BreakDistance, constraints, pivotMode))
                    {
                        return(true);
                    }
                    break;
                }
            }

            position += delta;

            return(false);
        }
 public void CycleEntityPivot(bool reverse)
 {
     m_pivot_mode = (PivotMode)(((int)m_pivot_mode + (reverse ? (int)PivotMode.NUM - 1 : 1)) % (int)PivotMode.NUM);
     UpdateOptionLabels();
 }
        public void LoadPreferences()
        {
            Directory.SetCurrentDirectory(m_filepath_root);

            m_grid_display = (GridDisplay)UserPrefs.GetInt("grid_display", (int)m_grid_display);
            m_grid_spacing = UserPrefs.GetInt("grid_spacing", m_grid_spacing);
            m_grid_snap    = UserPrefs.GetFloat("grid_snap", m_grid_snap);

            m_coplanar_tol   = UserPrefs.GetInt("coplanar_tol", m_coplanar_tol);
            m_rotate_angle   = UserPrefs.GetInt("rotate_angle", m_rotate_angle);
            m_side_select    = (SideSelect)UserPrefs.GetInt("side_select", (int)m_side_select);
            m_insert_advance = UserPrefs.GetBool("insert_advance", m_insert_advance);
            m_drag_mode      = (DragMode)UserPrefs.GetInt("drag_mode", (int)m_drag_mode);

            m_view_mode_ortho   = (ViewMode)UserPrefs.GetInt("view_mode_ortho", (int)m_view_mode_ortho);
            m_view_mode_persp   = (ViewMode)UserPrefs.GetInt("view_mode_persp", (int)m_view_mode_persp);
            m_view_persp_fov    = UserPrefs.GetInt("view_persp_fov", m_view_persp_fov);
            m_view_layout       = (ViewLayout)UserPrefs.GetInt("view_layout", (int)m_view_layout);
            m_bg_color          = (BGColor)UserPrefs.GetInt("bg_color", (int)m_bg_color);
            m_gimbal_display    = (GimbalDisplay)UserPrefs.GetInt("gimbal_display", (int)m_gimbal_display);
            m_lighting_type     = (LightingType)UserPrefs.GetInt("lighting_type", (int)m_lighting_type);
            m_cp_display        = (ClipPlaneDisplay)UserPrefs.GetInt("clip_decal", (int)m_cp_display);
            m_insert_decal      = (InsertDecal)UserPrefs.GetInt("insert_decal", (int)m_insert_decal);
            m_show_3d_text_type = (ShowTextType)UserPrefs.GetInt("show_segment_numbers", (int)m_show_3d_text_type);
            m_auto_center       = UserPrefs.GetBool("auto_center", m_auto_center);

            m_decal_list_loc       = UserPrefs.GetPoint("decal_list_loc", decal_list.Location);
            m_decal_list_sz        = UserPrefs.GetPoint("decal_list_sz", (Point)decal_list.Size);
            m_tex_list_loc         = UserPrefs.GetPoint("tex_list_loc", texture_list.Location);
            m_tex_list_sz          = UserPrefs.GetPoint("tex_list_sz", (Point)texture_list.Size);
            m_texture_set_list_loc = UserPrefs.GetPoint("texture_set_list_loc", texture_list.Location);
            m_texture_set_list_sz  = UserPrefs.GetPoint("texture_set_list_sz", (Point)texture_list.Size);
            m_uv_editor_loc        = UserPrefs.GetPoint("uv_editor_loc", uv_editor.Location);
            m_uv_editor_sz         = UserPrefs.GetPoint("uv_editor_sz", (Point)uv_editor.Size);

            decal_list.Size   = (Size)m_decal_list_sz;
            texture_list.Size = (Size)m_tex_list_sz;
            uv_editor.Size    = (Size)m_uv_editor_sz;

            for (int i = 0; i < NumRecentFiles; i++)
            {
                string recent_file = GetRecentFile(i);
                SetRecentFile(i, UserPrefs.GetString("recent" + i.ToString(), recent_file));
            }
            Shell.UpdateRecentFileMenu();

            m_pivot_mode = (PivotMode)UserPrefs.GetInt("entity_pivot", (int)m_pivot_mode);

            m_editor_layout = UserPrefs.GetString("layout", string.Empty);

            //Save whether pop-up windows are open at startup
            m_decal_list_visible       = UserPrefs.GetBool("decal_list_vis", false);
            m_texture_list_visible     = UserPrefs.GetBool("tex_list_vis", false);
            m_texture_set_list_visible = UserPrefs.GetBool("texture_set_list_vis", false);
            m_uv_editor_visible        = UserPrefs.GetBool("uv_editor_vis", false);

#if !PUBLIC_RELEASE
            Overload.Perforce.m_cached_username   = UserPrefs.GetString("m_cached_username", string.Empty);
            Overload.Perforce.m_cached_clientname = UserPrefs.GetString("m_cached_clientname", string.Empty);
#endif // !PUBLIC_RELEASE

            m_mm_edit_type = (EditMode)UserPrefs.GetInt("mm_edit_type", (int)m_mm_edit_type);
            m_mm_op_mode   = (OperationMode)UserPrefs.GetInt("mm_op_mode", (int)m_mm_op_mode);

            //Read texture collections
            int num_texture_collections = UserPrefs.GetInt("num_texture_collections", 0);
            for (int c = 0; c < num_texture_collections; c++)
            {
                TextureCollections.Add(new TextureCollection(UserPrefs.GetString("texture_collection_" + c), true));
            }
        }
コード例 #24
0
 /// <summary>
 /// Perform manipulator snapping: Translate a position vector using deltas while also respecting snapping
 /// </summary>
 /// <param name="rayOrigin">The ray doing the translating</param>
 /// <param name="transforms">The transforms being translated (used to determine bounds; Transforms do not get modified)</param>
 /// <param name="position">The position being modified by delta. This will be set with a snapped position if possible</param>
 /// <param name="rotation">The rotation to be modified if rotation snapping is enabled</param>
 /// <param name="delta">The position delta to apply</param>
 /// <param name="constraints">The axis constraints</param>
 /// <param name="pivotMode">The current pivot mode</param>
 /// <returns>Whether the position was set to a snapped position</returns>
 public static bool ManipulatorSnap(this IUsesSnapping usesSnaping, Transform rayOrigin, Transform[] transforms, ref Vector3 position, ref Quaternion rotation, Vector3 delta, AxisFlags constraints, PivotMode pivotMode)
 {
     return(manipulatorSnap(rayOrigin, transforms, ref position, ref rotation, delta, constraints, pivotMode));
 }
コード例 #25
0
ファイル: IUsesSnapping.cs プロジェクト: PushyPixels/EditorXR
        /// <summary>
        /// Perform manipulator snapping: Translate a position vector using deltas while also respecting snapping
        /// </summary>
        /// <param name="user">The functionality user</param>
        /// <param name="rayOrigin">The ray doing the translating</param>
        /// <param name="transforms">The transforms being translated (used to determine bounds; Transforms do not get modified)</param>
        /// <param name="position">The position being modified by delta. This will be set with a snapped position if possible</param>
        /// <param name="rotation">The rotation to be modified if rotation snapping is enabled</param>
        /// <param name="delta">The position delta to apply</param>
        /// <param name="constraints">The axis constraints</param>
        /// <param name="pivotMode">The current pivot mode</param>
        /// <returns>Whether the position was set to a snapped position</returns>
        public static bool ManipulatorSnap(this IUsesSnapping user, Transform rayOrigin, Transform[] transforms,
            ref Vector3 position, ref Quaternion rotation, Vector3 delta, AxisFlags constraints, PivotMode pivotMode)
        {
#if FI_AUTOFILL
            return default(bool);
#else
            return user.provider.ManipulatorSnap(rayOrigin, transforms, ref position, ref rotation, delta, constraints, pivotMode);
#endif
        }
コード例 #26
0
 public void CycleEntityPivot()
 {
     m_pivot_mode = (PivotMode)(((int)m_pivot_mode + 1) % (int)PivotMode.NUM);
     UpdateOptionLabels();
 }
コード例 #27
0
 public void ResetModifyPositionSettings()
 {
     modifyPivotMode = PivotMode.BoundsBottomCenter;
 }