public static PotatoBox MergePotatoBox(PotatoBox a, PotatoBox b)
        {
            Vector3 pos = Vector3.Add(a.Position, b.Position) * 0.5;
            Vector3 max = Vector3.Max(a.Max, b.Max);
            Vector3 min = Vector3.Max(a.Min, b.Min);

            return(new PotatoBox(pos, min, max));
        }
        public static bool Intersect(Ray ray, PotatoBox box, ref double distance)
        {
            double tx1 = (box.Min.X - ray.Origin.X) * ray.InverseDirection.X;
            double tx2 = (box.Max.X - ray.Origin.X) * ray.InverseDirection.X;

            double tmin = Math.Min(tx1, tx2);
            double tmax = Math.Max(tx1, tx2);

            double ty1 = (box.Min.Y - ray.Origin.Y) * ray.InverseDirection.Y;
            double ty2 = (box.Max.Y - ray.Origin.Y) * ray.InverseDirection.Y;

            tmin = Math.Max(tmin, Math.Min(ty1, ty2));
            tmax = Math.Min(tmax, Math.Max(ty1, ty2));

            distance = tmin;

            return(tmax >= tmin);
        }
Beispiel #3
0
        public void Build(List <PotatoEntity> sceneEntities)
        {
            List <BoundingBoxNode> defaultNodes = new List <BoundingBoxNode>();

            for (int i = 0; i < sceneEntities.Count; i++)
            {
                PotatoBox box = new PotatoBox(sceneEntities[i].Position, sceneEntities[i].Rotation, sceneEntities[i].Scale);
                defaultNodes.Add(new BoundingBoxNode(box, sceneEntities[i], null));
            }

            List <BoundingBoxNode> finalNodes = new List <BoundingBoxNode>();

            for (int i = 0; i < defaultNodes.Count; i++)
            {
                for (int j = 0; j < defaultNodes.Count; j++)
                {
                }
            }
        }
 public static bool Stack(PotatoBox a, PotatoBox b)
 {
     return((a.Min.X <= b.Max.X && a.Max.X >= b.Min.X) &&
            (a.Min.Y <= b.Max.Y && a.Max.Y >= b.Min.Y) &&
            (a.Min.Z <= b.Max.Z && a.Max.Z >= b.Min.Z));
 }
Beispiel #5
0
 public BoundingBoxNode(PotatoBox box, PotatoEntity entity, BoundingBoxNode parent) : this(parent)
 {
     Box    = box;
     Entity = entity;
     IsMesh = typeof(PotatoMesh).IsAssignableFrom(entity.GetType());
 }