Inheritance: MonoBehaviour
Example #1
0
        public SpotLightEquation(SpotLight light, Matrix3D viewMatrix)
            : base(light, viewMatrix)
        {
            // Account for model hierarchy transform
            direction = MatrixUtils.Transform(light.Direction, light.Transform);
            direction = MathEx.Normalize(direction);

            // Account for view dependent transform
            // Update inverse transpose matrix
            inverseTransposeTransform = viewMatrix;
            inverseTransposeTransform.Invert();
            inverseTransposeTransform = MatrixUtils.Transpose(inverseTransposeTransform);
            // forcing affine matrix - we really only care about the inner 3x3
            inverseTransposeTransform.M44 = 1.0;
            inverseTransposeTransform.M14 = 0.0;
            inverseTransposeTransform.M24 = 0.0;
            inverseTransposeTransform.M34 = 0.0;
            // update direction
            direction = MatrixUtils.Transform(direction, inverseTransposeTransform);
            direction = MathEx.Normalize(direction);

            // Our lighting model assumes angles are measured from light direction vector,
            // but DX and Avalon specify angles as total degrees of spread
            innerConeAngle = light.InnerConeAngle / 2.0;
            outerConeAngle = light.OuterConeAngle / 2.0;

            cosInnerConeAngle = Math.Cos(MathEx.ToRadians(innerConeAngle));
            cosOuterConeAngle = Math.Cos(MathEx.ToRadians(outerConeAngle));

            if (innerConeAngle > outerConeAngle)
            {
                Console.WriteLine("\n  WARNING: SpotLight OuterConeAngle is greater than InnerConeAngle!");
                Console.WriteLine("  This is an invalid light and should only be used with RenderingEffect.Silhouette\n");
            }
        }
Example #2
0
        public void UpdateUniforms(CoreEngine engine, Entity entity, SpotLight light)
        {
            SetUniform("projection", engine.RenderingEngine.Camera.Projection);
            SetUniform("transformation", entity.Transformation.GetTransformation());

            SetUniform("eyePosition", engine.RenderingEngine.Camera.Parent.Transformation.Position);

            SetUniform("specularIntensity", entity.Material.SpecularIntensity);
            SetUniform("specularExponent", entity.Material.SpecularExponent);

            SetUniform("displacementScale", entity.Material.DisplacementScale);
            SetUniform("displacementBias", -(entity.Material.DisplacementScale / 2f) + (entity.Material.DisplacementScale / 2f) * entity.Material.DisplacementOffset);

            SetUniform("useDisplacementMap", entity.Material.DisplacementMap.Initialized ? 1 : 0);
            SetUniform("displacementMap", 0);

            SetUniform("useNormalMap", entity.Material.NormalMap.Initialized ? 1 : 0);
            SetUniform("normalMap", 1);

            SetUniform("light.base.base.color", new Vector4(light.Base.Base.Color.R, light.Base.Base.Color.G, light.Base.Base.Color.B, light.Base.Base.Color.A));
            SetUniform("light.base.base.intensity", light.Base.Base.Intensity);
            SetUniform("light.base.attenuation.constant", light.Base.Attenuation.Constant);
            SetUniform("light.base.attenuation.linear", light.Base.Attenuation.Linear);
            SetUniform("light.base.attenuation.exponent", light.Base.Attenuation.Exponent);
            SetUniform("light.base.position", light.Base.Position);
            SetUniform("light.base.range", light.Base.Range);
            SetUniform("light.direction", light.Direction);
            SetUniform("light.cutoff", light.CutOff);
        }
Example #3
0
        private void Apply(object sender, RoutedEventArgs e)
        {
            try
            {
                ColorPicker colorPicker = (ColorPicker)FindName("ColorPicker");
                Color       color       = (Color)colorPicker.SelectedColor;

                TextBox x          = (TextBox)FindName("drlX");
                TextBox y          = (TextBox)FindName("drlY");
                TextBox z          = (TextBox)FindName("drlZ");
                TextBox xDir       = (TextBox)FindName("drlXdir");
                TextBox yDir       = (TextBox)FindName("drlYdir");
                TextBox zDir       = (TextBox)FindName("drlZdir");
                TextBox outerAngle = (TextBox)FindName("outerAngle");
                TextBox innerAngle = (TextBox)FindName("innerAngle");

                SpotLight pointLight = new SpotLight(color,
                                                     new Point3D(double.Parse(x.Text), double.Parse(y.Text), double.Parse(z.Text)),
                                                     new Vector3D(double.Parse(xDir.Text), double.Parse(yDir.Text), double.Parse(zDir.Text)),
                                                     double.Parse(outerAngle.Text), double.Parse(innerAngle.Text));

                model3DGroup.Children.Clear();
                model3DGroup.Children.Add(pointLight);
                this.Close();
            }
            catch (Exception ex)
            {
                System.Windows.MessageBox.Show(ex.ToString());
            }
        }
