Пример #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"
         ));
     }
 }
Пример #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"
                                      ));
     }
 }
Пример #3
0
 protected void MarkDirty(IAddCommand seq)
 {
     if (UseRenderLoop)
     {
         seq.AddCommand(new RSCommand("render_loop_cancel_render",
                                      "render_loop_name", RenderLoopName
                                      ));
     }
 }
Пример #4
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
                                             ));
            }
        }
Пример #5
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
                ));
            }
        }
Пример #6
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;
        }
Пример #7
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;
		}
Пример #8
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;
        }
Пример #9
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;
        }
Пример #10
0
        protected void MarkDirty(IAddCommand seq)
        {
            if (UseRenderLoop)
            {
				seq.AddCommand(new RSCommand("render_loop_cancel_render",
                        "render_loop_name", RenderLoopName
                ));
            }
        }