Example #1
0
        /// <summary>
        ///		Main constructor.  Should not be used directly, rather a controller should be created using the
        ///		ControllerManager so it can keep track of them.
        /// </summary>
        /// <param name="source"></param>
        /// <param name="destination"></param>
        /// <param name="function"></param>
        internal Controller(IControllerValue <T> source, IControllerValue <T> destination, IControllerFunction <T> function)
        {
            this.source      = source;
            this.destination = destination;
            this.function    = function;

            // enabled by default, of course
            isEnabled = true;
        }
Example #2
0
        /// <summary>
        ///		Factory method for creating an instance of a controller based on the input provided.
        /// </summary>
        /// <param name="source">Controller value to use as the source.</param>
        /// <param name="destination">Controller value to use as the destination.</param>
        /// <param name="function">Controller funcion that will use the source value to set the destination.</param>
        /// <returns>A newly created controller object that will be updated during the main render loop.</returns>
        public Controller <Real> CreateController(IControllerValue <Real> source, IControllerValue <Real> destination,
                                                  IControllerFunction <Real> function)
        {
            // create a new controller object
            var controller = new Controller <Real>(source, destination, function);

            // add the new controller to our list
            this.controllers.Add(controller);

            return(controller);
        }
Example #3
0
        /// <summary>
        ///     Creates a basic time-based texture coordinate modifier designed for creating rotating textures.
        /// </summary>
        /// <remarks>
        ///     This simple method allows you to easily create constant-speed scrolling textures. If you want more
        ///     control, look up the ControllerManager.CreateTextureWaveTransformer for more complex wave-based
        ///     scrollers / stretchers / rotaters.
        /// </remarks>
        /// <param name="layer">The texture unit to animate.</param>
        /// <param name="speedU">Horizontal speed, in wraps per second.</param>
        /// <param name="speedV">Vertical speed, in wraps per second.</param>
        /// <returns>A newly created controller object that will be updated during the main render loop.</returns>
        public Controller <float> CreateTextureScroller(TextureUnitState layer, float speedU, float speedV)
        {
            IControllerValue <float>    val        = null;
            IControllerFunction <float> func       = null;
            Controller <float>          controller = null;

            // if both u and v speeds are the same, we can use a single controller for it
            if (speedU != 0 && (speedU == speedV))
            {
                // create the value and function
                val  = new TexCoordModifierControllerValue(layer, true, true);
                func = new MultipyControllerFunction(-speedU, true);

                // create the controller (uses FrameTime for source by default)
                controller = CreateController(val, func);
            }
            else
            {
                // create seperate for U
                if (speedU != 0)
                {
                    // create the value and function
                    val  = new TexCoordModifierControllerValue(layer, true, false);
                    func = new MultipyControllerFunction(-speedU, true);

                    // create the controller (uses FrameTime for source by default)
                    controller = CreateController(val, func);
                }

                // create seperate for V
                if (speedV != 0)
                {
                    // create the value and function
                    val  = new TexCoordModifierControllerValue(layer, false, true);
                    func = new MultipyControllerFunction(-speedV, true);

                    // create the controller (uses FrameTime for source by default)
                    controller = CreateController(val, func);
                }
            }

            // TODO: Revisit, since we can't return 2 controllers in the case of non equal U and V speeds
            return(controller);
        }
Example #4
0
        /// <summary>
        ///     Creates a basic time-based texture v coordinate modifier designed for creating scrolling textures.
        /// </summary>
        /// <remarks>
        ///     This simple method allows you to easily create constant-speed scrolling textures. If you want more
        ///     control, look up the <see cref="CreateTextureWaveTransformer"/> for more complex wave-based
        ///     scrollers / stretchers / rotaters.
        /// </remarks>
        /// <param name="layer">The texture unit to animate.</param>
        /// <param name="speed">speed, in wraps per second.</param>
        /// <returns>A newly created controller object that will be updated during the main render loop.</returns>
        public Controller <Real> CreateTextureVScroller(TextureUnitState layer, Real speed)
        {
            IControllerValue <Real>    val        = null;
            IControllerFunction <Real> func       = null;
            Controller <Real>          controller = null;

            // if both u and v speeds are the same, we can use a single controller for it
            if (speed != 0)
            {
                // create the value and function
                val  = new TexCoordModifierControllerValue(layer, false, true);
                func = new MultipyControllerFunction(-speed, true);

                // create the controller (uses FrameTime for source by default)
                controller = CreateController(val, func);
            }

            return(controller);
        }