Example #4
0
    private void _OnMenuTimer_timeout()
    {
        SpotLight spotFront = (SpotLight)GetParent().GetNode("Spot_front");
        Color     spotColor = spotFront.GetColor();

        if (lightAsc)
        {
            if (spotColor.v >= 1)
            {
                lightAsc = false;
            }
            else
            {
                spotColor.v += 0.005F;
            }
        }
        else
        {
            if (spotColor.v <= 0)
            {
                lightAsc = true;
            }
            else
            {
                spotColor.v -= 0.005F;
            }
        }

        spotFront.SetColor(spotColor);
    }
Example #5
0
        public void AddQueryCombinedObjectTest()
        {
            Test(() =>
            {
                var spotLight  = new SpotLight(GraphicsDevice);
                var pointLight = new PointLight(GraphicsDevice);

                var container = new DisplayObject();
                container.Children.Add(spotLight);
                container.Children.Add(pointLight);

                var scene = new Scene(GraphicsDevice);

                scene.Add(container);
                Assert.AreEqual(1, scene.Count);

                scene.Add(new DirectionalLight(GraphicsDevice));
                Assert.AreEqual(2, scene.Count);

                var boundingBox  = new BoundingBox(Vector3.One * -100, Vector3.One * 100);
                var sceneObjects = new List <object>();
                scene.FindAll(ref boundingBox, sceneObjects);
                Assert.AreEqual(4, sceneObjects.Count);

                var pointLights = new List <PointLight>();
                scene.FindAll(ref boundingBox, pointLights);
                Assert.AreEqual(1, pointLights.Count);
                Assert.AreEqual(pointLight, pointLights[0]);
            });
        }
Example #6
0
        private void CreateLights()
        {
            _lightsModel3DGroup = new Model3DGroup();

            var ambientLight = new System.Windows.Media.Media3D.AmbientLight(Color.FromRgb(25, 25, 25));

            _lightsModel3DGroup.Children.Add(ambientLight);


            _lightHorizontalAngle = 0;
            _lightVerticalAngle   = 30;

            _lightDistance = 500;
            _lightRange    = 2000;

            _directionalLight = new System.Windows.Media.Media3D.DirectionalLight();

            _shadowSpotLight = new System.Windows.Media.Media3D.SpotLight();
            _shadowSpotLight.InnerConeAngle = 40;
            _shadowSpotLight.OuterConeAngle = 50;


            var modelVisual3D = new ModelVisual3D();

            modelVisual3D.Content = _lightsModel3DGroup;

            MainDXViewportView.Viewport3D.Children.Add(modelVisual3D);

            UpdateLights();
            UpdateCastingShadowLight();
        }
Example #7
0
        public void AddQueryRemoveObjectTest()
        {
            Test(() =>
            {
                var spotLight  = new SpotLight(GraphicsDevice);
                var pointLight = new PointLight(GraphicsDevice);
                var scene      = new Scene(GraphicsDevice);

                scene.Add(spotLight);
                Assert.AreEqual(1, scene.Count);

                scene.Add(pointLight);
                Assert.AreEqual(2, scene.Count);

                var boundingBox  = new BoundingBox(Vector3.One * -100, Vector3.One * 100);
                var sceneObjects = new List <object>();
                scene.FindAll(ref boundingBox, sceneObjects);

                Assert.AreEqual(2, sceneObjects.Count);
                Assert.AreNotEqual(sceneObjects[0].GetType(), sceneObjects[1].GetType());

                scene.Remove(spotLight);

                sceneObjects = new List <object>();
                scene.FindAll(ref boundingBox, sceneObjects);

                Assert.AreEqual(1, sceneObjects.Count);
                Assert.AreEqual(pointLight, sceneObjects[0]);
            });
        }
