Пример #1
0
 public PreviewWindowRayTrace()
 {
     LocalBounds               = new rect_d(0, 0, 100, 100);
     cameraData.upVector3      = Vector3.UnitY;
     cameraData.cameraPosition = new Vector3(0, 0, 300);
     cameraData.lookAtPoint    = new Vector3();
 }
Пример #2
0
        void SetGlContext()
        {
            Gl.glGetIntegerv(Gl.GL_VIEWPORT, oldViewport);
            rect_d screenRect = this.RectToScreen(LocalBounds);

            Gl.glViewport((int)screenRect.Left, (int)screenRect.Bottom, (int)screenRect.Width, (int)screenRect.Height);

            Gl.glLightfv(Gl.GL_LIGHT0, Gl.GL_AMBIENT, ambientLight);
            Gl.glLightfv(Gl.GL_LIGHT0, Gl.GL_DIFFUSE, diffuseLight);
            Gl.glLightfv(Gl.GL_LIGHT0, Gl.GL_SPECULAR, specularLight);
            Gl.glEnable(Gl.GL_LIGHT0);

            Gl.glShadeModel(Gl.GL_SMOOTH);                                                              // enable smooth shading
            Gl.glClearDepth(1.0f);                                                                      // depth buffer setup
            Gl.glEnable(Gl.GL_DEPTH_TEST);                                                              // enables depth testing
            Gl.glEnable(Gl.GL_BLEND);
            Gl.glEnable(Gl.GL_NORMALIZE);

            Gl.glFrontFace(Gl.GL_CCW);
            //Gl.glEnable(Gl.GL_CULL_FACE); // Enable cull face
            Gl.glCullFace(Gl.GL_BACK);                                  // Cull the back face (don't display)

            Gl.glDepthFunc(Gl.GL_LEQUAL);                               // type of depth test
            Gl.glHint(Gl.GL_PERSPECTIVE_CORRECTION_HINT, Gl.GL_NICEST); // nice perspective calculations

            Gl.glEnable(Gl.GL_LIGHTING);
            Gl.glColorMaterial(Gl.GL_FRONT_AND_BACK, Gl.GL_AMBIENT_AND_DIFFUSE);
            Gl.glEnable(Gl.GL_COLOR_MATERIAL);
        }
Пример #3
0
        public override void OnResize(int sx, int sy)
        {
            Bounds = new rect_d(0, 0, sx, sy);;
            int bitDepth = GetBitDepthForPixelFormat(m_format);

            backBuffer.Allocate((int)Width, (int)Height, (int)Width * bitDepth / 8, bitDepth);
            NewGraphics2D().Clear(new RGBA_Doubles(1, 1, 1, 1));
        }
Пример #4
0
        public CreditsMenu(rect_d bounds)
        {
            Bounds = bounds;

            ImageSequence cancelButtonSequence = (ImageSequence)DataAssetCache.Instance.GetAsset(typeof(ImageSequence), "NumPlayersCancelButton");
            ButtonWidget cancelGameButton = new ButtonWidget(400, 200, new ThreeImageButtonView(cancelButtonSequence.GetImageByIndex(0), cancelButtonSequence.GetImageByIndex(1), cancelButtonSequence.GetImageByIndex(2)));
            AddChild(cancelGameButton);
            cancelGameButton.ButtonClick += new ButtonWidget.ButtonEventHandler(OnCancelMenuButton);
        }
Пример #5
0
        public CreditsMenu(rect_d bounds)
        {
            Bounds = bounds;

            ImageSequence cancelButtonSequence = (ImageSequence)DataAssetCache.Instance.GetAsset(typeof(ImageSequence), "NumPlayersCancelButton");
            ButtonWidget  cancelGameButton     = new ButtonWidget(400, 200, new ThreeImageButtonView(cancelButtonSequence.GetImageByIndex(0), cancelButtonSequence.GetImageByIndex(1), cancelButtonSequence.GetImageByIndex(2)));

            AddChild(cancelGameButton);
            cancelGameButton.ButtonClick += new ButtonWidget.ButtonEventHandler(OnCancelMenuButton);
        }
