示例#1
0
        /// <summary>
        /// Request a command until we get one that we recognise.
        /// Display brief help if we don't recognise a command.
        /// </summary>
        /// <returns></returns>
        private GameCommand RequestCommand()
        {
            LightLocation location     = null;
            var           firstRequest = true;

            while (location == null)
            {
                if (!firstRequest)
                {
                    DisplayCommandSummary();
                }

                Console.Write("Please enter a location or 'exit': ");
                var command = Console.ReadLine().Trim().ToLower();

                var exitCommands = new List <string> {
                    "exit", "quit", "i've had enough"
                };
                if (exitCommands.Contains(command))
                {
                    return(new GameCommand(location: null, exit: true));
                }

                location     = ParseLocation(command);
                firstRequest = false;
            }

            return(new GameCommand(location, exit: false));
        }
示例#2
0
        public override Result Load()
        {
            var res = base.Load();

            if (res == Result.Success)
            {
                loc_mvp           = GetUniformLocation("MVP");
                loc_resolution    = GetUniformLocation("resolution");
                loc_resolutionInv = GetUniformLocation("resolutionInverse");
                loc_nearfar       = GetUniformLocation("nearFar");
                loc_camDir        = GetUniformLocation("wCamDir");
                loc_camPos        = GetUniformLocation("wCamPos");
                loc_gAmbient      = GetUniformLocation("gAmbient");
                loc_ibl           = GetUniformLocation("iblIntensity");
                loc_fog           = GetUniformLocation("fogIntensity");
                loc_fogcolor      = GetUniformLocation("fogColor");

                loc_dirLight = new LightLocation()
                {
                    dir       = GetUniformLocation("wDirLight.dir"),
                    color     = GetUniformLocation("wDirLight.color"),
                    intensity = GetUniformLocation("wDirLight.intensity"),
                };
            }
            return(res);
        }
示例#3
0
        /// <summary>
        /// Calculate the distance between the effect and a light location
        /// </summary>
        /// <param name="effect"></param>
        /// <param name="lightLocation"></param>
        /// <returns></returns>
        public static double Distance(this BaseEffect effect, LightLocation lightLocation)
        {
            var x1 = effect.X;
            var y1 = effect.Y;
            var x2 = lightLocation.X;
            var y2 = lightLocation.Y;

            return(Math.Sqrt((Math.Pow(x1 - x2, 2) + Math.Pow(y1 - y2, 2))));
        }
示例#4
0
 private void SetPointLightParameter(LightLocation ll, PointLight light)
 {
     SetParameter(ll.pos, light.GameObject.Transform.WorldPosition);
     SetParameter(ll.color, light.Color);
     SetParameter(ll.intensity, light.Intensity);
     SetParameter(ll.radius, light.Radius);
     SetParameter(ll.min, light.ClipBounds.Min);
     SetParameter(ll.max, light.ClipBounds.Max);
 }
示例#5
0
        public void NewLightLocationTest()
        {
            var location = new LightLocation(1, 0, 0.5);

            Assert.IsNotNull(location);
            Assert.AreEqual(1, location.X);
            Assert.AreEqual(0, location.Y);
            Assert.AreEqual(0.5, location.Z);
        }
示例#6
0
        private static (int x, int y) MapLightLocationToImage(LightLocation location, int width, int height)
        {
            //Hue gives coordinates relative to center of room where -1 is far left and 1 is far right etc.
            // So we need to remap it to 0-1 range then get value relative to image.
            // Y also needs to be flipped as front of room is 1 which should correspond to 0 in the image
            var x = (int)Math.Floor((location.X - -1.0) / 2 * (width));
            var y = (int)Math.Floor((1.0 - (location.Y - -1.0) / 2) * (height));

            return(x, y);
        }
示例#7
0
 private void CopyMembers(Light other)
 {
     this.id            = null;
     this.name          = other.name;
     this.modes         = new List <LightMode>(other.modes.Select(x => new LightMode(x, this)));
     this.location      = other.location;
     this.isConnected   = other.isConnected;
     this.batteryLevel  = other.batteryLevel;
     this.temperature   = other.temperature;
     this.mode          = other.mode;
     this.requestedMode = other.requestedMode;
 }
示例#8
0
 private void InitializeMembers()
 {
     this.id            = null;
     this.name          = null;
     this.modes         = new List <LightMode>();
     this.location      = LightLocation.Front;
     this.isConnected   = false;
     this.batteryLevel  = -1;
     this.temperature   = double.NaN;
     this.mode          = 255;
     this.requestedMode = 1;
 }
示例#9
0
 private void SetSpotLightParameter(LightLocation ll, SpotLight light)
 {
     SetParameter(ll.dir, light.WorldDirection);
     SetParameter(ll.pos, light.GameObject.Transform.WorldPosition);
     SetParameter(ll.color, light.Color);
     SetParameter(ll.intensity, light.Intensity);
     SetParameter(ll.radius, light.Radius);
     SetParameter(ll.min, light.ClipBounds.Min);
     SetParameter(ll.max, light.ClipBounds.Max);
     SetParameter(ll.innerAngle, light.InnerDot);
     SetParameter(ll.outerAngle, light.OuterDot);
 }
