public override bool MouseEventPointedVertex() { MeshManager m = MeshMGMT; BrushConfig bcf = GlobalBrush; //if (EditorInputManager.GetMouseButtonDown(1)) // m.pointedUV.vert.clearColor(cfg.brushConfig.mask); if ((EditorInputManager.GetMouseButtonDown(0))) { if (EditorInputManager.getControlKey()) { bcf.mask.Transfer(ref m.PointedUV._color, bcf.colorLinear.ToGamma()); } else { foreach (Vertex uvi in m.PointedUV.meshPoint.uvpoints) { bcf.mask.Transfer(ref uvi._color, Cfg.brushConfig.colorLinear.ToGamma()); } } m.edMesh.dirty_Color = true; } return(false); }
public override bool PEGI() { MeshManager m = MeshMGMT; pegi.write("OnClick:", 60); if ((MergeUnmerge ? "Merging (Shift: Unmerge)" : "Smoothing (Shift: Unsmoothing)").Click().nl()) { MergeUnmerge = !MergeUnmerge; } if ("Sharp All".Click()) { foreach (MeshPoint vr in MeshMGMT.edMesh.meshPoints) { vr.SmoothNormal = false; } m.edMesh.Dirty = true; Cfg.newVerticesSmooth = false; } if ("Smooth All".Click().nl()) { foreach (MeshPoint vr in MeshMGMT.edMesh.meshPoints) { vr.SmoothNormal = true; } m.edMesh.Dirty = true; Cfg.newVerticesSmooth = true; } if ("All shared".Click()) { m.edMesh.AllVerticesShared(); m.edMesh.Dirty = true; Cfg.newVerticesUnique = false; } if ("All unique".Click().nl()) { foreach (Triangle t in EditedMesh.triangles) { m.edMesh.Dirty |= m.edMesh.GiveTriangleUniqueVerticles(t); } Cfg.newVerticesUnique = true; } return(false); }
public override bool PEGI() { bool changed = false; MeshManager mm = MeshMGMT; if (("UV Set: " + mm.editedUV + "").Click().nl()) { mm.editedUV = 1 - mm.editedUV; } // if (mm.selectedUV != null) ("UV: " + (mm.selectedUV.editedUV.x) + "," + (mm.selectedUV.editedUV.y)).nl(); if (!ProjectionUV && "Projection UV Start".Click().nl()) { ProjectionUV = true; UpdatePreview(); } if (ProjectionUV) { if ("tiling".edit(ref tiling).nl()) { UpdatePreview(); } if ("offset".edit(ref offset).nl()) { UpdatePreview(); } if ("Projection UV Stop".Click()) { ProjectionUV = false; EditedMesh.Dirty = true; } } /* * if (mm.selectedUV != null && "All vert UVs from selected".Click().nl()) * { * foreach (UVpoint uv in mm.selectedUV.vert.uvpoints) * uv.editedUV = mm.selectedUV.editedUV; * mesh.dirty = true; * } */ return(changed); }
public void AddTextureAnimDisplacement() { MeshManager m = MeshManager.Inst; if (m.target != null) { PlaytimePainter em = m.target; if (em == null) { return; } int y = em.GetAnimationUVy(); foreach (MeshPoint v in meshPoints) { v.localPos += (v.anim[y]); } } }
public override bool PEGI() { MeshManager m = MeshMGMT; "Dominance True".toggle(ref SetTo).nl(); pegi.ClickToEditScript(); if ("Auto Bevel".Click()) { AutoAssignDominantNormalsForBeveling(); } "Sensitivity".edit(60, ref Cfg.bevelDetectionSensetivity, 3, 30).nl(); if ("Sharp All".Click()) { foreach (MeshPoint vr in MeshMGMT.edMesh.meshPoints) { vr.SmoothNormal = false; } m.edMesh.Dirty = true; Cfg.newVerticesSmooth = false; } if ("Smooth All".Click().nl()) { foreach (MeshPoint vr in MeshMGMT.edMesh.meshPoints) { vr.SmoothNormal = true; } m.edMesh.Dirty = true; Cfg.newVerticesSmooth = true; } return(false); }
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); }
// ******************* 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(); }