Exemplo n.º 1
0
        public static void SetDefaultMaterialData(List<MaterialData> materialDatas, int x, int y, int lod)
        {
            var current = new MaterialData();

            // newmtl material_0
            current.X = x;
            current.Y = y;
            current.Lod = lod;

            // Ka 0.200000 0.200000 0.200000
            current.Ambient = Gc(new[] {"Ka", "0.200000", "0.200000", "0.200000"});

            // Kd 0.800000 0.800000 0.800000
            current.Diffuse = Gc(new[] {"Kd", "0.800000", "0.800000", "0.800000"});

            // Ks 1.000000 1.000000 1.000000
            current.Specular = Gc(new[] {"Ks", "1.000000", "1.000000", "1.000000"});

            // Tr 1.000000
            current.Alpha = Cf("1.000000");

            // illum 2
            current.IllumType = Ci("2");

            // Ns 0.000000
            current.Shininess = Cf("0.000000")/1000;

            // map_Kd model.jpg
            current.DiffuseTexPath = "model.jpg";

            materialDatas.Add(current);
        }
Exemplo n.º 2
0
        public static Material[] GetMaterial(bool useUnlitShader, MaterialData md)
        {
            Material[] m;
            // Use an unlit shader for the model if set
            if (useUnlitShader)
            {
                m = new[] {new Material(Shader.Find(("Unlit/Texture")))};
            }
            else
            {
                if (md.IllumType == 2)
                {
                    m = new[] {new Material(Shader.Find("Specular"))};
                    m[0].SetColor("_SpecColor", md.Specular);
                    m[0].SetFloat("_Shininess", md.Shininess);
                }
                else
                {
                    m = new[] {new Material(Shader.Find("Diffuse"))};
                }

                m[0].SetColor("_Color", md.Diffuse);
            }

            if (md.DiffuseTex != null)
                m[0].SetTexture("_MainTex", md.DiffuseTex);

            return m;
        }