Example #1
0
        public override bool PEGI()
        {
            bool changed = false;

            MeshManager mgm = MeshMGMT;

            PainterDataAndConfig sd = TexMGMTdata;

            if (mgm.MeshTool.ShowGrid)
            {
                "Snap to grid:".toggle(100, ref sd.SnapToGrid);

                if (sd.SnapToGrid)
                {
                    "size:".edit(40, ref sd.SnapToGridSize);
                }
            }

            pegi.newLine();

            "Pixel-Perfect".toggle("New vertex will have UV coordinate rounded to half a pixel.", 120, ref Cfg.pixelPerfectMeshEditing).nl();

            "Add into mesh".toggle("Will split triangles and edges by inserting vertices", 120, ref addToTrianglesAndLines).nl();

            "Add Smooth:".toggle(70, ref Cfg.newVerticesSmooth);
            if (pegi.Click("Sharp All"))
            {
                foreach (MeshPoint vr in MeshMGMT.edMesh.meshPoints)
                {
                    vr.SmoothNormal = false;
                }
                mgm.edMesh.Dirty      = true;
                Cfg.newVerticesSmooth = false;
            }

            if (pegi.Click("Smooth All").nl())
            {
                foreach (MeshPoint vr in MeshMGMT.edMesh.meshPoints)
                {
                    vr.SmoothNormal = true;
                }
                mgm.edMesh.Dirty      = true;
                Cfg.newVerticesSmooth = true;
            }

            "Add Unique:".toggle(70, ref Cfg.newVerticesUnique);
            if (pegi.Click("All shared"))
            {
                mgm.edMesh.AllVerticesShared();
                mgm.edMesh.Dirty      = true;
                Cfg.newVerticesUnique = false;
            }

            if (pegi.Click("All unique"))
            {
                foreach (Triangle t in EditedMesh.triangles)
                {
                    mgm.edMesh.GiveTriangleUniqueVerticles(t);
                }
                mgm.edMesh.Dirty      = true;
                Cfg.newVerticesUnique = true;
            }
            pegi.newLine();


            if ("Auto Bevel".Click())
            {
                SharpFacesTool.inst.AutoAssignDominantNormalsForBeveling();
            }
            "Sensitivity".edit(60, ref Cfg.bevelDetectionSensetivity, 3, 30).nl();

            if ("Offset".foldout())
            {
                "center".edit(ref offset).nl();
                if ("Modify".Click().nl())
                {
                    foreach (var v in EditedMesh.meshPoints)
                    {
                        v.localPos += offset;
                    }

                    offset = -offset;

                    Dirty = true;
                }

                if ("Auto Center".Click().nl())
                {
                    Vector3 avr = Vector3.zero;
                    foreach (var v in EditedMesh.meshPoints)
                    {
                        avr += v.localPos;
                    }

                    offset = -avr / EditedMesh.meshPoints.Count;
                }
            }

            /*
             * if (pegi.Click("Mirror by Center")) {
             *  GridNavigator.onGridPos = mgm.target.transform.position;
             *  mgm.UpdateLocalSpaceV3s();
             *  mgm.edMesh.MirrorVerticlesAgainsThePlane(mgm.onGridLocal);
             * }
             *
             * if (pegi.Click("Mirror by Plane")) {
             *  mgm.UpdateLocalSpaceV3s();
             *  mgm.edMesh.MirrorVerticlesAgainsThePlane(mgm.onGridLocal);
             * }
             * pegi.newLine();
             *
             * pegi.edit(ref displace);
             * pegi.newLine();
             *
             * if (pegi.Click("Cancel")) displace = Vector3.zero;
             *
             * if (pegi.Click("Apply")) {
             *  mgm.edMesh.Displace(displace);
             *  mgm.edMesh.dirty = true;
             *  displace = Vector3.zero;
             * }
             * pegi.newLine();
             */
            return(changed);
        }
Example #2
0
        // *******************  Component MGMT
        private void OnEnable()
        {
            PainterStuff.applicationIsQuitting = false;

            Inst = this;

            if (!Data)
            {
                dataHolder = Resources.Load("Painter_Data") as PainterDataAndConfig;
            }

            if (meshManager == null)
            {
                meshManager = new MeshManager();
            }

            meshManager.OnEnable();

            if (Data)
            {
                rtcam.cullingMask = 1 << Data.myLayer;
            }

            if (PlaytimeToolComponent.enabledTool == null)
            {
                if (!Application.isEditor)
                {
#if BUILD_WITH_PAINTER
                    PlaytimeToolComponent.enabledTool = typeof(PlaytimePainter);
#else
                    PlaytimeToolComponent.GetPrefs();
#endif
                }
                else
                {
                    PlaytimeToolComponent.GetPrefs();
                }
            }
#if UNITY_EDITOR
            EditorSceneManager.sceneSaving -= BeforeSceneSaved;
            EditorSceneManager.sceneSaving += BeforeSceneSaved;
            // Debug.Log("Adding scene saving delegate");
            EditorSceneManager.sceneOpening -= OnSceneOpening;
            EditorSceneManager.sceneOpening += OnSceneOpening;

            if (defaultMaterial == null)
            {
                defaultMaterial = AssetDatabase.GetBuiltinExtraResource <Material>("Default-Material.mat");
            }

            if (defaultMaterial == null)
            {
                Debug.Log("Default Material not found.");
            }

            isLinearColorSpace = UnityEditor.PlayerSettings.colorSpace == ColorSpace.Linear;

            EditorApplication.update -= CombinedUpdate;
            if (!this.ApplicationIsAboutToEnterPlayMode())
            {
                EditorApplication.update += CombinedUpdate;
            }


            if (brushPrefab == null)
            {
                GameObject go = Resources.Load("prefabs/RenderCameraBrush") as GameObject;
                brushPrefab = go.GetComponent <RenderBrush>();
                if (brushPrefab == null)
                {
                    Debug.Log("Couldn't find brush prefab.");
                }
            }

            if (Data)
            {
                UnityHelperFunctions.RenamingLayer(Data.myLayer, "Painter Layer");
            }
#endif

            if (brushRendy == null)
            {
                brushRendy = GetComponentInChildren <RenderBrush>();
                if (brushRendy == null)
                {
                    brushRendy = Instantiate(brushPrefab.gameObject).GetComponent <RenderBrush>();
                    brushRendy.transform.parent = this.transform;
                }
            }
            if (Data)
            {
                brushRendy.gameObject.layer = Data.myLayer;
            }

#if BUILD_WITH_PAINTER || UNITY_EDITOR
            transform.position = Vector3.up * 3000;
            if (rtcam == null)
            {
                rtcam = GetComponent <Camera>();
                if (rtcam == null)
                {
                    rtcam = gameObject.AddComponent <Camera>();
                }
            }

            rtcam.orthographic     = true;
            rtcam.orthographicSize = orthoSize;
            rtcam.clearFlags       = CameraClearFlags.Nothing;
            rtcam.enabled          = Application.isPlaying;

#if UNITY_EDITOR
            EditorApplication.update -= CombinedUpdate;
            if (EditorApplication.isPlayingOrWillChangePlaymode == false)
            {
                EditorApplication.update += CombinedUpdate;
            }
#endif

            UpdateBuffersState();
#endif

            autodisabledBufferTarget = null;

            RefreshPlugins();
        }