Exemplo n.º 1
0
        // is called on startup
        public override void Init()
        {
            //TestSerialize();
            //TestDeserialize();

            // GUI initialization
            _zVal = 500;
            _guiHandler = new GUIHandler();
            _guiHandler.AttachToContext(RC);

            _guiFuseeLink = new GUIButton(6, 6, 157, 87);
            _guiFuseeLink.ButtonColor = new float4(0, 0, 0, 0);
            _guiFuseeLink.BorderColor = new float4(0, 0.6f, 0.2f, 1);
            _guiFuseeLink.BorderWidth = 0;
            _guiFuseeLink.OnGUIButtonDown += _guiFuseeLink_OnGUIButtonDown;
            _guiFuseeLink.OnGUIButtonEnter += _guiFuseeLink_OnGUIButtonEnter;
            _guiFuseeLink.OnGUIButtonLeave += _guiFuseeLink_OnGUIButtonLeave;
            _guiHandler.Add(_guiFuseeLink);

            _guiFuseeLogo = new GUIImage("Assets/FuseeLogo150.png", 10, 10, -5, 150, 80);
            _guiHandler.Add(_guiFuseeLogo);

            _guiLatoBlack = RC.LoadFont("Assets/Lato-Black.ttf", 14);
            _guiSubText = new GUIText("FUSEE 3D Scene Viewer", _guiLatoBlack, 100, 100);
            _guiSubText.TextColor = new float4(0.05f, 0.25f, 0.15f, 0.8f);
            _guiHandler.Add(_guiSubText);

            // Scene loading
            SceneContainer scene;
            var ser = new Serializer();
            using (var file = File.OpenRead(@"Assets/Model.fus"))
            {
                scene = ser.Deserialize(file, null, typeof(SceneContainer)) as SceneContainer;
            }
            _sr = new SceneRenderer(scene, "Assets");
            AdjustModelScaleOffset();
            _guiSubText.Text = "FUSEE 3D Scene";
            if (scene.Header.CreatedBy != null || scene.Header.CreationDate != null)
            {
                _guiSubText.Text += " created";
                if (scene.Header.CreatedBy != null)
                {
                    _guiSubText.Text += " by " + scene.Header.CreatedBy;
                }
                if (scene.Header.CreationDate != null)
                {
                    _guiSubText.Text += " on " + scene.Header.CreationDate;
                }
            }

            _subtextWidth = GUIText.GetTextWidth(_guiSubText.Text, _guiLatoBlack);
            _subtextHeight = GUIText.GetTextHeight(_guiSubText.Text, _guiLatoBlack);

            _sColor = MoreShaders.GetDiffuseColorShader(RC);
            RC.SetShader(_sColor);
            _colorParam = _sColor.GetShaderParam("color");
            RC.SetShaderParam(_colorParam, new float4(1, 1, 1, 1));
            RC.ClearColor = new float4(1, 1, 1, 1);
        }
Exemplo n.º 2
0
        // Konstruktor
        public GUIRender(RenderContext rc, BeeTheGame thisGame)
        {
            RC = rc;
            _game = thisGame;
            //GUIHandler an den Kontext anhaengen
            _guiHandler = new GUIHandler();
            _guiHandler.AttachToContext(rc);

            //Bilder einbinden
            _guiImageDummy = new GUIImage("Assets/dummy.png", 0, 0, 0, 5, 5);
            _guiImageBarText = new GUIImage("Assets/nectarCollected.png", 10, 10, -1, 153, 23);

            _guiImageStartBack = new GUIImage("Assets/background.png", 0, 0, 0, System.Windows.Forms.Screen.PrimaryScreen.Bounds.Width, (System.Windows.Forms.Screen.PrimaryScreen.Bounds.Height/9)*2);
            _guiImageGameHelp = new GUIImage("Assets/gameHelp.png", 0, 0, 0, System.Windows.Forms.Screen.PrimaryScreen.Bounds.Width, (System.Windows.Forms.Screen.PrimaryScreen.Bounds.Height/9)*2);
            _guiImageStartBee = new GUIImage("Assets/beePlaceholder.png", 200, 30, 1, 130, 118);
            _guiImageStartPlay = new GUIImage("Assets/play.png", (System.Windows.Forms.Screen.PrimaryScreen.Bounds.Width/2 - 300/2), 0, 2, 300, (System.Windows.Forms.Screen.PrimaryScreen.Bounds.Height/9)*2);

            _guiImageHelpButton = new GUIImage("Assets/helpButton.png", 10, 10, 2, 41, 50);
            _guiImageHelpOne = new GUIImage("Assets/helpOne.png", 100, 10, 1, 300, 129);
            _guiImageHelpTwo = new GUIImage("Assets/helpTwo.png", 950, 20, 1, 300, 130);

            //Text
            _guiFontArial24 = RC.LoadFont("Assets/arial.ttf", 16);
            _guiArial24 = new GUIText("Score: ", _guiFontArial24, 1200, 25);
            _guiArial24.TextColor = new float4(1, 1, 1, 1);

            //Button
            _guiButtonPlay = new GUIButton((System.Windows.Forms.Screen.PrimaryScreen.Bounds.Width/2 - 300/2), 0, 3, 300, (System.Windows.Forms.Screen.PrimaryScreen.Bounds.Height/9)*2);

            _guiButtonPlay.ButtonColor = new float4(0, 0, 0, 0);
            _guiButtonPlay.BorderColor = new float4(0, 0, 0, 1);
            _guiButtonPlay.BorderWidth = 0;

            _guiButtonHelp = new GUIButton(10, 10, 1, 50, 50);
            //Buttonfarbe setzen
            _guiButtonHelp.ButtonColor = new float4(0, 0, 0, 0);
            _guiButtonHelp.BorderColor = new float4(0, 0, 0, 1);
            _guiButtonHelp.BorderWidth = 0;

            //an den Handler anhaengen
            _guiHandler.Add(_guiImageDummy);
            _guiHandler.Add(_guiImageBarText);

            _guiImagePause = new GUIImage("Assets/gamePaused.png", 350, 40, 0, 500, 100);
        }
