Ejemplo n.º 1
0
 public void Execute(List <string> param, ObjModel model)
 {
     if (param.Count > 0)
     {
         model.CurrentMesh.UseMaterial(param[0], true);
     }
 }
Ejemplo n.º 2
0
        public void Execute(List <string> param, ObjModel model)
        {
            var vertices = param.ConvertAll <ObjVertex>(
                (str) => {
                var vertex = ObjVertex.Parse(model.CurrentMesh, str);
                for (int i = 0; i < vertex.attrIndex.Length; i++)
                {
                    vertex.attrIndex[i] -= 1;
                }
                return(vertex);
            }
                );

            if (vertices.Count > 0)
            {
                if (model.CurrentMesh.vertexVaiidFlag == 0)
                {
                    model.CurrentMesh.vertexVaiidFlag = vertices[0] != null ? vertices[0].GetValidFlag() : 0;
                }
                if (model.CurrentMesh.vertexVaiidFlag == 0)
                {
                    return;
                }
                AddNewFace(model.CurrentMesh, vertices);
            }
        }
Ejemplo n.º 3
0
        public void Execute(List <string> param, ObjModel model)
        {
            string name = param.Count > 0 ? param[0] : string.Empty;

            if (string.IsNullOrEmpty(name))
            {
                name = "mesh";
            }
            model.SwitchMesh(name, true);
        }
Ejemplo n.º 4
0
        public void Execute(List <string> param, ObjModel model)
        {
            var vec = new ParamVector {
                values = param.ToArray()
            };                                                                  //Vector.Parse(param.ToArray());

            if (!model.CurrentMesh.attrNames.Contains(name))
            {
                model.CurrentMesh.attrNames.Add(name);
            }
            if (!model.CurrentMesh.data.ContainsKey(name))
            {
                model.CurrentMesh.data[name] = new List <ParamVector>();
            }
            model.CurrentMesh.data[name].Add(vec);
        }
Ejemplo n.º 5
0
        public ObjModel Run(StreamReader reader = null)
        {
            if (reader != null)
            {
                GetLine = reader.ReadLine;
            }
            ObjModel model = new ObjModel();
            string   line;

            while (null != (line = GetLine()))
            {
                if (string.IsNullOrWhiteSpace(line))
                {
                    continue;
                }
                if (line[0] == '#')
                {
                    continue;
                }
                var           split  = line.Split(" ");
                List <string> tokens = new List <string>();
                foreach (var str in split)
                {
                    if (!string.IsNullOrWhiteSpace(str))
                    {
                        tokens.Add(str);
                    }
                }

                if (tokens.Count > 0)
                {
                    string        name  = tokens[0];
                    List <string> param = tokens.GetRange(1, tokens.Count - 1);
                    IObjCommand   cmd   = null;
                    if (commands.TryGetValue(name, out cmd))
                    {
                        cmd.Execute(param, model);
                    }
                }
            }
            return(model);
        }