Example #8
0
        protected override void UpdateModelFromMouse(Base3DElement selected3DElement, Vector mousePositionDelta)
        {
            Vector3D normal = this.CalculateTransformationForSpotLightAdorner().Transform(new Vector3D(0.0, 0.0, 1.0));

            normal.Normalize();
            Plane3D          plane3D            = new Plane3D(normal, this.centerOfCone);
            Viewport3DVisual adorningViewport3D = this.ActiveView.AdornerLayer.GetAdornerSet3DContainer(this.ActiveAdorner.Element.Viewport).ShadowAdorningViewport3D;
            Ray3D            ray = CameraRayHelpers.RayFromViewportPoint(adorningViewport3D.Viewport.Size, adorningViewport3D.Camera, this.LastMousePosition + mousePositionDelta);
            double           t;

            if (!plane3D.IntersectWithRay(ray, out t))
            {
                return;
            }
            double    num1      = Math.Atan((ray.Evaluate(t) - this.centerOfCone).Length / 1.0) / Math.PI * 180.0;
            SpotLight spotLight = (SpotLight)this.Selected3DElement.ViewObject.PlatformSpecificObject;

            if (this.ActiveAdorner.TypeOfConeAngle == SpotLightAdornerBehavior3D.TypeOfConeAngle.InnerConeAngle)
            {
                double num2 = spotLight.OuterConeAngle - spotLight.InnerConeAngle;
                this.Selected3DElement.SetValue(SpotLightElement.InnerConeAngleProperty, (object)num1);
                this.Selected3DElement.SetValue(SpotLightElement.OuterConeAngleProperty, (object)(num1 + num2));
            }
            else
            {
                this.Selected3DElement.SetValue(SpotLightElement.OuterConeAngleProperty, (object)num1);
            }
            this.ActiveAdorner.PositionAndOrientGeometry();
        }
Example #9
0
        private float GetSpotValue(SpotLight light, BoundingVolume volume)
        {
            if (volume == null)
            {
                return(0);
            }

            Vector3 dir   = light.Direction;
            Vector3 pos   = light.Position;
            Plane   plane = new Plane(dir, Vector3.Dot(dir, pos));
            PlaneIntersectionType result;

            volume.Intersects(ref plane, out result);
            if (result != PlaneIntersectionType.Back)
            {
                if (!light.Attenuate)
                {
                    return(GetColorStrength(light));
                }
                else
                {
                    float dist     = volume.DistanceTo(pos);
                    float strength = GetColorStrength(light);
                    float att      = light.Constant + (light.Linear * dist) + (light.Quadratic * dist * dist);
                    return(strength / att);
                }
            }
            else
            {
                return(0);
            }
        }
Example #10
0
 /// <summary>
 /// Creates the configuration controls of this component.
 /// </summary>
 public static void AddControls(SpotLight spotLight, ClipControl owner)
 {
     // Enabled
     CheckBox enabled = CommonControls.CheckBox("Enabled", owner, spotLight.Enabled, spotLight, "Enabled");
     enabled.Top = 10;
     // Intensity
     var intensity = CommonControls.SliderNumericFloat("Intensity", owner, spotLight.Intensity, false, true, 0, 100, spotLight, "Intensity");
     // Diffuse Color
     var diffuseColor = CommonControls.SliderColor("Color", owner, spotLight.Color, spotLight, "Color");
     // Range
     var range = CommonControls.SliderNumericFloat("Range", owner, spotLight.Range, false, true, 0, 500, spotLight, "Range");
     // Inner Cone Angle
     var innerConeAngle = CommonControls.SliderNumericFloat("Inner Cone Angle", owner, spotLight.InnerConeAngle, false, false, 0, 175, spotLight, "InnerConeAngle");
     // Outer Cone Angle
     var outerConeAngle = CommonControls.SliderNumericFloat("Outer Cone Angle", owner, spotLight.OuterConeAngle, false, false, 0, 175, spotLight, "OuterConeAngle");
     // Mask Texture
     var maskTexture = CommonControls.AssetSelector<Texture>("Mask Texture", owner, spotLight, "LightMaskTexture");
     // Shadow
     var shadow = CommonControls.AssetSelector<BasicShadow>("Shadow", owner, spotLight, "Shadow");
     // Enabled
     enabled.CheckedChanged += delegate
     {
         intensity.Enabled      = spotLight.Enabled;
         diffuseColor.Enabled   = spotLight.Enabled;
         range.Enabled          = spotLight.Enabled;
         innerConeAngle.Enabled = spotLight.Enabled;
         outerConeAngle.Enabled = spotLight.Enabled;
         maskTexture.Enabled    = spotLight.Enabled;
         shadow.Enabled         = spotLight.Enabled;
     };
     owner.AdjustHeightFromChildren();
 } // AddControls
Example #11
0
    private IEnumerator TakeScrShot()
    {
        yield return(new WaitForEndOfFrame());


        int       width  = Screen.width;
        int       height = Screen.height;
        Texture2D tex    = new Texture2D(width, height, TextureFormat.RGB24, false);

        tex.ReadPixels(new Rect(0, 0, width, height), 0, 0);
        tex.Apply();

        var bytes = tex.EncodeToPNG();

        var path = System.IO.Path.Combine(Application.persistentDataPath, "IMG_" + CountScreen.ToString() + ".png");

        System.IO.File.WriteAllBytes(path, bytes);

        Debug.Log(path);
        CountScreen++;

        PlayerPrefs.SetInt("CountScreen", CountScreen);
        canvasObject.SetActive(true);
        SpotLight.SetActive(false);
        for (int i = 0; i < sprites.Length; i++)
        {
            if (sprites [i] == null)
            {
                sprites [i] = Sprite.Create(tex, new Rect(0, 0, tex.width, tex.height), new Vector2(0.5f, 0.5f));
                i           = sprites.Length;
            }
        }
    }
