コード例 #1
0
ファイル: CreateNewModelSystem.cs プロジェクト: Cocotus/XTMF
 public bool Do(ref string error)
 {
     var repository = Config.ModelSystemRepository;
     if ( !Project.ValidateProjectName( this.Name ) )
     {
         return false;
     }
     if ( repository.ModelSystems.Any( (ms) => ms.Name.Equals( this.Name, StringComparison.InvariantCultureIgnoreCase ) ) )
     {
         error = "There already exists a model system with the name '" + this.Name + "'!";
         return false;
     }
     this.GeneratedModelSystem = new ModelSystem( Config, this.Name );
     this.GeneratedModelSystem.Description = Description;
     if ( this.Strucuture != null )
     {
         this.GeneratedModelSystem.ModelSystemStructure = this.Strucuture.Clone();
         SetupLinkedParameters( ref error );
     }
     if ( !GeneratedModelSystem.Save( ref error ) )
     {
         this.GeneratedModelSystem = null;
         return false;
     }
     repository.Add( this.GeneratedModelSystem );
     return true;
 }
コード例 #2
0
        public bool Do(ref string error)
        {
            if (this.Replace)
            {
                var modelSystems = this.Configuration.ModelSystemRepository.ModelSystems;
                for (int i = 0; i < modelSystems.Count; i++)
                {
                    if (modelSystems[i].Name.Equals(this.Name, StringComparison.InvariantCultureIgnoreCase))
                    {
                        this.Configuration.ModelSystemRepository.Remove(modelSystems[i]);
                        break;
                    }
                }
            }
            try
            {
                File.Copy(this.Location, Path.Combine(this.Configuration.ModelSystemDirectory, this.Name + ".xml"), true);
            }
            catch (IOException)
            {
            }
            ModelSystem ms = new ModelSystem(this.Configuration, this.Name);

            this.Configuration.ModelSystemRepository.Add(ms);
            this.ModelSystem = ms;
            return(ms.Save(ref error));
        }
コード例 #3
0
        public RenderModelsStage(ModelSystem modelSystem, ModelPipeline modelPipeline)
        {
            this.ModelSystem   = modelSystem;
            this.ModelPipeline = modelPipeline;

            this.Input = new ModelPipelineInput();
        }
コード例 #4
0
ファイル: CreateNewModelSystem.cs プロジェクト: dianatle/XTMF
        public bool Do(ref string error)
        {
            var repository = Config.ModelSystemRepository;

            if (!Project.ValidateProjectName(this.Name))
            {
                return(false);
            }
            if (repository.ModelSystems.Any((ms) => ms.Name.Equals(this.Name, StringComparison.InvariantCultureIgnoreCase)))
            {
                error = "There already exists a model system with the name '" + this.Name + "'!";
                return(false);
            }
            this.GeneratedModelSystem             = new ModelSystem(Config, this.Name);
            this.GeneratedModelSystem.Description = Description;
            if (this.Strucuture != null)
            {
                this.GeneratedModelSystem.ModelSystemStructure = this.Strucuture.Clone();
                SetupLinkedParameters(ref error);
            }
            if (!GeneratedModelSystem.Save(ref error))
            {
                this.GeneratedModelSystem = null;
                return(false);
            }
            repository.Add(this.GeneratedModelSystem);
            return(true);
        }
コード例 #5
0
ファイル: ImportModelSystem.cs プロジェクト: Cocotus/XTMF
 public bool Do(ref string error)
 {
     if ( this.Replace )
     {
         var modelSystems = this.Configuration.ModelSystemRepository.ModelSystems;
         for ( int i = 0; i < modelSystems.Count; i++ )
         {
             if ( modelSystems[i].Name.Equals( this.Name, StringComparison.InvariantCultureIgnoreCase ) )
             {
                 this.Configuration.ModelSystemRepository.Remove( modelSystems[i] );
                 break;
             }
         }
     }
     try
     {
         File.Copy( this.Location, Path.Combine( this.Configuration.ModelSystemDirectory, this.Name + ".xml" ), true );
     }
     catch ( IOException )
     {
     }
     ModelSystem ms = new ModelSystem( this.Configuration, this.Name );
     this.Configuration.ModelSystemRepository.Add( ms );
     this.ModelSystem = ms;
     return ms.Save( ref error );
 }
