示例#1
0
        private void CreateOARFile(ImportSettings settings, string filename)
        {
            string rootDir = ExportCommand.dumpDir + "../oarfile/";

            OarFile.PrepareDir(rootDir);

            // Objects
            foreach (PrimToCreate parent in parents)
            {
                var ls = new Linkset()
                {
                    Parent = parent
                };
                parent.Link = ls;
                LocalScene.Links.Add(ls);
            }
            foreach (PrimToCreate ch in childs)
            {
                var pp = ch.ParentPrim;
                if (pp == null)
                {
                    continue;
                }
                pp.Link.ChildAdd(ch);
            }
            foreach (var ls in LockInfo.CopyOf(LocalScene.Links))
            {
                ls.Children.Sort(compareLocalIDs);
                if (ls.Parent.IsAsset)
                {
                    LocalScene.AssetLinks.Add(ls);
                    LocalScene.Links.Remove(ls);
                }
            }
            foreach (var ls in LocalScene.Links)
            {
                OarFile.SaveLinkset(ls, rootDir + "objects/" + ls.Parent.NewID + ArchiveConstants.ASSET_TYPE_TO_EXTENSION[AssetType.Object], false, settings);
            }
            // Assets
            foreach (ItemToCreate asset in LocalScene.Assets)
            {
                File.WriteAllBytes(rootDir + "assets/" + asset.OldID + ArchiveConstants.ASSET_TYPE_TO_EXTENSION[asset.AssetType], asset.AssetData);
            }
            foreach (var ls in LocalScene.AssetLinks)
            {
                OarFile.SaveLinkset(ls, rootDir + "assets/" + ls.Parent.NewID + ArchiveConstants.ASSET_TYPE_TO_EXTENSION[AssetType.Object], true, settings);
            }
            // Terrain
            if (settings.ContainsKey("terrain"))
            {
                ExportCommand.Exporting.SaveTerrainRaw32(rootDir + "terrains/heightmap.raw");
            }

            string parcelDirs = rootDir + "landdata/";

            Directory.CreateDirectory(parcelDirs);

            OarFile.PackageArchive(rootDir, filename, settings.ContainsKey("terrain"), settings.ContainsKey("land"));
        }