Example #12
0
        public async Task <SpotLight> GetAwardSpotlightAsync(int theMonth)
        {
            SpotLight spotlight = null;
            string    sql       = "select ID, Name, Img, Status, Amount from Awards where ID=@awardId";

            using (var conn = _connProvider.GetConnection())
            {
                var tmp = await conn.QueryFirstOrDefaultAsync <dynamic>(sql,
                                                                        new {
                    AwardId = theMonth
                });

                if (tmp != null)
                {
                    spotlight          = new SpotLight();
                    spotlight.TheMonth = tmp.ID;
                    string name = tmp.Name;
                    spotlight.Img = tmp.Img;
                    int amount = tmp.Amount;
                    spotlight.Info = string.Format("{0}期赛程已开启,本期奖品:【{1}】,共设{2}个获奖名额。小伙伴们,加油哦!", spotlight.TheMonth, name, amount);
                    spotlight.Type = 2;
                }
            }

            return(spotlight);
        }
Example #13
0
        public void AddQueryCombinedObjectUsingFindResultTest()
        {
            Test(() =>
            {
                var spotLight  = new SpotLight(GraphicsDevice);
                var pointLight = new PointLight(GraphicsDevice);

                var container = new DisplayObject();
                container.Children.Add(spotLight);
                container.Children.Add(pointLight);

                var scene = new Scene(GraphicsDevice);
                scene.Add(container);

                var boundingBox = new BoundingBox(Vector3.One * -100, Vector3.One * 100);
                var findResults = new List <FindResult>();
                scene.FindAll(ref boundingBox, findResults);
                Assert.AreEqual(2, findResults.Count);
                Assert.IsTrue(findResults[0].Target == findResults[1].Target);
                Assert.IsTrue(findResults[0].OriginalTarget != findResults[1].OriginalTarget);
                Assert.AreEqual(container, findResults[0].Target);
                Assert.IsTrue(findResults[0].OriginalTarget == spotLight || findResults[1].OriginalTarget == spotLight);
                Assert.IsTrue(findResults[0].OriginalTarget == pointLight || findResults[1].OriginalTarget == pointLight);
            });
        }
Example #14
0
    public override void _Ready()
    {
        Camera            = GetNode <Camera>("Rotation_Helper/Camera");
        _rotationalHelper = GetNode <Spatial>("Rotation_Helper");

        AnimationManager = GetNode <AnimationPlayerManager>("Rotation_Helper/Model/Animation_Player");
        AnimationManager.CallbackFunction = FireBullet;

        Input.SetMouseMode(Input.MouseMode.Captured);

        _weapons["KNIFE"]  = GetNode <WeaponKnife>("Rotation_Helper/Gun_Fire_Points/Knife_Point");
        _weapons["RIFLE"]  = GetNode <WeaponRifle>("Rotation_Helper/Gun_Fire_Points/Rifle_Point");
        _weapons["PISTOL"] = GetNode <WeaponPistol>("Rotation_Helper/Gun_Fire_Points/Pistol_Point");

        var gunAimPointPos = GetNode <Spatial>("Rotation_Helper/Gun_Aim_Point").GlobalTransform.origin;

        foreach (var weapon in _weapons.Values)
        {
            if (weapon != null)
            {
                weapon.PlayerNode = this;
                weapon.LookAt(gunAimPointPos, Vector3.Up);
                weapon.RotateObjectLocal(Vector3.Up, Mathf.Deg2Rad(180));
            }
        }

        _currentWeaponName  = "UNARMED";
        _changingWeaponName = "UNARMED";

        _uiStatusLabel = GetNode <Label>("HUD/Panel/Gun_label");
        _flashLight    = GetNode <SpotLight>("Rotation_Helper/Flashlight");
    }
        public RevealScenarioLights()
        {
            this.InitializeComponent();
            _revealTest = new RevealTestApi { TargetTheme = CurrentTheme };

            _backgroundLight = Window.Current.Compositor.CreateSpotLight();
            _borderLight = Window.Current.Compositor.CreateSpotLight();
            _borderWideLight = Window.Current.Compositor.CreateSpotLight();

            _borderLight.Offset = _borderWideLight.Offset = 
            _backgroundLight.Offset = new Vector3((float)SwatchInnerGrid.Width / 2, (float)SwatchInnerGrid.Height / 2, 100);

            ExprBind(_backgroundLight, _revealTest.BackgroundLight, "InnerConeAngle");
            ExprBind(_backgroundLight, _revealTest.BackgroundLight, "OuterConeAngle");
            ExprBind(_backgroundLight, _revealTest.BackgroundLight, "ConstantAttenuation");
            ExprBind(_backgroundLight, _revealTest.BackgroundLight, "InnerConeColor");
            ExprBind(_backgroundLight, _revealTest.BackgroundLight, "OuterConeColor");

            SpotLight borderSpotlight = _revealTest.GetSpotLight(_revealTest.BorderLight as XamlLight);
            ExprBind(_borderLight, borderSpotlight, "InnerConeAngle");
            ExprBind(_borderLight, borderSpotlight, "OuterConeAngle");
            ExprBind(_borderLight, borderSpotlight, "ConstantAttenuation");
            ExprBind(_borderLight, borderSpotlight, "InnerConeColor");
            ExprBind(_borderLight, borderSpotlight, "OuterConeColor");

            SpotLight borderWideSpotlight = _revealTest.GetSpotLight(_revealTest.BorderWideLight as XamlLight);
            ExprBind(_borderWideLight, borderWideSpotlight, "InnerConeAngle");
            ExprBind(_borderWideLight, borderWideSpotlight, "OuterConeAngle");
            ExprBind(_borderWideLight, borderWideSpotlight, "ConstantAttenuation");
            ExprBind(_borderWideLight, borderWideSpotlight, "InnerConeColor");
            ExprBind(_borderWideLight, borderWideSpotlight, "OuterConeColor");
        }
