static void WGEOTest() { WGEOFile wgeo = new WGEOFile("room.wgeo"); int index = 0; foreach (OBJFile obj in OBJConverter.ConvertWGEOModels(wgeo)) { obj.Write(string.Format("wgeo//{1}_{0}.obj", index, wgeo.Models[index].Material)); index++; } }
public static IEnumerable <OBJFile> ConvertWGEOModels(WGEOFile WGEO) { foreach (WGEOModel Model in WGEO.Models) { List <Vector3> Vertices = new List <Vector3>(); List <Vector2> UVs = new List <Vector2>(); foreach (WGEOVertex Vertex in Model.Vertices) { Vertices.Add(Vertex.Position); UVs.Add(Vertex.UV); } yield return(new OBJFile(Vertices, UVs, Model.Indices)); } }
/// <summary> /// Converts the models of <paramref name="wgeo"/> into the <see cref="OBJFile"/> format /// </summary> /// <param name="wgeo">The <see cref="WGEOFile"/> to convert models from</param> /// <returns>Converted <see cref="WGEOModel"/> models in the <see cref="OBJFile"/> format</returns> public static IEnumerable <OBJFile> ConvertWGEOModels(WGEOFile wgeo) { foreach (WGEOModel model in wgeo.Models) { List <Vector3> vertices = new List <Vector3>(); List <Vector2> uvs = new List <Vector2>(); foreach (WGEOVertex vertex in model.Vertices) { vertices.Add(vertex.Position); uvs.Add(vertex.UV); } yield return(new OBJFile(vertices, model.Indices, uvs)); } }
/// <summary> /// Converts <paramref name="wgeo"/> to a list of <see cref="MeshGeometry3D"/> /// </summary> /// <param name="wgeo">The <see cref="WGEOFile"/> to convert to a <c>Tuple{string, string, MeshGeometry3D}(materialName, textureName, modelData)</c></param> /// <returns>A collection of converted <see cref="WGEOModel"/></returns> public static IEnumerable <Tuple <string, string, MeshGeometry3D> > ConvertWGEO(WGEOFile wgeo) { foreach (WGEOModel model in wgeo.Models) { MeshGeometry3D mesh = new MeshGeometry3D(); Int32Collection indices = new Int32Collection(model.Indices.Select(x => (int)x)); Point3DCollection vertices = new Point3DCollection(); PointCollection uv = new PointCollection(); foreach (WGEOVertex vertex in model.Vertices) { vertices.Add(new Point3D(vertex.Position.X, vertex.Position.Y, vertex.Position.Z)); uv.Add(new Point(vertex.UV.X, vertex.UV.Y)); } mesh.TextureCoordinates = uv; mesh.Positions = vertices; mesh.TriangleIndices = indices; yield return(new Tuple <string, string, MeshGeometry3D>(model.Material, model.Texture, mesh)); } }
static void NVRConvertion() { string root = @"WGEO"; //When the Directory don't exist create it! if (!Directory.Exists(root)) { Directory.CreateDirectory(root); } //Checking the wgeo file if exist. If not download. if (File.Exists("room.wgeo")) { Console.WriteLine("File room.wgeo found"); } else { Console.WriteLine("room.wgeo does not exist and will be downloaded now."); WebClient webClient = new WebClient(); Console.WriteLine("Downloading now"); webClient.DownloadFile("https://uce213b75ebc39ebd44e366ef7ac.dl.dropboxusercontent.com/cd/0/get/Aw9eirvQFzt_9NL4WBS04jiEjRaXMCO4lU87jdwcHEmoi6lOva-fiY62WlfBO0hOwNjbYrMj16-oyynK5CpxQEQm-lutnygQs8GHMo5YgRJMISRuObmm0IyhyJ4M-XP2ofI/file?dl=1#", @"room.wgeo"); Console.WriteLine("Finished downloading :)"); } if (File.Exists("room.nvr")) { Console.WriteLine("File room.nvr found! Convert starts"); } else { Console.WriteLine("File room.nvr not found. PLS check if room.nvr is right to the exe"); Thread.Sleep(5000); System.Environment.Exit(1); } //Convert the Simple Enviroment to World Geometry NVRFile nvr = new NVRFile("room.nvr"); WGEOConverter.ConvertNVR(nvr, new WGEOFile("room.wgeo").BucketGeometry).Write("newnvr.wgeo"); //----------------------------------------------------------------------------------------------// //Convert the World Geometry to Object files WGEOFile wgeo = new WGEOFile("newnvr.wgeo"); int index = 0; foreach (OBJFile obj in OBJConverter.ConvertWGEOModels(wgeo)) { obj.Write(string.Format("wgeo//{1}_{0}.obj", index, wgeo.Models[index].Material)); //Material creation missing :( index++; } //Delete created WGEO file string NewNVRFile = "newnvr.wgeo"; File.Delete(NewNVRFile); Console.WriteLine(NewNVRFile, " deleted."); Console.WriteLine("Done"); }
public static OBJFile VisualiseWGEOBucketGeometry(WGEOFile WGEO) { return(new OBJFile(WGEO.BucketGeometry.Vertices, WGEO.BucketGeometry.Indices)); }