Example #5
0
        /// <summary>
        ///     Creates a basic time-based texture u coordinate modifier designed for creating scrolling textures.
        /// </summary>
        /// <remarks>
        ///     This simple method allows you to easily create constant-speed scrolling textures. If you want more
        ///     control, look up the <see cref="CreateTextureWaveTransformer"/> for more complex wave-based
        ///     scrollers / stretchers / rotaters.
        /// </remarks>
        /// <param name="layer">The texture unit to animate.</param>
        /// <param name="speed">speed, in wraps per second.</param>
        /// <returns>A newly created controller object that will be updated during the main render loop.</returns>
        public Controller <Real> CreateTextureUScroller(TextureUnitState layer, Real speed)
        {
            IControllerValue <Real>    val        = null;
            IControllerFunction <Real> func       = null;
            Controller <Real>          controller = null;

            // Don't create a controller if the speed is zero
            if (speed != 0)
            {
                // create the value and function
                val  = new TexCoordModifierControllerValue(layer, true);
                func = new MultipyControllerFunction(-speed, true);

                // create the controller (uses FrameTime for source by default)
                controller = CreateController(val, func);
            }

            return(controller);
        }
Example #6
0
        /// <summary>
        ///	    Creates a very flexible time-based texture transformation which can alter the scale, position or
        ///	    rotation of a texture based on a wave function.
        /// </summary>
        /// <param name="layer">The texture unit to effect.</param>
        /// <param name="type">The type of transform, either translate (scroll), scale (stretch) or rotate (spin).</param>
        /// <param name="waveType">The shape of the wave, see WaveformType enum for details.</param>
        /// <param name="baseVal">The base value of the output.</param>
        /// <param name="frequency">The speed of the wave in cycles per second.</param>
        /// <param name="phase">The offset of the start of the wave, e.g. 0.5 to start half-way through the wave.</param>
        /// <param name="amplitude">Scales the output so that instead of lying within 0..1 it lies within 0..(1 * amplitude) for exaggerated effects</param>
        /// <returns>A newly created controller object that will be updated during the main render loop.</returns>
        public Controller <Real> CreateTextureWaveTransformer(TextureUnitState layer, TextureTransform type,
                                                              WaveformType waveType, Real baseVal, Real frequency, Real phase,
                                                              Real amplitude)
        {
            IControllerValue <Real>    val      = null;
            IControllerFunction <Real> function = null;

            // determine which type of controller value this layer needs
            switch (type)
            {
            case TextureTransform.TranslateU:
                val = new TexCoordModifierControllerValue(layer, true, false);
                break;

            case TextureTransform.TranslateV:
                val = new TexCoordModifierControllerValue(layer, false, true);
                break;

            case TextureTransform.ScaleU:
                val = new TexCoordModifierControllerValue(layer, false, false, true, false, false);
                break;

            case TextureTransform.ScaleV:
                val = new TexCoordModifierControllerValue(layer, false, false, false, true, false);
                break;

            case TextureTransform.Rotate:
                val = new TexCoordModifierControllerValue(layer, false, false, false, false, true);
                break;
            }             // switch

            // create a new waveform controller function
            function = new WaveformControllerFunction(waveType, baseVal, frequency, phase, amplitude, true);

            // finally, create the controller using frame time as the source value
            return(CreateController(this.frameTimeController, val, function));
        }
