Example #1
0
        public void LoadMap(string filename)
        {
            int x = 0;
            int y = 0;
            Light light;

            map = MapFile.Load(resourcePath + "/Maps/" + filename);

            mapWidth = map.GetWidth();
            mapHeight = map.GetHeight();

            activeRobot = map.GetActiveRobot();
            robotCamera.Attach(activeRobot);
            map.AddRobotToRemoteControlUnitList(activeRobot);

            light = new Light(LightName.Light7);
            activeRobot.AddLight(light);

            someRobot = activeRobot;

            LightPost lightpost = new LightPost(4);
            map.SetTile(lightpost, x, y);

            light = new Light(LightName.Light0);
            light.setCutOff(45.0f);
            light.lookAt(0.0f, 6.0f, 0.0f,
                         2.0f * (float) Math.Sqrt(2.0f), 0.0f, -2.0f * (float) Math.Sqrt(2.0f),
                         1.0f, 1.0f, 1.0f);

            lightpost.AddLight(light);

            l = light;

            lightCamera1 = new Camera(0.0f, 6.0f, 0.0f,
                         2.0f * (float) Math.Sqrt(2.0f), 0.0f, -2.0f * (float) Math.Sqrt(2.0f),
                         0.0f, 1.0f, 0.0f);

            lightpost = new LightPost(3);
            map.SetTile(lightpost, x + mapWidth - 1, y);

            light = new Light(LightName.Light1);
            light.setCutOff(45.0f);
            light.lookAt(0.0f, 6.0f, 0.0f,
                -2.0f * (float) Math.Sqrt(2.0f), 0.0f, -2.0f * (float) Math.Sqrt(2.0f),
                0.0f, 0.0f, 1.0f);
            lightpost.AddLight(light);

            lightCamera2 = new Camera(mapWidth - 1, 6.0f, 0.0f,
                (mapWidth - 1) - 2.0f * (float) Math.Sqrt(2.0f), 0.0f, -2.0f * (float) Math.Sqrt(2.0f),
                0.0f, 1.0f, 0.0f);

            lightpost = new LightPost(2);
            map.SetTile(lightpost, x + mapWidth - 1, y + mapHeight -1);

            light = new Light(LightName.Light2);
            light.setCutOff(45.0f);
            light.lookAt(0.0f, 6.0f, 0.0f,
                -2.0f * (float) Math.Sqrt(2.0f), 0.0f, 2.0f * (float) Math.Sqrt(2.0f),
                1.0f, 1.0f, 1.0f);
            lightpost.AddLight(light);

            lightCamera3 = new Camera(mapWidth, 6.0f, -(mapHeight - 1),
                (mapWidth - 1) - 2.0f * (float) Math.Sqrt(2.0f), 0.0f, -(mapHeight - 1) + 2.0f * (float) Math.Sqrt(2.0f),
                0.0f, 1.0f, 0.0f);

            lightpost = new LightPost(1);
            map.SetTile(lightpost, x, y + (mapHeight - 1));

            light = new Light(LightName.Light3);
            light.setCutOff(45.0f);
            light.lookAt(0.0f, 6.0f, 0.0f,
                2.0f * (float) Math.Sqrt(2.0f), 0.0f, 2.0f * (float) Math.Sqrt(2.0f),
                1.0f, 1.0f, 1.0f);
            lightpost.AddLight(light);

            lightCamera4 = new Camera(0.0f, 6.0f, -(mapHeight - 1),
                2.0f * (float) Math.Sqrt(2.0f), 0.0f, -(mapHeight - 1) + 2.0f * (float) Math.Sqrt(2.0f),
                0.0f, 1.0f, 0.0f);

            this.Title = this.baseTitle;

            PrintHelp();

            prevMousePosition = this.WindowCenter;
            prevMouseDelta = new Point(0, 0);
            nullDelta = new Point(0, 0);

            globalCamera.SetMap(map);
            robotCamera.SetMap(map);

            camera = globalCamera;

            System.Windows.Forms.Cursor.Hide();

            GL.Enable(EnableCap.Lighting);
            GL.Enable(EnableCap.ColorMaterial);
            GL.Enable(EnableCap.Texture2D);

            /* To Avoid Having Z-Fighting for projecting surfaces onto another surface (Shadows) */
            GL.PolygonOffset(-10.0f, -25.0f);
        }