Пример #6
0
        public override void Init(int width, int height, GuiHalSurface.CreateFlags flags, GuiHalSurface.PixelFormat pixelFormat)
        {
            //if (windowsFormsWindow.m_sys_format == PlatformSupportAbstract.ImageFormats.pix_format_undefined)
            {
                //  return false;
            }

            m_window_flags = flags;

            initialWidth  = width;
            initialHeight = height;

            int bitDepth = GetBitDepthForPixelFormat(m_format);

            switch (bitDepth)
            {
            case 24:
                backBuffer = new ImageBuffer(initialWidth, initialHeight, 24, new BlenderBGR());
                break;

            case 32:
                backBuffer = new ImageBuffer(initialWidth, initialHeight, 32, new BlenderBGRA());
                break;

            case 128:
                throw new NotImplementedException();
            //backBuffer = null;
            //m_BackBufferFloat = new ImageBufferFloat(initialWidth, initialHeight, 128, new BlenderBGRAFloat());
            //break;

            default:
                throw new NotImplementedException("Don't support this bit depth yet.");
            }

            System.Drawing.Size clientSize = new System.Drawing.Size();
            clientSize.Width              = (int)width;
            clientSize.Height             = (int)height;
            windowsFormsWindow.ClientSize = clientSize;

            if ((m_window_flags & CreateFlags.Resizable) == 0)
            {
                windowsFormsWindow.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
                windowsFormsWindow.MaximizeBox     = false;
            }

            clientSize.Width              = width;
            clientSize.Height             = height;
            windowsFormsWindow.ClientSize = clientSize;

            Bounds = new rect_d(0, 0, width, height);

            OnInitialize();
            windowsFormsWindow.m_WindowContentNeedsRedraw = true;
        }
Пример #7
0
        public override void OnDraw(Graphics2D graphics2D)
        {
            CameraCalibrationWidget_OnDraw.Start();
            graphics2D.Clear(RGBA_Bytes.White);
            rect_d rect = new rect_d(Width - 40, 10, Width - 10, 40);

            graphics2D.Rectangle(rect, RGBA_Bytes.Black);
            Invalidate(rect);

            base.OnDraw(graphics2D);
            CameraCalibrationWidget_OnDraw.Stop();
        }
Пример #8
0
        public override void OnDraw(Graphics2D graphics2D)
        {
            MatterCadWidget_OnDraw.Start();
            graphics2D.Clear(RGBA_Bytes.White);
            rect_d rect = new rect_d(Width - 40, 10, Width - 10, 40);

            graphics2D.FillRectangle(rect, previewWindowRayTrace.mouseOverColor);
            graphics2D.Rectangle(rect, RGBA_Bytes.Black);
            Invalidate(rect);

            base.OnDraw(graphics2D);
            MatterCadWidget_OnDraw.Stop();
        }
Пример #9
0
        public PlayfieldView(rect_d bounds)
        {
            Bounds = bounds;

            backgroundImageSequence = (ImageSequence)DataAssetCache.Instance.GetAsset(typeof(ImageSequence), "Map1Background");
            backgroundImage = backgroundImageSequence.GetImageByIndex(0);

            ImageSequence menuButtonSequence = (ImageSequence)DataAssetCache.Instance.GetAsset(typeof(ImageSequence), "MenuButtonFromGame");
            ButtonWidget menuButton = new ButtonWidget(400, 12, new ThreeImageButtonView(menuButtonSequence.GetImageByIndex(0), menuButtonSequence.GetImageByIndex(1), menuButtonSequence.GetImageByIndex(2)));
            AddChild(menuButton);
            menuButton.ButtonClick += new ButtonWidget.ButtonEventHandler(EscapeMenu);

            playerViews[0] = new PlayerView(new rect_d(400, 300, 800, 600));
            playerViews[1] = new PlayerView(new rect_d(400, 0, 800, 300));
            playerViews[2] = new PlayerView(new rect_d(0, 300, 400, 600));
            playerViews[3] = new PlayerView(new rect_d(0, 0, 400, 300));
        }