Exemplo n.º 3
0
        public GUI(RenderContext rc, GameWorld gw)
        {
            //Basic Init
            _gw = gw;

            _fontSmall = rc.LoadFont("Assets/Cabin.ttf", 12);
            _fontMedium = rc.LoadFont("Assets/Cabin.ttf", 18);
            _fontBig = rc.LoadFont("Assets/Cabin.ttf", 40);

            _guiHandler = new GUIHandler();
            _guiHandler.AttachToContext(rc);

            //Start Pannel Init
            _startPanel1 = new GUIPanel("RocketGame", _fontMedium, 10, 10, 150, 110);
            _startPanelButtonStart = new GUIButton("Start", _fontSmall, 10, 30, 130, 30);
            _startPanelButtonStart.OnGUIButtonDown += OnGUIButtonDown;
            _startPanelButtonStart.OnGUIButtonUp += OnGUIButtonUp;
            _startPanelButtonStart.OnGUIButtonEnter += OnGUIButtonEnter;
            _startPanelButtonStart.OnGUIButtonLeave += OnGUIButtonLeave;
            _startPanelButtonStuff = new GUIButton("Stuff", _fontSmall, 10, 70, 130, 30);
            _startPanelButtonStuff.OnGUIButtonDown += OnGUIButtonDown;
            _startPanelButtonStuff.OnGUIButtonUp += OnGUIButtonUp;
            _startPanelButtonStuff.OnGUIButtonEnter += OnGUIButtonEnter;
            _startPanelButtonStuff.OnGUIButtonLeave += OnGUIButtonLeave;
            _startPanel1.ChildElements.Add(_startPanelButtonStart);
            _startPanel1.ChildElements.Add(_startPanelButtonStuff);

            _startPanel2 = new GUIPanel("Find and activate all the red cubes!", _fontMedium, 170, 20, 300, 30);

            _playPanel = new GUIPanel("Goals found:", _fontMedium, 10, 10, 150, 60);
            _playScore = new GUIText("", _fontMedium, 48, 45, new float4(1, 0, 0, 1));
            _playPanel.ChildElements.Add(_playScore);

            _overText = new GUIText("Game Over, you Win!", _fontBig, 200, 100, new float4(0, 1, 0, 1));

            ShowStartGUI();
        }
Exemplo n.º 4
0
 private void _guiFuseeLink_OnGUIButtonEnter(GUIButton sender, MouseEventArgs mea)
 {
     _guiFuseeLink.ButtonColor = new float4(0, 0.6f, 0.2f, 0.4f);
     _guiFuseeLink.BorderWidth = 1;
     SetCursor(CursorType.Hand);
 }
Exemplo n.º 5
0
 private void OnPlayButtonDown(GUIButton sender, Fusee.Engine.MouseEventArgs mea)
 {
     //entfernen nicht benoetigter GUI Elemente
     _guiHandler.Remove(_guiButtonPlay);
     _guiHandler.Remove(_guiImageHelpButton);
     _guiHandler.Remove(_guiButtonHelp);
     _guiHandler.Remove(_guiImageStartBack);
     _guiHandler.Remove(_guiImageStartBee);
     _guiHandler.Remove(_guiImageStartPlay);
     _guiHandler.Remove(_guiImageGameHelp);
     _guiHandler.Remove(_guiImageHelpOne);
     _guiHandler.Remove(_guiImageHelpTwo);
     //Starten des Spiels
     _game._gameState = GameState.InGame;
 }
Exemplo n.º 6
0
 private void OnGUIButtonLeave(GUIButton sender, MouseEventArgs mea)
 {
     sender.TextColor = _color2;
 }
Exemplo n.º 7
0
        private void OnGUIButtonDown(GUIButton sender, MouseEventArgs mea)
        {
            sender.BorderWidth = 2;

            if (sender == _startPanelButtonStart)
            {
                _gw.SetGamestate((int)GameState.Running);
            }
        }
Exemplo n.º 8
0
        private void OnMenuButtonUp(GUIButton sender, MouseEventArgs mea)
        {
            sender.BorderWidth = 1;

            var bWidth = (sender == _guiSolveButton) ? 2 : 0;

            foreach (var guiButton in _guiUDiffs)
                guiButton.BorderWidth = bWidth;
            foreach (var guiButton in _guiBDiffs)
                guiButton.BorderWidth = bWidth;
        }
Exemplo n.º 9
0
        private void OnDiffButtonDown(GUIButton sender, MouseEventArgs mea)
        {
            sender.BorderWidth = 2;

            var guiButton = sender.Tag as GUIButton;
            if (guiButton != null) guiButton.BorderWidth = 2;
        }
 private static void OnMenuButtonEnter(GUIButton sender, MouseEventArgs mea)
 {
     sender.TextColor = new float4(0.8f, 0.1f, 0.1f, 1);
 }
