/// <summary> /// /// </summary> /// <param name="scene"></param> /// <param name="filePath"></param> public void ExportScene(IOScene scene, string filePath, ExportSettings settings) { // create collada document _collada = new IONET.Collada.Collada(); _settings = settings; _collada.Version = "1.4.1"; // export materials foreach (var mat in scene.Materials) { ProcessMaterial(mat); } // initialize scene var visscene = new Visual_Scene { Name = scene.Name }; visscene.ID = scene.Name; // export models nodes List <Node> nodes = new List <Node>(); foreach (var mod in scene.Models) { nodes.AddRange(ProcessModel(mod)); } visscene.Node = nodes.ToArray(); // instance the scene var scene_instance = new Instance_Visual_Scene(); scene_instance.URL = "#" + visscene.Name; _collada.Library_Visual_Scene = new Library_Visual_Scenes(); _collada.Library_Visual_Scene.Visual_Scene = new Visual_Scene[] { visscene }; _collada.Scene = new Scene(); _collada.Scene.Visual_Scene = scene_instance; // initialize asset InitAsset(); // save to file _collada.SaveToFile(filePath); // cleanup _usedIDs.Clear(); _collada = null; }
private Library_Visual_Scenes GetScenes(Node geometryNode, IEnumerable <Node> lightNodes, string modelName) { var visualScenes = new Library_Visual_Scenes(); var visualScene = new Visual_Scene() { Id = "scene" }; var masterNode = new Node() { Id = modelName, Name = modelName }; masterNode.NodeProperty.Add(geometryNode); lightNodes.ToList().ForEach(l => geometryNode.NodeProperty.Add(l)); visualScene.Node.Add(masterNode); visualScenes.Visual_Scene.Add(visualScene); return(visualScenes); }