示例#2
0
        /*
         * void texturePipeline_OnDownloadFinished(UUID id, bool success)
         * {
         *  if (success)
         *  {
         *      // Save this texture to the hard drive
         *      ImageDownload image = texturePipeline.GetTextureToRender(id);
         *      try
         *      {
         *          File.WriteAllBytes(directoryname + "/assets/" + id.ToString() + "_texture.jp2", image.AssetData);
         *          lock (texturesFinished) texturesFinished[id] = id;
         *      }
         *      catch (Exception ex)
         *      {
         *          Logger.Log("Failed to save texture: " + ex.Message, Helpers.LogLevel.Error);
         *      }
         *  }
         *  else
         *  {
         *      Logger.Log("Texture failed to download: " + id.ToString(), Helpers.LogLevel.Warning);
         *  }
         * }
         */
        void Run()
        {
            // Start the thread that monitors the queue of prims that need ObjectSelect packets sent
            Thread thread = new Thread(new ThreadStart(MonitorPrimsAwaitingSelect));

            thread.Start();

            while (running)
            {
                string command = Console.ReadLine();

                switch (command)
                {
                case "queue":
                    Logger.Log(String.Format("Client Outbox contains {0} packets, ObjectSelect queue contains {1} prims",
                                             client.Network.OutboxCount, primsAwaitingSelect.Count), Helpers.LogLevel.Info);
                    break;

                case "prims":
                    Logger.Log(String.Format("Prims captured: {0}, Total: {1}", prims.Count, totalPrims), Helpers.LogLevel.Info);
                    break;

                case "parcels":
                    if (!client.Network.CurrentSim.IsParcelMapFull())
                    {
                        Logger.Log("Downloading sim parcel information and prim totals", Helpers.LogLevel.Info);
                        client.Parcels.RequestAllSimParcels(client.Network.CurrentSim, false, 10);
                    }
                    else
                    {
                        Logger.Log("Sim parcel information has been retrieved", Helpers.LogLevel.Info);
                    }
                    break;

                case "camera":
                    Thread cameraThread = new Thread(new ThreadStart(MoveCamera));
                    cameraThread.Start();
                    Logger.Log("Started random camera movement thread", Helpers.LogLevel.Info);
                    break;

                case "movement":
                    Vector3 destination = RandomPosition();
                    Logger.Log("Teleporting to " + destination.ToString(), Helpers.LogLevel.Info);
                    client.Self.Teleport(client.Network.CurrentSim.Handle, destination, RandomPosition());
                    break;

                case "textures":
                    Logger.Log(String.Format("Current texture requests: {0}, queued texture requests: {1}, completed textures: {2}",
                                             texturePipeline.TransferCount, /*texturePipeline.QueuedCount*/ float.NaN, /*texturesFinished.Count*/ float.NaN), Helpers.LogLevel.Info);
                    break;

                case "terrain":
                    TerrainPatch[] patches = client.Network.CurrentSim.Terrain;
                    if (patches != null)
                    {
                        int count = 0;
                        for (int i = 0; i < patches.Length; i++)
                        {
                            if (patches[i] != null)
                            {
                                ++count;
                            }
                        }

                        Logger.Log(count + " terrain patches have been received for the current simulator", Helpers.LogLevel.Info);
                    }
                    else
                    {
                        Logger.Log("No terrain information received for the current simulator", Helpers.LogLevel.Info);
                    }
                    break;

                case "saveterrain":
                    patches = client.Network.CurrentSim.Terrain;
                    if (patches != null)
                    {
                        try
                        {
                            using (FileStream stream = new FileStream(directoryname + "/terrains/heightmap.r32", FileMode.Create, FileAccess.Write))
                            {
                                for (int y = 0; y < 256; y++)
                                {
                                    for (int x = 0; x < 256; x++)
                                    {
                                        int xBlock = x / 16;
                                        int yBlock = y / 16;
                                        int xOff   = x - (xBlock * 16);
                                        int yOff   = y - (yBlock * 16);

                                        TerrainPatch patch = patches[yBlock * 16 + xBlock];
                                        float        t     = 0f;

                                        if (patch != null)
                                        {
                                            t = patch.Data[yOff * 16 + xOff];
                                        }
                                        else
                                        {
                                            Logger.Log(String.Format("Skipping missing patch at {0},{1}", xBlock, yBlock),
                                                       Helpers.LogLevel.Warning);
                                        }

                                        stream.Write(BitConverter.GetBytes(t), 0, 4);
                                    }
                                }
                            }
                        }
                        catch (Exception ex)
                        {
                            Logger.Log("Failed saving terrain: " + ex.Message, Helpers.LogLevel.Error);
                        }
                    }
                    else
                    {
                        Logger.Log("No terrain information received for the current simulator", Helpers.LogLevel.Info);
                    }
                    break;

                case "save":
                    Logger.Log(String.Format("Preparing to serialize {0} objects", prims.Count), Helpers.LogLevel.Info);
                    SavePrims(prims, directoryname + "/objects", importSettings);
                    Logger.Log("Saving " + directoryname, Helpers.LogLevel.Info);
                    OarFile.PackageArchive(directoryname, filename, true, false);
                    Logger.Log("Done", Helpers.LogLevel.Info);
                    break;

                case "quit":
                    End();
                    break;
                }
            }
        }