Exemplo n.º 11
0
 private void OnbtnPlay(GUIButton sender, Fusee.Engine.MouseEventArgs mea)
 {
     if (_gameHandler.GameState.CurrentState != GameState.State.Playing)
     {
         _gameHandler.GameState.CurrentState = GameState.State.Playing;
     }
 }
Exemplo n.º 12
0
 private void OnbtnHighscore(GUIButton sender, Fusee.Engine.MouseEventArgs mea)
 {
     PlayerDataDb[] playerData = new PlayerDataDb[5];
     if (nameInput.Text.Length <= 0)
     {
         nameInput.Text = "Anonymous";
     }
     playername = nameInput.Text;
     // _gameHandler.DbConnection.Insert(playername, _points, endlevel); //Übergebe Daten an DB
      _hsYpos = 50;  //Schleifenvariable um die Einträge zeilenweise untereinander zu setzen
        //  playerData = _gameHandler.DbConnection.ShowFirstFiveHighScore(); //Hole Daten von DB
      foreach (PlayerDataDb data in playerData) // Setze Strings aus Datenbank in Zeilen untereinander
      {
          _guiHandler.Add(new GUIText("Name: "+data.Name, _guiFontCabin12, 120, _hsYpos, -1, new float4(1, 1, 1, 1))); // oder highscoreHandler???
          _guiHandler.Add(new GUIText("                                      Level: "+data.Level.ToString(), _guiFontCabin12, 120, _hsYpos, -1, new float4(1, 1, 1, 1))); // oder highscoreHandler???
          _guiHandler.Add(new GUIText("                                                           Points: "+data.Score.ToString(), _guiFontCabin12, 120, _hsYpos, -1, new float4(1, 1, 1, 1))); // oder highscoreHandler???
          _hsYpos = _hsYpos + 20;
      }
      int _brettposition = 38; //Schleifenvariable um die Bretter zeilenweise untereinander zu setzen
      for (int i = 0; i < 5; i++)
      {
          _highscoreBretter[i] = new GUIImage("Assets/Holz.png", 115, _brettposition, -2, 300, 15); //Bretterbilder anlegen
          _guiHandler.Add(_highscoreBretter[i]); // oder highscoreHandler???
          _brettposition = _brettposition + 20;
      }
 }
Exemplo n.º 13
0
 private void Credits(GUIButton sender, Fusee.Engine.MouseEventArgs mea)
 {
     if (_gameHandler.GameState.CurrentState == GameState.State.Highscore)
     {
         _guiHandler.Remove(_guiCredits);
         _guiHandler.Remove(_guiDiffs[(int)_buttons.btnCredits]);
         _guiHandler.Remove(_guiImages[(int)_btnimages.btniCreditsA]);
         _guiDiffs[(int)_buttons.btnCredits].OnGUIButtonDown -= Credits;
         _guiHandler.Add(_guiImages[(int) _btnimages.btniCreditsB]);
         _guiHandler.Add(_guiTextCredits1);
         _guiHandler.Add(_guiTextCredits2);
         _guiHandler.Add(_guiTextCredits3);
         _guiHandler.Add(_guiTextCredits4);
         _guiHandler.Add(_guiTextCredits5);
     }
 }
Exemplo n.º 14
0
 private void _guiFuseeLink_OnGUIButtonLeave(GUIButton sender, MouseEventArgs mea)
 {
     _guiFuseeLink.ButtonColor = new float4(0, 0, 0, 0);
     _guiFuseeLink.BorderWidth = 0;
     SetCursor(CursorType.Standard);
 }
Exemplo n.º 15
0
        private static void OnMenuButtonEnter(GUIButton sender, MouseEventArgs mea)
        {
            if (Input.Instance.IsButton(MouseButtons.Left))
                sender.BorderWidth = 2;

            sender.TextColor = new float4(0.8f, 0.1f, 0.1f, 1);
        }
Exemplo n.º 16
0
 private static void OnMenuButtonLeave(GUIButton sender, MouseEventArgs mea)
 {
     sender.BorderWidth = 1;
     sender.TextColor = new float4(0f, 0f, 0f, 1);
 }
        private void OnMenuButtonDown(GUIButton sender, MouseEventArgs mea)
        {
            if (sender == _guiExampleOneButton)
            {
                //particelcount,minLife, maxLife,minSize, maxSize,transparency, randPosX,randPosY,randPosY,randVelX,randVelY,randVelZ,gravityX, gravityY, gravityZ,
                _smokeEmitter               = new ParticleEmitter(10000, 999999, 999999, 0.9f, 1.0f, 0.012f, 0.01f, 50.6f, 1.6f, 50.6f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f);
                //deactivate other emitter
                _fireYellowEmitter          = null;
                _fireRedEmitter             = null;
                _starEmitter                = null;

            }

            if (sender == _guiExampleTwoButton)
            {
                //particelcount,minLife, maxLife,minSize, maxSize, rotation, transparency, randPosX,randPosY,randPosY,randVelX,randVelY,randVelZ,gravityX, gravityY, gravityZ,
                _smokeEmitter               = new ParticleEmitter(600, 0, 200, 0.4f, 0.5f, 0.012f, 0.2f, 0.5f, 1.0f, 0.5f, 1.0f, 1.5f, 1.0f, 0.0f, -0.05f, 0.0f);
                _fireYellowEmitter          = new ParticleEmitter(150, 5, 200, 0.5f, 0.9f, 0.012f, 0.1f, 1.0f, 0.5f, 1.0f, 0.025f, 0.0f, 0.025f, 0.0f, -0.03f, 0.0f);
                _fireRedEmitter             = new ParticleEmitter(450, 0, 200, 0.3f, 0.6f, 0.012f, 0.4f, 0.5f, 0.1f, 0.5f, 0.4f, 1.5f, 0.4f, 0.0f, -0.03f, 0.0f);

                //deactivate other emitter
                _starEmitter                = null;
            }

            if (sender == _guiExampleThreeButton)
            {
                //particelcount,minLife, maxLife,minSize, maxSize,rotation,transparency, randPosX,randPosY,randPosY,randVelX,randVelY,randVelZ,gravityX, gravityY, gravityZ,
                _starEmitter                = new ParticleEmitter(200, 600, 600, 0.2f, 0.2f, 0.012f, 1.0f, 0.5f, 0.0f, 0.5f, 8.2f, 8.0f, 8.2f, 0.0f, 0.032f, 0.0f);
                //deactivate other emitter
                _smokeEmitter               = null;
                _fireYellowEmitter          = null;
                _fireRedEmitter             = null;
            }
        }