Example #2
0
        public void LoadMap(string filename)
        {
            int   x = 0;
            int   y = 0;
            Light light;

            map = MapFile.Load(resourcePath + "/Maps/" + filename);

            mapWidth  = map.GetWidth();
            mapHeight = map.GetHeight();

            activeRobot = map.GetActiveRobot();
            robotCamera.Attach(activeRobot);
            map.AddRobotToRemoteControlUnitList(activeRobot);

            light = new Light(LightName.Light7);
            activeRobot.AddLight(light);

            someRobot = activeRobot;

            LightPost lightpost = new LightPost(4);

            map.SetTile(lightpost, x, y);

            light = new Light(LightName.Light0);
            light.setCutOff(45.0f);
            light.lookAt(0.0f, 6.0f, 0.0f,
                         2.0f * (float)Math.Sqrt(2.0f), 0.0f, -2.0f * (float)Math.Sqrt(2.0f),
                         1.0f, 1.0f, 1.0f);

            lightpost.AddLight(light);

            l = light;

            lightCamera1 = new Camera(0.0f, 6.0f, 0.0f,
                                      2.0f * (float)Math.Sqrt(2.0f), 0.0f, -2.0f * (float)Math.Sqrt(2.0f),
                                      0.0f, 1.0f, 0.0f);

            lightpost = new LightPost(3);
            map.SetTile(lightpost, x + mapWidth - 1, y);

            light = new Light(LightName.Light1);
            light.setCutOff(45.0f);
            light.lookAt(0.0f, 6.0f, 0.0f,
                         -2.0f * (float)Math.Sqrt(2.0f), 0.0f, -2.0f * (float)Math.Sqrt(2.0f),
                         0.0f, 0.0f, 1.0f);
            lightpost.AddLight(light);

            lightCamera2 = new Camera(mapWidth - 1, 6.0f, 0.0f,
                                      (mapWidth - 1) - 2.0f * (float)Math.Sqrt(2.0f), 0.0f, -2.0f * (float)Math.Sqrt(2.0f),
                                      0.0f, 1.0f, 0.0f);

            lightpost = new LightPost(2);
            map.SetTile(lightpost, x + mapWidth - 1, y + mapHeight - 1);

            light = new Light(LightName.Light2);
            light.setCutOff(45.0f);
            light.lookAt(0.0f, 6.0f, 0.0f,
                         -2.0f * (float)Math.Sqrt(2.0f), 0.0f, 2.0f * (float)Math.Sqrt(2.0f),
                         1.0f, 1.0f, 1.0f);
            lightpost.AddLight(light);

            lightCamera3 = new Camera(mapWidth, 6.0f, -(mapHeight - 1),
                                      (mapWidth - 1) - 2.0f * (float)Math.Sqrt(2.0f), 0.0f, -(mapHeight - 1) + 2.0f * (float)Math.Sqrt(2.0f),
                                      0.0f, 1.0f, 0.0f);

            lightpost = new LightPost(1);
            map.SetTile(lightpost, x, y + (mapHeight - 1));

            light = new Light(LightName.Light3);
            light.setCutOff(45.0f);
            light.lookAt(0.0f, 6.0f, 0.0f,
                         2.0f * (float)Math.Sqrt(2.0f), 0.0f, 2.0f * (float)Math.Sqrt(2.0f),
                         1.0f, 1.0f, 1.0f);
            lightpost.AddLight(light);

            lightCamera4 = new Camera(0.0f, 6.0f, -(mapHeight - 1),
                                      2.0f * (float)Math.Sqrt(2.0f), 0.0f, -(mapHeight - 1) + 2.0f * (float)Math.Sqrt(2.0f),
                                      0.0f, 1.0f, 0.0f);

            this.Title = this.baseTitle;

            PrintHelp();

            prevMousePosition = this.WindowCenter;
            prevMouseDelta    = new Point(0, 0);
            nullDelta         = new Point(0, 0);

            globalCamera.SetMap(map);
            robotCamera.SetMap(map);

            camera = globalCamera;

            System.Windows.Forms.Cursor.Hide();

            GL.Enable(EnableCap.Lighting);
            GL.Enable(EnableCap.ColorMaterial);
            GL.Enable(EnableCap.Texture2D);

            /* To Avoid Having Z-Fighting for projecting surfaces onto another surface (Shadows) */
            GL.PolygonOffset(-10.0f, -25.0f);
        }