Example #1
0
        public CommonMaterial CreateLimeMaterial(FbxMaterial material, string modelPath, Target target)
        {
            var commonMaterial = new CommonMaterial {
                Name = material.Name
            };

            if (!string.IsNullOrEmpty(material.Path))
            {
                var tex = CreateSerializableTexture(modelPath, material.Path);
                commonMaterial.DiffuseTexture = tex;
                var rulesPath = tex.SerializationPath + ".png";

                // TODO: implement U and V wrapping modes separately for cooking rules.
                // Set "Repeat" wrpap mode if wrap mode of any of the components is set as "Repeat".
                var mode = material.WrapModeU == TextureWrapMode.Repeat || material.WrapModeV == TextureWrapMode.Repeat ?
                           TextureWrapMode.Repeat : TextureWrapMode.Clamp;
                if (cookingRulesMap.ContainsKey(rulesPath))
                {
                    var cookingRules = cookingRulesMap[rulesPath] = cookingRulesMap[rulesPath].InheritClone();
                    if (cookingRules.CommonRules.WrapMode != mode)
                    {
                        cookingRules.CommonRules.WrapMode = mode;
                        cookingRules.SourceFilename       = rulesPath + ".txt";
                        cookingRules.CommonRules.Override(nameof(ParticularCookingRules.WrapMode));
                        cookingRules.DeduceEffectiveRules(target);
                        cookingRules.Save();
                    }
                }
            }
            commonMaterial.DiffuseColor = material.DiffuseColor;
            return(commonMaterial);
        }
Example #2
0
        public CommonMaterial ToLime(string path)
        {
            var res = new CommonMaterial();

            res.Name = Name;
            if (!string.IsNullOrEmpty(Path))
            {
                res.DiffuseTexture = CreateSerializableTexture(path);
            }
            if (DiffuseColor != null)
            {
                res.DiffuseColor = DiffuseColor;
            }

            return(res);
        }