////////////////////////////////////////////////////////////////////////////////////////////////////////////// // =============================================== CONSTRUCTORS =========================================== // ////////////////////////////////////////////////////////////////////////////////////////////////////////////// public OcTree() { this.nodeLines = new List <Utils.LineWHistory>(); this.childNodes = new OcTree[8]; this.activeNodes = 0; this.parent = null; // this.lifeCyclesLeft = OcTree.NR_LIFE_CYCLES_INIT; this.region = new BoundingBox(Vector3.Zero, Vector3.Zero); this.minVolSize = VOLUME_SIZE_MAX; this.TreeBuilt = false; }
private OcTree createNode(BoundingBox _region, List <Utils.LineWHistory> _lines, double _minVolSize) { if (_lines == null || _lines.Count == 0) { return(null); } OcTree n = new OcTree(); n.region = _region; n.nodeLines = _lines; n.minVolSize = _minVolSize; n.parent = this; return(n); }
////////////////////////////////////////////////////////////////////////////////////////////////////////////// // =============================================== CONSTRUCTORS =========================================== // ////////////////////////////////////////////////////////////////////////////////////////////////////////////// #region CONSTRUCTOR public OcTreeManager() { this.root = new OcTree(); // OcTree CELL visualization this.cell = new LineGeometryModel3D() { Geometry = OcTreeManager.CellFrame, Color = SharpDX.Color.White, Thickness = 0.5, Visibility = Visibility.Visible, IsHitTestVisible = false, Transform = new MatrixTransform3D(Matrix3D.Identity), Instances = new List <SharpDX.Matrix>(), }; this.Children.Add(cell); // Collision MARKERS visualization this.colPointMarker = new LineGeometryModel3D() { Geometry = OcTreeManager.IntPoint, Color = SharpDX.Color.Red, Thickness = 1.5, Visibility = Visibility.Visible, IsHitTestVisible = false, Transform = new MatrixTransform3D(Matrix3D.Identity), Instances = new List <SharpDX.Matrix>(), }; this.Children.Add(colPointMarker); // Collision REGIONS visualization this.cellFill = new MeshGeometryModel3D() { Geometry = OcTreeManager.ChamferedBoxMesh, Material = OcTreeManager.RedTransparent, Visibility = Visibility.Visible, IsHitTestVisible = false, Transform = new MatrixTransform3D(Matrix3D.Identity), Instances = new List <SharpDX.Matrix>(), }; this.Children.Add(cellFill); // Visible REGIONS visualization this.cellVisible = new MeshGeometryModel3D() { Geometry = OcTreeManager.ChamferedBoxMesh, Material = OcTreeManager.YellowTransparent, Visibility = Visibility.Visible, IsHitTestVisible = false, Transform = new MatrixTransform3D(Matrix3D.Identity), Instances = new List <SharpDX.Matrix>(), }; this.Children.Add(cellVisible); // DEBUG this.cellVisibleNormals = new LineGeometryModel3D() { Geometry = OcTreeManager.ChamferedBoxMesh_Normals, Color = Color.DarkBlue, Thickness = 0.5, Visibility = Visibility.Hidden, IsHitTestVisible = false, Transform = new MatrixTransform3D(Matrix3D.Identity), Instances = new List <SharpDX.Matrix>(), }; this.Children.Add(cellVisibleNormals); // DEBUG // ------------------------------------ OBJECT SNAP -------------------------------------- // this.PointsCollision = new List <Point3D>(); this.PointsVisible_End = new List <Point3D>(); this.PointsVisible_Mid = new List <Point3D>(); this.snapMarker = new LineGeometryModel3D() { Geometry = OcTreeManager.EndPoint, Color = SharpDX.Color.Yellow, Thickness = 1, Visibility = Visibility.Hidden, IsHitTestVisible = false, Transform = new MatrixTransform3D(Matrix3D.Identity), }; this.Children.Add(this.snapMarker); // ------------------------------------ OBJECT SNAP -------------------------------------- // // commands this.CheckForCollisionsSimpleCmd = new RelayCommand((x) => CheckForCollisionSimpleCommand(), (x) => CanExecute_CheckForCollisionsCommand()); this.CheckForCollisionsCmd = new RelayCommand((x) => CheckForCollisionsCommand(), (x) => CanExecute_CheckForCollisionsCommand()); this.CheckForVisibilitySimpleCmd = new RelayCommand((x) => CheckForVisibilitySimpleCommand(x), (x) => CanExecute_CheckForVisibilityCommand(x)); this.CheckForVisibilityCmd = new RelayCommand((x) => CheckForVisibilityCommand(x), (x) => CanExecute_CheckForVisibilityCommand(x)); this.UpdateOcTreeCmd = new RelayCommand((x) => UpdateOcTree()); this.CleanVisualAidsCmd = new RelayCommand((x) => CleanUpCells()); }