Ejemplo n.º 1
0
        bool SectionScene(string[] tokens)
        {
            MqoScene scene = new MqoScene();

            mqo.scene = scene;

            switch (tokens[0])
            {
            case "pos": scene.pos = Point3.Parse(tokens, 1); break;

            case "lookat": scene.lookat = Point3.Parse(tokens, 1); break;

            case "head": scene.head = float.Parse(tokens[1]); break;

            case "pich": scene.pich = float.Parse(tokens[1]); break;

            case "ortho": scene.ortho = float.Parse(tokens[1]); break;

            case "zoom2": scene.zoom2 = float.Parse(tokens[1]); break;

            case "amb": scene.amb = Color3.Parse(tokens, 1); break;

            case "dirlights":
            {
                // dirlights 1 {
                // ...
                // }
                if (tokens[2] != "{")
                {
                    Error(tokens);
                }

                DoRead(SectionDirlights);
            }
            break;

            case "}":
                return(false);
            }
            return(true);
        }
Ejemplo n.º 2
0
        private bool SectionMaterial(string[] tokens)
        {
            if (tokens[0] == "}")
            {
                return(false);
            }

            StringBuilder sb = new StringBuilder();

            foreach (string i in tokens)
            {
                sb.Append(' ').Append(i);
            }

            string      line = sb.ToString().Trim();
            MqoMaterial m    = new MqoMaterial(tokens[0].Trim('"'));

            tokens = SplitString(line);
            materials.Add(m);

            for (int i = 1; i < tokens.Length; ++i)
            {
                string t  = tokens[i];
                string t2 = t.ToLower();

                if (t2.StartsWith("shader("))
                {
                    m.shader = int.Parse(SplitParam(t)[1]);
                }
                else if (t2.StartsWith("col("))
                {
                    m.col = Color3.Parse(SplitParam(t), 1);
                }
                else if (t2.StartsWith("dif("))
                {
                    m.dif = float.Parse(SplitParam(t)[1]);
                }
                else if (t2.StartsWith("amb("))
                {
                    m.amb = float.Parse(SplitParam(t)[1]);
                }
                else if (t2.StartsWith("emi("))
                {
                    m.emi = float.Parse(SplitParam(t)[1]);
                }
                else if (t2.StartsWith("spc("))
                {
                    m.spc = float.Parse(SplitParam(t)[1]);
                }
                else if (t2.StartsWith("power("))
                {
                    m.power = float.Parse(SplitParam(t)[1]);
                }
                else if (t2.StartsWith("tex("))
                {
                    m.tex = t.Substring(3).Trim('(', ')', '"');
                }
            }

            return(true);
        }