示例#10
0
 /// <summary>
 /// Calculate the distance between the effect and a light location
 /// </summary>
 /// <param name="effect"></param>
 /// <param name="lightLocation"></param>
 /// <returns></returns>
 public double Angle(LightLocation lightLocation)
 {
     return(lightLocation.Angle(this.X, this.Y));
 }
 /// <summary>
 /// Calculate the distance between the effect and a light location
 /// </summary>
 /// <param name="effect"></param>
 /// <param name="lightLocation"></param>
 /// <returns></returns>
 public double Distance(LightLocation lightLocation)
 {
     return(lightLocation.Distance(this.X, this.Y));
 }
示例#12
0
        private static int GetMatrixPositionY(LightLocation lightLocation, int matrixSize)
        {
            double pos = ((1 - (lightLocation.Y + 1) / 2)) * matrixSize;

            return((int)pos);
        }
示例#13
0
        public override Result Load()
        {
            var res = base.Load();

            if (res == Result.Success)
            {
                loc_m          = GetUniformLocation("M");
                loc_mit        = GetUniformLocation("MIT");
                loc_mvp        = GetUniformLocation("MVP");
                loc_camDir     = GetUniformLocation("wCamDir");
                loc_camPos     = GetUniformLocation("wCamPos");
                loc_resolution = GetUniformLocation("resolutionInverse");
                loc_gAmbient   = GetUniformLocation("gAmbient");
                loc_ibl        = GetUniformLocation("iblIntensity");

                loc_dirLight = new LightLocation()
                {
                    dir       = GetUniformLocation("wDirLight.dir"),
                    color     = GetUniformLocation("wDirLight.color"),
                    intensity = GetUniformLocation("wDirLight.intensity"),
                };

                loc_pointLights = new LightLocation[PointLightNum];
                for (var i = 0; i < PointLightNum; i++)
                {
                    loc_pointLights[i] = new LightLocation()
                    {
                        color     = GetUniformLocation(string.Format("wPointLights[{0}].color", i)),
                        intensity = GetUniformLocation(string.Format("wPointLights[{0}].intensity", i)),
                        radius    = GetUniformLocation(string.Format("wPointLights[{0}].radius", i)),
                        pos       = GetUniformLocation(string.Format("wPointLights[{0}].pos", i)),
                        min       = GetUniformLocation(string.Format("wPointLights[{0}].min", i)),
                        max       = GetUniformLocation(string.Format("wPointLights[{0}].max", i)),
                    };
                }

                loc_spotLights = new LightLocation[SpotLightNum];
                for (var i = 0; i < SpotLightNum; i++)
                {
                    loc_spotLights[i] = new LightLocation()
                    {
                        dir        = GetUniformLocation(string.Format("wSpotLights[{0}].dir", i)),
                        color      = GetUniformLocation(string.Format("wSpotLights[{0}].color", i)),
                        intensity  = GetUniformLocation(string.Format("wSpotLights[{0}].intensity", i)),
                        radius     = GetUniformLocation(string.Format("wSpotLights[{0}].radius", i)),
                        pos        = GetUniformLocation(string.Format("wSpotLights[{0}].pos", i)),
                        min        = GetUniformLocation(string.Format("wSpotLights[{0}].min", i)),
                        max        = GetUniformLocation(string.Format("wSpotLights[{0}].max", i)),
                        innerAngle = GetUniformLocation(string.Format("wSpotLights[{0}].innerAngle", i)),
                        outerAngle = GetUniformLocation(string.Format("wSpotLights[{0}].outerAngle", i)),
                    };
                }

                loc_shadowMV1 = GetUniformLocation("shadowMV1");
                loc_shadowMV2 = GetUniformLocation("shadowMV2");
                loc_shadowMV3 = GetUniformLocation("shadowMV3");

                loc_skinning = GetUniformLocation("skinning");
                loc_morphing = GetUniformLocation("morphing");
            }
            return(res);
        }
        // public List<Transition> Transitions { get; set; } = new List<Transition>();


        public StreamingLight(string id, LightLocation location)
        {
            Id            = byte.Parse(id);
            LightLocation = location;
        }
示例#15
0
 public LightPositionVm(KeyValuePair <string, LightLocation> original)
 {
     this.Id            = original.Key;
     this.LightLocation = original.Value;
 }
示例#16
0
 private void SetDirectionalLightParameter(LightLocation ll, DirectionalLight light)
 {
     SetParameter(ll.dir, light.WorldDirection);
     SetParameter(ll.color, light.Color);
     SetParameter(ll.intensity, light.Intensity);
 }
示例#17
0
 /// <summary>
 /// Calculate the distance between the effect and a light location
 /// </summary>
 /// <param name="effect"></param>
 /// <param name="lightLocation"></param>
 /// <returns></returns>
 public double Distance(LightLocation lightLocation)
 {
     return(Math.Abs(this.X - lightLocation.X));
 }
示例#18
0
 public EntertainmentLight(byte id, LightLocation location)
 {
     Id            = id;
     LightLocation = location;
 }
示例#19
0
 /// <summary>
 /// Light location specified by user. May be null if user has specified
 /// something other than a move.
 /// </summary>
 /// <value></value>
 internal GameCommand(LightLocation location, bool exit)
 {
     this.Location = location;
     this.Exit     = exit;
 }