Пример #1
0
        void SetupBaseTextures(SplatSet set)
        {
            // map base texture index to mask index
            // map mask index to indices of other textures in mask
            Dictionary <int, int>         baseTexToMask = new Dictionary <int, int>();
            Dictionary <int, List <int> > maskToIndices = new Dictionary <int, List <int> >();

            foreach (var attr in meshAttributes)
            {
                if (attr.isBaseTexture)
                {
                    baseTexToMask.Add((int)attr.index, attr.mask);
                }
                else
                {
                    List <int> indices;
                    if (maskToIndices.TryGetValue(attr.mask, out indices))
                    {
                        indices.Add((int)attr.index);
                        maskToIndices[attr.mask] = indices;
                    }
                    else
                    {
                        maskToIndices.Add(attr.mask, new List <int>()
                        {
                            (int)attr.index
                        });
                    }
                }
            }
            set.SetChannelBaseTextureWeights(MeshChannel.Color, baseTexToMask, maskToIndices);
        }
        void SetupBaseTextures(SplatSet set)
        {
            // map base texture index to mask index
            // map mask index to indices of other textures in mask
            Dictionary <MeshChannel, List <int> > channelsToBaseTex = new Dictionary <MeshChannel, List <int> >();
            Dictionary <int, int>         baseTexToMask             = new Dictionary <int, int>();
            Dictionary <int, List <int> > maskToIndices             = new Dictionary <int, List <int> >();

            foreach (var attr in meshAttributes)
            {
                if (attr.isBaseTexture)
                {
                    if (channelsToBaseTex.TryGetValue(attr.channel, out List <int> baseTexIndices))
                    {
                        baseTexIndices.Add((int)attr.index);
                        channelsToBaseTex[attr.channel] = baseTexIndices;
                    }
                    else
                    {
                        channelsToBaseTex.Add(attr.channel, new List <int>()
                        {
                            (int)attr.index
                        });
                    }

                    baseTexToMask.Add((int)attr.index, attr.mask);
                }
                else
                {
                    if (maskToIndices.TryGetValue(attr.mask, out List <int> indices))
                    {
                        indices.Add((int)attr.index);
                        maskToIndices[attr.mask] = indices;
                    }
                    else
                    {
                        maskToIndices.Add(attr.mask, new List <int>()
                        {
                            (int)attr.index
                        });
                    }
                }
            }
            if (baseTexToMask.Count > 0)
            {
                set.SetChannelBaseTextureWeights(channelsToBaseTex, baseTexToMask, maskToIndices);
            }
        }