Пример #1
0
 static void getNormals(Mesh mesh, RElement ele)
 {
     bool hasNormals = ele.HasElement("Mesh.Normals");
     if (hasNormals)
     {
         foreach (RElement xe in ele.GetElement(P.Obj.Mesh + ".Normals").Elements)
         {
             mesh.Normals.Add(xe.Attributes["Vector"].ToVector3());
         }
     }
 }
Пример #2
0
 static void getFaces(Mesh mesh, RElement ele)
 {
     bool hasNormals = ele.HasElement("Mesh.Normals");
     int i = -1;
     foreach (RElement xe in ele.GetElement(P.Obj.Mesh + ".Faces").Elements)
     {
         i++;
         string[] w = xe.Attributes["Indices"].Value.Replace(" ", "").Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
         if (hasNormals)
         {
             SmoothMeshTriangle fmt = new SmoothMeshTriangle(int.Parse(w[0]), int.Parse(w[1]), int.Parse(w[2]), mesh, i + "" + "smsh" + "Mesh" + mesh.Name);
             mesh.AddObject(fmt);
         }
         else
         {
             FlatMeshTriangle fmt = new FlatMeshTriangle(int.Parse(w[0]), int.Parse(w[1]), int.Parse(w[2]), mesh, i + "" + "fmsh" + "Mesh" + mesh.Name);
             fmt.ComputeNormal(false);
             mesh.AddObject(fmt);
         }
     }
 }
Пример #3
0
 static void transform(Instance ins, RElement ele)
 {
     if (ele.HasElement("Instance.Transforms"))
         foreach (RElement el in ele.GetElement("Instance.Transforms").Elements)
             if (el.Name == P.Trans)
             {
                 ins.Transform(el.Attributes[P.Matr].ToMatrix4());
             }
 }
Пример #4
0
 static void getVertices(Mesh mesh, RElement ele)
 {
     foreach (RElement xe in ele.GetElement(P.Obj.Mesh + ".Vertices").Elements)
     {
         mesh.Vertices.Add(xe.Attributes[P.Pos].ToVector3());
     }
 }
Пример #5
0
 static Material getMaterial(RElement ele, Dictionary<string, Texture> texts)
 {
     if (ele.HasAttribute(P.Mat))
     {
         throw new Exception(); //Create exception for non-matching values or spelling mistakes.
     }
     else
     {
         if (ele.HasElement(ele.Name + "." + P.Mat))
         {
             if (ele.GetElement(ele.Name + "." + P.Mat).Elements.Count > 0)
             {
                 return ele.GetElement(ele.Name + "." + P.Mat).Elements[0].CreateMaterialFromElement(texts);
             }
             else
             {
                 throw new Exception(); //Create exception for elements not found.
             }
         }
         else
         {
             return null;
         }
     }
 }