Ejemplo n.º 1
0
        public override void WriteMap(BrushMap map)
        {
            Console.WriteLine("----------------------------------------------------------------");
            Console.WriteLine(" Urho3D Model Writer");
            Console.WriteLine("----------------------------------------------------------------");

            SceneBuilder sb = new SceneBuilder(map, QMapConverter.Settings.CellSize);
            List<string> matlist = new List<string>();
            sb.WriteModel(outputFile, matlist);
        }
Ejemplo n.º 2
0
        public override void WriteMap(BrushMap map)
        {
            Console.WriteLine("----------------------------------------------------------------");
            Console.WriteLine(" Urho3D Prefab Writer");
            Console.WriteLine("----------------------------------------------------------------");

            Console.WriteLine("Building material database");
            MaterialDatabase matDb = new MaterialDatabase(Settings.ContentDir);

            Scene scene = new Scene("node");
            Node entRoot = scene.CreateChild("Entities");

            // Write 'void' entity nodes
            using (QMapConverter.Util.ConsoleProgress prog = new QMapConverter.Util.ConsoleProgress("Writing entities", map.Entities.Count))
                for (int i = 0; i < map.Entities.Count; ++i)
                {
                    prog.Increment();
                    prog.Write();
                    Entity entity = map.Entities[i];
                    if (entity.Brushes.Count == 0)
                    {
                        Node brushNode = entRoot.CreateChild();
                        brushNode.WriteVariables(entity.Properties);
                    }
                }

            // Write world geometry elements
            Node geoNode = scene.CreateChild("Geometry");

            string outputPath = System.IO.Path.Combine(Settings.ContentDir, "Data");
            outputPath = System.IO.Path.Combine(outputPath, "Models");
            outputPath = System.IO.Path.Combine(outputPath, System.IO.Path.GetFileNameWithoutExtension(outputFile));
            outputPath = System.IO.Path.Combine(outputPath, "geo.mdl");

            SceneBuilder sb = new SceneBuilder(map, QMapConverter.Settings.CellSize);
            List<string> materials = new List<string>();
            sb.WriteModel(outputPath, materials);

            using (QMapConverter.Util.ConsoleProgress prog = new QMapConverter.Util.ConsoleProgress("Writing geometry", map.Entities.Count))
            {
                Component staticModel = geoNode.CreateComponent("StaticModel");
                string relPath = outputPath.Replace(Settings.ContentDir + "\\", "").Replace("\\","/");
                staticModel.SetAttribute("Model", String.Format("Model;{0}", relPath));
                StringBuilder matString = new StringBuilder();
                foreach (string m in materials)
                {
                    string matFile = matDb.GetMaterial(m);
                    if (matFile != null && matFile.Length > 0)
                    {
                        if (matString.Length > 0)
                            matString.AppendFormat(";Material;{0}", matFile);
                        else
                            matString.AppendFormat("Material;{0}", matFile);
                    }
                }
                if (matString.Length > 0)
                    staticModel.SetAttribute("Material", matString.ToString());
            }

            using (QMapConverter.Util.ConsoleProgress prog = new QMapConverter.Util.ConsoleProgress("Writing file", map.Entities.Count))
                scene.Save(outputFile);

            Console.WriteLine("File written: " + outputFile);
        }
Ejemplo n.º 3
0
 public override void WriteMap(string outputFile, BrushMap map)
 {
     SceneBuilder sb = new SceneBuilder(map, Settings.CellSize);
     sb.WriteScene(outputFile, Settings.ContentDir, "entity");
 }
Ejemplo n.º 4
0
 public override void WriteMap(string outputFile, BrushMap map)
 {
     SceneBuilder sb = new SceneBuilder(map, QMapConverter.Settings.CellSize);
     sb.WriteModel(outputFile, QMapConverter.Settings.MaterialSourceDir);
 }