コード例 #6
0
ファイル: ShadowMapSystem.cs プロジェクト: 0000duck/MiniRTS
        public ShadowMapSystem(
            GraphicsDevice device,
            IComponentContainer <ShadowMap> shadowMaps,
            IComponentContainer <CascadedShadowMap> cascadedShadowMaps,
            ModelSystem modelSystem,
            IMeterRegistry meterRegistry)
        {
            this.Device             = device;
            this.ShadowMaps         = shadowMaps;
            this.CascadedShadowMaps = cascadedShadowMaps;
            this.ModelSystem        = modelSystem;
            this.MeterRegistry      = meterRegistry;

            this.MeterRegistry.CreateGauge(ShadowMapCounter);
            this.MeterRegistry.CreateGauge(ShadowMapTotal);
            this.MeterRegistry.CreateGauge(ShadowMapStep, "step");

            this.NullSkybox = new TextureCube(device, 1, false, SurfaceFormat.Color);
            this.NullSkybox.SetData(CubeMapFace.PositiveX, new Color[] { Color.White });
            this.NullSkybox.SetData(CubeMapFace.NegativeX, new Color[] { Color.White });
            this.NullSkybox.SetData(CubeMapFace.PositiveY, new Color[] { Color.White });
            this.NullSkybox.SetData(CubeMapFace.NegativeY, new Color[] { Color.White });
            this.NullSkybox.SetData(CubeMapFace.PositiveZ, new Color[] { Color.White });
            this.NullSkybox.SetData(CubeMapFace.NegativeZ, new Color[] { Color.White });
        }
コード例 #7
0
 private void LoadModelSystem(ModelSystem modelSystem)
 {
     if (modelSystem != null)
     {
         ModelSystemEditingSession session     = null;
         OperationProgressing      progressing = new OperationProgressing
         {
             Owner = GetWindow()
         };
         var loadingTask = Task.Run(() =>
         {
             session = Runtime.ModelSystemController.EditModelSystem(modelSystem);
         });
         MainWindow.Us.Dispatcher.BeginInvoke(new Action(() =>
         {
             progressing.ShowDialog();
         }));
         loadingTask.Wait();
         if (session != null)
         {
             MainWindow.Us.EditModelSystem(session);
         }
         MainWindow.Us.Dispatcher.BeginInvoke(new Action(() =>
         {
             progressing.Close();
         }));
     }
 }
コード例 #8
0
 public void OneTimeSetUp()
 {
     AndroidDriver       = new AndroidDriverCore(DriverConfiguration).StartEngine();
     ModelChromeCore     = new ModelChrome(AndroidDriver);
     ModelSystemCore     = new ModelSystem(AndroidDriver);
     ModelCalculatorCore = new ModelCalculator(AndroidDriver);
     ModelPhoneCore      = new ModelPhone(AndroidDriver);
 }
コード例 #9
0
        public DeferredRenderPipeline(
            GraphicsDevice device,
            ShadowMapSystem shadowMapSystem,
            ModelSystem modelSystem,
            AveragedParticleSystem particleSystem,
            AdditiveParticleSystem additiveParticleSystem,
            ProjectorSystem projectorSystem,
            EffectFactory effectFactory,
            AmbientLightSystem ambientLightSystem,
            DirectionalLightSystem directionalLightSystem,
            PointLightSystem pointLightSystem,
            CascadedShadowMapSystem cascadedShadowMapSystem,
            ShadowCastingLightSystem shadowCastingLightSystem,
            SunlightSystem sunlightSystem,
            BoundarySystem boundarySystem,
            DynamicTextureSystem dynamicTextureSystem,
            IconSystem iconSystem,
            CutsceneSystem cutsceneSystem,
            IMeterRegistry meterRegistry)
        {
            this.ShadowMapSystem           = shadowMapSystem;
            this.ModelSystem               = modelSystem;
            this.TransparentParticleSystem = particleSystem;
            this.AdditiveParticleSystem    = additiveParticleSystem;
            this.ProjectorSystem           = projectorSystem;
            this.CombineEffect             = effectFactory.Construct <CombineEffect>();
            this.FxaaEffect               = effectFactory.Construct <FxaaEffect>();
            this.AmbientLightSystem       = ambientLightSystem;
            this.DirectionalLightSystem   = directionalLightSystem;
            this.PointLightSystem         = pointLightSystem;
            this.CascadedShadowMapSystem  = cascadedShadowMapSystem;
            this.ShadowCastingLightSystem = shadowCastingLightSystem;
            this.SunlightSystem           = sunlightSystem;
            this.BoundarySystem           = boundarySystem;
            this.DynamicTextureSystem     = dynamicTextureSystem;
            this.CutsceneSystem           = cutsceneSystem;
            this.IconSystem               = iconSystem;

            var width  = device.PresentationParameters.BackBufferWidth;
            var height = device.PresentationParameters.BackBufferHeight;

            this.GBuffer = new GBuffer(device, width, height);

            this.Input = new RenderPipelineInput();

            this.Settings = new RenderPipelineSettings();

            this.ShadowPipeline    = ShadowPipeline.Create(device, meterRegistry);
            this.LightingPipeline  = LightingPipeline.Create(device, meterRegistry);
            this.ModelPipeline     = ModelPipeline.Create(device, meterRegistry);
            this.ParticlePipeline  = ParticlePipeline.Create(device, meterRegistry);
            this.ProjectorPipeline = ProjectorPipeline.Create(device, meterRegistry);

            this.Pipeline = RenderPipeline.Create(device, meterRegistry);
            this.RootPass = new Pass(PassType.Opaque, 0);

            this.Recreate();
        }
