Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cutting a hole in the wall (Cube in the center of the Cube) #17

Closed
bartekkaminski opened this issue Dec 16, 2020 · 1 comment
Closed

Comments

@bartekkaminski
Copy link

bartekkaminski commented Dec 16, 2020

I have a function that draws a Cube in 3D:

GameObject DrawMesh3D(Vector3 startPoint, Vector3 endPoint, float width, string name)
{
    var between = endPoint - startPoint;
    var distance = Vector3.Distance(startPoint, endPoint);
    var mesh = GameObject.CreatePrimitive(PrimitiveType.Cube);
    mesh.name = name;

    mesh.transform.position = startPoint + (between / 2.0f);
    mesh.transform.LookAt(endPoint);
    mesh.transform.eulerAngles = new Vector3(mesh.transform.eulerAngles.x, mesh.transform.eulerAngles.y - 90f, mesh.transform.eulerAngles.z);
    mesh.transform.localScale = new Vector3(distance, 5f, width);
    mesh.transform.Translate(new Vector3(2000, 2.5f, 0), Space.World);

    mesh.transform.parent = area3D.transform;

    return mesh;
}

Next I would like to cut a hole in this Cube. It is a Wall for me. For this I am creating another Cube and want to call a function Subtract

GameObject wall = domaManager.HoleInWall2D.domaElement.DomaObject3D;
GameObject hole = GameObject.CreatePrimitive(PrimitiveType.Cube);
hole.transform.position = cube.transform.position;
hole.transform.localScale = Vector3.one * 1.5f;

// Perform boolean operation
CSG_Model result = Boolean.Subtract(wall, hole);

// Create a gameObject to render the result
var composite = new GameObject();
composite.name = "New Object TEST";
composite.AddComponent<MeshFilter>().sharedMesh = result.mesh;
composite.AddComponent<MeshRenderer>().sharedMaterials = result.materials.ToArray();

I am getting this error:
image

@karl-
Copy link
Owner

karl- commented Aug 19, 2021

Should be fixed as of e2d2e1d, please re-open if not addressed.

@karl- karl- closed this as completed Aug 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants