示例#1
0
文件: Entity.cs 项目: q4a/MMEd
        public Cuboid GetBoundingBox()
        {
            Cuboid lRet = new Cuboid();

            lRet.XMin = double.MaxValue;
            lRet.YMin = double.MaxValue;
            lRet.ZMin = double.MaxValue;
            lRet.XMax = double.MinValue;
            lRet.YMax = double.MinValue;
            lRet.ZMax = double.MinValue;

            foreach (Mesh lMesh in Meshes)
            {
                foreach (Vertex lVertex in lMesh.Vertices)
                {
                    if (lVertex.Position.x < lRet.XMin)
                    {
                        lRet.XMin = lVertex.Position.x;
                    }
                    if (lVertex.Position.x > lRet.XMax)
                    {
                        lRet.XMax = lVertex.Position.x;
                    }
                    if (lVertex.Position.y < lRet.YMin)
                    {
                        lRet.YMin = lVertex.Position.y;
                    }
                    if (lVertex.Position.y > lRet.YMax)
                    {
                        lRet.YMax = lVertex.Position.y;
                    }
                    if (lVertex.Position.z < lRet.ZMin)
                    {
                        lRet.ZMin = lVertex.Position.z;
                    }
                    if (lVertex.Position.z > lRet.ZMax)
                    {
                        lRet.ZMax = lVertex.Position.z;
                    }
                }
            }
            return(lRet);
        }
示例#2
0
        public Cuboid GetBoundingBox()
        {
            Cuboid lRet = new Cuboid();
              lRet.XMin = double.MaxValue;
              lRet.YMin = double.MaxValue;
              lRet.ZMin = double.MaxValue;
              lRet.XMax = double.MinValue;
              lRet.YMax = double.MinValue;
              lRet.ZMax = double.MinValue;

              foreach (Mesh lMesh in Meshes)
              {
            foreach (Vertex lVertex in lMesh.Vertices)
            {
              if (lVertex.Position.x < lRet.XMin) lRet.XMin = lVertex.Position.x;
              if (lVertex.Position.x > lRet.XMax) lRet.XMax = lVertex.Position.x;
              if (lVertex.Position.y < lRet.YMin) lRet.YMin = lVertex.Position.y;
              if (lVertex.Position.y > lRet.YMax) lRet.YMax = lVertex.Position.y;
              if (lVertex.Position.z < lRet.ZMin) lRet.ZMin = lVertex.Position.z;
              if (lVertex.Position.z > lRet.ZMax) lRet.ZMax = lVertex.Position.z;
            }
              }
              return lRet;
        }