Exemple #1
0
        static void ImportImages(string[] args)
        {
            if (args.Length < 3)
            {
                AddLog(string.Format("Invalid arguments! 3 <Scene' Name> <Src Folder>."));
                return;
            }
            string scene_name = args[1];

            if (scene_name.Length < 3)
            {
                AddLog(string.Format("Scenes name is wrong! {0}", scene_name));
                return;
            }
            AddLog("-Scene Name: " + scene_name);
            select_folder = args[2];
            if (!Directory.Exists(select_folder))
            {
                AddLog(string.Format("Directory doesn't exist! {0}", select_folder));
                return;
            }
            AddLog("-Source Folder: " + select_folder);
            select_images_folder = select_folder /* + "\\Images\\"*/;
            //if (!Directory.Exists(select_images_folder))
            //{
            //    AddLog(string.Format("Images directory doesn't exist! {0}", select_images_folder));
            //    return;
            //}

            UE4Directory ue4Dir = new UE4Directory();

            ue4Dir.Init();
            string destFolder = UE4Directory.project_content_folder;

            destFolder += "\\Scene\\";
            destFolder += scene_name;
            destFolder += "\\";

            AddLog("....Start import images....");
            AddLog("-Image Folder: " + select_images_folder);
            AddLog("-Dest Folder: " + destFolder);
            ue4Dir.Command_ImportImages(select_images_folder, destFolder);
            UE4Directory.Run();
            AddLog("....End import images....");
            return;
        }