Example #16
0
    public void OnEnable( )
    {
        Lightmapping.RequestLightsDelegate testDel = (Light [] requests, Unity.Collections.NativeArray <LightDataGI> lightsOutput) =>
        {
            DirectionalLight dLight = new DirectionalLight( );
            PointLight       point  = new PointLight( );
            SpotLight        spot   = new SpotLight( );
            RectangleLight   rect   = new RectangleLight( );
            LightDataGI      ld     = new LightDataGI( );

            for (int i = 0; i < requests.Length; i++)
            {
                Light l = requests [i];
                switch (l.type)
                {
                case UnityEngine.LightType.Directional: LightmapperUtils.Extract(l, ref dLight); ld.Init(ref dLight); break;

                case UnityEngine.LightType.Point: LightmapperUtils.Extract(l, ref point); ld.Init(ref point); break;

                case UnityEngine.LightType.Spot: LightmapperUtils.Extract(l, ref spot); ld.Init(ref spot); break;

                case UnityEngine.LightType.Area: LightmapperUtils.Extract(l, ref rect); ld.Init(ref rect); break;

                default: ld.InitNoBake(l.GetInstanceID( )); break;
                }

                ld.falloff       = FalloffType.InverseSquared;
                lightsOutput [i] = ld;
            }
        };

        Lightmapping.SetDelegate(testDel);
    }
Example #17
0
        private SceneNodeBase GetRootElement()
        {
            var lightPosition = new vec3(0, 3, 5) * 2;
            var localLight    = new SpotLight(lightPosition, new vec3(0, 0, 0), 60, 1, 500)
            {
                Color = new vec3(1, 1, 1),
            };
            var lightContainer = new LightContainerNode(localLight);
            {
                {
                    var teapot = DepthTeapotNode.Create();
                    teapot.RotateSpeed = 1;
                    lightContainer.Children.Add(teapot);
                }
                {
                    var ground = DepthGroundNode.Create();
                    ground.Color         = Color.Gray.ToVec4();
                    ground.Scale        *= 30;
                    ground.WorldPosition = new vec3(0, -3, 0);
                    lightContainer.Children.Add(ground);
                }
            }

            var rectangle = RectangleNode.Create();

            rectangle.TextureSource = localLight;

            var group = new GroupNode();

            group.Children.Add(lightContainer);
            group.Children.Add(rectangle);

            return(group);
        }
Example #18
0
        public void AddQueryNamedObjectTest()
        {
            Test(() =>
            {
                var spotLight = new SpotLight(GraphicsDevice)
                {
                    Name = "A"
                };
                var pointLight = new PointLight(GraphicsDevice)
                {
                    Name = "B"
                };

                var container = new DisplayObject()
                {
                    Name = "A"
                };
                container.Children.Add(spotLight);
                container.Children.Add(pointLight);

                var scene = new Scene(GraphicsDevice);
                scene.Add(container);

                Assert.AreEqual(pointLight, scene.Find <PointLight>("B"));

                var allObjects = new List <object>();
                scene.FindAll("A", allObjects);
                Assert.AreEqual(2, allObjects.Count);

                var allSpotLights = new List <SpotLight>();
                scene.FindAll("A", allSpotLights);
                Assert.AreEqual(1, allSpotLights.Count);
                Assert.AreEqual(spotLight, allSpotLights[0]);
            });
        }
