Ejemplo n.º 1
0
 protected void UpdateIrayBackground(IAddCommand seq)
 {
     if (Enabled)
     {
         Hashtable colour = new Hashtable() {
             {"r", Colour.r},
             {"g", Colour.g},
             {"b", Colour.b},
             {"a", 1.0f}
         };
         seq.AddCommand(new RSCommand("element_set_attribute",
                 "element_name", Viewport.Scene.OptionsName,
                 "attribute_name", "iray_background_color",
                 "attribute_type", "Color",
                 "attribute_value", colour,
                 "create", true
         ));
     }
     else
     {
         seq.AddCommand(new RSCommand("element_remove_attribute",
                 "element_name", Viewport.Scene.OptionsName,
                 "attribute_name", "iray_background_color"
         ));
     }
 }
Ejemplo n.º 2
0
 protected void UpdateIrayBackground(IAddCommand seq)
 {
     if (Enabled)
     {
         Hashtable colour = new Hashtable()
         {
             { "r", Colour.r },
             { "g", Colour.g },
             { "b", Colour.b },
             { "a", 1.0f }
         };
         seq.AddCommand(new RSCommand("element_set_attribute",
                                      "element_name", Viewport.Scene.OptionsName,
                                      "attribute_name", "iray_background_color",
                                      "attribute_type", "Color",
                                      "attribute_value", colour,
                                      "create", true
                                      ));
     }
     else
     {
         seq.AddCommand(new RSCommand("element_remove_attribute",
                                      "element_name", Viewport.Scene.OptionsName,
                                      "attribute_name", "iray_background_color"
                                      ));
     }
 }
Ejemplo n.º 3
0
 public Controller(IExitCommand exitCommand,
                   IHelpCommand helpCommand,
                   ICd cdCommand,
                   IDirCommand dirCommand,
                   IInitCommand initComman,
                   IStatusCommand statusCommand,
                   IListCommand listCommand,
                   IRegisterCommand registerCommand,
                   ILoginCommand logInCommand,
                   IAddCommand addCommand,
                   IRemoveCommand removeCommand,
                   ITestHttp testHttp, ICommitCommand commitCommand)
 {
     this.exitCommand     = exitCommand;
     this.helpCommand     = helpCommand;
     this.cdCommand       = cdCommand;
     this.dirCommand      = dirCommand;
     this.initComman      = initComman;
     this.statusCommand   = statusCommand;
     this.listCommand     = listCommand;
     this.registerCommand = registerCommand;
     this.loginCommand    = logInCommand;
     this.addCommand      = addCommand;
     this.removeCommand   = removeCommand;
     this.testHttp        = testHttp;
     this.commitCommand   = commitCommand;
 }
Ejemplo n.º 4
0
        public AddCommandHandler(IAddCommand args)
        {
            FileSystem = args.FileSystem ?? Program.FileSystem;
            Options    = args.Options;

            Assert.ArgumentNotNull(FileSystem);
            Assert.ArgumentNotNull(Options);
        }
Ejemplo n.º 5
0
 public T Add <T>(IAddCommand <T> command)
 {
     if (command.RequiresTransaction && _transaction == null)
     {
         throw new Exception($"The command {command.GetType()} requires a transaction");
     }
     return(Retry.Invoke(() => command.Execute(_connection, _transaction), _options));
 }
Ejemplo n.º 6
0
 protected void MarkDirty(IAddCommand seq)
 {
     if (UseRenderLoop)
     {
         seq.AddCommand(new RSCommand("render_loop_cancel_render",
                                      "render_loop_name", RenderLoopName
                                      ));
     }
 }
Ejemplo n.º 7
0
        public async Task <IActionResult> Post([FromRoute] Guid storyId, [FromBody] NewFeatureRequest newFeatureRequest,
                                               [FromServices] IAddCommand <AddFeature, int> addFeatureCommand)
        {
            var addFeature = new AddFeature {
                Title   = newFeatureRequest.Title,
                StoryId = storyId
            };
            var newFeatureId = await addFeatureCommand.Execute(addFeature);

            return(Ok(newFeatureId));
        }
        public void TestExecutingTheSameCommandTwice()
        {
            IAddCommand command = CreateAddCommand(10);

            AssertEquals("AddCommand 10", 10, ExecuteCommand(command));

            command.Amount = 20;
            AssertEquals("AddCommand 20", 30, ExecuteCommand(command));

            CrashRecover();
            AssertTotal(30);
        }
