public static List <Mesh> Intersect(GameObject _objectA, GameObject _objectB, CSGMeshingSettings _meshSettings) { CSGModel modelA = new CSGModel(_objectA); CSGModel modelB = new CSGModel(_objectB); CSGNode nodeA = new CSGNode(modelA.ToPolygons()); CSGNode nodeB = new CSGNode(modelB.ToPolygons()); return(CSGNode.Intersect(nodeA, nodeB, _meshSettings)); }
public static List <Mesh> NVSubtract(GameObject _objectA, GameObject _objectB, CSGMeshingSettings _meshSettings) { CSGModel modelA = new CSGModel(_objectA); CSGModel modelB = new CSGModel(_objectB); CSGModel modelC = new CSGModel(_objectA); CSGModel modelD = new CSGModel(_objectB); CSGNode nodeA = new CSGNode(modelA.ToPolygons()); CSGNode nodeB = new CSGNode(modelB.ToPolygons()); CSGNode nodeC = new CSGNode(modelC.ToPolygons()); CSGNode nodeD = new CSGNode(modelD.ToPolygons()); return(CSGNode.NVSubtract(nodeA, nodeB, nodeC, nodeD, _meshSettings)); }
// Return a new CSG solid representing space in this solid but not in the // solid `csg`. Neither this solid nor the solid `csg` are modified. public static List <Mesh> HVSubtract(CSGNode _nodeAIn, CSGNode _nodeBIn, CSGMeshingSettings _meshSettings) { List <Mesh> resultantMeshes = new List <Mesh>(); CSGNode nodeA = _nodeAIn.Clone(); CSGNode nodeB = _nodeBIn.Clone(); nodeA.ClipTo(nodeB); CSGModel resultantModels = new CSGModel(nodeA.AllPolygons()); resultantModels.SubDivideMesh(_meshSettings); resultantMeshes.Add(resultantModels.ToMesh()); return(resultantMeshes); }
// Return a new CSG solid representing space in either this solid or in the // solid `csg`. Neither this solid nor the solid `csg` are modified. public static List <Mesh> NVUnion(CSGNode _nodeAIn, CSGNode _nodeBIn, CSGMeshingSettings _meshSettings) { List <Mesh> resultantMeshes = new List <Mesh>(); CSGNode nodeA = _nodeAIn.Clone(); CSGNode nodeB = _nodeBIn.Clone(); nodeA.Build(nodeB.AllPolygons()); CSGModel resultantModel = new CSGModel(nodeA.AllPolygons()); resultantModel.SubDivideMesh(_meshSettings); resultantMeshes.Add(resultantModel.ToMesh()); return(resultantMeshes); }
public static List <Mesh> NVIntersect(GameObject _objectA, GameObject _objectB, CSGMeshingSettings _meshSettings) { Mesh mesh = _objectB.GetComponent <MeshFilter>().mesh; GameObject planeRight = GameObject.Instantiate(_objectB); planeRight.AddComponent <DestroyOnLateUpdate>(); GameObject planeLeft = GameObject.Instantiate(_objectB); planeLeft.AddComponent <DestroyOnLateUpdate>(); GameObject planeUP = GameObject.Instantiate(_objectB); planeUP.AddComponent <DestroyOnLateUpdate>(); GameObject planeBack = GameObject.Instantiate(_objectB); planeBack.AddComponent <DestroyOnLateUpdate>(); GameObject planeFront = GameObject.Instantiate(_objectB); planeFront.AddComponent <DestroyOnLateUpdate>(); planeRight.transform.position = _objectB.transform.position + new Vector3(mesh.bounds.max.x * planeRight.transform.localScale.x, 0.0f, 0.0f); planeRight.transform.Rotate(new Vector3(0.0f, 0.0f, 90.0f)); planeLeft.transform.position = _objectB.transform.position + new Vector3(mesh.bounds.min.x * planeLeft.transform.localScale.x, 0.0f, 0.0f); planeLeft.transform.Rotate(new Vector3(0.0f, 0.0f, -90.0f)); planeUP.transform.position = _objectB.transform.position; planeUP.transform.Rotate(new Vector3(180.0f, 0.0f, 0.0f)); planeBack.transform.position = _objectB.transform.position + new Vector3(0.0f, 0.0f, mesh.bounds.max.z * planeRight.transform.localScale.z); planeBack.transform.Rotate(new Vector3(-90.0f, 0.0f, 0.0f)); planeFront.transform.position = _objectB.transform.position + new Vector3(0.0f, 0.0f, mesh.bounds.min.z * planeRight.transform.localScale.z); planeFront.transform.Rotate(new Vector3(90.0f, 0.0f, 0.0f)); CSGModel modelA = new CSGModel(_objectA); CSGModel modelB = new CSGModel(planeRight); CSGModel modelC = new CSGModel(planeLeft); CSGModel modelD = new CSGModel(planeUP); CSGModel modelE = new CSGModel(planeBack); CSGModel modelF = new CSGModel(planeFront); CSGNode nodeA = new CSGNode(modelA.ToPolygons()); CSGNode nodeB = new CSGNode(modelB.ToPolygons()); CSGNode nodeC = new CSGNode(modelC.ToPolygons()); CSGNode nodeD = new CSGNode(modelD.ToPolygons()); CSGNode nodeE = new CSGNode(modelE.ToPolygons()); CSGNode nodeF = new CSGNode(modelF.ToPolygons()); return(CSGNode.NVIntersect(nodeA, nodeB, nodeC, nodeD, nodeE, nodeF, _meshSettings)); }
// Return a new CSG solid representing space in this solid but not in the // solid `csg`. Neither this solid nor the solid `csg` are modified. public static List <Mesh> NVSubtract(CSGNode _nodeAIn, CSGNode _nodeBIn, CSGNode _nodeCIn, CSGNode _nodeDIn, CSGMeshingSettings _meshSettings) { List <Mesh> resultantMeshes = new List <Mesh>(); CSGNode nodeA = _nodeAIn.Clone(); CSGNode nodeB = _nodeBIn.Clone(); nodeA.ClipTo(nodeB); CSGNode nodeC = _nodeCIn.Clone(); CSGNode nodeD = _nodeDIn.Clone(); nodeD.Invert(); nodeC.ClipTo(nodeD); CSGModel resultantModelA = new CSGModel(nodeA.AllPolygons()); CSGModel resultantModelB = new CSGModel(nodeC.AllPolygons()); resultantMeshes.Add(resultantModelA.ToMesh()); resultantMeshes.Add(resultantModelB.ToMesh()); return(resultantMeshes); }
// Return a new CSG solid representing space both this solid and in the // solid `csg`. Neither this solid nor the solid `csg` are modified. public static List <Mesh> NVIntersect(CSGNode _nodeAIn, CSGNode _nodeBIn, CSGNode _nodeCIn, CSGNode _nodeDIn, CSGNode _nodeEIn, CSGNode _nodeFIn, CSGMeshingSettings _meshSettings) { List <Mesh> resultantMeshes = new List <Mesh>(); CSGNode nodeA = _nodeAIn.Clone(); CSGNode nodeB = _nodeBIn.Clone(); CSGNode nodeC = _nodeCIn.Clone(); CSGNode nodeD = _nodeDIn.Clone(); CSGNode nodeE = _nodeEIn.Clone(); CSGNode nodeF = _nodeFIn.Clone(); nodeA.ClipTo(nodeB); nodeA.ClipTo(nodeC); nodeA.ClipTo(nodeD); nodeA.ClipTo(nodeE); nodeA.ClipTo(nodeF); CSGModel resultantModels = new CSGModel(nodeA.AllPolygons()); resultantModels.SubDivideMesh(_meshSettings); resultantMeshes.Add(resultantModels.ToMesh()); return(resultantMeshes); }
public CSGSubModel(CSGModel _parent) { m_parent = _parent; }