示例#3
0
        public CmdResult Execute(string[] args, UUID fromAgentID, OutputDelegate writeLine)
        {
            if (!IsLocalScene)
            {
                ExportCommand.IsExporting = false;
            }
            else
            {
                ExportCommand.IsExporting = true;
            }
            const string hlp = @"
            
            Toplevel Directives

            // todo  = shows what must be done for import to be complete (suggest adding verbose)
            // perms  = shows what perms are going to be a problem (suggest adding verbose)
            // clear - clear the export dir
            // reset - reset the exporter state
            // cache - blow away asset cache

            // prims [spec] - do only prims meeting spec (default is prims $region) 
            // incr - do only do what is 'todo'
            // nonincr - do things 'todo' but also 'redo' things already done

            // noperms = dont skip things when perms might be a problem
            // quietly = terser output
            // verbose = more verbose
            // request = will rerequest missing things like textures
            // force = will allow unequal LLSD files - this should only be used as last resort

            // users - load users files 
            // prims - load llsd files 
            // trees - load trees files 
            // terrain - load terrain files 
            // links - operate on linkset
            // tasks - save task files
            // taskobjs - task objects
            // all = users llsd tasks deps links (dl and taskobj not included)           
            ";

            if (args == null || args.Length == 0)
            {
                return(Failure(hlp));
            }
            ImportSettings importSettings = new ImportSettings();

            ExportCommand.Exporting.settings = importSettings;
            importSettings.GroupID           = (args.Length > 1) ? TheBotClient.GroupID : UUID.Zero;
            importSettings.CurSim            = Client.Network.CurrentSim;
            var arglist = importSettings;

            writeLine("Starting SimImport...");
            foreach (string s in args)
            {
                arglist.Add(s);
            }
            if (arglist.Contains("reoar"))
            {
                OarFile.PackageArchive("cog_export/oarfile/", "repack.oar", false, false);
                return(SuccessOrFailure());
            }
            if (arglist.Contains("nolldie"))
            {
                ReplaceLSLText(ExportCommand.assetDumpDir, "llDie()",
                               "llOwnerSay((string)llGetKey() + \",script caused die ,\" + llGetObjectName() + \",\" + (string)llGetPos() + \",\" + llGetScriptName() + \",\" + llGetLinkNumber())",
                               arglist);
                return(SuccessOrFailure());
            }
            if (arglist.Contains("hhp"))
            {
                //arglist.Add("keepmissing");
                //arglist.Add("all");
                //arglist.Add("oar");
                arglist.Add("fullperms");
                // arglist.Add("lslprims");
                //arglist.Add("request");
                //arglist.Add("KillMissing");
                arglist.Add("reztaskobj");
                arglist.Add("prim");
                arglist.Add("confirm");
                arglist.Add("link");
                arglist.Add("checktasks");
                arglist.Add("tasklsl");
            }
            bool doRez = false;

            if (arglist.Contains("all"))
            {
                //  arglist.Add("terrain");
                arglist.Add("asset");
                arglist.Add("user");
                arglist.Add("group");
                arglist.Add("prim");
                arglist.Add("confirm");
                arglist.Add("link");
                arglist.Add("task");
                arglist.Add("taskobj");
                arglist.Add("CountReady");
            }
            if (arglist.Contains("prim"))
            {
                doRez = true;
                arglist.Add("asset");
                arglist.Add("link");
            }
            if (arglist.Contains("nolink"))
            {
                arglist.Remove("link");
            }
            if (arglist.Contains("noasset"))
            {
                arglist.Remove("asset");
            }
            if (arglist.Contains("link"))
            {
                arglist.Add("confirm");
            }
            if (arglist.Contains("user") || arglist.Contains("group") || true)
            {
                LoadUsersAndGroups(arglist);
            }
            if (arglist.Contains("asset") || true)
            {
                UploadAllAssets(arglist);
            }
            GleanUUIDsFrom(GetAssetUploadsFolder());
            ScanForChangeList();
            if (arglist.Contains("terrain"))
            {
                UploadTerrain(importSettings);
            }
            WriteLine("NewAsset ChangeList Size is " + ChangeList.Count);

            if (arglist.Contains("confirm"))
            {
                ImportPTCFiles(importSettings, false, doRez);
            }
            if (arglist.Contains("prim"))
            {
                ImportPrims(importSettings, doRez);
            }
            if (doRez)
            {
                RezPrims(importSettings);
            }
            if (arglist.Contains("confirm"))
            {
                ConfirmLocalIDs(importSettings);
            }
            if (arglist.Contains("link"))
            {
                ImportLinks(importSettings);
            }
            if (arglist.Contains("move"))
            {
                MoveToKnownObjects();
                Success("Moving to " + _parents.Count);
            }
            bool tasksObjs = arglist.Contains("taskobj") && !IsLocalScene;

            if (tasksObjs || arglist.Contains("checktasks"))
            {
                ImportTaskObjects(importSettings);
            }
            if (arglist.Contains("task") || tasksObjs)
            {
                ImportTaskFiles(importSettings, tasksObjs);
            }
            GleanUUIDsFrom(GetAssetUploadsFolder());
            SaveMissingIDs();
            if (arglist.Contains("request"))
            {
                RequestMissingIDs(importSettings);
            }
            if (arglist.Contains("locate"))
            {
                LocatePrims(importSettings);
            }
            DivideTaskObjects(importSettings);
            if (arglist.Contains("killmissing"))
            {
                KillMissing(importSettings);
            }
            if (arglist.Contains("lslprims"))
            {
                ConfirmLSLPrims(importSettings);
            }
            if (arglist.Contains("todo"))
            {
                DoTodo(importSettings);
            }
            if (arglist.Contains("checktasks"))
            {
                CheckTasks(importSettings);
            }
            if (arglist.Contains("upackobjs"))
            {
                UnpackTaskObjs(importSettings);
            }
            if (arglist.Contains("oar"))
            {
                CreateOARFile(importSettings, "exported.oar");
            }
            if (arglist.Contains("CountReady"))
            {
                CountReady(importSettings);
            }
            if (arglist.Contains("cleanup"))
            {
                CleanupPrims(importSettings);
            }
            if (arglist.Contains("cleanuptasks"))
            {
                CleanupTasks(importSettings);
            }
            writeLine("Completed SimImport");
            return(SuccessOrFailure());
        }