コード例 #10
0
 public Game1()
 {
     graphics = new GraphicsDeviceManager(this);
     Content.RootDirectory = "Content";
     cameraSystem          = new CameraSystem();
     transformSystem       = new TransformSystem();
     modelSystem           = new ModelSystem();
     heightmapSystem       = new HeightmapSystem();
 }
コード例 #11
0
 /// <summary>
 /// Allows the game to perform any initialization it needs to before starting to run.
 /// This is where it can query for any required services and load any non-graphic
 /// related content.  Calling base.Initialize will enumerate through any components
 /// and initialize them as well.
 /// </summary>
 protected override void Initialize()
 {
     // TODO: Add your initialization logic here
     cameraSystem    = new CameraSystem();
     transformSystem = new TransformSystem();
     modelSystem     = new ModelSystem();
     heightmapSystem = new HeightmapSystem();
     base.Initialize();
 }
コード例 #12
0
        public static RenderPipeline RenderModels(
            this RenderPipeline pipeline,
            ModelSystem modelSystem,
            ModelPipeline modelPipeline)
        {
            var stage = new RenderModelsStage(modelSystem, modelPipeline);

            pipeline.Add(stage);
            return(pipeline);
        }
コード例 #13
0
ファイル: Game1.cs プロジェクト: henwist/Datorgrafik_lab1
        protected override void Initialize()
        {
            graphics.PreferredBackBufferWidth  = 1024;
            graphics.PreferredBackBufferHeight = 768;
            graphics.IsFullScreen = false;
            graphics.ApplyChanges();

            modelSystem     = ModelSystem.Instance;
            transformSystem = TransformSystem.Instance;

            createGameEntities();

            base.Initialize();
        }
コード例 #14
0
 public void SetActive(object data)
 {
     this.ModelSystemSelector.ClearFilter();
     if (data is QuestionResult)
     {
         var res = data as QuestionResult;
         if (res.Success)
         {
             if (res.Data is IModelSystemStructure)
             {
                 var selectedModule = res.Data as IModelSystemStructure;
                 selectedModule.Name = res.Result;
                 var    index = this._CurrentProject.ModelSystemStructure.IndexOf(selectedModule);
                 string error = null;
                 if (!this._CurrentProject.Save(ref error))
                 {
                     MessageBox.Show("Unable to save Project!\r\n" + error, "Unable to save!", MessageBoxButton.OK, MessageBoxImage.Error);
                 }
                 this.SetModelSystems();
             }
             else if (res.Data is IModelSystem)
             {
                 IModelSystem baseMS = res.Data as IModelSystem;
                 string       error  = null;
                 var          lp     = this.CurrentProject.LinkedParameters[this.CurrentProject.ModelSystemStructure.IndexOf(this.CurrentModelSystem)];
                 var          ms     = this.XTMF.CreateCopy(this.CurrentModelSystem, lp, baseMS.Name, this.CurrentModelSystem.Description);
                 if (!ms.Save(ref error))
                 {
                     MessageBox.Show("Unable to save Model System!\r\n" + error, "Unable to save!", MessageBoxButton.OK, MessageBoxImage.Error);
                 }
             }
         }
     }
     else if (data is BooleanQuestionResult)
     {
         var res = data as BooleanQuestionResult;
         if (res.Success && res.Result)
         {
             string error = null;
             this._CurrentProject.ModelSystemStructure.Remove(res.Data as IModelSystemStructure);
             if (!this._CurrentProject.Save(ref error))
             {
                 MessageBox.Show("Unable to save project!\r\n" + error, "Unable to save!", MessageBoxButton.OK, MessageBoxImage.Error);
             }
             this.SetModelSystems();
         }
     }
     this.SaveAsMS = null;
 }
