private void GeneralSettings(RageSpline rageSpline) { EditorGUIUtility.LookLikeControls(170f, 10f); GuiExtensions.Vertical (GUI.skin.box, ( ) => { GuiExtensions.Horizontal (( ) => EditorGUILayout.LabelField (" General:", "")); var vDensity = EditorGUILayout.IntField(" Vertex density", rageSpline.VertexDensity); if (_currentVertexDensity != vDensity) { _currentVertexDensity = vDensity; rageSpline.VertexDensity = vDensity; } var vCount = EditorGUILayout.IntField (" Vertex count", !rageSpline.lowQualityRender ? rageSpline.GetVertexCount() : rageSpline.vertexCount); if (vCount != _currentVertexCount) { _currentVertexCount = vCount; rageSpline.SetVertexCount(vCount); } rageSpline.SetAntialiasingWidth (EditorGUILayout.FloatField (" Anti-aliasing width", rageSpline.GetAntialiasingWidth())); rageSpline.SetOptimize (EditorGUILayout.Toggle (" Optimize", rageSpline.GetOptimize())); if (rageSpline.GetOptimize()) rageSpline.SetOptimizeAngle(EditorGUILayout.FloatField(" Optimize Angle", rageSpline.GetOptimizeAngle())); rageSpline.PerspectiveMode = EditorGUILayout.Toggle(" 3D Mode", rageSpline.PerspectiveMode); if (rageSpline.CurrentPerspective != rageSpline.PerspectiveMode) { rageSpline.SwitchPerspectiveMode(); EditorUtility.SetDirty(target); rageSpline.CurrentPerspective = rageSpline.PerspectiveMode; rageSpline.RefreshMeshInEditor(true,true,true); } displayOptions = EditorGUILayout.Foldout(displayOptions, " Display Options"); if (displayOptions) { rageSpline.showSplineGizmos = EditorGUILayout.Toggle(" Show spline gizmos", rageSpline.showSplineGizmos); rageSpline.showOtherGizmos = EditorGUILayout.Toggle(" Show other gizmos", rageSpline.showOtherGizmos); rageSpline.showWireFrameInEditor = EditorGUILayout.Toggle(" Show wireframe", rageSpline.showWireFrameInEditor); rageSpline.hideHandles = !(EditorGUILayout.Toggle(" Show handles", !rageSpline.hideHandles)); rageSpline.ShowTriangleCount = EditorGUILayout.Toggle(" Show tri count", rageSpline.ShowTriangleCount); if (rageSpline.ShowTriangleCount) EditorGUILayout.FloatField(" Triangle Count", rageSpline.GetTriangleCount()); } }); EditorGUILayout.Separator(); }
private static void GenerateMesh(RageSpline rs, bool refreshTriangulation) { // if(rs.GetFill() != RageSpline.Fill.None) // rs.ShiftOverlappingControlPoints(); bool fillAntialiasing = false; float aaWidth = rs.GetAntialiasingWidth(); if (aaWidth > 0f) { if (rs.inverseTriangleDrawOrder) { fillAntialiasing = true; } else if (rs.GetOutline() == RageSpline.Outline.None || Mathf.Abs(rs.GetOutlineNormalOffset()) > (rs.GetOutlineWidth() + (aaWidth))) { fillAntialiasing = true; } } bool outlineAntialiasing = rs.GetAntialiasingWidth() > 0f; bool multipleMaterials = false; var renderer = rs.GetComponent <Renderer>(); if (renderer != null) { if (renderer.sharedMaterials.GetLength(0) > 1) { multipleMaterials = true; } } RageSpline.RageVertex[] outlineVerts = rs.GenerateOutlineVerts(outlineAntialiasing, multipleMaterials); RageSpline.RageVertex[] fillVerts = rs.GenerateFillVerts(fillAntialiasing, multipleMaterials); int vertexCount = outlineVerts.Length + fillVerts.Length; Vector3[] verts = new Vector3[vertexCount]; Vector2[] uvs = null; Vector2[] uvs2 = null; if (rs.PinUvs) { uvs = new Vector2[vertexCount]; uvs2 = new Vector2[vertexCount]; } Color[] colors = new Color[vertexCount]; for (int i = 0; i < fillVerts.Length; i++) { verts[i] = fillVerts[i].position; colors[i] = fillVerts[i].color; if (uvs == null) { continue; } uvs[i] = fillVerts[i].uv1; uvs2[i] = fillVerts[i].uv2; } for (int i = 0; i < outlineVerts.Length; i++) { int v = i + fillVerts.Length; verts[v] = outlineVerts[i].position; colors[v] = outlineVerts[i].color; if (uvs == null) { continue; } uvs[v] = outlineVerts[i].uv1; uvs2[v] = outlineVerts[i].uv2; } var mFilter = rs.GetComponent(typeof(MeshFilter)) as MeshFilter; if (verts.Length > 0) { verts[0] += new Vector3(0f, 0f, -0.001f); } if (mFilter != null) { var mesh = mFilter.sharedMesh; if (mesh == null) { mesh = new Mesh(); } if (refreshTriangulation) { mesh.Clear(); } //if (rs.optimize) Debug.Log ("mesh verts: " + mesh.vertices.Length + " | triangs: " + mesh.triangles.Length); mesh.vertices = verts; if (refreshTriangulation) { rs.GenerateTriangles(mesh, fillVerts, new RageSpline.RageVertex[0], outlineVerts, fillAntialiasing, false, outlineAntialiasing, multipleMaterials); } if (rs.PinUvs) { mesh.uv = uvs; mesh.uv2 = uvs2; } mesh.colors = colors; mesh.RecalculateBounds(); mFilter.sharedMesh = mesh; } }