I am thinking of using ProBuilder for procedural level generation. But it seems there is no API documentation available anywhere. The documentation does not contain any information about the API and FAQ just says “The ProBuilder API is currently considered to be in beta. It will change before the final release.”
There is this ProBuilder API example repository, but it just contains a couple of examples which are not really documented/explained.
So is it really true that there is no any kind of documentation for the ProBuilder API available yet? If so, is there a roadmap for the ProBuilder that would indicate when the API would be officially released and supported?
It’s true that currently there is not any official documentation for the API. However, preparing the code and documentation for public use is what I’ve been doing for the last few months. The 4.0.0 update introduces a public API along with a scripting reference.
There is not a set release date yet, but I anticipate it within the next few weeks.
Thanks for the answer, @kaarrrllll . I have been toying with the API examples and it seems it is quite straight forward in terms of creating geometry. But will the API support all the geometry editing methods as well? In other words, will everything that is possible from the ProBuilder editor GUI be also possible via scripting? What I am especially interested are the boolean operations (which are now marked as experimental).
I’ve been playing with CSG and while it does work, it creates a real dogs-breakfast of the mesh after a couple of operations. The tris count skyrockets to the point where it would be unusable on mobile and eventually the mesh breaks catastrophically. It might be fine if we had a solid and efficient way of optimizing/simplifying the mesh between operations, but for my purposes right now it seems unworkable.
Other issues include:
Not working with complicated or merged pb_objects, or pb_objects where extrude was used.
Losing nice quad face selection ability and can only select triangles.
public static pb_Object ExtractIntersection(GameObject source, GameObject stamp)
{
var sourcePb = source.GetComponent<pb_Object>();
var sourceMeshFilter = source.GetComponent<MeshFilter>();
var originalCenter = sourceMeshFilter.sharedMesh.bounds.center;
// Create a mesh comprising only parts of the original mesh that overlap with the stamp.
var intersectionMesh = CSG.Intersect(source, stamp);
// Create a game object and pb_object from mesh
var intersectionPb = ProBuilderize(intersectionMesh);
// Cut out the intersection from the original, so that the original object remains the same visually but is now split into two objects.
var newMesh = CSG.Subtract(source, intersectionPb.gameObject);
sourceMeshFilter.sharedMesh = newMesh;
//// Update the pb_object to reflect changes to the underlying mesh.
ResetPbObjectWithMeshFilter(sourcePb, true);
// The modified mesh coming out of CSG probably needs to be repositioned relative to previous pivot.
var newCenter = sourceMeshFilter.sharedMesh.bounds.center;
var offset = originalCenter - newCenter;
var indices = sourceMeshFilter.sharedMesh.GetIndices(0);
sourcePb.TranslateVertices(indices, offset);
CenterPivot(sourcePb, indices);
sourcePb.ToMesh();
sourcePb.Refresh();
//pb_Smoothing.ApplySmoothingGroups(sourcePb, sourcePb.faces, 1, pb_Vertex.GetVertices(newMesh).Select(x => x.normal).ToArray());
//CollapseCoincidentVertices(sourcePb, sourcePb.faces);
return intersectionPb;
}
I think we need two things, a mesh simplification function and an easy way to clean a mesh, for example, if i create a rectangle box platform and a circular platform to place on the end of it, drag them over each other, then click a button and it strips all the overlapping parts.
Currently unless i’m missing something, if i use ‘merge objects’ it keeps them intact and if i want to properly merge them i have to go in and edit out all the internal parts manually.
Another related and frustrating thing is that it doesn’t sub-divide faces ‘properly’ when the faces next to them have already been sub-divided and extruded. This is pretty limiting for progressive modifications, we’ll end up having to know in advance and sub-divide everything up front.
In the video there, it knows already that it is a single big square face so it could re-do its layout to 2x2/2 tri
I see. I take that currently ProBuilder API does not expose CSG in any way, but it will be in the future. So right now my only option is to use CSG “in parallel” with ProBuilder?
Hi @kaarrrllll , still looking forward to 4.0.0 and the docs!. In particular I’d like to clear smoothing groups and triangulate objects from the API, but I can’t seem to find it. Is this already available in 3.X or do I need to wait for 4.0?