Пример #10
0
        public PlayfieldView(rect_d bounds)
        {
            Bounds = bounds;

            backgroundImageSequence = (ImageSequence)DataAssetCache.Instance.GetAsset(typeof(ImageSequence), "Map1Background");
            backgroundImage         = backgroundImageSequence.GetImageByIndex(0);

            ImageSequence menuButtonSequence = (ImageSequence)DataAssetCache.Instance.GetAsset(typeof(ImageSequence), "MenuButtonFromGame");
            ButtonWidget  menuButton         = new ButtonWidget(400, 12, new ThreeImageButtonView(menuButtonSequence.GetImageByIndex(0), menuButtonSequence.GetImageByIndex(1), menuButtonSequence.GetImageByIndex(2)));

            AddChild(menuButton);
            menuButton.ButtonClick += new ButtonWidget.ButtonEventHandler(EscapeMenu);

            playerViews[0] = new PlayerView(new rect_d(400, 300, 800, 600));
            playerViews[1] = new PlayerView(new rect_d(400, 0, 800, 300));
            playerViews[2] = new PlayerView(new rect_d(0, 300, 400, 600));
            playerViews[3] = new PlayerView(new rect_d(0, 0, 400, 300));
        }
Пример #11
0
        public MainMenu(rect_d bounds)
        {
            Bounds = bounds;

            ImageSequence startButtonSequence = (ImageSequence)DataAssetCache.Instance.GetAsset(typeof(ImageSequence), "MainMenuStartButton");
            ButtonWidget  StartGameButton     = new ButtonWidget(400, 310, new ThreeImageButtonView(startButtonSequence.GetImageByIndex(0), startButtonSequence.GetImageByIndex(1), startButtonSequence.GetImageByIndex(2)));

            AddChild(StartGameButton);
            StartGameButton.ButtonClick += new ButtonWidget.ButtonEventHandler(OnStartGameButton);

            ImageSequence creditsButtonSequence = (ImageSequence)DataAssetCache.Instance.GetAsset(typeof(ImageSequence), "MainMenuCreditsButton");
            ButtonWidget  creditsGameButton     = new ButtonWidget(400, 230, new ThreeImageButtonView(creditsButtonSequence.GetImageByIndex(0), creditsButtonSequence.GetImageByIndex(1), creditsButtonSequence.GetImageByIndex(2)));

            AddChild(creditsGameButton);
            creditsGameButton.ButtonClick += new ButtonWidget.ButtonEventHandler(OnShowCreditsButton);

            ImageSequence exitButtonSequence = (ImageSequence)DataAssetCache.Instance.GetAsset(typeof(ImageSequence), "MainMenuExitButton");
            ButtonWidget  exitGameButton     = new ButtonWidget(400, 170, new ThreeImageButtonView(exitButtonSequence.GetImageByIndex(0), exitButtonSequence.GetImageByIndex(1), exitButtonSequence.GetImageByIndex(2)));

            AddChild(exitGameButton);
            exitGameButton.ButtonClick += new ButtonWidget.ButtonEventHandler(OnExitGameButton);
        }
        public override void OnDraw(Graphics2D graphics2D)
        {
            CameraCalibrationWidget_OnDraw.Start();
            graphics2D.Clear(RGBA_Bytes.White);
            rect_d rect = new rect_d(Width - 40, 10, Width - 10, 40);
            graphics2D.Rectangle(rect, RGBA_Bytes.Black);
            Invalidate(rect);

            base.OnDraw(graphics2D);
            CameraCalibrationWidget_OnDraw.Stop();
        }