Ejemplo n.º 9
0
        public async Task <IActionResult> Post([FromRoute] Guid storyId, [FromBody] NewOptionRequest model,
                                               [FromServices] IAddCommand <NewOption, int> addOptionCommand)
        {
            var newOption = new NewOption {
                Title   = model.Title,
                StoryId = storyId
            };

            var newOptionId = await addOptionCommand.Execute(newOption);

            return(Ok(newOptionId));
        }
Ejemplo n.º 10
0
        public async Task <IActionResult> Post(
            [FromRoute] Guid storyId,
            [FromRoute] int featureId,
            [FromRoute] int optionId,
            [FromBody] NewOptionValueRequest optionValueRequest,
            [FromServices] IAddCommand <NewOptionValue, int> addCommand)
        {
            var model = mapper.Map <NewOptionValue>(optionValueRequest);

            model.StoryId   = storyId;
            model.FeatureId = featureId;
            model.OptionId  = optionId;
            var newOptionValueId = await addCommand.Execute(model);

            return(Ok(newOptionValueId));
        }
Ejemplo n.º 11
0
        protected void UpdateMovement(IAddCommand seq)
        {
            Matrix3D m = new Matrix3D();

            // NB: X is not negated to deal with handedness difference between RS and Unity
            m.SetTranslation(NewPosition.x, -NewPosition.y, -NewPosition.z);

            seq.AddCommand(new RSCommand("instance_set_world_to_obj",
                                         "instance_name", RealityServerObject,
                                         "transform", m.GetMatrixForRS()
                                         ));
            if (Viewport.Viewport.RenderLoopRunning)
            {
                Viewport.Viewport.RestartLoop();
            }
            Moved = false;
        }
Ejemplo n.º 12
0
		protected void UpdateMovement(IAddCommand seq)
		{
			//Debug.Log ("- move in RS " + RealityServerObject + " " + NewPosition) ;

			Matrix3D m = new Matrix3D ();
			// NB: X is not negated to deal with handedness difference between RS and Unity
			m.SetTranslation(NewPosition.x,-NewPosition.y,-NewPosition.z);

			seq.AddCommand(new RSCommand("instance_set_world_to_obj",
			                             "instance_name", RealityServerObject,
			                             "transform", m.GetMatrixForRS()
			                             ));
			if (Viewport.Viewport.RenderLoopRunning)
			{
				Viewport.Viewport.RestartLoop();
			}
			Moved = false;
		}
Ejemplo n.º 13
0
        protected void UpdateGroundShadows(IAddCommand seq)
        {
            seq.AddCommand(new RSCommand("element_set_attribute",
                                         "element_name", Viewport.Scene.OptionsName,
                                         "attribute_name", "environment_dome_ground",
                                         "attribute_type", "Boolean",
                                         "attribute_value", Enabled,
                                         "create", true
                                         ));

            if (Enabled)
            {
                Vector3D position = new Vector3D(0, Viewport.Scene.BBoxMin.Y);
                if (!AutoCalculateGroundHeight)
                {
                    position.Y = GroundHeight;
                }

                seq.AddCommand(new RSCommand("element_set_attribute",
                                             "element_name", Viewport.Scene.OptionsName,
                                             "attribute_name", "environment_dome_ground_position",
                                             "attribute_type", "Float32<3>",
                                             "attribute_value", position.GetVectorForRS(),
                                             "create", true
                                             ));

                Vector3D axis = new Vector3D(0, 0, 1);
                if (Viewport.SceneYUp)
                {
                    axis.Y = 1;
                    axis.Z = 0;
                }

                seq.AddCommand(new RSCommand("element_set_attribute",
                                             "element_name", Viewport.Scene.OptionsName,
                                             "attribute_name", "environment_dome_rotation_axis",
                                             "attribute_type", "Float32<3>",
                                             "attribute_value", axis.GetVectorForRS(),
                                             "create", true
                                             ));
            }
        }