Exemplo n.º 18
0
 private void OnMenuButtonDown(GUIButton sender, MouseEventArgs mea)
 {
     sender.BorderWidth = 2;
 }
        // is called on startup
        public override void Init()
        {
            RC.ClearColor = new float4(0.2f, 0.2f, 0.2f, 1);

            _smokeTexture           = RC.CreateShader(_smokeEmitter.VsSimpleTexture, _smokeEmitter.PsSimpleTexture);
            _fireRedTexture         = RC.CreateShader(_fireRedEmitter.VsSimpleTexture, _fireRedEmitter.PsSimpleTexture);
            _fireYellowTexture      = RC.CreateShader(_fireYellowEmitter.VsSimpleTexture, _fireYellowEmitter.PsSimpleTexture);
            _starTexture            = RC.CreateShader(_starEmitter.VsSimpleTexture, _starEmitter.PsSimpleTexture);

            _smokeParam             = _smokeTexture.GetShaderParam("texture1");
            _fireRedParam           = _fireRedTexture.GetShaderParam("texture1");
            _fireYellowParam        = _fireYellowTexture.GetShaderParam("texture1");
            _starParam              = _starTexture.GetShaderParam("texture1");

            // load texture
            var imgSmokeData        = RC.LoadImage("Assets/smoke_particle.png");
            var imgFireRedData      = RC.LoadImage("Assets/fireRed.png");
            var imgFireYellowData   = RC.LoadImage("Assets/fireYellowTexture.png");
            var imgStarData         = RC.LoadImage("Assets/star.png");

            _iSmoke                 = RC.CreateTexture(imgSmokeData);
            _iFireRed               = RC.CreateTexture(imgFireRedData);
            _iFireYellow            = RC.CreateTexture(imgFireYellowData);
            _iStar                  = RC.CreateTexture(imgStarData);

            RC.SetRenderState(new RenderStateSet
            {
                ZEnable = false,
                AlphaBlendEnable = true,
                BlendOperation = BlendOperation.Add,
                SourceBlend = Blend.SourceAlpha,
                DestinationBlend = Blend.InverseSourceAlpha
            });

            // GUIHandler
            _guiHandler = new GUIHandler();
            _guiHandler.AttachToContext(RC);

            // font + text
            _guiFontCabin18 = RC.LoadFont("Assets/Cabin.ttf", 18);
            _guiFontCabin24 = RC.LoadFont("Assets/Cabin.ttf", 24);

            _guiText = new GUIText("Fusee3D Particle System ", _guiFontCabin24, 510, 35);
            _guiText.TextColor = new float4(1, 1, 1, 1);

            _guiHandler.Add(_guiText);

            // panel
            _guiPanel = new GUIPanel("Menu", _guiFontCabin18, 10, 10, 150, 150);
            _guiHandler.Add(_guiPanel);

            // Example 1 button
            _guiExampleOneButton = new GUIButton("Fog", _guiFontCabin18, 25, 40, 100, 25);

            _guiExampleOneButton.OnGUIButtonDown += OnMenuButtonDown;
            _guiExampleOneButton.OnGUIButtonUp += OnMenuButtonUp;
            _guiExampleOneButton.OnGUIButtonEnter += OnMenuButtonEnter;
            _guiExampleOneButton.OnGUIButtonLeave += OnMenuButtonLeave;

            _guiPanel.ChildElements.Add(_guiExampleOneButton);

            // Example 2 button
            _guiExampleTwoButton = new GUIButton("Fire", _guiFontCabin18, 25, 70, 100, 25);

            _guiExampleTwoButton.OnGUIButtonDown += OnMenuButtonDown;
            _guiExampleTwoButton.OnGUIButtonUp += OnMenuButtonUp;
            _guiExampleTwoButton.OnGUIButtonEnter += OnMenuButtonEnter;
            _guiExampleTwoButton.OnGUIButtonLeave += OnMenuButtonLeave;

            _guiPanel.ChildElements.Add(_guiExampleTwoButton);

            // Example 2 button
            _guiExampleThreeButton = new GUIButton("Stars", _guiFontCabin18, 25, 100, 100, 25);

            _guiExampleThreeButton.OnGUIButtonDown += OnMenuButtonDown;
            _guiExampleThreeButton.OnGUIButtonUp += OnMenuButtonUp;
            _guiExampleThreeButton.OnGUIButtonEnter += OnMenuButtonEnter;
            _guiExampleThreeButton.OnGUIButtonLeave += OnMenuButtonLeave;

            _guiPanel.ChildElements.Add(_guiExampleThreeButton);
        }
