public static void ConvertSimpleEnvironmentToGltf(ConvertSimpleEnvironmentToGltf opts) // NVR -> GLTF not supported yet { NVRFile NVRModel = ReadNVR(opts.SimpleEnvironmentPath); LightDatFile LightFile = ReadLightDAT(opts.PointLightPath); NVRModel.Write(opts.SimpleEnvironmentPath); }
/// <summary> /// Converts <paramref name="nvr"/> to a <see cref="WGEOFile"/> /// </summary> /// <param name="nvr">The <see cref="NVRFile"/> to be used for models</param> /// <param name="bucketTemplate">The <see cref="WGEOBucketGeometry"/> to be used a a template for bucket geometry</param> /// <returns>A <see cref="WGEOFile"/> converted from <paramref name="nvr"/></returns> public static WGEOFile ConvertNVR(NVRFile nvr, WGEOBucketGeometry bucketTemplate) { List <WGEOModel> models = new List <WGEOModel>(); foreach (NVRMesh mesh in nvr.Meshes) { List <WGEOVertex> vertices = new List <WGEOVertex>(); List <uint> indices = mesh.IndexedPrimitives[0].Indices.Select(x => (uint)x).ToList(); foreach (NVRVertex vertex in mesh.IndexedPrimitives[0].Vertices) { if (mesh.IndexedPrimitives[0].VertexType == NVRVertexType.NVRVERTEX_4) { NVRVertex4 vertex4 = vertex as NVRVertex4; vertices.Add(new WGEOVertex(vertex4.Position, NVRVertex.IsGroundType(mesh.Material) ? new Vector2(0, 0) : vertex4.UV)); } else if (mesh.IndexedPrimitives[0].VertexType == NVRVertexType.NVRVERTEX_8) { NVRVertex8 vertex8 = vertex as NVRVertex8; vertices.Add(new WGEOVertex(vertex8.Position, NVRVertex.IsGroundType(mesh.Material) ? new Vector2(0, 0) : vertex8.UV)); } else if (mesh.IndexedPrimitives[0].VertexType == NVRVertexType.NVRVERTEX_12) { NVRVertex12 vertex12 = vertex as NVRVertex12; vertices.Add(new WGEOVertex(vertex12.Position, vertex12.UV)); } } models.Add(new WGEOModel(mesh.Material.Channels[0].Name, mesh.Material.Name, vertices, indices)); } return(new WGEOFile(models, bucketTemplate)); }
static void NVRTest() { NVRFile nvr = new NVRFile("room.nvr"); WGEOConverter.ConvertNVR(nvr, new WGEOFile("room.wgeo").BucketGeometry).Write("roomNVR.wgeo"); //IO.OBJ.OBJFile obj = new IO.OBJ.OBJFile("zed.obj"); //var test = NVRMesh.GetGeometryFromOBJ(obj); //NVRMaterial mat = NVRMaterial.CreateMaterial("Zed", "zed.dds"); //NVRFile nvr = new NVRFile("Map1/scene/roomOR.nvr"); //nvr.AddMesh(NVRMeshQuality.VERY_LOW, mat, test.Item1, test.Item2); //nvr.Save("Map1/scene/room.nvr"); //OBJConverter.VisualiseNVRNodes(nvr).Write("nodes.obj"); }
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"); }