Ejemplo n.º 14
0
        protected void UpdateGroundShadows(IAddCommand seq)
        {
            seq.AddCommand(new RSCommand("element_set_attribute",
                    "element_name", Viewport.Scene.OptionsName,
                    "attribute_name", "environment_dome_ground",
                    "attribute_type", "Boolean",
                    "attribute_value", Enabled,
                    "create", true
            ));
        
            if (Enabled)
            {
                Vector3D position = new Vector3D(0, Viewport.Scene.BBoxMin.Y);
                if (!AutoCalculateGroundHeight)
                {
                    position.Y = GroundHeight;
                }

                seq.AddCommand(new RSCommand("element_set_attribute",
                        "element_name", Viewport.Scene.OptionsName,
                        "attribute_name", "environment_dome_ground_position",
                        "attribute_type", "Float32<3>",
                        "attribute_value", position.GetVectorForRS(),
                        "create", true
                ));
                
                Vector3D axis = new Vector3D(0, 0, 1);
                if (Viewport.SceneYUp)
                {
                    axis.Y = 1;
                    axis.Z = 0;
                }

                seq.AddCommand(new RSCommand("element_set_attribute",
                        "element_name", Viewport.Scene.OptionsName,
                        "attribute_name", "environment_dome_rotation_axis",
                        "attribute_type", "Float32<3>",
                        "attribute_value", axis.GetVectorForRS(),
                        "create", true
                ));
            }
        }
Ejemplo n.º 15
0
        /**
         * If any changes have been made to the camera since the last time this function was called,
         * then commands for updating those values on the server will be added to the given command sequence.
         */
        public void UpdateCamera(IAddCommand seq)
        {
            if (CameraName == null || CameraName.Length == 0 ||
                CameraInstanceName == null || CameraInstanceName.Length == 0)
            {
                Logger.Log("error", "Cannot update camera until names have been set.");
                return;
            }

            if (changedValues.Count == 0)
            {
                return;
            }

            if (HasChanged("matrix"))
            {
                seq.AddCommand(new RSCommand("instance_set_world_to_obj",
                                             "instance_name", CameraInstanceName,
                                             "transform", TransformMatrix.GetMatrixForRS()
                                             ));
            }

            if (HasChanged("resX") || HasChanged("resY"))
            {
                seq.AddCommand(new RSCommand("camera_set_aspect",
                                             "camera_name", CameraName,
                                             "aspect", Aspect
                                             ));

                seq.AddCommand(new RSCommand("camera_set_resolution",
                                             "camera_name", CameraName,
                                             "resolution", new Hashtable()
                {
                    { "x", ResolutionX },
                    { "y", ResolutionY }
                }
                                             ));
            }

            if (HasChanged("ortho"))
            {
                seq.AddCommand(new RSCommand("camera_set_orthographic",
                                             "camera_name", CameraName,
                                             "orthographic", Orthographic
                                             ));
            }

            // As the aperture is used by both orthographic and perspective cameras
            // got slightly different things, we need to update the aperture if
            // the orthographic value has changed.
            if ((HasChanged("ortho") && Orthographic) || HasChanged("orthoSize"))
            {
                seq.AddCommand(new RSCommand("camera_set_aperture",
                                             "camera_name", CameraName,
                                             "aperture", OrthographicSize * 2.0f * Aspect
                                             ));
            }
            else if ((HasChanged("ortho") && !Orthographic) || HasChanged("fov"))
            {
                // As we currently do not load any camera values from the
                // server, we need to choose an aperture to work with.
                double aperture = 1.417;
                double deg2rad  = Math.PI / 180.0;
                double focal    = ((aperture / Aspect) / 2.0f)
                                  / Math.Tan(FieldOfView / 2.0f * deg2rad);
                seq.AddCommand(new RSCommand("camera_set_aperture",
                                             "camera_name", CameraName,
                                             "aperture", aperture
                                             ));
                seq.AddCommand(new RSCommand("camera_set_focal",
                                             "camera_name", CameraName,
                                             "focal", focal
                                             ));
            }

            changedValues.Clear();
            _hasNewChanges = false;
        }