Exemplo n.º 20
0
        public override void Init()
        {
            // is called on startup
            Width = 616;
            Height = 688;

            // GUIHandler
            _guiHandler = new GUIHandler();
            _guiHandler.AttachToContext(RC);

            // font + text
            _guiFontCabin18 = RC.LoadFont("Assets/Cabin.ttf", 18);
            _guiFontCabin24 = RC.LoadFont("Assets/Cabin.ttf", 24);

            _guiText = new GUIText("Spot all seven differences!", _guiFontCabin24, 310, 35);
            _guiText.TextColor = new float4(1, 1, 1, 1);

            _guiHandler.Add(_guiText);

            // image
            _guiImage = new GUIImage("Assets/spot_the_diff.png", 0, 0, -5, 600, 650);
            _guiHandler.Add(_guiImage);

            // buttons / rectangles
            _guiUDiffs = new GUIButton[7];
            _guiBDiffs = new GUIButton[7];

            _guiUDiffs[0] = new GUIButton(240, 3, 40, 40);
            _guiBDiffs[0] = new GUIButton(240, 328, 40, 40);

            _guiUDiffs[1] = new GUIButton(3, 270, 40, 40);
            _guiBDiffs[1] = new GUIButton(3, 595, 40, 40);

            _guiUDiffs[2] = new GUIButton(220, 255, 40, 40);
            _guiBDiffs[2] = new GUIButton(220, 580, 40, 40);

            _guiUDiffs[3] = new GUIButton(325, 170, 40, 40);
            _guiBDiffs[3] = new GUIButton(325, 495, 40, 40);

            _guiUDiffs[4] = new GUIButton(265, 110, 40, 40);
            _guiBDiffs[4] = new GUIButton(265, 435, 40, 40);

            _guiUDiffs[5] = new GUIButton(490, 215, 40, 40);
            _guiBDiffs[5] = new GUIButton(490, 540, 40, 40);

            _guiUDiffs[6] = new GUIButton(495, 280, 40, 40);
            _guiBDiffs[6] = new GUIButton(495, 605, 40, 40);

            for (int i = 0; i < 7; i++)
            {
                _guiUDiffs[i].ButtonColor = new float4(0, 0, 0, 0);
                _guiBDiffs[i].ButtonColor = new float4(0, 0, 0, 0);

                _guiUDiffs[i].BorderColor = new float4(0, 0, 0, 1);
                _guiBDiffs[i].BorderColor = new float4(0, 0, 0, 1);

                _guiUDiffs[i].BorderWidth = 0;
                _guiBDiffs[i].BorderWidth = 0;

                _guiUDiffs[i].Tag = _guiBDiffs[i];
                _guiBDiffs[i].Tag = _guiUDiffs[i];

                _guiBDiffs[i].OnGUIButtonDown += OnDiffButtonDown;
                _guiUDiffs[i].OnGUIButtonDown += OnDiffButtonDown;

                _guiHandler.Add(_guiUDiffs[i]);
                _guiHandler.Add(_guiBDiffs[i]);
            }

            // panel
            _guiPanel = new GUIPanel("Menu", _guiFontCabin18, 10, 10, 150, 110);
            _guiHandler.Add(_guiPanel);

            // reset button
            _guiResetButton = new GUIButton("Reset", _guiFontCabin18, 25, 40, 100, 25);

            _guiResetButton.OnGUIButtonDown += OnMenuButtonDown;
            _guiResetButton.OnGUIButtonUp += OnMenuButtonUp;
            _guiResetButton.OnGUIButtonEnter += OnMenuButtonEnter;
            _guiResetButton.OnGUIButtonLeave += OnMenuButtonLeave;

            _guiPanel.ChildElements.Add(_guiResetButton);

            // solve button
            _guiSolveButton = new GUIButton("Solve", _guiFontCabin18, 25, 70, 100, 25);

            _guiSolveButton.OnGUIButtonDown += OnMenuButtonDown;
            _guiSolveButton.OnGUIButtonUp += OnMenuButtonUp;
            _guiSolveButton.OnGUIButtonEnter += OnMenuButtonEnter;
            _guiSolveButton.OnGUIButtonLeave += OnMenuButtonLeave;

            _guiPanel.ChildElements.Add(_guiSolveButton);
        }