Пример #13
0
		public MainMenu(rect_d bounds)
		{
            Bounds = bounds;

            ImageSequence startButtonSequence = (ImageSequence)DataAssetCache.Instance.GetAsset(typeof(ImageSequence), "MainMenuStartButton");
            ButtonWidget StartGameButton = new ButtonWidget(400, 310, new ThreeImageButtonView(startButtonSequence.GetImageByIndex(0), startButtonSequence.GetImageByIndex(1), startButtonSequence.GetImageByIndex(2)));
            AddChild(StartGameButton);
            StartGameButton.ButtonClick += new ButtonWidget.ButtonEventHandler(OnStartGameButton);

            ImageSequence creditsButtonSequence = (ImageSequence)DataAssetCache.Instance.GetAsset(typeof(ImageSequence), "MainMenuCreditsButton");
            ButtonWidget creditsGameButton = new ButtonWidget(400, 230, new ThreeImageButtonView(creditsButtonSequence.GetImageByIndex(0), creditsButtonSequence.GetImageByIndex(1), creditsButtonSequence.GetImageByIndex(2)));
            AddChild(creditsGameButton);
            creditsGameButton.ButtonClick += new ButtonWidget.ButtonEventHandler(OnShowCreditsButton);

            ImageSequence exitButtonSequence = (ImageSequence)DataAssetCache.Instance.GetAsset(typeof(ImageSequence), "MainMenuExitButton");
            ButtonWidget exitGameButton = new ButtonWidget(400, 170, new ThreeImageButtonView(exitButtonSequence.GetImageByIndex(0), exitButtonSequence.GetImageByIndex(1), exitButtonSequence.GetImageByIndex(2)));
			AddChild(exitGameButton);
			exitGameButton.ButtonClick += new ButtonWidget.ButtonEventHandler(OnExitGameButton);
		}
Пример #14
0
 public PreviewWindowRayTrace()
 {
     LocalBounds = new rect_d(0, 0, 100, 100);
     cameraData.upVector3 = Vector3.UnitY;
     cameraData.cameraPosition = new Vector3(0, 0, 300);
     cameraData.lookAtPoint = new Vector3();
 }
Пример #15
0
 public PlayerView(rect_d inScreenWindow)
 {
     screenWindow = inScreenWindow;
 }
Пример #16
0
        public override void OnDraw(RendererBase rendererToDrawWith)
        {
            ImageBuffer levelMap = playfield.LevelMap;
            int offset;
            byte[] buffer = levelMap.GetBuffer(out offset);

            if (!haveDrawnWalls)
            {
                RendererBase backgroundRenderer = BackgroundImage.NewRenderer();
                rect_i boundsI = BackgroundImage.GetBoundingRect();
                rect_d bounds = new rect_d(boundsI.Left, boundsI.Bottom, boundsI.Right, boundsI.Top);
                backgroundRenderer.SetClippingRect(bounds);
                ImageSequence wallTileSequence = (ImageSequence)DataAssetCache.Instance.GetAsset(typeof(ImageSequence), "WallTile");
                for (int y = 0; y < levelMap.Height(); y++)
                {
                    for (int x = 0; x < levelMap.Width(); x++)
                    {
                        if (buffer[levelMap.GetBufferOffsetXY(x, y)] == 0)
                        {
                            int index = 0;
                            // what type of wall
                            if (x < levelMap.Width() -1 
                                && buffer[levelMap.GetBufferOffsetXY(x + 1, y + 0)] == 0)
                            {
                                index |= 8;
                            }

                            if (y < levelMap.Height() -1 
                                && buffer[levelMap.GetBufferOffsetXY(x + 0, y + 1)] == 0)
                            {
                                index |= 4;
                            }

                            if (x > 0
                                && buffer[levelMap.GetBufferOffsetXY(x - 1, y + 0)] == 0)
                            {
                                index |= 2;
                            }

                            if (y > 0
                                && buffer[levelMap.GetBufferOffsetXY(x + 0, y - 1)] == 0)
                            {
                                index |= 1;
                            }

                            backgroundRenderer.Render(wallTileSequence.GetImageByIndex(index), x * 16, y * 16);
                        }
                    }
                }
                haveDrawnWalls = true;
            }

            //for (int i = 0; i < 1; i++)
            for (int i = 0; i < numPlayers; i++)
            {
                playerViews[i].SetRendererPreDraw(BackgroundImage, rendererToDrawWith, playfield.PlayerList[i]);

                rendererToDrawWith.Render(BackgroundImage, 0, 0);

                foreach (SequenceEntity aSequenceEntity in playfield.SequenceEntityList)
                {
                    aSequenceEntity.Draw(rendererToDrawWith);
                }

                foreach (Player aPlayer in playfield.PlayerList)
                {
                    aPlayer.Draw(rendererToDrawWith);
                }

                playfield.sword.Draw(rendererToDrawWith);
                playfield.key.Draw(rendererToDrawWith);
                playfield.shield.Draw(rendererToDrawWith);

                playerViews[i].SetRendererPostDraw(rendererToDrawWith);
            }

            ImageSequence hud = (ImageSequence)DataAssetCache.Instance.GetAsset(typeof(ImageSequence), (playfield.PlayerList.Count).ToString() + "PlayerHUD");
            rendererToDrawWith.Render(hud.GetImageByIndex(0), 400, 300);

            foreach (Player aPlayer in playfield.PlayerList)
            {
                aPlayer.DrawScore(rendererToDrawWith);
            }

            rendererToDrawWith.Line(0.5, 300.5, 800.5, 300.5, new RGBA_Bytes(255, 20, 20));
            rendererToDrawWith.Line(400.5, 0.5, 400.5, 600.5, new RGBA_Bytes(255, 20, 20));

            base.OnDraw(rendererToDrawWith);
        }
