Esempio n. 1
0
        private int ChooseGroupSize(int resolution, GRID_GROUPS groups, int width, int height)
        {
            int num = this.GroupToNumber(groups);
            int num2;
            int num3;

            if (num == -1)
            {
                num2 = width / resolution;
                num3 = height / resolution;
            }
            else
            {
                num2 = num / resolution;
                num3 = num / resolution;
            }
            while (num2 * num3 > 65000)
            {
                if (groups == GRID_GROUPS.EXTREME)
                {
                    throw new InvalidOperationException("Can not increase group size");
                }
                int num4 = (int)(groups + 1);
                groups = (GRID_GROUPS)num4;
                num    = this.GroupToNumber(groups);
                num2   = num / resolution;
                num3   = num / resolution;
            }
            return(num);
        }
Esempio n. 2
0
        /// <summary>
        /// Converts the group enum to a number.
        /// The group number is the sqrt of the number of verts in each mesh at resolution of 1.
        /// It will require less meshes to fill the screen the bigger they are.
        /// </summary>
        int GroupToNumber(GRID_GROUPS groups)
        {
            switch (groups)
            {
            case GRID_GROUPS.EXTREME:
                return(128);

            case GRID_GROUPS.HIGH:
                return(196);

            case GRID_GROUPS.MEDIUM:
                return(256);

            case GRID_GROUPS.LOW:
                return(512);

            case GRID_GROUPS.SINGLE:
                //special case. Will try and create just 1 mesh.
                //OYM:  只创建一个唯一的mesh
                return(-1);

            default:
                return(128);
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Chooses the number of verts that can be in each mesh given the mesh resolution.
        /// </summary>
        int ChooseGroupSize(int resolution, GRID_GROUPS groups, int width, int height)
        {
            int numVertsX = 0, numVertsY = 0;
            int groupSize = GroupToNumber(groups);//OYM:  -1,2,3,4,4为最好

            if (groupSize == -1)
            {
                //If group size -1 try and create just a single mesh.
                numVertsX = width / resolution;//OYM:  1,2,4,8,16,1为最好
                numVertsY = height / resolution;
            }
            else
            {
                //Else work out how many verts will be in the group.
                numVertsX = groupSize / resolution;
                numVertsY = groupSize / resolution;
            }
            //OYM:  这里的numVertsY与numVertsX是防止加载的网格过大而设置的
            //OYM:  一旦发现网格超限就缩小网格的分割,弄成多个子网格
            //If the number of verts is greater than Unitys max then will have to use a larger number of verts.
            //OYM:  unity规定一个mesh只能有65536个顶点
            while (numVertsX * numVertsY > 65000)
            {
                //This should never happen as the Extreme size should not be over max verts
                if (groups == GRID_GROUPS.EXTREME)
                {
                    throw new InvalidOperationException("Can not increase group size");
                }

                int nextSize = (int)groups + 1;//OYM:  注意,这里是+1,而不是*2

                //Ocean.LogWarning("Mesh resolution to high for group size. Trying next group size of " + ((GRID_GROUPS)nextSize));

                groups = (GRID_GROUPS)nextSize;

                groupSize = GroupToNumber(groups);

                numVertsX = groupSize / resolution;
                numVertsY = groupSize / resolution;
            }

            //gridGroups = groups;

            return(groupSize);
        }
Esempio n. 4
0
        /// <summary>
        /// Chooses the number of verts that can be in each mesh given the mesh resolution.
        /// </summary>
        int ChooseGroupSize(int resolution, GRID_GROUPS groups, int width, int height)
        {
            int numVertsX = 0, numVertsY = 0;
            int groupSize = GroupToNumber(groups);

            if (groupSize == -1)
            {
                //If group size -1 try and create just a single mesh.
                numVertsX = width / resolution;
                numVertsY = height / resolution;
            }
            else
            {
                //Else work out how many verts will be in the group.
                numVertsX = groupSize / resolution;
                numVertsY = groupSize / resolution;
            }

            //If the number of verts is greater than Unitys max then will have to use a larger number of verts.
            while (numVertsX * numVertsY > 65000)
            {
                //This should never happen as the Extreme size should not be over max verts
                if (groups == GRID_GROUPS.EXTREME)
                {
                    throw new InvalidOperationException("Can not increase group size");
                }

                int nextSize = (int)groups + 1;

                //Ocean.LogWarning("Mesh resolution to high for group size. Trying next group size of " + ((GRID_GROUPS)nextSize));

                groups = (GRID_GROUPS)nextSize;

                groupSize = GroupToNumber(groups);

                numVertsX = groupSize / resolution;
                numVertsY = groupSize / resolution;
            }

            //gridGroups = groups;

            return(groupSize);
        }
Esempio n. 5
0
        private int GroupToNumber(GRID_GROUPS groups)
        {
            switch (groups)
            {
            case GRID_GROUPS.SINGLE:
                return(-1);

            case GRID_GROUPS.LOW:
                return(512);

            case GRID_GROUPS.MEDIUM:
                return(256);

            case GRID_GROUPS.HIGH:
                return(196);

            case GRID_GROUPS.EXTREME:
                return(128);

            default:
                return(128);
            }
        }
Esempio n. 6
0
        /// <summary>
        /// Converts the group enum to a number.
        /// The group number is the sqrt of the number of verts in each mesh at resolution of 1.
        /// It will require less meshes to fill the screen the bigger they are.
        /// </summary>
        int GroupToNumber(GRID_GROUPS groups)
        {
            switch(groups)
            {

            case GRID_GROUPS.EXTREME:
                return 128;

            case GRID_GROUPS.HIGH:
                return 196;

            case GRID_GROUPS.MEDIUM:
                return 256;

            case GRID_GROUPS.LOW:
                return 512;

            case GRID_GROUPS.SINGLE:
                //special case. Will try and create just 1 mesh.
                return -1;

            default:
                return 128;
            }
        }
Esempio n. 7
0
        /// <summary>
        /// Chooses the number of verts that can be in each mesh given the mesh resolution. 
        /// </summary>
        int ChooseGroupSize(int resolution, GRID_GROUPS groups, int width, int height)
        {
            int numVertsX = 0, numVertsY = 0;
            int groupSize = GroupToNumber(groups);

            if(groupSize == -1)
            {
                //If group size -1 try and create just a single mesh.
                numVertsX = width / resolution;
                numVertsY = height / resolution;
            }
            else
            {
                //Else work out how many verts will be in the group.
                numVertsX = groupSize / resolution;
                numVertsY = groupSize / resolution;
            }

            //If the number of verts is greater than Unitys max then will have to use a larger number of verts.
            while(numVertsX * numVertsY > 65000)
            {
                //This should never happen as the Extreme size should not be over max verts
                if(groups == GRID_GROUPS.EXTREME)
                    throw new InvalidOperationException("Can not increase group size");

                int nextSize = (int)groups + 1;

                //Ocean.LogWarning("Mesh resolution to high for group size. Trying next group size of " + ((GRID_GROUPS)nextSize));

                groups = (GRID_GROUPS)nextSize;

                groupSize = GroupToNumber(groups);

                numVertsX = groupSize / resolution;
                numVertsY = groupSize / resolution;
            }

            //gridGroups = groups;

            return groupSize;
        }
Esempio n. 8
0
 private int GroupToNumber(GRID_GROUPS groups)
 {
     switch (groups)
     {
     case GRID_GROUPS.SINGLE:
         return -1;
     case GRID_GROUPS.LOW:
         return 512;
     case GRID_GROUPS.MEDIUM:
         return 256;
     case GRID_GROUPS.HIGH:
         return 196;
     case GRID_GROUPS.EXTREME:
         return 128;
     default:
         return 128;
     }
 }
Esempio n. 9
0
 private int ChooseGroupSize(int resolution, GRID_GROUPS groups, int width, int height)
 {
     int num = this.GroupToNumber(groups);
     int num2;
     int num3;
     if (num == -1)
     {
         num2 = width / resolution;
         num3 = height / resolution;
     }
     else
     {
         num2 = num / resolution;
         num3 = num / resolution;
     }
     while (num2 * num3 > 65000)
     {
         if (groups == GRID_GROUPS.EXTREME)
         {
             throw new InvalidOperationException("Can not increase group size");
         }
         int num4 = (int)(groups + 1);
         groups = (GRID_GROUPS)num4;
         num = this.GroupToNumber(groups);
         num2 = num / resolution;
         num3 = num / resolution;
     }
     return num;
 }