Пример #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;
        }