Exemplo n.º 21
0
        public override void Init()
        {
            // Set ToonShaderEffect
            _shaderEffect.AttachToContext(RC);

            // Setup GUI

            // GUIHandler
            _guiHandler = new GUIHandler();
            _guiHandler.AttachToContext(RC);

            // font + text
            _guiFontCabin18 = RC.LoadFont("Assets/Cabin.ttf", 18);
            _guiFontCabin24 = RC.LoadFont("Assets/Cabin.ttf", 24);

            _guiText = new GUIText("FUSEE Shader Demo", _guiFontCabin24, 30, Height - 30)
            {
                TextColor = new float4(1, 1, 1, 1)
            };

            _guiHandler.Add(_guiText);

            // image
            _guiImage = new GUIImage("Assets/repbg.jpg", 0, 0, -5, Width, Height);
            _guiHandler.Add(_guiImage);
            _borderImage = new GUIImage("Assets/redbg.png", 0, 0, -4, 230, 32);
            //_guiHandler.Add(_borderImage);

            //* Menu1: Select Shader
            _panelSelectShader = new GUIPanel("Select Shader", _guiFontCabin24, 10, 10, 230, 230);
            _panelSelectShader.ChildElements.Add(_borderImage);
            _guiHandler.Add(_panelSelectShader);

            //** Possible Shader Buttons
            _btnDiffuseColorShader = new GUIButton("Diffuse Color", _guiFontCabin18, 25, 40, 180, 25);
            _btnTextureShader = new GUIButton("Texture Only", _guiFontCabin18, 25, 70, 180, 25);
            _btnDiffuseTextureShader = new GUIButton("Diffuse Texture", _guiFontCabin18, 25, 100, 180, 25);
            _btnDiffuseBumpTextureShader = new GUIButton("Diffuse Bump Texture", _guiFontCabin18, 25, 130, 180, 25);
            _btnSpecularTexture = new GUIButton("Specular Texture", _guiFontCabin18, 25, 160, 180, 25);
            _btnToon = new GUIButton("Toon", _guiFontCabin18, 25, 190, 180, 25);

            //*** Add Handlers
            _btnDiffuseColorShader.OnGUIButtonDown += OnMenuButtonDown;
            _btnDiffuseColorShader.OnGUIButtonUp += OnMenuButtonUp;
            _btnDiffuseColorShader.OnGUIButtonEnter += OnMenuButtonEnter;
            _btnDiffuseColorShader.OnGUIButtonLeave += OnMenuButtonLeave;

            _btnTextureShader.OnGUIButtonDown += OnMenuButtonDown;
            _btnTextureShader.OnGUIButtonUp += OnMenuButtonUp;
            _btnTextureShader.OnGUIButtonEnter += OnMenuButtonEnter;
            _btnTextureShader.OnGUIButtonLeave += OnMenuButtonLeave;

            _btnDiffuseTextureShader.OnGUIButtonDown += OnMenuButtonDown;
            _btnDiffuseTextureShader.OnGUIButtonUp += OnMenuButtonUp;
            _btnDiffuseTextureShader.OnGUIButtonEnter += OnMenuButtonEnter;
            _btnDiffuseTextureShader.OnGUIButtonLeave += OnMenuButtonLeave;

            _btnDiffuseBumpTextureShader.OnGUIButtonDown += OnMenuButtonDown;
            _btnDiffuseBumpTextureShader.OnGUIButtonUp += OnMenuButtonUp;
            _btnDiffuseBumpTextureShader.OnGUIButtonEnter += OnMenuButtonEnter;
            _btnDiffuseBumpTextureShader.OnGUIButtonLeave += OnMenuButtonLeave;

            _btnSpecularTexture.OnGUIButtonDown += OnMenuButtonDown;
            _btnSpecularTexture.OnGUIButtonUp += OnMenuButtonUp;
            _btnSpecularTexture.OnGUIButtonEnter += OnMenuButtonEnter;
            _btnSpecularTexture.OnGUIButtonLeave += OnMenuButtonLeave;

            _btnToon.OnGUIButtonDown += OnMenuButtonDown;
            _btnToon.OnGUIButtonUp += OnMenuButtonUp;
            _btnToon.OnGUIButtonEnter += OnMenuButtonEnter;
            _btnToon.OnGUIButtonLeave += OnMenuButtonLeave;

            //**** Add Buttons to Panel
            _panelSelectShader.ChildElements.Add(_btnDiffuseColorShader);
            _panelSelectShader.ChildElements.Add(_btnTextureShader);
            _panelSelectShader.ChildElements.Add(_btnDiffuseTextureShader);
            _panelSelectShader.ChildElements.Add(_btnDiffuseBumpTextureShader);
            _panelSelectShader.ChildElements.Add(_btnSpecularTexture);
            _panelSelectShader.ChildElements.Add(_btnToon);

            //* Menu3: Select Mesh
            _panelSelectMesh = new GUIPanel("Select Mesh", _guiFontCabin24, 270, 10, 230, 130);
            _panelSelectMesh.ChildElements.Add(_borderImage);
            _guiHandler.Add(_panelSelectMesh);

            //** Possible Meshes
            _btnCube = new GUIButton("Cube", _guiFontCabin18, 25, 40, 180, 25);
            _btnSphere = new GUIButton("Sphere", _guiFontCabin18, 25, 70, 180, 25);
            _btnTeapot = new GUIButton("Teapot", _guiFontCabin18, 25, 100, 180, 25);
            _panelSelectMesh.ChildElements.Add(_btnCube);
            _panelSelectMesh.ChildElements.Add(_btnSphere);
            _panelSelectMesh.ChildElements.Add(_btnTeapot);

            //** Add handlers
            _btnCube.OnGUIButtonDown += OnMenuButtonDown;
            _btnCube.OnGUIButtonUp += OnMenuButtonUp;
            _btnCube.OnGUIButtonEnter += OnMenuButtonEnter;
            _btnCube.OnGUIButtonLeave += OnMenuButtonLeave;

            _btnSphere.OnGUIButtonDown += OnMenuButtonDown;
            _btnSphere.OnGUIButtonUp += OnMenuButtonUp;
            _btnSphere.OnGUIButtonEnter += OnMenuButtonEnter;
            _btnSphere.OnGUIButtonLeave += OnMenuButtonLeave;

            _btnTeapot.OnGUIButtonDown += OnMenuButtonDown;
            _btnTeapot.OnGUIButtonUp += OnMenuButtonUp;
            _btnTeapot.OnGUIButtonEnter += OnMenuButtonEnter;
            _btnTeapot.OnGUIButtonLeave += OnMenuButtonLeave;

            //* Menu2: Light Settings
            _panelLightSettings = new GUIPanel("Light Settings", _guiFontCabin24, 530, 10, 230, 130);
            _panelLightSettings.ChildElements.Add(_borderImage);
            _guiHandler.Add(_panelLightSettings);

            //** Possible Light Settings
            _btnDirectionalLight = new GUIButton("Directional Light", _guiFontCabin18, 25, 40, 180, 25);
            _btnPointLight = new GUIButton("Point Light", _guiFontCabin18, 25, 70, 180, 25);
            _btnSpotLight = new GUIButton("Spot Light", _guiFontCabin18, 25, 100, 180, 25);
            _panelLightSettings.ChildElements.Add(_btnDirectionalLight);
            _panelLightSettings.ChildElements.Add(_btnPointLight);
            _panelLightSettings.ChildElements.Add(_btnSpotLight);

            //*** Add Handlers
            _btnDirectionalLight.OnGUIButtonDown += OnMenuButtonDown;
            _btnDirectionalLight.OnGUIButtonUp += OnMenuButtonUp;
            _btnDirectionalLight.OnGUIButtonEnter += OnMenuButtonEnter;
            _btnDirectionalLight.OnGUIButtonLeave += OnMenuButtonLeave;

            _btnPointLight.OnGUIButtonDown += OnMenuButtonDown;
            _btnPointLight.OnGUIButtonUp += OnMenuButtonUp;
            _btnPointLight.OnGUIButtonEnter += OnMenuButtonEnter;
            _btnPointLight.OnGUIButtonLeave += OnMenuButtonLeave;

            _btnSpotLight.OnGUIButtonDown += OnMenuButtonDown;
            _btnSpotLight.OnGUIButtonUp += OnMenuButtonUp;
            _btnSpotLight.OnGUIButtonEnter += OnMenuButtonEnter;
            _btnSpotLight.OnGUIButtonLeave += OnMenuButtonLeave;

            // Setup 3D Scene
            // Load Images and Assign iTextures
            var imgTexture = RC.LoadImage("Assets/crateTexture.jpg");
            var imgBumpTexture = RC.LoadImage("Assets/crateNormal.jpg");
            _texCube = RC.CreateTexture(imgTexture);
            _texBumpCube = RC.CreateTexture(imgBumpTexture);

            imgTexture = RC.LoadImage("Assets/earthTexture.jpg");
            imgBumpTexture = RC.LoadImage("Assets/earthNormal.jpg");
            _texSphere = RC.CreateTexture(imgTexture);
            _texBumpSphere = RC.CreateTexture(imgBumpTexture);

            imgTexture = RC.LoadImage("Assets/porcelainTexture.png");
            imgBumpTexture = RC.LoadImage("Assets/normalRust.jpg");
            _texTeapot = RC.CreateTexture(imgTexture);
            _texBumpTeapot = RC.CreateTexture(imgBumpTexture);

            _currentTexture = _texCube;
            _currentBumpTexture = _texBumpCube;

            // Load Meshes
            _meshCube = MeshReader.LoadMesh(@"Assets/Cube.obj.model");
            _meshSphere = MeshReader.LoadMesh(@"Assets/Sphere.obj.model");
            _meshTeapot = MeshReader.LoadMesh(@"Assets/Teapot.obj.model");

            // Set current Mesh and Update GUI
            _currentMesh = _meshCube;
            _btnCube.ButtonColor = ColorHighlightedButton;

            // Setup Shaderprograms and Update GUI
            _shaderDiffuseColor = MoreShaders.GetDiffuseColorShader(RC);
            _shaderDiffuseTexture = MoreShaders.GetDiffuseTextureShader(RC);
            _shaderTexture = MoreShaders.GetSkyboxShader(RC);
            _shaderDiffuseBumpTexture = MoreShaders.GetBumpDiffuseShader(RC);
            _shaderSpecularTexture = MoreShaders.GetSpecularShader(RC);
            _btnDiffuseColorShader.ButtonColor = ColorHighlightedButton;
            _currentShader = _shaderDiffuseColor;
            RC.SetShader(_shaderDiffuseColor);

            // Setup ShaderParams
            _paramColor = _shaderDiffuseColor.GetShaderParam("color");

            // Setup Light and Update GUI
            RC.SetLightActive(0, 1);
            RC.SetLightPosition(0, new float3(5.0f, 0.0f, -2.0f));
            RC.SetLightAmbient(0, new float4(0.2f, 0.2f, 0.2f, 1.0f));
            RC.SetLightSpecular(0, new float4(0.1f, 0.1f, 0.1f, 1.0f));
            RC.SetLightDiffuse(0, new float4(0.8f, 0.8f, 0.8f, 1.0f));
            RC.SetLightDirection(0, new float3(-1.0f, 0.0f, 0.0f));
            RC.SetLightSpotAngle(0, 10);

            _btnDirectionalLight.ButtonColor = ColorHighlightedButton;
        }