Exemple #2
0
        static void DeployScene(string[] args)
        {
            if (args.Length < 3)
            {
                //2 TestDeploy Front D:\TestGoProGPSData
                AddLog(string.Format("Invalid arguments! 2 <New Scene' Name> <Src Folder>."));
                return;
            }
            AddLog(string.Format("....Check...."));
            string scene_name = args[1];

            if (scene_name.Length < 3)
            {
                AddLog(string.Format("Scenes name is wrong! {0}", scene_name));
                return;
            }
            AddLog("-Scene Name: " + scene_name);
            //string keyword = args[2];
            //AddLog("-Image Keyword: " + keyword);
            select_folder = args[2];
            if (!Directory.Exists(select_folder))
            {
                AddLog(string.Format("Directory doesn't exist! {0}", select_folder));
                return;
            }
            AddLog("-Source Folder: " + select_folder);

            select_images_folder = select_folder + "\\Images\\";// Path.Combine(select_folder,"Images");
            if (!Directory.Exists(select_images_folder))
            {
                AddLog(string.Format("Images directory doesn't exist! {0}", select_images_folder));
                return;
            }
            AddLog("-Source Images: " + select_images_folder);
            string imagelist_filename = select_folder + "\\imagelist.csv";

            if (!File.Exists(imagelist_filename))
            {
                AddLog(string.Format("Image list doesn't exist! {0}", imagelist_filename));
                return;
            }
            AddLog("-Images List: " + imagelist_filename);
            string maya_filename = select_folder + "\\maya_ascii_data.ma";

            if (!File.Exists(maya_filename))
            {
                AddLog(string.Format("Maya ASCII data doesn't exist! {0}", maya_filename));
                return;
            }
            AddLog("-Maya ASCII Data: " + maya_filename);
            string sceneInfo_xml_filename = select_folder + "\\SceneInfo.xml";

            if (!File.Exists(sceneInfo_xml_filename))
            {
                AddLog(string.Format("Scene info xml file doesn't exist! {0}", sceneInfo_xml_filename));
                return;
            }
            AddLog("-Maya ASCII Data: " + sceneInfo_xml_filename);



            select_folder = Path.GetDirectoryName(select_folder);
            UE4Directory ue4Dir = new UE4Directory();

            ue4Dir.Init();
            if (!ue4Dir.CheckSceneName(scene_name))
            {
                AddLog(string.Format("Scene's content directory alreay exist! {0}", select_folder));
                return;
            }

            SceneInfoData sceneInfoData = new SceneInfoData();

            if (!sceneInfoData.Load(sceneInfo_xml_filename))
            {
                AddLog(string.Format("Failed, load scene info xml file! {0}", sceneInfo_xml_filename));
                return;
            }
            AddLog("-Open SceneInfo: " + sceneInfo_xml_filename);

            ImageList imgList = new ImageList();

            if (!imgList.Load(imagelist_filename))
            {
                AddLog(string.Format("Failed, load images list file! {0}", imagelist_filename));
                return;
            }
            string[] keywordArr = sceneInfoData.keywords;
            foreach (var str in keywordArr)
            {
                if (!imgList.image_info_map.ContainsKey(str))
                {
                    AddLog(string.Format("Failed, Can't find out Keyword in images list file! {0}", imagelist_filename));
                    return;
                }

                ImageList.ImageInfo imgInfo = imgList.image_info_map[str];
                AddLog(string.Format("-Images List: {0} nb:{1} {2}-{3}", imgInfo.keyword, imgInfo.count, imgInfo.idxMin, imgInfo.idxMax));
            }

            MayaASCIIFile mayaFile = new MayaASCIIFile();

            if (!mayaFile.Load(maya_filename))
            {
                AddLog(string.Format("Failed, load maya ascii data file! {0}", maya_filename));
                return;
            }
            foreach (var str in keywordArr)
            {
                if (!mayaFile.image_info_map.ContainsKey(str))
                {
                    AddLog(string.Format("Failed, Can't find Keyword in maya ascii data! {0}", imagelist_filename));
                    return;
                }
                MayaASCIIFile.ImageInfo mayaInfo = mayaFile.image_info_map[str];
                AddLog(string.Format("-Maya Data: {0} nb:{1}", mayaInfo.keyword, mayaInfo.count));
            }
            string backupFolder = select_folder + "\\Backup\\";
            int    matchFile    = mayaFile.CheckImagesFolder(select_images_folder, backupFolder);

            if (matchFile <= 1)
            {
                AddLog(string.Format("Failed, Maya ASCII Data doesn't match the images! {0}", imagelist_filename));
                return;
            }
            AddLog(string.Format("-Check Images: {0}", matchFile));


            AddLog(string.Format("....Start Deploy...."));
            string destFolder = string.Format("{0}\\Scene\\{1}\\", UE4Directory.project_content_folder, scene_name);

            RoadInfoFile roadinfo_file     = new RoadInfoFile();
            string       roadinfo_filename = string.Format("{0}\\Scene\\{1}\\{1}.csv", UE4Directory.project_content_folder, scene_name);

            roadinfo_file.BuildRoadInfoFromImageList(imgList, keywordArr, roadinfo_filename);
            AddLog("-Create Road Info File: " + roadinfo_filename);

            string copy_imagelist_file = string.Format("{0}\\Scene\\{1}\\exported.csv", UE4Directory.project_content_folder, scene_name);

            File.Copy(imagelist_filename, copy_imagelist_file);
            AddLog("-Copy Image List File: " + copy_imagelist_file);

            string copy_maya_file = string.Format("{0}\\Scene\\{1}\\maya_ascii_data.ma", UE4Directory.project_content_folder, scene_name);

            File.Copy(maya_filename, copy_maya_file);
            AddLog("-Copy Maya ASCII Data File: " + copy_imagelist_file);

            string copy_sceneinfo_xml_file = string.Format("{0}\\Scene\\{1}\\SceneInfo.xml", UE4Directory.project_content_folder, scene_name);

            File.Copy(sceneInfo_xml_filename, copy_sceneinfo_xml_file);
            AddLog("-Copy Scene Info XML File: " + copy_sceneinfo_xml_file);


            AddLog("....Start import images....");
            AddLog("-Image Folder: " + select_images_folder);
            AddLog("-Dest Folder: " + destFolder);
            ue4Dir.Command_ImportImages(select_images_folder, destFolder);
            UE4Directory.Run();
            AddLog("....End import images....");

            string select_mesh_folder = select_folder + "\\Mesh\\";

            if (Directory.Exists(select_mesh_folder))
            {
                AddLog("....Start import mesh....");
                ue4Dir.Command_ImportMesh(select_mesh_folder, destFolder);
                UE4Directory.Run();
                AddLog("....End import mesh....");
            }
            else
            {
                AddLog(string.Format("No mesh folder! {0}", select_mesh_folder));
            }

            AddLog("....End....");
        }