Example #7
0
 /// <summary>
 ///		Overloaded method.  Creates a new controller, using a reference to a FrameTimeControllerValue as
 ///		the source.
 /// </summary>
 /// <param name="destination">Controller value to use as the destination.</param>
 /// <param name="function">Controller funcion that will use the source value to set the destination.</param>
 /// <returns>A newly created controller object that will be updated during the main render loop.</returns>
 public Controller <Real> CreateController(IControllerValue <Real> destination, IControllerFunction <Real> function)
 {
     // call the overloaded method passing in our precreated frame time controller value as the source
     return(CreateController(this.frameTimeController, destination, function));
 }
Example #8
0
		/// <summary>
		///		Factory method for creating an instance of a controller based on the input provided.
		/// </summary>
		/// <param name="source">Controller value to use as the source.</param>
		/// <param name="destination">Controller value to use as the destination.</param>
		/// <param name="function">Controller funcion that will use the source value to set the destination.</param>
		/// <returns>A newly created controller object that will be updated during the main render loop.</returns>
		public Controller<Real> CreateController( IControllerValue<Real> source, IControllerValue<Real> destination,
		                                          IControllerFunction<Real> function )
		{
			// create a new controller object
			var controller = new Controller<Real>( source, destination, function );

			// add the new controller to our list
			this.controllers.Add( controller );

			return controller;
		}
Example #9
0
		/// <summary>
		///		Overloaded method.  Creates a new controller, using a reference to a FrameTimeControllerValue as
		///		the source.
		/// </summary>
		/// <param name="destination">Controller value to use as the destination.</param>
		/// <param name="function">Controller funcion that will use the source value to set the destination.</param>
		/// <returns>A newly created controller object that will be updated during the main render loop.</returns>
		public Controller<Real> CreateController( IControllerValue<Real> destination, IControllerFunction<Real> function )
		{
			// call the overloaded method passing in our precreated frame time controller value as the source
			return CreateController( this.frameTimeController, destination, function );
		}
Example #10
0
        /// <summary>
        ///		Factory method for creating an instance of a controller based on the input provided.
        /// </summary>
        /// <param name="source">Controller value to use as the source.</param>
        /// <param name="destination">Controller value to use as the destination.</param>
        /// <param name="function">Controller funcion that will use the source value to set the destination.</param>
        /// <returns>A newly created controller object that will be updated during the main render loop.</returns>
        public Controller <float> CreateController(IControllerValue <float> source, IControllerValue <float> destination, IControllerFunction <float> function)
        {
            // create a new controller object
            Controller <float> controller = new Controller <float>(source, destination, function);

            // add the new controller to our list
            controllers.Add(controller);

            return(controller);
        }
