private IEnumerable <IdleStatus> finishInitialization(String defaultModel) { yield return(IdleStatus.Ok); splashScreen.updateStatus(15, "Loading Resources"); VirtualFileSystem.Instance.addArchive(OgreModelEditorConfig.VFSRoot); emptyResourceManager = pluginManager.createScratchResourceManager(); liveResourceManager = pluginManager.createLiveResourceManager("Scene"); resourceManager = pluginManager.createScratchResourceManager(); yield return(IdleStatus.Ok); splashScreen.updateStatus(40, "Creating GUI"); //Initialize controllers modelController = new ModelController(this); //Create the GUI consoleWindow = new LogWindow(); guiManager.addManagedDialog(consoleWindow); consoleWindow.Visible = true; Log.Default.addLogListener(consoleWindow); virtualTextureDebugger = new VirtualTextureDebugger(virtualTextureLink.VirtualTextureManager); guiManager.addManagedDialog(virtualTextureDebugger); textureCompiler = new TextureCompilerGUI(pluginManager, mainWindow); textureCompiler.CurrentSrc = OgreModelEditorConfig.LastTextureCompilerSourceDirectory; guiManager.addManagedDialog(textureCompiler); materialEditor = new MDIObjectEditor("Materials", "MaterialEditor", false); guiManager.addManagedDialog(materialEditor); materialEditor.CurrentDockLocation = DockLocation.Left; materialEditor.Visible = true; materialEditor.EditInterface = materialController.EditInterface; yield return(IdleStatus.Ok); splashScreen.updateStatus(70, "Creating Scene"); //Create a simple scene to use to show the models SimSceneDefinition sceneDefiniton = new SimSceneDefinition(); OgreSceneManagerDefinition ogreScene = new OgreSceneManagerDefinition("Ogre"); SimSubSceneDefinition mainSubScene = new SimSubSceneDefinition("Main"); sceneDefiniton.addSimElementManagerDefinition(ogreScene); sceneDefiniton.addSimSubSceneDefinition(mainSubScene); mainSubScene.addBinding(ogreScene); sceneDefiniton.DefaultSubScene = "Main"; scene = sceneDefiniton.createScene(); sceneViewController.createCameras(scene); lightManager.sceneLoaded(scene); objectMover.sceneLoaded(scene); virtualTextureLink.sceneLoaded(scene); yield return(IdleStatus.Ok); if (!String.IsNullOrEmpty(defaultModel)) { splashScreen.updateStatus(80, "Loading Model"); openModel(defaultModel); yield return(IdleStatus.Ok); } splashScreen.updateStatus(100, "Loaded"); splashScreen.hide(); yield return(IdleStatus.Ok); }
public void initialize(StandaloneController standaloneController) { GUIManager guiManager = standaloneController.GUIManager; //UI Helpers gridProperties = new GridPropertiesDialog(standaloneController.MeasurementGrid); guiManager.addManagedDialog(gridProperties); developerRenderer = new DeveloperRenderPropertiesDialog(standaloneController.SceneViewController, standaloneController.ImageRenderer, guiManager, standaloneController.NotificationManager); guiManager.addManagedDialog(developerRenderer); discControl = new DiscControl(); guiManager.addManagedDialog(discControl); advancedMandibleMovement = new AdvancedMandibleMovementDialog(standaloneController.MovementSequenceController, standaloneController.MusclePositionController); guiManager.addManagedDialog(advancedMandibleMovement); performanceGui = new PerformanceGui(standaloneController); guiManager.addManagedDialog(performanceGui); measurementGUI = new MeasurementGUI(standaloneController); guiManager.addManagedDialog(measurementGUI); debugVisualizer = new DebugVisualizer(standaloneController); guiManager.addManagedDialog(debugVisualizer); advancedCameraGui = new AdvancedCameraGui(standaloneController.SceneViewController); guiManager.addManagedDialog(advancedCameraGui); libRocketDebugger = new ShowLibRocketDebugger(guiManager, "ShowLibRocketDebugger", "Show LibRocket Debugger", "Developer.libRocketDebugger", "Developer"); resolutionGui = new ResolutionGui(standaloneController.MainWindow); guiManager.addManagedDialog(resolutionGui); RocketInterface.Instance.FileInterface.addExtension(new RocketAssemblyResourceLoader(this.GetType().Assembly)); changeRenderingMode = new ChangeRenderingMode(standaloneController.SceneViewController); disablePhysics = new DisablePhysicsTask(int.MaxValue); //Task Controller TaskController taskController = standaloneController.TaskController; taskController.addTask(new MDIDialogOpenTask(developerRenderer, "Developer.DeveloperRender", "Render", "AnomalousMedical/RenderIcon", TaskMenuCategories.Create)); if (MedicalConfig.ShowDeveloperTools) { taskController.addTask(new MDIDialogOpenTask(discControl, "Medical.DiscEditor", "Disc Editor", "Developer.DiscEditorIcon", TaskMenuCategories.Developer)); taskController.addTask(new MDIDialogOpenTask(advancedMandibleMovement, "Medical.AdvancedMandibleMovement", "Advanced Mandible Movement", "Developer.MovementIcon", TaskMenuCategories.Developer)); taskController.addTask(new MDIDialogOpenTask(gridProperties, "Medical.GridProperties", "Grid", "Developer.GridIcon", TaskMenuCategories.Developer)); taskController.addTask(new MDIDialogOpenTask(performanceGui, "Medical.Performance", "Performance", "Developer.StatisticsIcon", TaskMenuCategories.Developer)); taskController.addTask(new MDIDialogOpenTask(measurementGUI, "Developer.Measurement", "Measurements", "Developer.Measurements", TaskMenuCategories.Developer)); taskController.addTask(new MDIDialogOpenTask(debugVisualizer, "Developer.DebugVisualizer", "Debug Visualizer", "Developer.DebugVisualizer", TaskMenuCategories.Developer)); taskController.addTask(new MDIDialogOpenTask(advancedCameraGui, "Developer.AdvancedCameraGui", "Advanced Camera Settings", CommonResources.NoIcon, TaskMenuCategories.Developer)); taskController.addTask(new MDIDialogOpenTask(resolutionGui, "Developer.SetResolution", "Set Resolution", CommonResources.NoIcon, TaskMenuCategories.Developer)); taskController.addTask(libRocketDebugger); taskController.addTask(new SaveMicrocodeCacheTask()); taskController.addTask(new CallbackTask("Developer.SaveToMax", "Save to 3ds Max", "Developer.MaxDumpIcon", TaskMenuCategories.Developer, (item) => { if (!item.Active) { item.setActive(true); MaxExport maxExport = new MaxExport(standaloneController); guiManager.addManagedDialog(maxExport); maxExport.Visible = true; maxExport.Closed += (evt, args) => { maxExport.Dispose(); item.setActive(false); item.closeTask(); }; } })); taskController.addTask(new CallbackTask("Developer.TogglePhysicalTextures", "Toggle Physical Textures", CommonResources.NoIcon, TaskMenuCategories.Developer, (item) => { if (standaloneController.VirtualTextureManager.Active) { standaloneController.VirtualTextureManager.suspend(); } else { standaloneController.VirtualTextureManager.resume(); } })); taskController.addTask(new CallbackTask("Developer.ToggleCompactMode", "Toggle Compact Mode", CommonResources.NoIcon, TaskMenuCategories.Developer, item => { standaloneController.GUIManager.CompactMode = !standaloneController.GUIManager.CompactMode; standaloneController.GUIManager.layout(); })); taskController.addTask(new CallbackTask("Developer.SpawnTestSplint", "Spawn Test Splint", CommonResources.NoIcon, TaskMenuCategories.Developer, item => { GenericSimObjectDefinition def = new GenericSimObjectDefinition("TestSplint" + Guid.NewGuid()); def.addElement(new SceneNodeDefinition("Node")); var rigidBody = new ReshapeableRigidBodyDefinition("RigidBody"); def.addElement(rigidBody); MultiProp multiProp = new MultiProp(); def.addElement(new BehaviorDefinition("MultiProp", multiProp)); DynamicSplint splint = new DynamicSplint() { MultiPropName = "MultiProp", }; def.addElement(new BehaviorDefinition("Behavior", splint)); PositionCollection positions; using (var stream = VirtualFileSystem.Instance.openStream("Plugins/SplintProps/PartModels/SplintSpace.positions", Engine.Resources.FileMode.Open)) { positions = new PositionCollection(stream); } Position position; if (false) { position = positions.getPosition("MaxillaryGroup"); splint.StartIndex = 1; splint.EndIndex = 17; rigidBody.Mass = 0; rigidBody.CollisionFilterMask = -3; rigidBody.CollisionFilterGroup = 1; } else { position = positions.getPosition("MandibularGroup"); splint.StartIndex = 17; splint.EndIndex = 33; rigidBody.Mass = 1; rigidBody.CollisionFilterMask = -5; rigidBody.CollisionFilterGroup = 1; var joint = new Generic6DofConstraintDefinition(Splint.JointName) { RigidBodyASimObject = "Mandible", RigidBodyAElement = "Actor", RigidBodyBSimObject = "this", RigidBodyBElement = "RigidBody", }; joint.TranslationMotor.LowerLimit = Vector3.Zero; joint.TranslationMotor.UpperLimit = Vector3.Zero; joint.XRotMotor.LoLimit = 0; joint.XRotMotor.HiLimit = 0; joint.YRotMotor.LoLimit = 0; joint.YRotMotor.HiLimit = 0; joint.ZRotMotor.LoLimit = 0; joint.ZRotMotor.HiLimit = 0; def.addElement(joint); def.addElement(new BehaviorDefinition("JointHandler", new MultiPropJointHandler(joint.Name, multiProp.Name))); //def.addElement(new BehaviorDefinition(Splint.SplintBehaviorName, new Splint() //{ //})); } def.Translation = position.Translation; def.Rotation = position.Rotation; PropDefinition propDef = new PropDefinition(def); standaloneController.PropFactory.addDefinition(propDef); Vector3 translationOffset = Quaternion.quatRotate(MandibleController.StartRotation.inverse(), position.Translation - MandibleController.StartTranslation); SimObject mandibleObject = MandibleController.Mandible.Owner; Vector3 trans = mandibleObject.Translation + Quaternion.quatRotate(mandibleObject.Rotation, translationOffset); Quaternion rotation = mandibleObject.Rotation; standaloneController.PropFactory.createProp(def.Name, trans, rotation); //SimObjectBase instance = def.register(standaloneController.MedicalController.CurrentScene.getDefaultSubScene()); //standaloneController.MedicalController.addSimObject(instance); //standaloneController.MedicalController.CurrentScene.buildScene(); //if (SimObjectErrorManager.HasErrors) //{ // standaloneController.NotificationManager.showCallbackNotification("Errors loading the prop.\nClick for details.", MessageBoxIcons.Error, () => // { // SceneErrorWindow errorGui = new SceneErrorWindow(guiManager); // errorGui.Visible = true; // }); //} })); taskController.addTask(disablePhysics); taskController.addTask(changeRenderingMode); #if ALLOW_CRASH_PROGRAM taskController.addTask(new CallbackTask("Developer.Crash", "Crash The Program", CommonResources.NoIcon, TaskMenuCategories.Developer, (item) => { throw new Exception("Manually crashed program"); })); #endif } standaloneController.ViewHostFactory.addFactory(new WizardComponentViews()); if (PlatformConfig.AllowFullscreenToggle && MedicalConfig.ShowDeveloperTools) { CallbackTask toggleBorderless = new CallbackTask("Developer.ToggleBorderless", "Toggle Borderless", "AnomalousMedical/ToggleFullscreen", TaskMenuCategories.Developer, int.MaxValue, false, (item) => { MainWindow.Instance.toggleBorderless(); }); taskController.addTask(toggleBorderless); } if (standaloneController.VirtualTextureManager != null && MedicalConfig.ShowDeveloperTools) { virtualTextureDebugger = new VirtualTextureDebugger(standaloneController.VirtualTextureManager); guiManager.addManagedDialog(virtualTextureDebugger); taskController.addTask(new MDIDialogOpenTask(virtualTextureDebugger, "Developer.VirtualTextureDebugger", "Virtual Texture Debugger", CommonResources.NoIcon, TaskMenuCategories.Developer)); } var screenshotButtonEvent = new ButtonEvent(EventLayers.Gui, frameUp: (evtMgr) => { try { String screenshotFolder = Path.Combine(MedicalConfig.UserDocRoot, "Screenshots"); if (!Directory.Exists(screenshotFolder)) { Directory.CreateDirectory(screenshotFolder); } OgreInterface.Instance.OgrePrimaryWindow.OgreRenderTarget.writeContentsToTimestampedFile(Path.Combine(screenshotFolder, "Screenshot"), ".png"); } catch (Exception ex) { MessageBox.show(String.Format("{0} saving screenshot. Message {1}", ex.GetType().Name, ex.Message), "Error saving screenshot", MessageBoxStyle.IconError | MessageBoxStyle.Ok); } }); screenshotButtonEvent.addButton(KeyboardButtonCode.KC_F8); screenshotButtonEvent.addButton(KeyboardButtonCode.KC_LSHIFT); standaloneController.MedicalController.EventManager.addEvent(screenshotButtonEvent); }