Пример #1
0
        protected override void Initialize()
        {
            // Setup resource manager
            ResourceManager.FileSystems.Add(new DiskFileSystem("Content"));

            // Setup debug blender
            //Renderer.Blender = new DebugBlender(0, Services);

            // Add view
            camera = new Camera(new Vector3(0, 5, 5), new Vector2(-(float)Math.PI / 4f, 0), 3.1415f / 3f, 4f / 3f, 0.1f, 100f);
            view = Renderer.CreateDefaultView(camera);
            Renderer.Views.Add(view);

            // Add sector
            sector = new ListSector(new BoundingBox(new Vector3(-10), new Vector3(10)));
            WorldManager.RegisterSector(sector);

            // Fill world
            boxObject1 = SimpleObject.CreateCube("Shaders/Test.fx", "Textures/Crate.jpg", "Box1", Services);
            boxObject1.Position = new Vector3(0.4f, 1, 1.2f);
            sector.RegisterObject(boxObject1);
            boxObject2 = SimpleObject.CreateCube("Shaders/Test.fx", "Textures/Crate.jpg", "Box2", Services);
            boxObject2.Position = new Vector3(-0.4f, 1, -1);
            sector.RegisterObject(boxObject2);
            boxObject3 = SimpleObject.CreateCube("Shaders/Test.fx", "Textures/Crate.jpg", "Box3", Services);
            boxObject3.Position = new Vector3(0, 3.001f, 0);
            boxObject3.Rotation = Quaternion.RotationAxis(Vector3.UnitY, (float)Math.PI / 3f);
            sector.RegisterObject(boxObject3);
            floorObject = SimpleObject.CreatePlane("Shaders/Test.fx", "Textures/Floor.jpg", "Floor", Services, 20, 20);
            floorObject.Position = new Vector3(0, -0.001f, 0);
            sector.RegisterObject(floorObject);

            // Add lighting
            ambientLighting = new AmbientLightingEffect(Services);
            //Renderer.VisualEffects.Add(ambientLighting);
            sunLighting = new DirectionalLightingEffect(Services);
            Renderer.VisualEffects.Add(sunLighting);

            // Register input handler
            InputManager.KeyDown += InputManager_KeyDown;
        }
Пример #2
0
        protected override void Initialize()
        {
            // Setup resource manager
            ResourceManager.FileSystems.Add(new DiskFileSystem("Content"));

            // Setup debug blender
            //Renderer.Blender = new DebugBlender(0, Services);

            // Add view
            camera = new Camera(new Vector3(0, 5, 5), new Vector2(-(float)Math.PI / 4f, 0), 3.1415f / 3f, 4f / 3f, 0.1f, 100f);
            view   = Renderer.CreateDefaultView(camera);
            Renderer.Views.Add(view);

            // Add sector
            sector = new ListSector(new BoundingBox(new Vector3(-10), new Vector3(10)));
            WorldManager.RegisterSector(sector);

            // Fill world
            boxObject1          = SimpleObject.CreateCube("Shaders/Test.fx", "Textures/Crate.jpg", "Box1", Services);
            boxObject1.Position = new Vector3(0.4f, 1, 1.2f);
            sector.RegisterObject(boxObject1);
            boxObject2          = SimpleObject.CreateCube("Shaders/Test.fx", "Textures/Crate.jpg", "Box2", Services);
            boxObject2.Position = new Vector3(-0.4f, 1, -1);
            sector.RegisterObject(boxObject2);
            boxObject3          = SimpleObject.CreateCube("Shaders/Test.fx", "Textures/Crate.jpg", "Box3", Services);
            boxObject3.Position = new Vector3(0, 3.001f, 0);
            boxObject3.Rotation = Quaternion.RotationAxis(Vector3.UnitY, (float)Math.PI / 3f);
            sector.RegisterObject(boxObject3);
            floorObject          = SimpleObject.CreatePlane("Shaders/Test.fx", "Textures/Floor.jpg", "Floor", Services, 20, 20);
            floorObject.Position = new Vector3(0, -0.001f, 0);
            sector.RegisterObject(floorObject);

            // Add lighting
            ambientLighting = new AmbientLightingEffect(Services);
            //Renderer.VisualEffects.Add(ambientLighting);
            sunLighting = new DirectionalLightingEffect(Services);
            Renderer.VisualEffects.Add(sunLighting);

            // Register input handler
            InputManager.KeyDown += InputManager_KeyDown;
        }