private void Button1Click(object sender, EventArgs e) { LayerName = comboBoxLayerList.Text; Max = (double)numericUpDownMax.Value; Min = (double)numericUpDownMin.Value; Eve = (double)numericUpDownEvery.Value; Contourtype = GetSelectedType(); Lev = Contour.CreateLevels(Min, Max, Eve); Contours = Contour.Execute(Layers[comboBoxLayerList.SelectedIndex].DataSet as Raster, Contourtype, "Value", Lev); Contours.Projection = Layers[comboBoxLayerList.SelectedIndex].Projection; int numLev = Lev.GetLength(0); switch (Contourtype) { case Contour.ContourType.Line: { Color = new Color[numLev]; for (int i = 0; i < numLev; i++) { Color[i] = tomPaletteEditor1.GetColor(Lev[i]); } } break; case Contour.ContourType.Polygon: { Color = new Color[numLev - 1]; for (int i = 0; i < numLev - 1; i++) { Color[i] = tomPaletteEditor1.GetColor(Lev[i] + (Eve / 2)); } } break; } DialogResult = DialogResult.OK; Close(); }
private void DebuggerWindow(int ID) { if (GUI.Button(backButton, "➡")) { le = Lev.Root; } if (GUI.Button(closeButton, "×")) { isShowWindow = false; isShowLog = false; } if (GUI.Button(fullButton, "■")) { isFullScreen = !isFullScreen; } if (GUI.Button(lockrect, "●")) { isLockWindow = !isLockWindow; } if (!isFullScreen) { scrollPosition = GUILayout.BeginScrollView(scrollPosition, GUILayout.Width(390), GUILayout.Height(175)); } else { scrollPosition = GUILayout.BeginScrollView(scrollPosition, GUILayout.Width(390)); } switch (le) { case Lev.Root: { GUILayout.Label($"解像度 : {resolution_info.PadLeft(71)}"); GUILayout.Label($"リフレッシュレート : {refleshRate.PadLeft(55)}"); if (GUILayout.Button($"デバイス情報 >>", "Label")) { le = Lev.Setting; } GUILayout.Label(HorizontalStick); foreach (var classdata in classData) { if (GUILayout.Button(classdata + " >>", "Label")) { possession = classdata; le = Lev.Manager; } } GUILayout.Label(HorizontalStick); GUILayout.Label($"ターゲットFPS : {targetFrame.ToString().PadLeft(65)}"); GUILayout.Label($"FPS : {fps.ToString("F1").PadLeft(79)} "); GUILayout.Label($"タイムスケール : {Time.timeScale.ToString().PadLeft(65)}"); GUILayout.Label(HorizontalStick); GUILayout.Label($"全オブジェクト総数 :{totalObj.ToString().PadLeft(58)}"); GUILayout.Label($"GC Count : {GC.CollectionCount(0).ToString().PadLeft(71)}"); GUILayout.Label($"ヒープメモリサイズ[MB] : {AcquisitionHeapMemorySizeory.ToString().PadLeft(49)}"); GUILayout.Label($"メモリサイズ[MB] : {TotalMemoryCapacity.ToString().PadLeft(58)}"); var Percent = (float)AcquisitionHeapMemorySizeory / TotalMemoryCapacity * 100; GUILayout.Label($"使用割合[%] : {Percent.ToString("F1").PadLeft(68)}"); GUILayout.Label(HorizontalStick); if (GUILayout.Button("<Edit>", "Box")) { le = Lev.Edit; } break; } case Lev.Setting: GUILayout.Label("-System Information-", style); ScreenSetting(); GUILayout.Label(HorizontalStick); GUILayout.Label("-Audio-", style); AudioConfiguration(); break; case Lev.Manager: { foreach (var s in this[possession]) { GUILayout.Label(s.Remove(0, possession.Length)); } GUILayout.Label(HorizontalStick); break; } case Lev.Edit: GUILayout.Label($"Edit"); break; } GUILayout.EndScrollView(); if (!isLockWindow) { GUI.DragWindow(titleBarRect); } }
private void AddCurrent() { Lev.Pictures.Insert(0, _currentPicture); Lev.SortPictures(); }
internal List <Polygon> AutoGrass(Polygon p) { double autoGrassThickness = Global.AppSettings.LevelEditor.AutoGrassThickness; List <Polygon> grassPolys = new List <Polygon>(); bool isSky = Lev.IsSky(p); if (!(isSky ^ p.IsCounterClockwise)) { p.ChangeOrientation(); } int i; int j; for (i = 0; i < p.Vertices.Count; i++) { Vector v = p[i + 1] - p[i]; if (Math.Abs(v.Angle) > MaximumGrassAngle) { break; } } for (j = i; j < p.Vertices.Count; j++) { if (Math.Abs((p[j + 1] - p[j]).Angle) <= MaximumGrassAngle) { break; } } var exploredVerts = new HashSet <int>(); j = j % p.Vertices.Count; while (!exploredVerts.Contains(j)) { while (!(Math.Abs((p[j + 1] - p[j]).Angle) <= MaximumGrassAngle)) { exploredVerts.Add(j); j++; j = j % p.Vertices.Count; if (exploredVerts.Contains(j)) { return(grassPolys); } } exploredVerts.Add(j); Vector directionVector = p[j + 1] - p[j]; Vector previousDirectionVector = p[j] - p[j - 1]; Vector previousDirectionVectorNeg = -previousDirectionVector; Vector firstGrassVertex; Vector a = new Vector(p[j].X, p[j].Y + autoGrassThickness / Math.Cos(directionVector.Angle * Constants.DegToRad)); Vector b = new Vector(p[j + 1].X, p[j + 1].Y + autoGrassThickness / Math.Cos(directionVector.Angle * Constants.DegToRad)); if (previousDirectionVectorNeg.Angle > -90 && previousDirectionVectorNeg.Angle < directionVector.Angle) { Vector c = new Vector(p[j].X, p[j].Y + GrassHeight); double s = (Vector.CrossProduct(c, previousDirectionVectorNeg) - Vector.CrossProduct(a, previousDirectionVectorNeg)) / Vector.CrossProduct(directionVector, previousDirectionVectorNeg); double r = (Vector.CrossProduct(a, directionVector) - Vector.CrossProduct(c, directionVector)) / Vector.CrossProduct(previousDirectionVectorNeg, directionVector); if (s > 1) { if (b.X - p[j - 1].X > 0) { firstGrassVertex = a + directionVector.Unit() * (p[j - 1].X - a.X); } else { j++; continue; } } else { if (r > 1) { firstGrassVertex = a + directionVector.Unit() * (p[j - 1].X - a.X); } else if (r > 0) { firstGrassVertex = a + s * directionVector; } else { j++; continue; } } } else if (previousDirectionVectorNeg.Angle < -90) { firstGrassVertex = new Vector(p[j].X, p[j].Y + autoGrassThickness / Math.Cos(directionVector.Angle * Constants.DegToRad)) + directionVector.Unit() * 0.0; } else if (previousDirectionVectorNeg.Angle > 90) { Vector c = p[j].Clone(); double r = (Vector.CrossProduct(a, directionVector) - Vector.CrossProduct(c, directionVector)) / Vector.CrossProduct(previousDirectionVectorNeg, directionVector); firstGrassVertex = c + r * previousDirectionVectorNeg; } else { firstGrassVertex = new Vector(p[j].X, p[j].Y + autoGrassThickness / Math.Cos(directionVector.Angle * Constants.DegToRad)) + directionVector.Unit() * 0.0; } grassPolys.Add(new Polygon()); grassPolys[grassPolys.Count - 1].IsGrass = true; grassPolys[grassPolys.Count - 1].Add(firstGrassVertex); bool found = false; if (Math.Abs((p[j + 2] - p[j + 1]).Angle) <= MaximumGrassAngle) { while (!(Math.Abs((p[j + 2] - p[j + 1]).Angle) > MaximumGrassAngle)) { j++; grassPolys[grassPolys.Count - 1].Add(GeometryUtils.FindPoint(p[j - 1], p[j], p[j + 1], autoGrassThickness)); } j++; found = true; } else { grassPolys[grassPolys.Count - 1].Add(firstGrassVertex + directionVector.Unit() * 0.1); j++; } j = j % p.Vertices.Count; directionVector = p[j] - p[j - 1]; Vector nextDirectionVector = p[j + 1] - p[j]; Vector lastGrassVertex; a = new Vector(p[j - 1].X, p[j - 1].Y + autoGrassThickness / Math.Cos(directionVector.Angle * Constants.DegToRad)); b = new Vector(p[j].X, p[j].Y + autoGrassThickness / Math.Cos(directionVector.Angle * Constants.DegToRad)); if ((nextDirectionVector.Angle < -90 || nextDirectionVector.Angle > 90) && nextDirectionVector.AnglePositive > (-directionVector).AnglePositive) { Vector c = new Vector(p[j].X, p[j].Y + GrassHeight); double s = (Vector.CrossProduct(c, nextDirectionVector) - Vector.CrossProduct(a, nextDirectionVector)) / Vector.CrossProduct(directionVector, nextDirectionVector); if (s > 1) { if (grassPolys[grassPolys.Count - 1].Count < 3) { if (found) { Polygon x = grassPolys[grassPolys.Count - 1]; Vector dirvect = x.Vertices[x.Count - 1] - x.Vertices[x.Count - 2]; lastGrassVertex = x.Vertices[x.Count - 1] - dirvect.Unit() * 0.1; } else { grassPolys.RemoveAt(grassPolys.Count - 1); continue; } } else { continue; } } else { double r = (Vector.CrossProduct(a, directionVector) - Vector.CrossProduct(c, directionVector)) / Vector.CrossProduct(nextDirectionVector, directionVector); if (r > 1) { lastGrassVertex = b - directionVector.Unit() * (b.X - p[j + 1].X); } else { lastGrassVertex = a + s * directionVector; } } } else if (nextDirectionVector.AnglePositive > 270) { lastGrassVertex = new Vector(p[j].X, p[j].Y + autoGrassThickness / Math.Cos(directionVector.Angle * Constants.DegToRad)) - directionVector.Unit() * 0.1; } else if (nextDirectionVector.AnglePositive < 90) { Vector c = p[j].Clone(); double s = (Vector.CrossProduct(a, directionVector) - Vector.CrossProduct(c, directionVector)) / Vector.CrossProduct(nextDirectionVector, directionVector); lastGrassVertex = c + s * nextDirectionVector; } else { lastGrassVertex = new Vector(p[j].X, p[j].Y + autoGrassThickness / Math.Cos(directionVector.Angle * Constants.DegToRad)); } grassPolys[grassPolys.Count - 1].Add(lastGrassVertex); } return(grassPolys); }