Exemplo n.º 1
0
        public void RecalculateAABB()
        {
            UpdateTransfromMatrix();

            LocalAABB = new AABB();
            foreach(var child in Children)
            {
                LocalAABB.Union(child.LocalAABB);
            }

            foreach(var model in AttachedObjects)
            {
                LocalAABB.Union(model.ModelAABB * TransformationMatrix);
            }

            if(Parent != null)
                Parent.RecalculateAABB();
        }
Exemplo n.º 2
0
Arquivo: AABB.cs Projeto: KFlaga/Cam3D
 public void Union(AABB other)
 {
     TopLeftFront.X = Math.Max(TopLeftFront.X, other.TopLeftFront.X);
     TopLeftFront.Y = Math.Max(TopLeftFront.Y, other.TopLeftFront.Y);
     TopLeftFront.Z = Math.Max(TopLeftFront.Z, other.TopLeftFront.Z);
     BotRightBack.X = Math.Min(BotRightBack.X, other.BotRightBack.X);
     BotRightBack.Y = Math.Min(BotRightBack.Y, other.BotRightBack.Y);
     BotRightBack.Z = Math.Min(BotRightBack.Z, other.BotRightBack.Z);
 }
Exemplo n.º 3
0
Arquivo: AABB.cs Projeto: KFlaga/Cam3D
 public static AABB Unioned(AABB aabb, AABB other)
 {
     return new AABB(
             new Vector3(
     Math.Max(aabb.TopLeftFront.X, other.TopLeftFront.X),
     Math.Max(aabb.TopLeftFront.Y, other.TopLeftFront.Y),
     Math.Max(aabb.TopLeftFront.Z, other.TopLeftFront.Z)),
             new Vector3(
     Math.Min(aabb.BotRightBack.X, other.BotRightBack.X),
     Math.Min(aabb.BotRightBack.Y, other.BotRightBack.Y),
     Math.Min(aabb.BotRightBack.Z, other.BotRightBack.Z))
         );
 }
Exemplo n.º 4
0
Arquivo: AABB.cs Projeto: KFlaga/Cam3D
        public static AABB Transformed(AABB aabb, Matrix trans)
        {
            var maxr = Vector3.Transform(aabb.TopLeftFront, trans);
            var minr = Vector3.Transform(aabb.BotRightBack, trans);

            return new AABB(new Vector3(
                Math.Max(maxr.X, minr.X),
                Math.Max(maxr.Y, minr.Y),
                Math.Max(maxr.Z, minr.Z)),
                    new Vector3(
                Math.Min(maxr.X, minr.X),
                Math.Min(maxr.Y, minr.Y),
                Math.Min(maxr.Z, minr.Z)));
        }
Exemplo n.º 5
0
Arquivo: AABB.cs Projeto: KFlaga/Cam3D
 public static AABB Scaled(AABB aabb, Vector3 scale)
 {
     return new AABB(aabb.TopLeftFront * scale,
         aabb.BotRightBack * scale);
 }
Exemplo n.º 6
0
Arquivo: AABB.cs Projeto: KFlaga/Cam3D
 public static AABB Moved(AABB aabb, Vector3 move)
 {
     return new AABB(aabb.TopLeftFront + move,
         aabb.BotRightBack + move);
 }