Beispiel #1
0
        public static Va3cContainer ToVa3c(this VimScene vim)
        {
            var r = new Va3cContainer();

            r.geometries   = vim.Geometries.Select(ToGeometry).ToList();
            r.obj.children = vim.VimNodes.Select(ToObject).ToList();
            return(r);
        }
Beispiel #2
0
        public static VimScene ToVim(this Va3cContainer va3c)
        {
            var db             = new DocumentBuilder();
            var geometryLookup = new Dictionary <string, int>();

            foreach (var g in va3c.geometries)
            {
                geometryLookup.Add(g.uuid, geometryLookup.Count);
            }
            db.AddGeometries(va3c.geometries.Select(ToGeometryBuilder));
            ProcessNode(db, va3c.obj, geometryLookup);
            return(new VimScene(db.ToDocument()));
        }
Beispiel #3
0
        public static void SaveAsVim(this Va3cContainer va3c, string filePath)
        {
            var db             = new DocumentBuilder();
            var geometryLookup = new Dictionary <string, int>();

            foreach (var g in va3c.geometries)
            {
                if (g != null && g.data.vertices.Count > 0 && g.data.faces.Count > 0)
                {
                    geometryLookup.Add(g.uuid, geometryLookup.Count);
                }
            }
            db.AddGeometries(va3c.geometries.Select(ToGeometryBuilder));
            ProcessNode(db, va3c.obj, geometryLookup);
            Serializer.Serialize(db.ToDocument(), filePath);
        }
Beispiel #4
0
 public static void Write(this Va3cContainer va3c, string filePath)
 {
     using (var file = File.CreateText(filePath))
         new JsonSerializer().Serialize(file, va3c);
 }
Beispiel #5
0
 public static void SaveAsVim(this Va3cContainer va3c, string filePath)
 => va3c.ToVim().Save(filePath);