Exemplo n.º 22
0
 private void OnGUIButtonEnter(GUIButton sender, MouseEventArgs mea)
 {
     sender.TextColor = _color1;
 }
Exemplo n.º 23
0
        private static void DeselectOtherButtonsFromPanel(GUIPanel panel, GUIButton newselectedBtn)
        {
            foreach (var element in panel.ChildElements)
            {
                var button = element as GUIButton;

                if (button != null)
                {
                    if (element == newselectedBtn)
                        continue;

                    var temp = button;
                    if (temp.ButtonColor == ColorHighlightedButton)
                    {
                        temp.ButtonColor = ColorDefaultButton;
                    }
                }
            }
        }
Exemplo n.º 24
0
 private void OnGUIButtonUp(GUIButton sender, MouseEventArgs mea)
 {
     sender.BorderWidth = 1;
 }
Exemplo n.º 25
0
 private static bool IsButtonSelected(GUIButton btn)
 {
     return btn.ButtonColor == ColorHighlightedButton;
 }
Exemplo n.º 26
0
        private void OnHelpButtonDown(GUIButton sender, Fusee.Engine.MouseEventArgs mea)
        {
            _guiButtonPlay.OnGUIButtonDown += OnPlayButtonDown;
            _guiButtonPlay.OnGUIButtonDown += OnPlayButtonDown;
            //entfernen nicht benoetigter GUI Elemente
            _guiHandler.Remove(_guiImageStartBack);
            _guiHandler.Remove(_guiImageStartBee);
            _guiHandler.Remove(_guiButtonHelp);
            _guiHandler.Remove(_guiTextScore);
            _guiHandler.Remove(_guiImageHelpButton);
            //hinzufuegen der benoetigten GUI Elemente fuer Help Screen
            _guiHandler.Add(_guiImageGameHelp);
            _guiHandler.Add(_guiImageHelpOne);
            _guiHandler.Add(_guiImageHelpTwo);

            _game._gameState = GameState.GameHelp;
        }
