Esempio n. 1
0
        Unity3DTileBoundingVolume CreateBoundingVolume(Schema.BoundingVolume boundingVolume, Matrix4x4 transform)
        {
            if (boundingVolume.Box.Count == 12)
            {
                var     box       = boundingVolume.Box;
                Vector3 center    = new Vector3((float)box[0], (float)box[1], (float)box[2]);
                Vector3 halfAxesX = new Vector3((float)box[3], (float)box[4], (float)box[5]);
                Vector3 halfAxesY = new Vector3((float)box[6], (float)box[7], (float)box[8]);
                Vector3 halfAxesZ = new Vector3((float)box[9], (float)box[10], (float)box[11]);

                // TODO: Review this coordinate frame change
                // This does not take into account the coodinate frame of the glTF files and gltfUpAxis
                // https://github.com/AnalyticalGraphicsInc/3d-tiles/issues/280#issuecomment-359980111
                center.x    *= -1;
                halfAxesX.x *= -1;
                halfAxesY.x *= -1;
                halfAxesZ.x *= -1;

                var result = new TileOrientedBoundingBox(center, halfAxesX, halfAxesY, halfAxesZ);
                result.Transform(transform);
                return(result);
            }
            if (boundingVolume.Sphere.Count == 4)
            {
                var     sphere = boundingVolume.Sphere;
                Vector3 center = new Vector3((float)sphere[0], (float)sphere[1], (float)sphere[2]);
                float   radius = (float)sphere[3];
                var     result = new TileBoundingSphere(center, radius);
                result.Transform(transform);
                return(result);
            }
            if (boundingVolume.Region.Count == 6)
            {
                // TODO: Implement support for regions
                Debug.LogError("Regions not supported");
                return(null);
            }
            Debug.LogError("boundingVolume must contain a box, sphere, or region");
            return(null);
        }
 public static bool IsDefined(this Schema.BoundingVolume volume)
 {
     return(volume.Box.Count != 0 || volume.Sphere.Count != 0 || volume.Region.Count != 0);
 }