private void DrawPaint() { EditorGUILayout.Separator(); BeginGroup(ref showPaint, "Paint"); if (showPaint == true) { BeginLabelWidth(Mathf.Min(85.0f, position.width * 0.5f)); { //currentCoord = (P3D_CoordType)GUI.Toolbar(P3D_Helper.Reserve(20.0f, true), (int)currentCoord, coordNames); currentCoord = P3D_CoordType.UV2; resolution = EditorGUILayout.Slider("Resolution", resolution, 0.0f, 5.0f); scatterPosition = EditorGUILayout.FloatField("Scatter Position", scatterPosition); scatterAngle = EditorGUILayout.Slider("Scatter Angle", scatterAngle, 0.0f, Mathf.PI * 2.0f); scatterScale = EditorGUILayout.Slider("Scatter Scale", scatterScale, 0.0f, 1.0f); //passThrough = EditorGUILayout.Toggle("Pass Through", passThrough); } EndLabelWidth(); } EndGroup(); }
// This causes the current paint operation to get applied to the specified result public bool Paint(P3D_Brush brush, P3D_Result result, P3D_CoordType coord = P3D_CoordType.UV1) { if (result != null) { return(Paint(brush, result.GetUV(coord))); } return(false); }
// This paints all triangles perpendicular to the input position // NOTE: This method requires you to call SetMesh first public void PaintPerpendicularAll(Vector3 position, float maxDistance, P3D_CoordType coord = P3D_CoordType.UV1) { if (CanMeshPaint == true) { position = transform.InverseTransformPoint(position); Paint(tree.FindPerpendicularAll(position, maxDistance), coord); } }
// This causes the current paint operation to get applied to all the specified results public void Paint(List <P3D_Result> results, P3D_CoordType coord = P3D_CoordType.UV1) { if (results != null) { for (var i = 0; i < results.Count; i++) { Paint(results[i], coord); } } }
// This paints all triangles between the input positions // NOTE: This method requires you to call SetMesh first public void PaintBetweenAll(Vector3 startPosition, Vector3 endPosition, P3D_CoordType coord = P3D_CoordType.UV1) { if (CanMeshPaint == true) { startPosition = transform.InverseTransformPoint(startPosition); endPosition = transform.InverseTransformPoint(endPosition); Paint(tree.FindBetweenAll(startPosition, endPosition), coord); } }
// This paints all triangles along the ray // NOTE: This method requires you to call SetMesh first public void PaintBetweenAll(Ray ray, float maxDistance, P3D_CoordType coord = P3D_CoordType.UV1) { if (CanMeshPaint == true) { var startPosition = transform.InverseTransformPoint(ray.origin); var endPosition = startPosition + transform.InverseTransformDirection(ray.direction) * maxDistance; Paint(tree.FindBetweenAll(startPosition, endPosition), coord); } }
public Vector2 GetUV(P3D_CoordType coord) { switch (coord) { case P3D_CoordType.UV1: return(UV1); case P3D_CoordType.UV2: return(UV2); } return(default(Vector2)); }
public static Vector2 GetUV(RaycastHit hit, P3D_CoordType coord) { switch (coord) { case P3D_CoordType.UV1: return(hit.textureCoord); case P3D_CoordType.UV2: return(hit.textureCoord2); } return(default(Vector2)); }
public Vector2 GetUV(P3D_CoordType coord) { if (coord == P3D_CoordType.UV1) { return(this.UV1); } if (coord == P3D_CoordType.UV2) { return(this.UV2); } return(new Vector2()); }
// This causes the current paint operation to get applied to the specified result public void Paint(P3D_Result result, P3D_CoordType coord = P3D_CoordType.UV1) { if (result != null) { switch (coord) { case P3D_CoordType.UV1: Paint(result.UV1); break; case P3D_CoordType.UV2: Paint(result.UV2); break; } } }
public static Vector2 GetUV(RaycastHit hit, P3D_CoordType coord) { if (coord == P3D_CoordType.UV1) { return(hit.textureCoord); } if (coord == P3D_CoordType.UV2) { return(hit.textureCoord2); } return(new Vector2()); }
public static Vector2 GetUV(RaycastHit hit, P3D_CoordType coord) { var uv = default(Vector2); switch (coord) { case P3D_CoordType.UV1: uv = hit.textureCoord; break; case P3D_CoordType.UV2: uv = hit.textureCoord2; break; } return(uv); }
public bool Paint(P3D_Brush brush, List <P3D_Result> results, P3D_CoordType coord = 0) { bool flag = false; if (results != null) { for (int i = 0; i < results.Count; i++) { flag |= this.Paint(brush, results[i], coord); } } return(flag); }
// This causes the current paint operation to get applied to all the specified results public bool Paint(P3D_Brush brush, List <P3D_Result> results, P3D_CoordType coord = P3D_CoordType.UV1) { var painted = false; if (results != null) { for (var i = 0; i < results.Count; i++) { painted |= Paint(brush, results[i], coord); } } return(painted); }
public static Vector2 GetUV(P3D_Result result, P3D_CoordType coord) { var uv = default(Vector2); if (result != null) { switch (coord) { case P3D_CoordType.UV1: uv = result.UV1; break; case P3D_CoordType.UV2: uv = result.UV2; break; } } return(uv); }
public bool Paint(P3D_Brush brush, P3D_Result result, P3D_CoordType coord = 0) => (result != null) && this.Paint(brush, result.GetUV(coord));
public static void PaintBetweenNearest(Vector3 startPosition, Vector3 endPosition, P3D_Brush brush, int raycastMask = -1, P3D_CoordType coord = P3D_CoordType.UV1) { var maxDistance = Vector3.Distance(startPosition, endPosition); if (maxDistance > 0.0f) { var bestPaintable = default(P3D_Paintable); var bestDistance01 = 1.0f; var bestUV = default(Vector2); for (var i = AllPaintables.Count - 1; i >= 0; i--) { var paintable = AllPaintables[i]; var painter = paintable.GetPainter(); if (painter.CanMeshPaint == true) { var startPoint = painter.Transform.InverseTransformPoint(startPosition); var endPoint = painter.Transform.InverseTransformPoint(endPosition); var results = painter.Tree.FindBetweenNearest(startPoint, startPoint + (endPoint - startPoint) * bestDistance01); if (results.Count > 0) { var result = results[0]; if (result.Distance01 < bestDistance01) { bestPaintable = paintable; bestDistance01 = result.Distance01; bestUV = GetUV(result, coord); } } } } var ray = new Ray(startPosition, endPosition - startPosition); var hit = default(RaycastHit); if (Physics.Raycast(ray, out hit, maxDistance * bestDistance01, raycastMask) == true) { bestPaintable = hit.collider.GetComponent <P3D_Paintable>(); bestUV = GetUV(hit, coord); } if (bestPaintable != null) { var painter = bestPaintable.GetPainter(); painter.SetBrush(brush); painter.Paint(bestUV); } } }