Пример #17
0
        public override void OnDraw(Graphics2D graphics2D)
        {
            MatterCadWidget_OnDraw.Start();
            graphics2D.Clear(RGBA_Bytes.White);
            rect_d rect = new rect_d(Width - 40, 10, Width - 10, 40);
            graphics2D.FillRectangle(rect, previewWindowRayTrace.mouseOverColor);
            graphics2D.Rectangle(rect, RGBA_Bytes.Black);
            Invalidate(rect);

            base.OnDraw(graphics2D);
            MatterCadWidget_OnDraw.Stop();
        }
Пример #18
0
        public override void OnDraw(RendererBase rendererToDrawWith)
        {
            ImageBuffer levelMap = playfield.LevelMap;
            int         offset;

            byte[] buffer = levelMap.GetBuffer(out offset);

            if (!haveDrawnWalls)
            {
                RendererBase backgroundRenderer = BackgroundImage.NewRenderer();
                rect_i       boundsI            = BackgroundImage.GetBoundingRect();
                rect_d       bounds             = new rect_d(boundsI.Left, boundsI.Bottom, boundsI.Right, boundsI.Top);
                backgroundRenderer.SetClippingRect(bounds);
                ImageSequence wallTileSequence = (ImageSequence)DataAssetCache.Instance.GetAsset(typeof(ImageSequence), "WallTile");
                for (int y = 0; y < levelMap.Height(); y++)
                {
                    for (int x = 0; x < levelMap.Width(); x++)
                    {
                        if (buffer[levelMap.GetBufferOffsetXY(x, y)] == 0)
                        {
                            int index = 0;
                            // what type of wall
                            if (x < levelMap.Width() - 1 &&
                                buffer[levelMap.GetBufferOffsetXY(x + 1, y + 0)] == 0)
                            {
                                index |= 8;
                            }

                            if (y < levelMap.Height() - 1 &&
                                buffer[levelMap.GetBufferOffsetXY(x + 0, y + 1)] == 0)
                            {
                                index |= 4;
                            }

                            if (x > 0 &&
                                buffer[levelMap.GetBufferOffsetXY(x - 1, y + 0)] == 0)
                            {
                                index |= 2;
                            }

                            if (y > 0 &&
                                buffer[levelMap.GetBufferOffsetXY(x + 0, y - 1)] == 0)
                            {
                                index |= 1;
                            }

                            backgroundRenderer.Render(wallTileSequence.GetImageByIndex(index), x * 16, y * 16);
                        }
                    }
                }
                haveDrawnWalls = true;
            }

            //for (int i = 0; i < 1; i++)
            for (int i = 0; i < numPlayers; i++)
            {
                playerViews[i].SetRendererPreDraw(BackgroundImage, rendererToDrawWith, playfield.PlayerList[i]);

                rendererToDrawWith.Render(BackgroundImage, 0, 0);

                foreach (SequenceEntity aSequenceEntity in playfield.SequenceEntityList)
                {
                    aSequenceEntity.Draw(rendererToDrawWith);
                }

                foreach (Player aPlayer in playfield.PlayerList)
                {
                    aPlayer.Draw(rendererToDrawWith);
                }

                playfield.sword.Draw(rendererToDrawWith);
                playfield.key.Draw(rendererToDrawWith);
                playfield.shield.Draw(rendererToDrawWith);

                playerViews[i].SetRendererPostDraw(rendererToDrawWith);
            }

            ImageSequence hud = (ImageSequence)DataAssetCache.Instance.GetAsset(typeof(ImageSequence), (playfield.PlayerList.Count).ToString() + "PlayerHUD");

            rendererToDrawWith.Render(hud.GetImageByIndex(0), 400, 300);

            foreach (Player aPlayer in playfield.PlayerList)
            {
                aPlayer.DrawScore(rendererToDrawWith);
            }

            rendererToDrawWith.Line(0.5, 300.5, 800.5, 300.5, new RGBA_Bytes(255, 20, 20));
            rendererToDrawWith.Line(400.5, 0.5, 400.5, 600.5, new RGBA_Bytes(255, 20, 20));

            base.OnDraw(rendererToDrawWith);
        }