コード例 #15
0
ファイル: ShadowMapSystem.cs プロジェクト: third1020/MiniRTS
        public ShadowMapSystem(
            GraphicsDevice device,
            IComponentContainer <ShadowMap> shadowMaps,
            ModelSystem modelSystem,
            AveragedParticleSystem particleSystem,
            IMeterRegistry meterRegistry)
        {
            this.Device         = device;
            this.ShadowMaps     = shadowMaps;
            this.ModelSystem    = modelSystem;
            this.ParticleSystem = particleSystem;
            this.MeterRegistry  = meterRegistry;

            this.MeterRegistry.CreateGauge(ShadowMapCounter);
            this.MeterRegistry.CreateGauge(ShadowMapTotal);
            this.MeterRegistry.CreateGauge(ShadowMapStep, "step");
        }
コード例 #16
0
 private void MSContextMenu_SaveAsModelSystemPressed()
 {
     if (this.CurrentModelSystem != null)
     {
         this.SaveAsMS = new ModelSystem(this.XTMF.XTMF.Configuration);
         QuestionData question = new QuestionData();
         question.Path          = this.Path;
         question.OnSuccess     = XTMFPage.ProjectSettingsPage;
         question.OnSuccessData = this.SaveAsMS;
         question.OnCancel      = XTMFPage.ProjectSettingsPage;
         question.OnCancelData  = null;
         question.Validate      = ValidateModelSystemName;
         question.Question      = "Select a unique name for the Model System";
         question.Hint          = "Model System";
         question.DefaultText   = this.CurrentModelSystem.Name;
         this.XTMF.Navigate(XTMFPage.QuestionPage, question);
     }
 }
コード例 #17
0
ファイル: PipelineBuilder.cs プロジェクト: 0000duck/MiniRTS
        public PipelineBuilder(GraphicsDevice device, ShadowMapSystem shadowMapSystem, ModelSystem modelSystem, AveragedParticleSystem transparentParticleSystem, AdditiveParticleSystem additiveParticleSystem, ProjectorSystem projectorSystem, EffectFactory effectFactory, AmbientLightSystem ambientLightSystem, DirectionalLightSystem directionalLightSystem, PointLightSystem pointLightSystem, CascadedShadowMapSystem cascadedShadowMapSystem, ShadowCastingLightSystem shadowCastingLightSystem, SunlightSystem sunlightSystem, IconSystem iconSystem)
        {
            this.Device                    = device;
            this.ShadowMapSystem           = shadowMapSystem;
            this.ModelSystem               = modelSystem;
            this.TransparentParticleSystem = transparentParticleSystem;
            this.AdditiveParticleSystem    = additiveParticleSystem;
            this.ProjectorSystem           = projectorSystem;
            this.CombineEffect             = effectFactory.Construct <CombineEffect>();
            this.FxaaEffect                = effectFactory.Construct <FxaaEffect>();
            this.AmbientLightSystem        = ambientLightSystem;
            this.DirectionalLightSystem    = directionalLightSystem;
            this.PointLightSystem          = pointLightSystem;
            this.CascadedShadowMapSystem   = cascadedShadowMapSystem;
            this.ShadowCastingLightSystem  = shadowCastingLightSystem;
            this.SunlightSystem            = sunlightSystem;
            this.IconSystem                = iconSystem;

            this.MeterRegistry = new NullMeterRegistry();
        }
コード例 #18
0
 /// <summary>
 /// Create a model system session allowing for the editing of a model system.
 /// </summary>
 /// <param name="user">The user that is requesting access.</param>
 /// <param name="modelSystemHeader">The model system reference to load.</param>
 /// <param name="session">The resulting session.</param>
 /// <param name="error">An error message if the operation fails.</param>
 /// <returns>True if the operation succeeds, false otherwise with an error message.</returns>
 public bool EditModelSystem(User user, ModelSystemHeader modelSystemHeader, out ModelSystemSession?session, out CommandError?error)
 {
     if (user is null)
     {
         throw new ArgumentNullException(nameof(user));
     }
     if (modelSystemHeader is null)
     {
         throw new ArgumentNullException(nameof(modelSystemHeader));
     }
     session = null;
     lock (_sessionLock)
     {
         if (!Project.CanAccess(user))
         {
             error = new CommandError("The given user does not have access to this project!", true);
             return(false);
         }
         if (!Project.ContainsModelSystem(modelSystemHeader))
         {
             error = new CommandError("The model system header provided does not belong to this project!");
             return(false);
         }
         if (!_activeSessions.TryGetValue(modelSystemHeader, out session))
         {
             if (ModelSystem.Load(this, modelSystemHeader, out session, out error))
             {
                 _activeSessions.Add(modelSystemHeader, session !);
                 Interlocked.Increment(ref _references);
                 return(true);
             }
             return(false);
         }
         else
         {
             session.AddReference();
         }
         error = null;
         return(true);
     }
 }
