SetSpotlightRange() public method

public SetSpotlightRange ( float innerAngle, float outerAngle ) : void
innerAngle float
outerAngle float
return void
Ejemplo n.º 1
0
        public MultiLights(SceneManager pSceneManager, SceneNode pCamNode, MovingObject pPlayerShip, Int32 pNumberOfLights)
        {
            oldCamLightColor = CamLightColor = new ColorEx(0.13f, 0.1f, 0.05f);
            PlayerLightColor = ColorEx.White;
            camLights = new List<Light>(pNumberOfLights);

            innerLights = (Int32)Math.Round(pNumberOfLights / 3.0f, MidpointRounding.AwayFromZero);
            outerLights = pNumberOfLights - innerLights;

            // create the playership's light.
            playerLight = pSceneManager.CreateLight("playerSpotLight");
            playerLight.Type = LightType.Spotlight;
            playerLight.Diffuse = PlayerLightColor;
            playerLight.Specular = ColorEx.White;
            playerLight.SetSpotlightRange(0.0f, 120.0f);
            playerLight.Direction = Vector3.NegativeUnitZ;

            playerLightNode = pPlayerShip.Node.CreateChildSceneNode();
            playerLightNode.AttachObject(playerLight);
            playerLightNode.Position = new Vector3(0, 0, 0);
            playerLightNode.SetDirection(new Vector3(1, 0, 0), TransformSpace.Local);

            // create the camera spotlights around the camera's direction.
            camInnerLightNode = pCamNode.CreateChildSceneNode();
            camInnerLightNode.Position = new Vector3(0, 0, 0);
            camOuterLightNode = pCamNode.CreateChildSceneNode();
            camOuterLightNode.Position = new Vector3(0, 0, 0);

            for (var i = 0; i < innerLights; i++)
            {
                var light = pSceneManager.CreateLight("camInnerLight " + (i + 1));
                light.Type = LightType.Spotlight;
                light.Diffuse = CamLightColor;
                light.Specular = ColorEx.White;
                light.SetSpotlightRange(0.0f, 25.0f);
                light.Direction = Quaternion.FromAngleAxis(360.0 * i / innerLights * Constants.DegreesToRadians, Vector3.UnitZ) *
                    Quaternion.FromAngleAxis(10.0 * Constants.DegreesToRadians, Vector3.UnitX) *
                    Vector3.NegativeUnitZ;

                camLights.Add(light);
                camInnerLightNode.AttachObject(light);
            }
            for (var i = 0; i < outerLights; i++)
            {
                var light = pSceneManager.CreateLight("camOuterLight " + (i + 1));
                light.Type = LightType.Spotlight;
                light.Diffuse = CamLightColor;
                light.Specular = ColorEx.White;
                light.SetSpotlightRange(0.0f, 25.0f);
                light.Direction = Quaternion.FromAngleAxis(360.0 * i / outerLights * Constants.DegreesToRadians, Vector3.UnitZ) *
                    Quaternion.FromAngleAxis(20.0 * Constants.DegreesToRadians, Vector3.UnitX) *
                    Vector3.NegativeUnitZ;

                camLights.Add(light);
                camOuterLightNode.AttachObject(light);
            }
        }
Ejemplo n.º 2
0
        public void InitializeScene()
        {
            // Start the Stopwatch.
            stopwatch = new Stopwatch();
            stopwatch.Start();
            physicsDelayTicks = Stopwatch.Frequency / 35.0; // 30 physics steps per second
            ticksToMilliFactor = 1.0 / (Stopwatch.Frequency / 1000.0);
            ticksToPhysicsStepPercentFactor = 1.0 / physicsDelayTicks;
            lastPhysicsStepTicks = 0.0;

            // Create the World.
            World.Instance = new World(sceneManager);
            World.Instance.Initialize();
            World.Instance.Arena = new Arena(sceneManager, 500, 4);

            // Create a AI Ships.
            for (var i = 0; i < 36; i++)
            {
                World.Instance.AddShip(new Ship(sceneManager, new RandomController()));
            }

            // Camera.
            camera = new SmoothCamera("Camera", sceneManager, World.Instance.PlayerShip, 6);

            // Lighting.
            sunlight = sceneManager.CreateLight("Sunlight");
            sunlight.Type = LightType.Spotlight;
            sunlight.Specular = ColorEx.White;
            sunlight.Diffuse = new ColorEx(0.85f, 0.77f, 0.60f);
            sunlight.Position = new Vector3(0, 0, 0);
            sunlight.Direction = Vector3.NegativeUnitZ;
            sunlight.SetSpotlightRange(15, 60);
            sceneManager.AmbientLight = ColorEx.Black;
            camera.Node.AttachObject(sunlight);

            // Viewport.
            viewport = window.AddViewport(camera, 0, 0, 1.0f, 1.0f, 100);
            viewport.BackgroundColor = ColorEx.Black;
        }