Exemplo n.º 27
0
 private void OnMenuButtonDown(GUIButton sender, MouseEventArgs mea)
 {
     sender.BorderWidth = 2;
     //sender.ButtonColor = colorHighlightedButton;
 }
Exemplo n.º 28
0
        private void OnMenuButtonUp(GUIButton sender, MouseEventArgs mea)
        {
            sender.BorderWidth = 1;
            if (!IsButtonSelected(sender))
            {
                sender.ButtonColor = ColorHighlightedButton;
            }

            switch (sender.Text)
            {
                case "Diffuse Color":
                    _textShaderName = sender.Text;
                    DeselectOtherButtonsFromPanel(_panelSelectShader, sender);
                    _currentShader = _shaderDiffuseColor;
                    _paramColor = _currentShader.GetShaderParam("color");
                    break;

                case "Texture Only":
                    _textShaderName = sender.Text;
                    DeselectOtherButtonsFromPanel(_panelSelectShader, sender);
                    _currentShader = _shaderTexture;
                    _paramTexture = _currentShader.GetShaderParam("texture1");
                    break;

                case "Diffuse Texture":
                    _textShaderName = sender.Text;
                    DeselectOtherButtonsFromPanel(_panelSelectShader, sender);
                    _currentShader = _shaderDiffuseTexture;
                    _paramTexture = _currentShader.GetShaderParam("texture1");
                    break;

                case "Diffuse Bump Texture":
                    _textShaderName = sender.Text;
                    DeselectOtherButtonsFromPanel(_panelSelectShader, sender);
                    _currentShader = _shaderDiffuseBumpTexture;
                    _paramTexture = _currentShader.GetShaderParam("texture1");
                    _paramBumpTexture = _currentShader.GetShaderParam("normalTex");
                    _paramSpecular = _currentShader.GetShaderParam("specularLevel");
                    _paramShininess = _currentShader.GetShaderParam("shininess");
                    break;

                case "Specular Texture":
                    _textShaderName = sender.Text;
                    DeselectOtherButtonsFromPanel(_panelSelectShader, sender);
                    _currentShader = _shaderSpecularTexture;
                    _paramTexture = _currentShader.GetShaderParam("texture1");
                    _paramSpecular = _currentShader.GetShaderParam("specularLevel");
                    _paramShininess = _currentShader.GetShaderParam("shininess");
                    break;

                case "Toon":
                    _textShaderName = sender.Text;
                    DeselectOtherButtonsFromPanel(_panelSelectShader, sender);
                    break;

                case "Cube":
                    DeselectOtherButtonsFromPanel(_panelSelectMesh, sender);
                    SetMesh(_meshCube);
                    _currentTexture = _texCube;
                    _currentBumpTexture = _texBumpCube;
                    break;

                case "Sphere":
                    DeselectOtherButtonsFromPanel(_panelSelectMesh, sender);
                    SetMesh(_meshSphere);
                    _currentTexture = _texSphere;
                    _currentBumpTexture = _texBumpSphere;
                    break;

                case "Teapot":
                    DeselectOtherButtonsFromPanel(_panelSelectMesh, sender);
                    SetMesh(_meshTeapot);
                    _currentTexture = _texTeapot;
                    _currentBumpTexture = _texBumpTeapot;
                    break;

                case "Directional Light":
                    DeselectOtherButtonsFromPanel(_panelLightSettings, sender);
                    RC.SetLightActive(0, 1);
                    break;

                case "Point Light":
                    DeselectOtherButtonsFromPanel(_panelLightSettings, sender);
                    RC.SetLightActive(0, 2);
                    break;

                case "Spot Light":
                    DeselectOtherButtonsFromPanel(_panelLightSettings, sender);
                    RC.SetLightActive(0, 3);
                    break;
            }
        }
Exemplo n.º 29
0
 void _guiFuseeLink_OnGUIButtonDown(GUIButton sender, MouseEventArgs mea)
 {
     OpenLink("http://fusee3d.org");
 }