Jump to content

bzkarcade

Members
  • Content count

    3
  • Joined

  • Last visited

  1. bzkarcade

    Create a custom shape via script

    Thanks for your fast reply, in fact works, but, it's like I add a new face and the two previous ones stay. In Back view the figure is seen, with the overlap of one of the previous faces 004, but in front view nope. If I deleted the original faces or detach the new face, I ccan fix it So in the code I delete the previous faces, although rare This is my complete code: pb = new pb_Object(); List<Vector3> points = new List<Vector3>(); points.Add(new Vector3(160, 76, 0)); points.Add(new Vector3(69, 165, 0)); points.Add(new Vector3(67, 354, 0)); points.Add(new Vector3(169, 451, 0)); points.Add(new Vector3(343, 451, 0)); points.Add(new Vector3(445, 354, 0)); points.Add(new Vector3(443, 165, 0)); points.Add(new Vector3(352, 76, 0)); pb = pb_Object.CreateInstanceWithPoints(points.ToArray()); List<int> indices = new List<int>(); for (int i = 0; i < points.Count; i++) { indices.Add(i); } List<pb_Face> trashFaces = pb.faces.ToList(); pb_Face baseFace = new pb_Face(); pb.CreatePolygon(indices, false, out baseFace); pb.DeleteFaces(trashFaces); pb.ToMesh(); pb.Refresh(); In cap_006 finally have what I want PD: at this moment I do not need to have both faces of the figure, but if later I want my figure to have the back face, now I do it with the fillhole option in editor. Would there be an easy way to do it?
  2. bzkarcade

    Create a custom shape via script

    Thanks, in that moment, I could already make it work with some basic figures, but in some others with such vertices I have problems. For example 160,76,0 69,165,0 67,354,0 169,451,0 343,451,0 445,354,0 443,165,0 352,76,0 Produce ghost mesh in cap_002.PNG when what I'm looking for is cap_003.PNG I think it's the order of the vertices, but I'm not sure
  3. Hello, it's my first question. I need to create shapes based on vertices as in the editor (capture attached) I try to find something to create meshes procedurally, currently have this code, but it produces an exception pb = new pb_Object(); List<Vector3> points = new List<Vector3>(); points.Add(new Vector3(0, 0, 0)); points.Add(new Vector3(1, 0, 0)); points.Add(new Vector3(0, 1, 0)); points.Add(new Vector3(1, 1, 0)); //same as in editor pb_ActionResult ar = pb.CreateShapeFromPolygon(points, 1, false); pb.ToMesh(); pb.Refresh(); Exception: NullReferenceException UnityEngine.Component.GetComponent[MeshFilter] () (at C:/buildslave/unity/build/artifacts/generated/common/runtime/ComponentBindings.gen.cs:48) pb_Object.get_msh () pb_Object.ToMesh (MeshTopology preferredTopology) pb_Object.ToMesh () how can I do it?, it would help me a lot
×