realtime CSG   FEATURES TRY DOCUMENTATION UPDATES FORUMS FEEDBACK

MANUAL
KEYBOARD LAYOUT
EDITOR API
VIDEOS

Editor API

Note: Both the editor API, and the documentation for it, are a work in progress.


public class CSGBrush

This component represents a single convex CSG brush. Setting it's OperationType field allows you to control if this brush will be Additive, Subtractive or Intersecting.

public class CSGOperation

This component represents a branch in the CSG tree that can contain multiple brushes and/or operations, that themselves can contain multiple brushes and operations.

When the HandleAsOne field is set to true, then every time you select one of the children of this operation, you will select the entire operation. This is useful for grouping things.

Setting it's OperationType field allows you to control if this operation will be Additive, Subtractive or Intersecting.

If you set PassThrough to true, then it will still act as a single group in the editor, but it's ignored as an operation by the CSG algorithm. This is useful in combination with HandleAsOne to group things together without side effects.

public class CSGModel

This component represents a CSG model. This represents all the meshes that will be generated from all it's child brushes and operations. At runtime all the meshes will replace the model.



public static class CSGModelManager

public static void ForceRebuild()

This method allows you to force a full rebuild of all models in the current loaded scenes. If any models has been changed, any static method with an CSGModelModifiedEventAttribute will be called (see below).

public static void EnsureBuildFinished()

When the method EnsureBuildFinished is finished, all changes to all models are guaranteed to be handled, and all meshes updated. If any models has been changed, any static method with an CSGModelModifiedEventAttribute will be called (see below).

public static CSGModel[] GetAllModel()

Returns all the current active models in the currently loaded scene(s) and returns them in an array.

public static GameObject[] GetModelMeshes(CSGModel model)

Returns all the meshes that have been generated for the given model (if any).



public class CSGModelModifiedEventAttribute : Attribute

The CSGModelModifiedEvent attribute allows you to add create a callback that is called every time a model is modified:

[CSGModelModifiedEvent]
static void OnCSGModelModified(CSGModel modifiedModel, GameObject[] modifiedMeshes)
{
    // ... handle the event here ...
}

The model parameter is the model that has been modified

The modifiedMeshes parameter holds all the meshes of this model, that have changed since the last time it's been updated. It will not give you all it's meshes, only the modified ones.



public static class BrushFactory

public static CSGBrush 
       CreateBrushFromPlanes(
                    Transform           parent, 
                    string              brushName, 
                    UnityEngine.Plane[] planes, 
                    Vector3[]           tangents, 
                    Vector3[]           binormals,
                    Material[]          materials,
                    Matrix4x4[]         textureMatrices,
                    TextureMatrixSpace  textureMatrixSpace)

This method creates a brush by defining it as a shape enclosed by a number of infinite planes. Only valid shapes defined by the planes will create a brush.

Planes, tangents, binormals, materials and textureMatrices all need to have the same length.

Tangents, binormals, materials and textureMatrices are optional and will be replaced with appropriate defaults if not set.

The textureMatrices are only allowed to rotate, translate and scale the texture coordinates. The textureMatrixSpace allows you to specifiy if the given texture matrices calculate the texture coordinates for all the vertices, in world-space or plane-space.

public static bool 
       SetBrushFromPlanes(
                    CSGBrush            brush, 
                    UnityEngine.Plane[] planes, 
                    Vector3[]           tangents, 
                    Vector3[]           binormals, 
                    Material[]          materials, 
                    Matrix4x4[]         textureMatrices, 
                    TextureMatrixSpace  textureMatrixSpace)

This method modifies an existing brush with a new shape defined as a shape enclosed by a number of infinite planes. Only valid shapes will work.

Planes, tangents, binormals, materials and textureMatrices all need to have the same length.

Tangents, binormals, materials and textureMatrices are optional and will be replaced with appropriate defaults if not set.

The textureMatrices are only allowed to rotate, translate and scale the texture coordinates. The textureMatrixSpace allows you to specifiy if the given texture matrices calculate the texture coordinates for all the vertices, in world-space or plane-space.

public static CSGBrush 
       CreateCubeBrush(Transform parent, 
                       string brushName, 
                       Vector3 size)

This method creates a cube with a given size.

public static bool 
       SetBrushCubeMesh(CSGBrush brush, 
                        Vector3 size)

This method modifies an existing brush to become a cube with a given size.