Example #19
0
        public override bool ParseBytesAndExecute(byte[] data)
        {
            if (data.Length != 8 + 1 + 4 + 24)
            {
                return(false);
            }
            long     EID      = Utilities.BytesToLong(Utilities.BytesPartial(data, 0, 8));
            bool     enabled  = (data[8] & 1) == 1;
            float    distance = Utilities.BytesToFloat(Utilities.BytesPartial(data, 8 + 1, 4));
            Location color    = Location.FromDoubleBytes(data, 8 + 1 + 4);
            Entity   ent      = TheClient.TheRegion.GetEntity(EID);

            if (ent == null || !(ent is CharacterEntity))
            {
                return(false);
            }
            Destroy(ent);
            if (enabled)
            {
                SpotLight sl = new SpotLight(ent.GetPosition(), distance, color, Location.UnitX, 45)
                {
                    Direction = ((CharacterEntity)ent).ForwardVector()
                };
                sl.Reposition(ent.GetPosition());
                ((CharacterEntity)ent).Flashlight = sl;
                TheClient.MainWorldView.Lights.Add(sl);
            }
            return(true);
        }
        public void And_replace_light(string id, double t1, double t2, double t3, double c1, double c2, double c3)
        {
            var pointLight = new SpotLight(ColorModel.WhiteNormalized, new Tuple4(t1, t2, t3, TupleFlavour.Point), 1.0);

            worlds[id].ClearLights();
            worlds[id].AddLight(pointLight);
            worlds[id].AddLight(new AmbientLight(1.0));
        }
Example #21
0
 public void AddLight(SpotLight light)
 {
     if (spotLights.Count == maxSpotLights)
     {
         throw new Exception("Spotlight buffer full.");
     }
     spotLights.Add(light);
 }
Example #22
0
    public override void _Ready()
    {
        camera         = (Camera)GetNode("Rotation_Helper/Camera");
        rotationHelper = (Spatial)GetNode("Rotation_Helper");
        flashlight     = (SpotLight)GetNode("Rotation_Helper/Flashlight");

        Input.SetMouseMode(Input.MouseMode.Captured);
    }
 private void configureLight(SpotLight light, Vector3 spotTarget, Vector3 offset)
 {
     light.LightRadius    = 300;
     light.LightIntensity = 1;
     light.ShadowsEnabled = true;
     light.Color          = Color.White.dx().ToVector3();
     light.LightPosition  = spotTarget + offset;
     light.SpotDirection  = Vector3.Normalize(spotTarget - light.LightPosition);
 }
Example #24
0
        public override void InitWorld()
        {
            Light(0, 10, 0, White / 5);
            DefaultFloor(White, White / 2);
            SpotLight light1 = new SpotLight(Helper.CreatePoint(0, 2, 0), Blue, Helper.CreatePoint(-0.25, 1, 0), 0.1, 0.65);
            SpotLight light2 = new SpotLight(Helper.CreatePoint(0, 2, 0), Red, Helper.CreatePoint(0.25, 1, 0), 0.1, 0.65);
            SpotLight light3 = new SpotLight(Helper.CreatePoint(0, 2, 0), Green, Helper.CreatePoint(0, 1, 0.25), 0.1, 0.65);

            Add(light1, light2, light3);
        }
Example #25
0
        protected override void OnConnected(UIElement newElement)
        {
            if (CompositionLight == null)
            {
                _light           = _createLight();
                CompositionLight = _light;

                _createAnimation(Window.Current.Content, _light);
                _hookupWindowPointerHandlers();
            }
        }