Example #11
0
        protected override void CreateScene()
        {
            // set some ambient light
            scene.AmbientLight = new ColorEx(1, 0.1f, 0.1f, 0.1f);

            // set a basic skybox
            scene.SetSkyBox(true, "Skybox/Space", 5000.0f);

            // create the ogre head
            Entity ogre = scene.CreateEntity("OgreHead", "ogrehead.mesh");

            // attach the ogre to the scene
            scene.RootSceneNode.AttachObject(ogre);

            // create nodes for the billboard sets
            redYellowLightsNode = scene.RootSceneNode.CreateChildSceneNode();
            greenBlueLightsNode = scene.RootSceneNode.CreateChildSceneNode();

            // create a billboard set for creating billboards
            redYellowLights = scene.CreateBillboardSet("RedYellowLights", 20);
            redYellowLights.MaterialName = "Particles/Flare";
            redYellowLightsNode.AttachObject(redYellowLights);

            greenBlueLights = scene.CreateBillboardSet("GreenBlueLights", 20);
            greenBlueLights.MaterialName = "Particles/Flare";
            greenBlueLightsNode.AttachObject(greenBlueLights);

            // red light billboard in off set
            Vector3 redLightPos = new Vector3(78, -8, -70);

            redLightBoard = redYellowLights.CreateBillboard(redLightPos, ColorEx.Black);

            // yellow light billboard in off set
            Vector3 yellowLightPos = new Vector3(-4.5f, 30, -80);

            yellowLightBoard = redYellowLights.CreateBillboard(yellowLightPos, ColorEx.Black);

            // blue light billboard in off set
            Vector3 blueLightPos = new Vector3(-90, -8, -70);

            blueLightBoard = greenBlueLights.CreateBillboard(blueLightPos, ColorEx.Black);

            // green light billboard in off set
            Vector3 greenLightPos = new Vector3(50, 70, 80);

            greenLightBoard = greenBlueLights.CreateBillboard(greenLightPos, ColorEx.Black);

            // red light in off state
            redLight          = scene.CreateLight("RedLight");
            redLight.Position = redLightPos;
            redLight.Type     = LightType.Point;
            redLight.Diffuse  = ColorEx.Black;
            redYellowLightsNode.AttachObject(redLight);

            // yellow light in off state
            yellowLight          = scene.CreateLight("YellowLight");
            yellowLight.Type     = LightType.Point;
            yellowLight.Position = yellowLightPos;
            yellowLight.Diffuse  = ColorEx.Black;
            redYellowLightsNode.AttachObject(yellowLight);

            // green light in off state
            greenLight          = scene.CreateLight("GreenLight");
            greenLight.Type     = LightType.Point;
            greenLight.Position = greenLightPos;
            greenLight.Diffuse  = ColorEx.Black;
            greenBlueLightsNode.AttachObject(greenLight);

            // blue light in off state
            blueLight          = scene.CreateLight("BlueLight");
            blueLight.Type     = LightType.Point;
            blueLight.Position = blueLightPos;
            blueLight.Diffuse  = ColorEx.Black;
            greenBlueLightsNode.AttachObject(blueLight);

            // create controller function
            redLightFlasher =
                new LightFlasherControllerValue(redLight, redLightBoard, ColorEx.Red);
            yellowLightFlasher =
                new LightFlasherControllerValue(yellowLight, yellowLightBoard, ColorEx.Yellow);
            greenLightFlasher =
                new LightFlasherControllerValue(greenLight, greenLightBoard, ColorEx.Green);
            blueLightFlasher =
                new LightFlasherControllerValue(blueLight, blueLightBoard, ColorEx.Blue);

            // set up the controller value and function for flashing
            redLightFunc    = new WaveformControllerFunction(WaveformType.Sine, 0, 0.5f, 0, 1);
            yellowLightFunc = new WaveformControllerFunction(WaveformType.Triangle, 0, 0.25f, 0, 1);
            greenLightFunc  = new WaveformControllerFunction(WaveformType.Sine, 0, 0.25f, 0.5f, 1);
            blueLightFunc   = new WaveformControllerFunction(WaveformType.Sine, 0, 0.75f, 0.5f, 1);

            // set up the controllers
            ControllerManager.Instance.CreateController(redLightFlasher, redLightFunc);
            ControllerManager.Instance.CreateController(yellowLightFlasher, yellowLightFunc);
            ControllerManager.Instance.CreateController(greenLightFlasher, greenLightFunc);
            ControllerManager.Instance.CreateController(blueLightFlasher, blueLightFunc);
        }
Example #12
0
		/// <summary>
		///		Factory method for creating an instance of a controller based on the input provided.
		/// </summary>
		/// <param name="source">Controller value to use as the source.</param>
		/// <param name="destination">Controller value to use as the destination.</param>
		/// <param name="function">Controller funcion that will use the source value to set the destination.</param>
		/// <returns>A newly created controller object that will be updated during the main render loop.</returns>
		public Controller<float> CreateController( IControllerValue<float> source, IControllerValue<float> destination, IControllerFunction<float> function )
		{
			// create a new controller object
			Controller<float> controller = new Controller<float>( source, destination, function );

			// add the new controller to our list
			controllers.Add( controller );

			return controller;
		}