コード例 #19
0
        /// <summary>
        /// Validate the model system contained within this run context.
        /// </summary>
        /// <param name="error">An error message if the model system is invalid.</param>
        /// <returns>True if the model system is valid, false otherwise with an error message.</returns>
        private bool ValidateModelSystem(ref string?error)
        {
            string?moduleName = null;

            // Make sure that we are able to actually construct the directory
            try
            {
                Directory.CreateDirectory(_currentWorkingDirectory);
            }
            catch (IOException e)
            {
                error = e.Message;
                return(false);
            }
            // Construct the model system
            if (!Convert(_modelSystemAsData, out var modelSystemAsString))
            {
                error = "Unable to convert model system data into a string!";
                return(false);
            }
            if (!ModelSystem.Load(modelSystemAsString, _runtime, out var ms, ref error) ||
                !ms !.Construct(_runtime, ref error) ||
                !ms !.Validate(ref moduleName, ref error))
            {
                RunResults.WriteValidationError(_currentWorkingDirectory, moduleName, error);
                return(false);
            }
            _modelSystem = ms;
            // Ensure that the starting point exists
            if (!GetStart(Start.ParseStartString(StartToExecute),
                          out var _, ref error))
            {
                _modelSystem = null;
                return(false);
            }
            return(true);
        }
コード例 #20
0
 public void SetActive(object data)
 {
     this.ModelSystemSelector.ClearFilter();
     if ( data is QuestionResult )
     {
         var res = data as QuestionResult;
         if ( res.Success )
         {
             if ( res.Data is IModelSystemStructure )
             {
                 var selectedModule = res.Data as IModelSystemStructure;
                 selectedModule.Name = res.Result;
                 var index = this._CurrentProject.ModelSystemStructure.IndexOf( selectedModule );
                 string error = null;
                 if ( !this._CurrentProject.Save( ref error ) )
                 {
                     MessageBox.Show( "Unable to save Project!\r\n" + error, "Unable to save!", MessageBoxButton.OK, MessageBoxImage.Error );
                 }
                 this.SetModelSystems();
             }
             else if ( res.Data is IModelSystem )
             {
                 IModelSystem baseMS = res.Data as IModelSystem;
                 string error = null;
                 var lp = this.CurrentProject.LinkedParameters[this.CurrentProject.ModelSystemStructure.IndexOf( this.CurrentModelSystem )];
                 var ms = this.XTMF.CreateCopy( this.CurrentModelSystem, lp, baseMS.Name, this.CurrentModelSystem.Description );
                 if ( !ms.Save( ref error ) )
                 {
                     MessageBox.Show( "Unable to save Model System!\r\n" + error, "Unable to save!", MessageBoxButton.OK, MessageBoxImage.Error );
                 }
             }
         }
     }
     else if ( data is BooleanQuestionResult )
     {
         var res = data as BooleanQuestionResult;
         if ( res.Success && res.Result )
         {
             string error = null;
             this._CurrentProject.ModelSystemStructure.Remove( res.Data as IModelSystemStructure );
             if ( !this._CurrentProject.Save( ref error ) )
             {
                 MessageBox.Show( "Unable to save project!\r\n" + error, "Unable to save!", MessageBoxButton.OK, MessageBoxImage.Error );
             }
             this.SetModelSystems();
         }
     }
     this.SaveAsMS = null;
 }
コード例 #21
0
 private void MSContextMenu_SaveAsModelSystemPressed()
 {
     if ( this.CurrentModelSystem != null )
     {
         this.SaveAsMS = new ModelSystem( this.XTMF.XTMF.Configuration );
         QuestionData question = new QuestionData();
         question.Path = this.Path;
         question.OnSuccess = XTMFPage.ProjectSettingsPage;
         question.OnSuccessData = this.SaveAsMS;
         question.OnCancel = XTMFPage.ProjectSettingsPage;
         question.OnCancelData = null;
         question.Validate = ValidateModelSystemName;
         question.Question = "Select a unique name for the Model System";
         question.Hint = "Model System";
         question.DefaultText = this.CurrentModelSystem.Name;
         this.XTMF.Navigate( XTMFPage.QuestionPage, question );
     }
 }