示例#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();
        }
示例#2
0
文件: AABB.cs 项目: 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);
 }
示例#3
0
文件: AABB.cs 项目: 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))
         );
 }
示例#4
0
文件: AABB.cs 项目: 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)));
        }
示例#5
0
文件: AABB.cs 项目: KFlaga/Cam3D
 public static AABB Scaled(AABB aabb, Vector3 scale)
 {
     return new AABB(aabb.TopLeftFront * scale,
         aabb.BotRightBack * scale);
 }
示例#6
0
文件: AABB.cs 项目: KFlaga/Cam3D
 public static AABB Moved(AABB aabb, Vector3 move)
 {
     return new AABB(aabb.TopLeftFront + move,
         aabb.BotRightBack + move);
 }