Пример #19
0
 public PlayerView(rect_d inScreenWindow)
 {
     screenWindow = inScreenWindow;
 }
Пример #20
0
 public override void SetClippingRect(rect_d clippingRect)
 {
     Gl.glScissor((int)Math.Floor(clippingRect.x1), (int)Math.Floor(clippingRect.y1),
         (int)Math.Ceiling(clippingRect.Width), (int)Math.Ceiling(clippingRect.Height));
 }
        public override void OnResize(int sx, int sy)
        {
            Bounds = new rect_d(0, 0, sx, sy); ;
            int bitDepth = GetBitDepthForPixelFormat(m_format);

            backBuffer.Allocate((int)Width, (int)Height, (int)Width * bitDepth / 8, bitDepth);
            NewGraphics2D().Clear(new RGBA_Doubles(1, 1, 1, 1));
        }
        public override void Init(int width, int height, GuiHalSurface.CreateFlags flags, GuiHalSurface.PixelFormat pixelFormat)
        {
            //if (windowsFormsWindow.m_sys_format == PlatformSupportAbstract.ImageFormats.pix_format_undefined)
            {
                //  return false;
            }

            m_window_flags = flags;

            initialWidth = width;
            initialHeight = height;

            int bitDepth = GetBitDepthForPixelFormat(m_format);
            switch (bitDepth)
            {
                case 24:
                    backBuffer = new ImageBuffer(initialWidth, initialHeight, 24, new BlenderBGR());
                    break;

                case 32:
                    backBuffer = new ImageBuffer(initialWidth, initialHeight, 32, new BlenderBGRA());
                    break;

                case 128:
                    throw new NotImplementedException();
                    //backBuffer = null;
                    //m_BackBufferFloat = new ImageBufferFloat(initialWidth, initialHeight, 128, new BlenderBGRAFloat());
                    //break;

                default:
                    throw new NotImplementedException("Don't support this bit depth yet.");
            }

            System.Drawing.Size clientSize = new System.Drawing.Size();
            clientSize.Width = (int)width;
            clientSize.Height = (int)height;
            windowsFormsWindow.ClientSize = clientSize;

            if ((m_window_flags & CreateFlags.Resizable) == 0)
            {
                windowsFormsWindow.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
                windowsFormsWindow.MaximizeBox = false;
            }

            clientSize.Width = width;
            clientSize.Height = height;
            windowsFormsWindow.ClientSize = clientSize;

            Bounds = new rect_d(0, 0, width, height);

            OnInitialize();
            windowsFormsWindow.m_WindowContentNeedsRedraw = true;
        }
Пример #23
0
 public override void SetClippingRect(rect_d clippingRect)
 {
     Gl.glScissor((int)Math.Floor(clippingRect.x1), (int)Math.Floor(clippingRect.y1),
                  (int)Math.Ceiling(clippingRect.Width), (int)Math.Ceiling(clippingRect.Height));
 }