Ejemplo n.º 16
0
 public RequestsFacade(INewRecordRequests newRecord, IAddCommand newRecordCommand)
 {
     _newRecord = newRecord;
     newRecordCommand.NewRecordRequested += _newRecord.AppendRequest;
 }
Ejemplo n.º 17
0
        protected void MarkDirty(IAddCommand seq)
        {
            if (UseRenderLoop)
            {
				seq.AddCommand(new RSCommand("render_loop_cancel_render",
                        "render_loop_name", RenderLoopName
                ));
            }
        }
Ejemplo n.º 18
0
 public AddFeatureCommand(IAddCommand addCommand)
 {
     this.addCommand = addCommand;
 }
Ejemplo n.º 19
0
 public AddOptionValueCommand(IAddCommand addCommad)
 {
     this.addCommad = addCommad;
 }
Ejemplo n.º 20
0
        /**
         * If any changes have been made to the camera since the last time this function was called,
         * then commands for updating those values on the server will be added to the given command sequence.
         */
        public void UpdateCamera(IAddCommand seq)
        {
            if (CameraName == null || CameraName.Length == 0 ||
                CameraInstanceName == null || CameraInstanceName.Length == 0)
            {
                Logger.Log("error", "Cannot update camera until names have been set.");
                return;
            }

            if (changedValues.Count == 0)
            {
                return;
            }

            if (HasChanged("matrix"))
            {
                seq.AddCommand(new RSCommand("instance_set_world_to_obj",
                        "instance_name", CameraInstanceName,
                        "transform", TransformMatrix.GetMatrixForRS()
                ));
            }

            if (HasChanged("resX") || HasChanged("resY"))
            {
                seq.AddCommand(new RSCommand("camera_set_aspect",
                        "camera_name", CameraName,
                        "aspect", Aspect
                ));

                seq.AddCommand(new RSCommand("camera_set_resolution",
                        "camera_name", CameraName,
                        "resolution", new Hashtable() {
                            { "x", ResolutionX },
                            { "y", ResolutionY }
                        }
                ));
            }

            if (HasChanged("ortho"))
            {
                seq.AddCommand(new RSCommand("camera_set_orthographic",
                        "camera_name", CameraName,
                        "orthographic", Orthographic
                ));
            }
            
            // As the aperture is used by both orthographic and perspective cameras
            // got slightly different things, we need to update the aperture if 
            // the orthographic value has changed.
            if ((HasChanged("ortho") && Orthographic) || HasChanged("orthoSize"))
            {
                seq.AddCommand(new RSCommand("camera_set_aperture",
                        "camera_name", CameraName,
                        "aperture", OrthographicSize * 2.0f * Aspect
                ));
            }
            else if ((HasChanged("ortho") && !Orthographic) || HasChanged("fov"))
            {
                // As we currently do not load any camera values from the 
                // server, we need to choose an aperture to work with.
                double aperture = 1.417;
                double deg2rad = Math.PI / 180.0;
                double focal = ((aperture / Aspect) / 2.0f) 
                    / Math.Tan(FieldOfView / 2.0f * deg2rad);
                seq.AddCommand(new RSCommand("camera_set_aperture",
                        "camera_name", CameraName,
                        "aperture", aperture
                ));
                seq.AddCommand(new RSCommand("camera_set_focal",
                        "camera_name", CameraName,
                        "focal", focal
                ));
            }

            changedValues.Clear();
            _hasNewChanges = false;
        }
Ejemplo n.º 21
0
 public CommandMapper(IGetCommand get, IAddCommand add, IImportCommand import)
 {
     _get    = get;
     _add    = add;
     _import = import;
 }
 public AddPlayerCommand(IAddCommand<Player> addCommand, IIsPlayerNameUniqueQuery isPlayerNameUniqueQuery)
 {
     _isPlayerNameUniqueQuery = isPlayerNameUniqueQuery;
     _addCommand = addCommand;
 }
Ejemplo n.º 23
0
 public async Task <IActionResult> Post([FromBody] NewStory model,
                                        [FromServices] IAddCommand <NewStory, Guid> addCommand)
 {
     return(Ok(await addCommand.Execute(model)));
 }