deltamish 1 Report post Posted February 28, 2018 Hey , I was working on a runtime simulation tool for which I wanted to use the pb_Poly shape to allow user to create meshes of any shape dynamically So decided to appent points in pb_poly shape manually Problem is the points are not getting connected at the end. And thus no poly is drawn Could you be kind enough to let me know how to go around this thanks Regards Share this post Link to post Share on other sites
karl 321 Report post Posted February 28, 2018 At the moment the poly shape functions are not in the public API. I've exposed them for the next update (3.0.2) and will include an API Example showing how to use it. Edit - If you're using the Asset Store version of ProBuilder this might actually work. I haven't tested it. using UnityEngine; using ProBuilder.Core; using ProBuilder.MeshOperations; namespace ProBuilder.Examples { public class CreatePolyShape : MonoBehaviour { public float m_RadiusMin = 1.5f; public float m_RadiusMax = 2f; public float m_Height = 1f; public bool m_FlipNormals = false; pb_Object m_Mesh; void Start() { // Create a new GameObject var go = new GameObject(); // Add a pb_Object component (ProBuilder mesh data is stored here) m_Mesh = go.gameObject.AddComponent<pb_Object>(); InvokeRepeating("Rebuild", 0f, .1f); } void Rebuild() { // Create a circle of points with randomized distance from origin. Vector3[] points = new Vector3[32]; for (int i = 0, c = points.Length; i < c; i++) { float angle = Mathf.Deg2Rad * ((i / (float)c) * 360f); points[i] = new Vector3(Mathf.Cos(angle), 0f, Mathf.Sin(angle)) * Random.Range(m_RadiusMin, m_RadiusMax); } // CreateShapeFromPolygon is an extension method that sets the pb_Object mesh data with vertices and faces // generated from a polygon path. m_Mesh.CreateShapeFromPolygon(points, m_Height, m_FlipNormals); } } } 1 deltamish reacted to this Share this post Link to post Share on other sites
vlevykin 1 Report post Posted March 1, 2018 Hi, it works fine in 2017.3 with ProBuilder from AssetStore, thanks! Just had to change usings. Keep updating API please. We are looking forward to procedurally generate objects in our game. 1 karl reacted to this Share this post Link to post Share on other sites
deltamish 1 Report post Posted March 7, 2018 Hey sorry for the delayed response. Solved the issue it was just I had missed out the following lines and had to add first point again pb_object.ToMesh(); pb_object.Refresh(); Thank you so much for the circle example will use that in my project Share this post Link to post Share on other sites