Example #26
0
        private void AddDefaultLights()
        {
            AmbientLight ambientLight = new AmbientLight(XNA.Color.White, 0.05f);

            Scene.CurrentScene.AddSceneObject(ambientLight);

            PointLight simpleLight = new PointLight(XNA.Color.Cyan, 1f);

            simpleLight.Position = new Microsoft.Xna.Framework.Vector3(1, 0.5f, 0.5f);
            PointLight simpleLight2 = new PointLight(XNA.Color.Magenta, 1f);

            simpleLight2.Position = new Microsoft.Xna.Framework.Vector3(-1, 0.5f, 0.5f);

            PointLight simpleLight3 = new PointLight(XNA.Color.Yellow, 0.2f);

            simpleLight3.Position = new Microsoft.Xna.Framework.Vector3(0, 2.5f, 0.25f);
            PointLight simpleLight4 = new PointLight(XNA.Color.Yellow, 0.2f);

            simpleLight4.Position = new Microsoft.Xna.Framework.Vector3(0, -2.5f, 0.25f);


            DirectionalLight dirLight0 = new DirectionalLight(XNA.Color.Red, 0.25f);

            dirLight0.Position  = new Microsoft.Xna.Framework.Vector3(1, 0, 1);
            dirLight0.Direction = -dirLight0.Position;
            DirectionalLight dirLight1 = new DirectionalLight(XNA.Color.Blue, 0.25f);

            dirLight1.Position  = new Microsoft.Xna.Framework.Vector3(-1, 0, 1);
            dirLight1.Direction = -dirLight1.Position;

            SpotLight spotLight0 = new SpotLight(XNA.Color.Green, 0.5f);

            spotLight0.Position   = new XNA.Vector3(0, -0.5f, 2.5f);
            spotLight0.Direction  = -spotLight0.Position;
            spotLight0.InnerAngle = 15f;
            spotLight0.OuterAngle = 20f;
            SpotLight spotLight1 = new SpotLight(XNA.Color.Cyan, 0.5f);

            spotLight1.Position   = new XNA.Vector3(0, 0.5f, 2.5f);
            spotLight1.Direction  = new XNA.Vector3(0, 0, -1);
            spotLight1.InnerAngle = 5f;
            spotLight1.OuterAngle = 10f;

            Scene.CurrentScene.AddSceneObject(simpleLight, "Light0");
            Scene.CurrentScene.AddSceneObject(simpleLight2, "Light1");
            Scene.CurrentScene.AddSceneObject(simpleLight3, "Light2");
            Scene.CurrentScene.AddSceneObject(simpleLight4, "Light3");

            Scene.CurrentScene.AddSceneObject(dirLight0, "DirLight0");
            Scene.CurrentScene.AddSceneObject(dirLight1, "DirLight1");

            Scene.CurrentScene.AddSceneObject(spotLight0, "spotLight0");
            Scene.CurrentScene.AddSceneObject(spotLight1, "spotLight1");
        }
        // Make a new spot light and give it a CheckBox.
        private void MakeSpotLight(Color color, double x, double y, double z,
                                   double vx, double vy, double vz,
                                   double outerAngle, double innerAngle)
        {
            SpotLight light = new SpotLight(color,
                                            new Point3D(x, y, z),
                                            new Vector3D(vx, vy, vz),
                                            outerAngle, innerAngle);

            MakeLightCheckbox(light, $"Spot({x}, {y}, {z})");
        }
Example #28
0
        public WorldScreen(Game Game)
            : base(Game, GeneralManager.ScreenX, GeneralManager.ScreenY)
        {
            GeneralManager.LoadAnimation("TestAnim", Vector2.One * 64, 6, 80);
            GeneralManager.LoadAnimation("PlayerIdle", Vector2.One * 64, 1, 10000);

            DebugWindow.Visible = false;
            DebugWindow.AddGUI(FarseerDebugCheck, DebugWindow);
            AddGUI(DebugWindow);

            LE = new LightingEngine();
            Color a = new Color(ambient, ambient, ambient);

            LE.SetAmbient(a, a);
            //LE.SetAmbient(Color.Gray, Color.Gray);
            Renderer.AddRendererEffect(LE, "LightingEngine");

            LoadContent();

            Map = new Map(this, tileSize, mapSize);
            //Renderer.AddPostProcess(new BlurEffect(), "Blur");
            SE               = new BlurSwitchEffect();
            SE.MaxTime       = 1f;
            SE.TurnOffAction = delegate() { Renderer.RemovePostProcess("Switch"); };
            Renderer.AddPostProcess(SE, "Switch");

            Camera.Init(GeneralManager.GetPartialRect(0, 0, 1, 1), new Rectangle(0, 0, tileSize * mapSize, tileSize * mapSize));

            PlayerLight = new SpotLight()
            {
                IsEnabled         = true,
                Color             = new Vector4(0.9f, .7f, .7f, 1f),
                Power             = .6f,
                LightDecay        = 600,
                Position          = new Vector3(500, 400, 20),
                SpotAngle         = 1.5f,
                SpotDecayExponent = 3,
                Direction         = new Vector3(0.244402379f, 0.969673932f, 0)
            };
            LE.AddLight(PlayerLight);

            Debug = new FarseerPhysics.DebugViews.DebugViewXNA(Map.PhysicalWorld);
            Debug.AppendFlags(FarseerPhysics.DebugViewFlags.Shape);
            Debug.AppendFlags(FarseerPhysics.DebugViewFlags.AABB);
            Debug.AppendFlags(FarseerPhysics.DebugViewFlags.PerformanceGraph);
            Debug.AppendFlags(FarseerPhysics.DebugViewFlags.Joint);
            Debug.AppendFlags(FarseerPhysics.DebugViewFlags.ContactPoints);
            Debug.DefaultShapeColor  = Color.White;
            Debug.SleepingShapeColor = Color.LightGray;
            Debug.LoadContent(Parent.GraphicsDevice, Parent.Content);

            //Weapon w = new Weapon("test", "Gun", 100, 10, Hands.One, 10, 600, 10, 10, 10);
            //Serializer.Serialize<Weapon>("weapon.xml", w);
        }
