Наследование: MonoBehaviour
Пример #1
0
        /* Adds four bounding boxes to the bounding hierarchy, each taking up a quadrant of the original bounding box. */
        public static void AddBoundingBoxChildren(BoxVolume boxVolume)
        {
            //    BoundingBox box = (BoundingBox)boxVolume.BoundingShape;
            //    Vector3[] corners = box.GetCorners();

            //    //May need some adjustments. Atm the min is the lowest X value of each corner. Might cause problems?
            //    //It would be more correct but more annoying to calculate the min for each sub-box instead of just using corners and the center.
            //    boxVolume.Children.Add(new BoundingBox(corners[0], boxVolume.Center));
            //    boxVolume.Children.Add(new BoundingBox(boxVolume.Center, corners[1]));
            //    boxVolume.Children.Add(new BoundingBox(boxVolume.Center, corners[2]));
            //    boxVolume.Children.Add(new BoundingBox(corners[3], boxVolume.Center));
        }
Пример #2
0
    static public void CreateSphereVolume()
    {
        GameObject newObject = new GameObject("Box Volume");

        if (SceneView.currentDrawingSceneView)
        {
            SceneView.currentDrawingSceneView.MoveToView(newObject.transform);
        }
        BoxVolume boxVolume = (BoxVolume)newObject.AddComponent <BoxVolume>();

        boxVolume.enabled = false;
        boxVolume.enabled = true;
    }
Пример #3
0
 private void BuildBoxVolue(PVSVoxel[,,] all, BoxVolume v)
 {
     for (int x = v.xMin; x <= v.xMax; x++)
     {
         for (int y = v.yMin; y <= v.yMax; y++)
         {
             for (int z = v.zMin; z <= v.zMax; z++)
             {
                 v.Voxels.Add(all[x, y, z]);
                 all[x, y, z] = null;
             }
         }
     }
 }
Пример #4
0
        public void BuildBoxList(PVSBuilder builder, List <CombineVoxel.BoxVolume> bvs)
        {
            var       vxFull = FullFill(builder);
            BoxVolume bv     = null;

            do
            {
                bv = FindBest(vxFull);
                if (bv != null)
                {
                    bvs.Add(bv);
                }
            } while (bv != null);
        }
Пример #5
0
    static public void CreateVolume()
    {
        GameObject newObject = new GameObject("Box Volume");

        if (UnityEditor.SceneView.currentDrawingSceneView)
        {
            UnityEditor.SceneView.currentDrawingSceneView.MoveToView(newObject.transform);
        }
        BoxVolume boxVolume = (BoxVolume)newObject.AddComponent <BoxVolume>();

        boxVolume.volumeShader = "Advanced SS/Volumetric/Box Volume";
        boxVolume.enabled      = false;
        boxVolume.enabled      = true;
    }
Пример #6
0
        private BoxVolume FindBest(PVSVoxel[,,] all)
        {
            int       maxNum = 0;
            BoxVolume result = new BoxVolume(this);

            for (int x = 0; x < all.GetLength(0); x++)
            {
                for (int y = 0; y < all.GetLength(1); y++)
                {
                    for (int z = 0; z < all.GetLength(2); z++)
                    {
                        if (all[x, y, z] == null)
                        {
                            continue;
                        }

                        int xMin = 0;
                        int yMin = 0;
                        int zMin = 0;
                        int xMax = 0;
                        int yMax = 0;
                        int zMax = 0;
                        var num  = GetExtendNum(all, all[x, y, z], ref xMin, ref yMin, ref zMin, ref xMax, ref yMax, ref zMax);
                        if (num > maxNum)
                        {
                            maxNum      = num;
                            result.xMin = xMin;
                            result.yMin = yMin;
                            result.zMin = zMin;

                            result.xMax = xMax;
                            result.yMax = yMax;
                            result.zMax = zMax;
                        }
                    }
                }
            }
            if (maxNum == 0)
            {
                return(null);
            }
            else
            {
                BuildBoxVolue(all, result);
            }

            return(result);
        }