示例#1
0
        internal unsafe static void RebuildMaterialFoliageTable()
        {
            var array = stackalloc MaterialFoliageConstantsElem[256];
            int N     = Table.Length;

            for (int i = 0; i < N; i++)
            {
                uint arraySize = 0;

                if (Table[i].FoliageColorTextureArray != null)
                {
                    arraySize = (uint)Table[i].FoliageColorTextureArray.ArrayLen;
                }
                else
                {
                    var arrayTexId = MyTextures.GetTexture(Table[i].FoliageArray_Texture, MyTextureEnum.COLOR_METAL, true);
                    arraySize = (uint)((Texture2D)MyTextures.Textures.Data[arrayTexId.Index].Resource).Description.ArraySize;
                }

                array[i] = new MaterialFoliageConstantsElem {
                    Scale       = Table[i].FoliageScale,
                    ScaleVar    = Table[i].FoliageScaleVariation,
                    TexturesNum = arraySize
                };
            }
            var mapping = MyMapping.MapDiscard(MyCommon.MaterialFoliageTableConstants);

            for (int arrayIndex = 0; arrayIndex < N; ++arrayIndex)
            {
                mapping.WriteAndPosition(ref array[arrayIndex]);
            }
            mapping.Unmap();
        }
示例#2
0
        internal static void RebuildMaterialFoliageTable()
        {
            var array = new MaterialFoliageConstantsElem[256];
            int N     = Table.Length;

            for (int i = 0; i < N; i++)
            {
                var arrayTexId = MyTextures.GetTexture(Table[i].FoliageArray_Texture, MyTextureEnum.COLOR_METAL, true);

                array[i] = new MaterialFoliageConstantsElem {
                    Scale       = Table[i].FoliageScale,
                    ScaleVar    = Table[i].FoliageScaleVariation,
                    TexturesNum = (uint)((Texture2D)MyTextures.Textures.Data[arrayTexId.Index].Resource).Description.ArraySize
                };
            }
            var mapping = MyMapping.MapDiscard(MyCommon.MaterialFoliageTableConstants);

            mapping.stream.WriteRange(array, 0, N);
            mapping.Unmap();
        }
示例#3
0
        internal static void RebuildMaterialFoliageTable()
        {
            var array = new MaterialFoliageConstantsElem[256];

            for (int i = 0; i < 256; i++)
            {
                var mat = m_materials.Get(i);
                if (mat == null)
                {
                    array[i] = new MaterialFoliageConstantsElem();
                }
                else
                {
                    array[i] = new MaterialFoliageConstantsElem(mat.FoliageScale, mat.FoliageRandomRescaleMult, mat.FoliageArraySize);
                }
            }
            var mapping = MyMapping.MapDiscard(MyCommon.MaterialFoliageTableConstants.Buffer);

            mapping.stream.WriteRange(array, 0, 256);
            mapping.Unmap();
        }
示例#4
0
        internal unsafe static void RebuildMaterialFoliageTable()
        {
            var array = stackalloc MaterialFoliageConstantsElem[256];
            int N = Table.Length;
            for (int i = 0; i < N; i++)
            {
                uint arraySize = 0;

                if (Table[i].FoliageColorTextureArray != null)
                {
                    arraySize = (uint)Table[i].FoliageColorTextureArray.SubtexturesCount;
                }
                else
                {
                    MyFileTextureManager texManager = MyManagers.FileTextures;
                    var arrayTex = texManager.GetTexture(Table[i].FoliageArray_Texture, MyFileTextureEnum.COLOR_METAL, true);
                    arraySize = (uint)((Texture2D)arrayTex.Resource).Description.ArraySize;
                }

                array[i] = new MaterialFoliageConstantsElem {
                    Scale = Table[i].FoliageScale,
                    ScaleVar = Table[i].FoliageScaleVariation,
                    TexturesNum = arraySize
                };
            }
            var mapping = MyMapping.MapDiscard(MyCommon.MaterialFoliageTableConstants);
            for (int arrayIndex = 0; arrayIndex < N; ++arrayIndex)
                mapping.WriteAndPosition(ref array[arrayIndex]);
            mapping.Unmap();
        }
示例#5
0
 internal static void RebuildMaterialFoliageTable()
 {
     var array = new MaterialFoliageConstantsElem[256];
     for(int i=0; i<256; i++)
     {
         var mat = m_materials.Get(i);
         if(mat == null)
         {
             array[i] = new MaterialFoliageConstantsElem();
         }
         else
         {
             array[i] = new MaterialFoliageConstantsElem(mat.FoliageScale, mat.FoliageRandomRescaleMult, mat.FoliageArraySize);
         }
     }
     var mapping = MyMapping.MapDiscard(MyCommon.MaterialFoliageTableConstants.Buffer);
     mapping.stream.WriteRange(array, 0, 256);
     mapping.Unmap();
 }
示例#6
0
        internal static void RebuildMaterialFoliageTable()
        {
            var array = new MaterialFoliageConstantsElem[256];
            int N = Table.Length;
            for (int i = 0; i < N; i++)
            {
                uint arraySize = 0;

                if (Table[i].FoliageColorTextureArray != null)
                {
                    arraySize = (uint)Table[i].FoliageColorTextureArray.ArrayLen;
                }
                else
                { 
                    var arrayTexId = MyTextures.GetTexture(Table[i].FoliageArray_Texture, MyTextureEnum.COLOR_METAL, true);
                    arraySize = (uint)((Texture2D)MyTextures.Textures.Data[arrayTexId.Index].Resource).Description.ArraySize;
                }

                array[i] = new MaterialFoliageConstantsElem {
                    Scale = Table[i].FoliageScale, 
                    ScaleVar = Table[i].FoliageScaleVariation,
                    TexturesNum = arraySize
                };
            }
            var mapping = MyMapping.MapDiscard(MyCommon.MaterialFoliageTableConstants);
            mapping.stream.WriteRange(array, 0, N);
            mapping.Unmap();
        }