Example #1
0
        public static MqMaterial Parse(MqChunk chunk)
        {
            var rt = new MqMaterial
            {
                baseChunk = chunk,
                Name      = chunk.Name.Trim('"'),
            };

            foreach (var i in chunk.Attributes)
            {
                switch (i.Name.ToLower())
                {
                case "shader":
                    rt.Shader = (MqShader)int.Parse(i.Arguments.First());

                    break;

                case "vcol":
                    rt.VertexColor = i.Arguments.FirstOrDefault() == "1";

                    break;

                case "col":
                    rt.Color = i.Arguments.Select(float.Parse).ToArray();

                    break;

                case "dif":
                    rt.Diffusion = float.Parse(i.Arguments.First());

                    break;

                case "amb":
                    rt.Ambient = float.Parse(i.Arguments.First());

                    break;

                case "emi":
                    rt.Emmisive = float.Parse(i.Arguments.First());

                    break;

                case "spc":
                    rt.Specular = float.Parse(i.Arguments.First());

                    break;

                case "power":
                    rt.Power = float.Parse(i.Arguments.First());

                    break;

                case "tex":
                    rt.Texture = i.Arguments.First().Trim('"');

                    break;

                case "aplane":
                    rt.Texture = i.Arguments.First().Trim('"');

                    break;

                case "bump":
                    rt.Texture = i.Arguments.First().Trim('"');

                    break;

                case "proj_type":
                    rt.ProjectionType = (MqProjectionType)int.Parse(i.Arguments.First());

                    break;

                case "proj_pos":
                    rt.ProjectionPosition = i.Arguments.Select(float.Parse).ToArray();

                    break;

                case "proj_scale":
                    rt.ProjectionScale = i.Arguments.Select(float.Parse).ToArray();

                    break;

                case "proj_angle":
                    rt.ProjectionAngle = i.Arguments.Select(float.Parse).ToArray();

                    break;
                }
            }

            return(rt);
        }
Example #2
0
        public static MqMaterial Parse(MqChunk chunk)
        {
            var rt = new MqMaterial
            {
                baseChunk = chunk,
                Name = chunk.Name.Trim('"'),
            };

            foreach (var i in chunk.Attributes)
                switch (i.Name.ToLower())
                {
                    case "shader":
                        rt.Shader = (MqShader)int.Parse(i.Arguments.First());

                        break;
                    case "vcol":
                        rt.VertexColor = i.Arguments.FirstOrDefault() == "1";

                        break;
                    case "col":
                        rt.Color = i.Arguments.Select(float.Parse).ToArray();

                        break;
                    case "dif":
                        rt.Diffusion = float.Parse(i.Arguments.First());

                        break;
                    case "amb":
                        rt.Ambient = float.Parse(i.Arguments.First());

                        break;
                    case "emi":
                        rt.Emmisive = float.Parse(i.Arguments.First());

                        break;
                    case "spc":
                        rt.Specular = float.Parse(i.Arguments.First());

                        break;
                    case "power":
                        rt.Power = float.Parse(i.Arguments.First());

                        break;
                    case "tex":
                        rt.Texture = i.Arguments.First().Trim('"');

                        break;
                    case "aplane":
                        rt.Texture = i.Arguments.First().Trim('"');

                        break;
                    case "bump":
                        rt.Texture = i.Arguments.First().Trim('"');

                        break;
                    case "proj_type":
                        rt.ProjectionType = (MqProjectionType)int.Parse(i.Arguments.First());

                        break;
                    case "proj_pos":
                        rt.ProjectionPosition = i.Arguments.Select(float.Parse).ToArray();

                        break;
                    case "proj_scale":
                        rt.ProjectionScale = i.Arguments.Select(float.Parse).ToArray();

                        break;
                    case "proj_angle":
                        rt.ProjectionAngle = i.Arguments.Select(float.Parse).ToArray();

                        break;
                }

            return rt;
        }