Ejemplo n.º 1
0
        public VertigoMaterial GetInstance(string materialName, IList <string> keywords)
        {
            if (keywords != null)
            {
                SortKeywords(keywords);
            }

            if (sharedMaterialMap.TryGetValue(materialName, out List <VertigoMaterial> materials))
            {
                for (int i = 0; i < materials.Count; i++)
                {
                    if (KeywordsMatch(keywords, materials[i]))
                    {
                        return(materials[i].GetInstance());
                    }
                }

                VertigoMaterial retn = CreateMaterial(materialName, keywords);
                if (retn.material == null)
                {
                    return(null);
                }

                materials.Add(retn);
                return(retn.GetInstance());
            }
            else
            {
                VertigoMaterial retn = CreateMaterial(materialName, keywords);
                materials = new List <VertigoMaterial>();
                materials.Add(retn);
                sharedMaterialMap.Add(materialName, materials);
                return(retn.GetInstance());
            }
        }
Ejemplo n.º 2
0
        private static bool KeywordsMatch(IList <string> keywords, VertigoMaterial material)
        {
            if (keywords == null)
            {
                if (material.keywords == null || material.keywords.Length == 0)
                {
                    return(true);
                }

                return(false);
            }

            if (material.keywords == null)
            {
                return(keywords.Count == 0);
            }

            if (keywords.Count != material.keywords.Length)
            {
                return(false);
            }

            for (int i = 0; i < material.keywords.Length; i++)
            {
                if (keywords[i] != material.keywords[i])
                {
                    return(false);
                }
            }

            return(true);
        }
Ejemplo n.º 3
0
 public VertigoMaterial(Material material)
 {
     this.material  = material;
     this.keywords  = null;
     this.isActive  = true;
     this.parent    = null;
     this.instances = null;
 }
Ejemplo n.º 4
0
        public VertigoMaterial GetInstance()
        {
            VertigoMaterial retn = null;

            if (instances.Count > 0)
            {
                retn = instances.RemoveLast();
            }
            else
            {
                retn = new VertigoMaterial(this);
            }

            retn.isActive = true;
            return(retn);
        }
Ejemplo n.º 5
0
        public VertigoMaterial GetInstance(string materialName, string keyword0 = null, string keyword1 = null, string keyword2 = null, string keyword3 = null)
        {
            if (keyword0 != null)
            {
                s_Keywords.Add(keyword0);
            }
            if (keyword1 != null)
            {
                s_Keywords.Add(keyword1);
            }
            if (keyword2 != null)
            {
                s_Keywords.Add(keyword2);
            }
            if (keyword3 != null)
            {
                s_Keywords.Add(keyword3);
            }
            VertigoMaterial retn = GetInstance(materialName, s_Keywords);

            s_Keywords.Clear();
            return(retn);
        }
Ejemplo n.º 6
0
        public void FillRoundedRect(float x, float y, float width, float height, float rTL, float rTR, float rBL, float rBR, VertigoMaterial material = null)
        {
            material = material ?? fillMaterial;
            int pathId = shapeGenerator.RoundedRect(x, y, width, height, rTL, rTR, rBL, rBR);

            geometryGenerator.Fill(shapeGenerator, new RangeInt(pathId, 1), defaultShapeMode, geometryCache);
            batcher.AddDrawCall(geometryCache, new RangeInt(geometryCache.shapeCount - 1, 1), material, renderState);
        }
Ejemplo n.º 7
0
 internal VertigoMaterial(VertigoMaterial parent)
 {
     this.material = new Material(parent.material);
     this.keywords = parent.keywords;
     this.parent   = parent;
 }