Example #29
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);
 }
Example #30
0
        public Transform3D CalculateSpotLightTransformation()
        {
            SpotLight        spotLight        = (SpotLight)this.Element.ViewObject.PlatformSpecificObject;
            Transform3DGroup transform3Dgroup = new Transform3DGroup();
            double           num = SpotLightAdorner3D.CalculateConeRadius(spotLight, this.typeOfConeAngle);

            transform3Dgroup.Children.Add((Transform3D) new ScaleTransform3D(num, num, 1.0));
            transform3Dgroup.Children.Add((Transform3D) new TranslateTransform3D(new Vector3D(0.0, 0.0, 1.0)));
            transform3Dgroup.Children.Add((Transform3D) new RotateTransform3D(Vector3DEditor.GetRotation3DFromDirection(spotLight.Direction)));
            transform3Dgroup.Children.Add((Transform3D) new TranslateTransform3D((Vector3D)spotLight.Position));
            return((Transform3D)transform3Dgroup);
        }
Example #31
0
        public override void Init()
        {
            shadowInfo = new ShadowInfo(Position, this.Angles.Forward(), Resource.GetTexture("effects/flashlight.png"), 1.0f );
            shadowInfo.Linear = 0.01f;
            cheapLight = new SpotLight();
            cheapLight.Linear = 0.01f;

            ShadowTechnique.SetLights += new Action(ShadowTechnique_SetLights);

            AmbientIntensity = 0.0f;
            DiffuseIntensity = 1.0f;

            this.Enabled = true;
            this.ExpensiveShadows = true;
            this.ShouldDraw = false;
        }
        public ThumbnailLighting()
        {
            Model = new LocalDataSource();
            this.InitializeComponent();

            // Get the current compositor
            _compositor = ElementCompositionPreview.GetElementVisual(this).Compositor;


            //
            // Create the lights
            //

            _ambientLight = _compositor.CreateAmbientLight();
            _pointLight = _compositor.CreatePointLight();
            _distantLight = _compositor.CreateDistantLight();
            _spotLight = _compositor.CreateSpotLight();
        }
Example #33
0
        /// <summary>
        /// Parses a <see cref="SpotLight" /> from the given XML node.
        /// </summary>
        /// <param name="node">The XML node.</param>
        /// <returns>A <see cref="SceneNode" /> instance.</returns>
        public SceneNode ParseSpotLight(XElement node)
        {
            SpotLight spotLight = new SpotLight(
                this.ParseVector3(node.Element("position")),
                Quaternion.Identity,
                Vector3.One,
                this.ParseVector3(node.Element("direction")),
                this.ParseColor(node.Element("color")),
                float.Parse(node.Attribute("intensity").Value),
                float.Parse(node.Element("clip").Attribute("near").Value),
                float.Parse(node.Element("clip").Attribute("far").Value),
                float.Parse(node.Element("projection").Attribute("field-of-view").Value),
                float.Parse(node.Attribute("bias").Value),
                bool.Parse(node.Attribute("cast-shadows").Value),
                int.Parse(node.Attribute("resolution").Value));

            SceneNode sceneNode = new SceneNode();
            sceneNode.AttachEntity(spotLight);
            return sceneNode;
        }
Example #34
0
 internal void add(SpotLight spotLight)
 {
     throw new NotImplementedException();
 }
Example #35
0
 void Start()
 {
     mLight = GameObject.Find("Camera").GetComponent<SpotLight>();
 }
        private void RenderShadowMap(SpotLight spotLight)
        {
            this.GraphicsDevice.SetRenderTarget(spotLight.ShadowMap);

            this.GraphicsDevice.Clear(Color.Transparent);
            
            this.DepthWriterEffect.Parameters ["View"].SetValue(spotLight.ViewMatrix);
            this.DepthWriterEffect.Parameters ["Projection"].SetValue(spotLight.ProjectionMatrix);
            this.DepthWriterEffect.Parameters ["LightPosition"].SetValue(spotLight.Position);
            this.DepthWriterEffect.Parameters ["DepthPrecision"].SetValue(spotLight.FarPlane);

            this.RenderSceneForShadows();
        }
Example #37
0
        public CompositionList()
        {
            this.InitializeComponent();

            this.Loaded += CompositionList_Loaded;
            this.Unloaded += CompositionList_Unloaded;

            // Get the current compositor
            _compositor = ElementCompositionPreview.GetElementVisual(this).Compositor;
            SurfaceLoader.Initialize(_compositor);
            
            //
            // Create the lights
            //
            _ambientLight = _compositor.CreateAmbientLight();
            _pointLight = _compositor.CreatePointLight();
            _distantLight = _compositor.CreateDistantLight();
            _spotLight = _compositor.CreateSpotLight();
        }