Exemple #1
0
        // is called on startup
        public override void Init()
        {
            RC.ClearColor = new float4(0.1f, 0.1f, 0.5f, 1);

            // IMPORTANT: You are supposed to use either one SetWindowSize() or VideoWall(). You can't use both.
            // It's possible to resize a window to fit on a video wall or display.
            // Here are some different variants how to use this functionality. Uncomment to test.
            //SetWindowSize(800, 600);
            //SetWindowSize(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height/5 * 2, true, 0, 0);
            //SetWindowSize(Screen.PrimaryScreen.Bounds.Width/9 * 2, Screen.PrimaryScreen.Bounds.Height, true, 0, 0);
            //SetWindowSize(640, 480, false, Screen.PrimaryScreen.Bounds.Width/2 - 640/2, Screen.PrimaryScreen.Bounds.Height/2 - 480/2);
            // IMPORTANT: For video Walls or projector matrices it's possible to let the system do the magic by
            // giving it the number of monitors/projectors per axis and specify some border information.
            // This only works in pseudo-fullscreen mode a.k.a borderless fullscreen-window.
            VideoWall(0, 0, true, true);

            // This is the old method. More than this could not be done directly in a project code(?)
            //Width = 640;
            //Height = 480;

            // Initialize an ui.
            _guiHandler = new GUIHandler();
            _guiHandler.AttachToContext(RC);

            // Create a new element.
            GUIElement element = new GUIImage("Assets/image.png", 0, 0, -10, 320, 130);

            // Add the element to the gui.
            _guiHandler.Add(element);

            // Add something to render.
            _cube       = new Cube();
            _spcolor    = Shaders.GetDiffuseColorShader(RC);
            _colorParam = _spcolor.GetShaderParam("color");
        }
        public GUI(RenderContext rc)
        {
            //Basic Init

            _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
            _guiPanel = new GUIPanel("PhysicsTest", _fontMedium, 10, 10, 330, 250);

            _info1 = new GUIText("Über die Tasten des Nummernblocks  " , _fontMedium, 30, 170, _color2);
            _info2 = new GUIText("(1-4) kann zwischen 4 verschiedenen ", _fontMedium, 30, 190, _color2);
            _info3 = new GUIText("Szenen gewechselt werden", _fontMedium, 30, 210, _color2);
            _fps = new GUIText("FPS", _fontMedium, 30, 55, _color2);
            _numberRb = new GUIText("Rigidbodies: ", _fontMedium, 30, 85, _color2);
            _shapeType = new GUIText("Collision Shapes: ", _fontMedium, 30, 115, _color2);
            _shapes = new GUIText("", _fontMedium, 50, 135, _color2);

            _guiPanel.ChildElements.Add(_info1);
            _guiPanel.ChildElements.Add(_info2);
            _guiPanel.ChildElements.Add(_info3);
            _guiPanel.ChildElements.Add(_fps);
            _guiPanel.ChildElements.Add(_numberRb);
            _guiPanel.ChildElements.Add(_shapeType);
            _guiPanel.ChildElements.Add(_shapes);

            ShowGUI();
        }
Exemple #3
0
        // Init is called on startup.
        public override void Init()
        {
            #if GUI_SIMPLE
            _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(AssetStorage.Get <ImageData>("FuseeLogo150.png"), 10, 10, -5, 150, 80);
            _guiHandler.Add(_guiFuseeLogo);
            var fontLato = AssetStorage.Get <Font>("Lato-Black.ttf");
            fontLato.UseKerning   = true;
            _guiLatoBlack         = new FontMap(fontLato, 18);
            _guiSubText           = new GUIText("Simple FUSEE Example", _guiLatoBlack, 100, 100);
            _guiSubText.TextColor = new float4(0.05f, 0.25f, 0.15f, 0.8f);
            _guiHandler.Add(_guiSubText);
            _subtextWidth  = GUIText.GetTextWidth(_guiSubText.Text, _guiLatoBlack);
            _subtextHeight = GUIText.GetTextHeight(_guiSubText.Text, _guiLatoBlack);
            #endif

            // Set the clear color for the backbuffer to white (100% intentsity in all color channels R, G, B, A).
            RC.ClearColor = new float4(1, 1, 1, 1);

            // Load the rocket model
            _rocketScene = AssetStorage.Get <SceneContainer>("RocketModel.fus");

            // Wrap a SceneRenderer around the model.
            _sceneRenderer = new SceneRenderer(_rocketScene);
        }
Exemple #4
0
        public GUI(RenderContext rc)
        {
            //Basic Init

            _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
            _guiPanel = new GUIPanel("PhysicsTest", _fontMedium, 10, 10, 330, 250);


            _info1     = new GUIText("Use NumPad keys 1..4", _fontMedium, 30, 170, _color2);
            _info2     = new GUIText("to switch between 4 ", _fontMedium, 30, 190, _color2);
            _info3     = new GUIText("different test scenes.", _fontMedium, 30, 210, _color2);
            _fps       = new GUIText("FPS", _fontMedium, 30, 55, _color2);
            _numberRb  = new GUIText("Rigidbodies: ", _fontMedium, 30, 85, _color2);
            _shapeType = new GUIText("Collision Shapes: ", _fontMedium, 30, 115, _color2);
            _shapes    = new GUIText("", _fontMedium, 50, 135, _color2);

            _guiPanel.ChildElements.Add(_info1);
            _guiPanel.ChildElements.Add(_info2);
            _guiPanel.ChildElements.Add(_info3);
            _guiPanel.ChildElements.Add(_fps);
            _guiPanel.ChildElements.Add(_numberRb);
            _guiPanel.ChildElements.Add(_shapeType);
            _guiPanel.ChildElements.Add(_shapes);

            ShowGUI();
        }
        // is called on startup
        public override void Init()
        {
            RC.ClearColor = new float4(0.1f, 0.1f, 0.5f, 1);

            // IMPORTANT: You are supposed to use either one SetWindowSize() or VideoWall(). You can't use both.
            // It's possible to resize a window to fit on a video wall or display.
            // Here are some different variants how to use this functionality. Uncomment to test.
            //SetWindowSize(800, 600);
            SetWindowSize(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height/9 * 2, true, 0, 0);
            //SetWindowSize(Screen.PrimaryScreen.Bounds.Width/9 * 2, Screen.PrimaryScreen.Bounds.Height, true, 0, 0);
            //SetWindowSize(640, 480, false, Screen.PrimaryScreen.Bounds.Width/2 - 640/2, Screen.PrimaryScreen.Bounds.Height/2 - 480/2);
            // IMPORTANT: For video Walls or projector matrices it's possible to let the system do the magic by
            // giving it the number of monitors/projectors per axis and specify some border information.
            // This only works in pseudo-fullscreen mode a.k.a borderless fullscreen-window.
            //VideoWall(0, 0, true, false);

            // This is the old method. More than this could not be done directly in a project code(?)
            //Width = 640;
            //Height = 480;

            // Initialize an ui.
            _guiHandler = new GUIHandler();
            _guiHandler.AttachToContext(RC);

            // Create a new element.
            GUIElement element = new GUIImage("Assets/image.png", 0, 0, -10, 320, 130);

            // Add the element to the gui.
            _guiHandler.Add(element);

            // Add something to render.
            _cube = new Cube();
            _spcolor = MoreShaders.GetDiffuseColorShader(RC);
            _colorParam = _spcolor.GetShaderParam("color");
        }
        // 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);
        }
Exemple #7
0
        // Init is called on startup.
        public override void Init()
        {
            #if GUI_SIMPLE
            _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(AssetStorage.Get <ImageData>("FuseeLogo150.png"), 10, 10, -5, 150, 80);
            _guiHandler.Add(_guiFuseeLogo);
            var fontLato = AssetStorage.Get <Font>("Lato-Black.ttf");
            fontLato.UseKerning   = true;
            _guiLatoBlack         = new FontMap(fontLato, 18);
            _guiSubText           = new GUIText("FUSEE Example", _guiLatoBlack, 100, 100);
            _guiSubText.TextColor = new float4(0.05f, 0.25f, 0.15f, 0.8f);
            _guiHandler.Add(_guiSubText);
            _subtextWidth  = GUIText.GetTextWidth(_guiSubText.Text, _guiLatoBlack);
            _subtextHeight = GUIText.GetTextHeight(_guiSubText.Text, _guiLatoBlack);
            #endif

            // Set the clear color for the backbuffer to white (100% intentsity in all color channels R, G, B, A).
            RC.ClearColor = new float4(1, 1, 1, 1);

            // Load the rocket model
            _rocketScene = AssetStorage.Get <SceneContainer>("RocketModel.fus");

            //Create StereoCam for S3D rendering
            _stereoCam = new StereoCameraRig(Stereo3DMode.Anaglyph, Width, Height, 6.5f);
            _stereoCam.AttachToContext(RC);

            //Create ScreenS3DTextures object holding the 4 textures to be used with the ScreenS3D object
            ScreenS3DTextures screenTex = new ScreenS3DTextures();
            screenTex.Left       = RC.CreateTexture(AssetStorage.Get <ImageData>("left.png"));
            screenTex.LeftDepth  = RC.CreateTexture(AssetStorage.Get <ImageData>("depthLeft.png"));
            screenTex.Right      = RC.CreateTexture(AssetStorage.Get <ImageData>("right.png"));
            screenTex.RightDepth = RC.CreateTexture(AssetStorage.Get <ImageData>("depthRight.png"));
            //Create ScreenS3D Object using the ScreenS3Dtextures object from above
            _screen = new ScreenS3D(RC, screenTex);
            //Set the config fort the Screen objet. This can also be doene using a whole ScreenConfig object and assiging direktly to the ScreenS3D object
            _screen.Config.ScaleSize  = 1000;
            _screen.Config.ScaleDepth = 5;
            _screen.Config.Transform  = float4x4.CreateTranslation(0, 200, 0);
            // Wrap a SceneRenderer around the model.
            _sceneRenderer = new SceneRenderer(_rocketScene);


            // vl = AssetStorage.Get<VideoStream>("left.mkv");
            capL  = new Capture("Assets/left.mkv");
            capLD = new Capture("Assets/depthLeft.mkv");
            capR  = new Capture("Assets/right.mkv");
            capRD = new Capture("Assets/depthRight.mkv");
        }
Exemple #8
0
        // Init is called on startup.
        public override void Init()
        {
            //Width and Height are 0 on our Android Device
            if (Width <= 0)
            {
                Width = 2560;
            }
            if (Height <= 0)
            {
                Height = 1440;
            }

            #if GUI_SIMPLE
            _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(AssetStorage.Get <ImageData>("FuseeLogo150.png"), 10, 10, -5, 150, 80);
            _guiHandler.Add(_guiFuseeLogo);
            var fontLato = AssetStorage.Get <Font>("Lato-Black.ttf");
            fontLato.UseKerning   = true;
            _guiLatoBlack         = new FontMap(fontLato, 18);
            _guiSubText           = new GUIText("Simple FUSEE Cardboard Example", _guiLatoBlack, 100, 100);
            _guiSubText.TextColor = new float4(0.05f, 0.25f, 0.15f, 0.8f);
            _guiHandler.Add(_guiSubText);
            _subtextWidth  = GUIText.GetTextWidth(_guiSubText.Text, _guiLatoBlack);
            _subtextHeight = GUIText.GetTextHeight(_guiSubText.Text, _guiLatoBlack);
            #endif

            // Set the clear color for the backbuffer to white (100% intentsity in all color channels R, G, B, A).
            RC.ClearColor = new float4(1, 1, 1, 1);

            //Initialize StereoRendering
            if (_renderStereo)
            {
                _stereo3d = new Stereo3D(Stereo3DMode.Cardboard, Width, Height);
                _stereo3d.AttachToContext(RC);
            }

            // Load the scene
            _WuggyScene = AssetStorage.Get <SceneContainer>("WuggyLand.fus");

            // Wrap a SceneRenderer around the scene.
            _sceneRenderer = new SceneRenderer(_WuggyScene);
        }
Exemple #9
0
        // public GUI()
        public void Init()
        {
            //guihandler
            _guiHandler = new GUIHandler();
            _guiHandler.AttachToContext(Instances.Renderer.RC);

            var fontLato = AssetStorage.Get<Font>("Montserrat-Regular.ttf");
            fontLato.UseKerning = true;
            _guiLatoBlack = new FontMap(fontLato, 18);

            //_guiBackground = new GUIImage(AssetStorage.Get<ImageData>("himmel.jpg"), -30, -300, -5, 1500, 1000);
            //_guiHandler.Add(_guiBackground);

            _guiPoints = new GUIText("SCORE" + " "+ Instances.Main.score, _guiLatoBlack, Instances.Main.Width - 150, 57);
            _guiHandler.Add(_guiPoints);
        }
Exemple #10
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);
        }
Exemple #11
0
        public void Init()
        // public GUI()
        {
            //guihandler
            _guiHandler = new GUIHandler();
            _guiHandler.AttachToContext(Instances.Renderer.RC);


            var fontLato = AssetStorage.Get <Font>("Montserrat-Regular.ttf");

            fontLato.UseKerning = true;
            _guiLatoBlack       = new FontMap(fontLato, 18);


            //_guiBackground = new GUIImage(AssetStorage.Get<ImageData>("himmel.jpg"), -30, -300, -5, 1500, 1000);
            //_guiHandler.Add(_guiBackground);

            _guiPoints = new GUIText("SCORE" + " " + Instances.Main.score, _guiLatoBlack, Instances.Main.Width - 150, 57);
            _guiHandler.Add(_guiPoints);
        }
Exemple #12
0
        public override void Init()
        {
            #region For some planned features.

            /*
             * _screenWidth = Screen.PrimaryScreen.Bounds.Width;
             * _screenHeight = Screen.PrimaryScreen.Bounds.Height;
             * SetWindowSize(_screenWidth, _screenHeight / 9 * 2, true);
             */
            #endregion

            #region GUI
            // GUIHandler
            _guiHandler = new GUIHandler();
            _guiHandler.AttachToContext(RC);

            _guiImage = new GUIImage("Assets/img/AudioTestWallpaper.png", 0, 0, 0, 1280, 720);
            _guiHandler.Add(_guiImage);
            #endregion

            // Set this to control the file formats and loading methods.
            _fileFormat   = AudioFileFormat.mp3;
            _streamOrLoad = LoadMethod.load;

            // Now load the correct files.
            LoadFiles();

            #region Audio settings
            _sound1.Volume = 3.0f;
            _sound2.Volume = 3.0f;
            _sound3.Volume = 3.0f;
            _sound4.Volume = 2.0f;

            _sound1.Loop = false;
            _sound2.Loop = false;
            _sound3.Loop = false;
            _sound4.Loop = false;
            #endregion
        }
        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();
        }
        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();
        }
        // Init is called on startup.
        public override void Init()
        {
            _guiHandler = new GUIHandler();
            _guiHandler.AttachToContext(RC);

            _guiFuseeLink                   = new GUIButton(6, 6, 253, 221);
            _guiFuseeLink.ButtonColor       = new float4(0, 0, 0, 0);
            _guiFuseeLink.BorderColor       = new float4(0.6f, 0.2f, 0.2f, 1);
            _guiFuseeLink.BorderWidth       = 0;
            _guiFuseeLink.OnGUIButtonDown  += _guiFuseeLink_OnGUIButtonDown;
            _guiFuseeLink.OnGUIButtonEnter += _guiFuseeLink_OnGUIButtonEnter;
            _guiFuseeLink.OnGUIButtonLeave += _guiFuseeLink_OnGUIButtonLeave;
            _guiHandler.Add(_guiFuseeLink);
            _guiFuseeLogo = new GUIImage(AssetStorage.Get <ImageData>("ClickMe.png"), 10, 10, -5, 253, 221);
            _guiHandler.Add(_guiFuseeLogo);
            var fontLato = AssetStorage.Get <Font>("Lato-Black.ttf");

            fontLato.UseKerning   = true;
            _guiLatoBlack         = new FontMap(fontLato, 64);
            _guiSubText           = new GUIText(Ticker.CurrentText, _guiLatoBlack, 100, 100);
            _guiSubText.TextColor = new float4(0, 0, 0.15f, 0.8f);
            _guiHandler.Add(_guiSubText);
            _subtextWidth  = GUIText.GetTextWidth(_guiSubText.Text, _guiLatoBlack);
            _subtextHeight = GUIText.GetTextHeight(_guiSubText.Text, _guiLatoBlack);

            // Initial "Zoom" value (it's rather the distance in view direction, not the camera's focal distance/opening angle)
            _zoom = 400;

            _angleRoll        = 0;
            _angleRollInit    = 0;
            _twoTouchRepeated = false;
            _offset           = float2.Zero;
            _offsetInit       = float2.Zero;

            // Set the clear color for the backbuffer to white (100% intentsity in all color channels R, G, B, A).
            RC.ClearColor = new float4(1, 1, 1, 1);

            // Load the standard model
            _scene = AssetStorage.Get <SceneContainer>("Model.fus");
            AABBCalculator aabbc = new AABBCalculator(_scene);
            var            bbox  = aabbc.GetBox();

            if (bbox != null)
            {
                // If the model origin is more than one third away from its bounding box,
                // recenter it to the bounding box. Do this check individually per dimension.
                // This way, small deviations will keep the model's original center, while big deviations
                // will make the model rotating around its geometric center.
                float3 bbCenter = bbox.Value.Center;
                float3 bbSize   = bbox.Value.Size;
                float3 center   = float3.Zero;
                if (System.Math.Abs(bbCenter.x) > bbSize.x * 0.3)
                {
                    center.x = bbCenter.x;
                }
                if (System.Math.Abs(bbCenter.y) > bbSize.y * 0.3)
                {
                    center.y = bbCenter.y;
                }
                if (System.Math.Abs(bbCenter.z) > bbSize.z * 0.3)
                {
                    center.z = bbCenter.z;
                }
                _sceneCenter = float4x4.CreateTranslation(-center);

                // Adjust the model size
                float maxScale = System.Math.Max(bbSize.x, System.Math.Max(bbSize.y, bbSize.z));
                if (maxScale != 0)
                {
                    _sceneScale = float4x4.CreateScale(200.0f / maxScale);
                }
                else
                {
                    _sceneScale = float4x4.Identity;
                }
            }
            // Wrap a SceneRenderer around the model.
            _sceneRenderer = new SceneRenderer(_scene);
        }
Exemple #16
0
        // is called on startup
        public override void Init()
        {
            // 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

            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 = Shaders.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);
        }
        // Init is called on startup.
        public override void Init()
        {
            Width  = 1295;
            Height = 760;

            listTowers = new Dictionary <int, Tower>();
            listWuggys = new List <Wuggy>();

            isTowerSelected = false;
            isUgradeMode    = false;
            towerCosts      = 100;

            // Load the scene
            _scene = AssetStorage.Get <SceneContainer>("TDMAPinWuggyFINAL.fus");
            _tower = AssetStorage.Get <SceneContainer>("TowerRed.fus");
            _wuggy = AssetStorage.Get <SceneContainer>("WuggyFromLand.fus");

            _sceneScale = float4x4.CreateScale(0.04f);

            listWuggys.Add(new Wuggy(DeepCopy(_wuggy), new float3(0, 0, 750), 8, new float3(0.2f, 0.9f, 0.2f), 0, 1, 100));

            // Instantiate our self-written renderer
            _renderer = new Renderer(RC);

            redColor    = new float4(1.0f, 0.0f, 0.2f, 1.0f);
            greenColor  = new float4(0.4f, 1.0f, 0.0f, 1.0f);
            blueColor   = new float4(0.0f, 0.4f, 1.0f, 1.0f);
            yellowColor = new float4(1.0f, 0.9f, 0.0f, 1.0f);
            whiteColor  = new float4(1.0f, 1.0f, 1.0f, 1.0f);
            cyanColor   = new float4(0.0f, 0.7f, 0.7f, 1.0f);

#if GUI_SIMPLE
            guiHandler = new GUIHandler();
            guiHandler.AttachToContext(RC);

            fontCabin            = AssetStorage.Get <Font>("AmericanCaptain.ttf");
            fontCabin.UseKerning = true;
            _guiCabinBlack       = new FontMap(fontCabin, 18);
            _guiCabinBlackBig    = new FontMap(fontCabin, 25);

            guiText           = new GUIText("Defend!", _guiCabinBlack, 310, 35);
            guiText.TextColor = new float4(0.05f, 0.25f, 0.15f, 0.8f);
            guiHandler.Add(guiText);

            guiPanelStatus             = new GUIPanel("Defend the Village", _guiCabinBlack, 880, 0, 400, 120);
            guiPanelStatus.PanelColor  = new float4(0.0f, 0.38f, 0.69f, 1.0f);
            guiPanelStatus.BorderWidth = 0;
            guiHandler.Add(guiPanelStatus);

            healthText           = new GUIText("Health Village: 10", _guiCabinBlackBig, 900, 60);
            healthText.TextColor = new float4(0.9f, 0.0f, 0.0f, 1.0f);
            guiHandler.Add(healthText);

            moneyText           = new GUIText("Money: 1000", _guiCabinBlackBig, 900, 90);
            moneyText.TextColor = new float4(0.0f, 0.9f, 0.1f, 1.0f);
            guiHandler.Add(moneyText);

            guiPanelShop             = new GUIPanel("Shop", _guiCabinBlack, 880, 370, 400, 250);
            guiPanelShop.PanelColor  = new float4(0.0f, 0.38f, 0.69f, 1.0f);
            guiPanelShop.BorderWidth = 0;
            guiHandler.Add(guiPanelShop);

            guiPanelWaves             = new GUIPanel("Wave", _guiCabinBlack, 880, 620, 400, 100);
            guiPanelWaves.PanelColor  = new float4(0.0f, 0.38f, 0.69f, 1.0f);
            guiPanelWaves.BorderWidth = 0;
            guiHandler.Add(guiPanelWaves);

            startButton = new GUIButton("Start Wave", _guiCabinBlack, 900, 650, 360, 50);
            startButton.OnGUIButtonDown  += startButtonClicked;
            startButton.OnGUIButtonEnter += shopButtonEnter;
            startButton.OnGUIButtonLeave += shopButtonLeave;
            guiHandler.Add(startButton);

            mapButtons = new List <GUIButton>();

            for (int i = 0; i < 146; i++)
            {
                mapButtons.Add(new GUIButton(500, 500, 8, 8));
                mapButtons[i].ButtonColor       = blueColor;
                mapButtons[i].BorderWidth       = 0;
                mapButtons[i].OnGUIButtonDown  += mapOnGUIButtonDown;
                mapButtons[i].OnGUIButtonEnter += mapOnGUIButtonEnter;
                mapButtons[i].OnGUIButtonLeave += mapOnGUIButtonLeave;
            }

            #region MapButtons
            //mapButtons[136].ButtonColor = new float4(0, 0, 1.0f, 1.0f);


            setButtonPosition(mapButtons[0], 945, 219);
            setButtonPosition(mapButtons[1], 932, 219);
            setButtonPosition(mapButtons[2], 957, 219);
            setButtonPosition(mapButtons[3], 969, 219);
            setButtonPosition(mapButtons[4], 981, 219);
            setButtonPosition(mapButtons[5], 981, 197);
            setButtonPosition(mapButtons[6], 967, 197);
            setButtonPosition(mapButtons[7], 953, 197);
            setButtonPosition(mapButtons[8], 939, 197);
            setButtonPosition(mapButtons[9], 979, 290);
            setButtonPosition(mapButtons[10], 967, 290);
            setButtonPosition(mapButtons[11], 955, 290);
            setButtonPosition(mapButtons[12], 942, 290);
            setButtonPosition(mapButtons[13], 942, 314);
            setButtonPosition(mapButtons[14], 955, 314);
            setButtonPosition(mapButtons[15], 967, 314);
            setButtonPosition(mapButtons[16], 979, 314);
            setButtonPosition(mapButtons[17], 1044, 314);
            setButtonPosition(mapButtons[18], 1032, 314);
            setButtonPosition(mapButtons[19], 1020, 314);
            setButtonPosition(mapButtons[20], 1008, 314);
            setButtonPosition(mapButtons[21], 1057, 314);
            setButtonPosition(mapButtons[22], 1069, 314);
            setButtonPosition(mapButtons[23], 1081, 314);
            setButtonPosition(mapButtons[24], 1175, 282);
            setButtonPosition(mapButtons[25], 1163, 282);
            setButtonPosition(mapButtons[26], 1151, 282);
            setButtonPosition(mapButtons[27], 1103, 282);
            setButtonPosition(mapButtons[28], 1115, 282);
            setButtonPosition(mapButtons[29], 1127, 282);
            setButtonPosition(mapButtons[30], 1139, 282);
            setButtonPosition(mapButtons[31], 1149, 307);
            setButtonPosition(mapButtons[32], 1137, 307);
            setButtonPosition(mapButtons[33], 1125, 307);
            setButtonPosition(mapButtons[34], 1113, 307);
            setButtonPosition(mapButtons[35], 1161, 307);
            setButtonPosition(mapButtons[36], 1173, 307);
            setButtonPosition(mapButtons[37], 1185, 307);
            setButtonPosition(mapButtons[38], 1081, 337);
            setButtonPosition(mapButtons[39], 1069, 337);
            setButtonPosition(mapButtons[40], 1057, 337);
            setButtonPosition(mapButtons[41], 1008, 337);
            setButtonPosition(mapButtons[42], 1020, 337);
            setButtonPosition(mapButtons[43], 1032, 337);
            setButtonPosition(mapButtons[44], 1044, 337);
            setButtonPosition(mapButtons[45], 1059, 259);
            setButtonPosition(mapButtons[46], 1047, 259);
            setButtonPosition(mapButtons[47], 1035, 259);
            setButtonPosition(mapButtons[48], 1023, 259);
            setButtonPosition(mapButtons[49], 1071, 259);
            setButtonPosition(mapButtons[50], 1091, 242);
            setButtonPosition(mapButtons[51], 1103, 242);
            setButtonPosition(mapButtons[52], 1127, 242);
            setButtonPosition(mapButtons[53], 1115, 242);
            setButtonPosition(mapButtons[54], 1167, 222);
            setButtonPosition(mapButtons[55], 1179, 222);
            setButtonPosition(mapButtons[56], 1155, 222);
            setButtonPosition(mapButtons[57], 1143, 222);
            setButtonPosition(mapButtons[58], 1143, 194);
            setButtonPosition(mapButtons[59], 1155, 194);
            setButtonPosition(mapButtons[60], 1182, 194);
            setButtonPosition(mapButtons[61], 1168, 194);
            setButtonPosition(mapButtons[62], 1102, 216);
            setButtonPosition(mapButtons[63], 1114, 216);
            setButtonPosition(mapButtons[64], 1090, 216);
            setButtonPosition(mapButtons[65], 1078, 216);
            setButtonPosition(mapButtons[66], 1023, 236);
            setButtonPosition(mapButtons[67], 1035, 236);
            setButtonPosition(mapButtons[68], 1047, 236);
            setButtonPosition(mapButtons[69], 1059, 236);
            setButtonPosition(mapButtons[70], 1008, 301);
            setButtonPosition(mapButtons[71], 1008, 287);
            setButtonPosition(mapButtons[72], 999, 243);
            setButtonPosition(mapButtons[73], 999, 258);
            setButtonPosition(mapButtons[74], 1058, 183);
            setButtonPosition(mapButtons[75], 1046, 183);
            setButtonPosition(mapButtons[76], 1034, 183);
            setButtonPosition(mapButtons[77], 1022, 183);
            setButtonPosition(mapButtons[78], 1070, 183);
            setButtonPosition(mapButtons[79], 1082, 183);
            setButtonPosition(mapButtons[80], 1147, 176);
            setButtonPosition(mapButtons[81], 1070, 157);
            setButtonPosition(mapButtons[82], 1022, 157);
            setButtonPosition(mapButtons[83], 1034, 157);
            setButtonPosition(mapButtons[84], 1046, 157);
            setButtonPosition(mapButtons[85], 1058, 157);
            setButtonPosition(mapButtons[86], 1135, 176);
            setButtonPosition(mapButtons[87], 1099, 176);
            setButtonPosition(mapButtons[88], 1111, 176);
            setButtonPosition(mapButtons[89], 1123, 176);
            setButtonPosition(mapButtons[90], 1113, 151);
            setButtonPosition(mapButtons[91], 1101, 151);
            setButtonPosition(mapButtons[92], 1089, 151);
            setButtonPosition(mapButtons[93], 1125, 151);
            setButtonPosition(mapButtons[94], 1137, 151);
            setButtonPosition(mapButtons[95], 1206, 146);
            setButtonPosition(mapButtons[96], 1194, 146);
            setButtonPosition(mapButtons[97], 1158, 146);
            setButtonPosition(mapButtons[98], 1170, 146);
            setButtonPosition(mapButtons[99], 1182, 146);
            setButtonPosition(mapButtons[100], 1179, 237);
            setButtonPosition(mapButtons[101], 1179, 252);
            setButtonPosition(mapButtons[102], 1206, 252);
            setButtonPosition(mapButtons[103], 1206, 237);
            setButtonPosition(mapButtons[104], 1206, 222);
            setButtonPosition(mapButtons[105], 1200, 278);
            setButtonPosition(mapButtons[106], 1200, 292);
            setButtonPosition(mapButtons[107], 1195, 194);
            setButtonPosition(mapButtons[108], 1182, 168);
            setButtonPosition(mapButtons[109], 1252, 194);
            setButtonPosition(mapButtons[110], 1264, 194);
            setButtonPosition(mapButtons[111], 1240, 194);
            setButtonPosition(mapButtons[112], 1228, 194);
            setButtonPosition(mapButtons[113], 1228, 168);
            setButtonPosition(mapButtons[114], 1240, 168);
            setButtonPosition(mapButtons[115], 1252, 168);
            setButtonPosition(mapButtons[116], 1264, 168);
            setButtonPosition(mapButtons[117], 1170, 168);
            setButtonPosition(mapButtons[118], 1194, 168);
            setButtonPosition(mapButtons[119], 1158, 168);
            setButtonPosition(mapButtons[120], 1023, 202);
            setButtonPosition(mapButtons[121], 1023, 216);
            setButtonPosition(mapButtons[122], 999, 194);
            setButtonPosition(mapButtons[123], 999, 179);
            setButtonPosition(mapButtons[124], 942, 276);
            setButtonPosition(mapButtons[125], 942, 261);
            setButtonPosition(mapButtons[126], 915, 209);
            setButtonPosition(mapButtons[127], 915, 227);
            setButtonPosition(mapButtons[128], 915, 245);
            setButtonPosition(mapButtons[129], 915, 191);
            setButtonPosition(mapButtons[130], 889, 191);
            setButtonPosition(mapButtons[131], 889, 245);
            setButtonPosition(mapButtons[132], 889, 227);
            setButtonPosition(mapButtons[133], 889, 209);
            setButtonPosition(mapButtons[134], 912, 276);
            setButtonPosition(mapButtons[135], 912, 290);
            setButtonPosition(mapButtons[136], 928, 314);
            setButtonPosition(mapButtons[137], 912, 305);
            setButtonPosition(mapButtons[138], 928, 245);
            setButtonPosition(mapButtons[139], 915, 161);
            setButtonPosition(mapButtons[140], 928, 161);
            setButtonPosition(mapButtons[141], 901, 161);
            setButtonPosition(mapButtons[142], 889, 174);
            setButtonPosition(mapButtons[143], 939, 178);
            setButtonPosition(mapButtons[144], 899, 276);
            setButtonPosition(mapButtons[145], 886, 276);
            #endregion

            foreach (GUIButton gb in mapButtons)
            {
                guiHandler.Add(gb);
            }



            guiHandlerTowers = new GUIHandler();
            guiHandlerTowers.AttachToContext(RC);
            buyButton = new GUIButton("Buy Tower (100)", _guiCabinBlack, 900, 400, 360, 50);
            buyButton.OnGUIButtonDown  += buyTower;
            buyButton.OnGUIButtonEnter += shopButtonEnter;
            buyButton.OnGUIButtonLeave += shopButtonLeave;
            guiHandlerTowers.Add(buyButton);

            guiHandlerTowersUpgrade = new GUIHandler();
            guiHandlerTowersUpgrade.AttachToContext(RC);

            speedUpgradeText             = new GUIButton("Shot Frequency: 1", _guiCabinBlack, 900, 400, 180, 50);
            speedUpgradeText.ButtonColor = new float4(0.0f, 0.38f, 0.69f, 1.0f);
            speedUpgradeText.TextColor   = new float4(1.0f, 1.0f, 1.0f, 1.0f);
            speedUpgradeText.BorderWidth = 0;
            guiHandlerTowersUpgrade.Add(speedUpgradeText);

            speedUpgradeButton = new GUIButton("Speed Upgrade", _guiCabinBlack, 1080, 400, 180, 50);
            //mapButtons[i].OnGUIButtonDown += mapOnGUIButtonDown;
            speedUpgradeButton.OnGUIButtonEnter += shopButtonEnter;
            speedUpgradeButton.OnGUIButtonLeave += shopButtonLeave;
            guiHandlerTowersUpgrade.Add(speedUpgradeButton);

            rangeUpgradeText             = new GUIButton("Range: 1", _guiCabinBlack, 900, 475, 180, 50);
            rangeUpgradeText.ButtonColor = new float4(0.0f, 0.38f, 0.69f, 1.0f);
            rangeUpgradeText.TextColor   = new float4(1.0f, 1.0f, 1.0f, 1.0f);
            rangeUpgradeText.BorderWidth = 0;
            guiHandlerTowersUpgrade.Add(rangeUpgradeText);

            rangeUpgradeButton = new GUIButton("Range Upgrade", _guiCabinBlack, 1080, 475, 180, 50);
            //mapButtons[i].OnGUIButtonDown += mapOnGUIButtonDown;
            rangeUpgradeButton.OnGUIButtonEnter += shopButtonEnter;
            rangeUpgradeButton.OnGUIButtonLeave += shopButtonLeave;
            guiHandlerTowersUpgrade.Add(rangeUpgradeButton);

            damageUpgradeText             = new GUIButton("Damage: 1", _guiCabinBlack, 900, 550, 180, 50);
            damageUpgradeText.ButtonColor = new float4(0.0f, 0.38f, 0.69f, 1.0f);
            damageUpgradeText.TextColor   = new float4(1.0f, 1.0f, 1.0f, 1.0f);
            damageUpgradeText.BorderWidth = 0;
            guiHandlerTowersUpgrade.Add(damageUpgradeText);

            damageUpgradeButton = new GUIButton("Damage Upgrade", _guiCabinBlack, 1080, 550, 180, 50);
            //mapButtons[i].OnGUIButtonDown += mapOnGUIButtonDown;
            damageUpgradeButton.OnGUIButtonEnter += shopButtonEnter;
            damageUpgradeButton.OnGUIButtonLeave += shopButtonLeave;
            guiHandlerTowersUpgrade.Add(damageUpgradeButton);
#endif

            // Set the clear color for the backbuffer
            RC.ClearColor = new float4(1, 1, 1, 1);
        }
        // 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);
        }
        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;
        }
Exemple #20
0
        public override void Init()
        {
            // 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);
        }
        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);
        }
Exemple #22
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                = Shaders.GetDiffuseColorShader(RC);
            _shaderDiffuseTexture              = Shaders.GetDiffuseTextureShader(RC);
            _shaderTexture                     = Shaders.GetTextureShader(RC);
            _shaderDiffuseBumpTexture          = Shaders.GetBumpDiffuseShader(RC);
            _shaderSpecularTexture             = Shaders.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;
        }
        // Init is called on startup.
        public override void Init()
        {
            // VERSION 1 - SYNCHRONER DOWNLOAD

            /*
             * ButtonDown += delegate (object sender, EventArgs args)
             * {
             *  WebClient client = new WebClient();
             *
             *  string fileContents = client.DownloadString(new Uri("http://www.fusee3d.org/Examples/Async/SomeText.txt"));
             *  Ticker.CompleteText = fileContents;
             * };
             * /* */


            // VERSION 2 - Asynchronous Programming Model (APM) - wird von WebClient nicht unterstützt, daher kein Beispiel

            // VERSION 3 - Event Based Asynchronous Pattern (EAP)

            /*
             * ButtonDown += delegate (object sender, EventArgs args)
             * {
             *  WebClient client = new WebClient();
             *
             *  client.DownloadStringCompleted += delegate(object o, DownloadStringCompletedEventArgs eventArgs)
             *  {
             *      Ticker.CompleteText = eventArgs.Result;
             *  };
             *  client.DownloadStringAsync(new Uri("http://www.fusee3d.org/Examples/Async/SomeText.txt"));
             * };
             * /*  */


            // VERSION 4 - Task-based Asynchronous Pattern (TAP)

            /*
             * ButtonDown += async delegate (object sender, EventArgs args)
             * {
             *  WebClient client = new WebClient();
             *
             *  String fileContents = await client.DownloadStringTaskAsync(new Uri("http://www.fusee3d.org/Examples/Async/SomeText.txt"));
             *  // Nach dem await - Code der hier steht, wird erst nach dem ENDE des Task aufgerufen
             *  Ticker.CompleteText = fileContents;
             *
             * };
             * /*  */


            /* */
            // VERSION 5 - Task-based Asynchronous Pattern (TAP) mit getrenntem await
            ButtonDown += async delegate(object sender, EventArgs args)
            {
                WebClient client = new WebClient();

                Task <string> task = client.DownloadStringTaskAsync(new Uri("http://www.fusee3d.org/Examples/Async/SomeText.txt"));
                // Dinge, die direkt nach dem Starten des Task passieren sollen

                Ticker.CompleteText = "- - - D O W N L O A D I N G - - - T H E   C O M P L E T E   W O R K S   O F   W I L L I A M   S H A K E S P E A R E ";


                // Vor dem await - hier passiert alles direkt nach dem Starten des Task
                String fileContents = await task;
                // Nach dem await - Code der hier steht, wird erst nach dem ENDE des Task aufgerufen
                Ticker.CompleteText = fileContents;
            };
            /*  */



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

            _guiFuseeLink                   = new GUIButton(6, 6, 253, 221);
            _guiFuseeLink.ButtonColor       = new float4(0, 0, 0, 0);
            _guiFuseeLink.BorderColor       = new float4(0.6f, 0.2f, 0.2f, 1);
            _guiFuseeLink.BorderWidth       = 0;
            _guiFuseeLink.OnGUIButtonDown  += _guiFuseeLink_OnGUIButtonDown;
            _guiFuseeLink.OnGUIButtonEnter += _guiFuseeLink_OnGUIButtonEnter;
            _guiFuseeLink.OnGUIButtonLeave += _guiFuseeLink_OnGUIButtonLeave;
            _guiHandler.Add(_guiFuseeLink);
            _guiFuseeLogo = new GUIImage(AssetStorage.Get <ImageData>("ClickMe.png"), 10, 10, -5, 253, 221);
            _guiHandler.Add(_guiFuseeLogo);
            var fontLato = AssetStorage.Get <Font>("Lato-Black.ttf");

            fontLato.UseKerning   = true;
            _guiLatoBlack         = new FontMap(fontLato, 64);
            _guiSubText           = new GUIText(Ticker.CurrentText, _guiLatoBlack, 100, 100);
            _guiSubText.TextColor = new float4(0, 0, 0.15f, 0.8f);
            _guiHandler.Add(_guiSubText);
            _subtextWidth  = GUIText.GetTextWidth(_guiSubText.Text, _guiLatoBlack);
            _subtextHeight = GUIText.GetTextHeight(_guiSubText.Text, _guiLatoBlack);

            // Initial "Zoom" value (it's rather the distance in view direction, not the camera's focal distance/opening angle)
            _zoom = 400;

            _angleRoll        = 0;
            _angleRollInit    = 0;
            _twoTouchRepeated = false;
            _offset           = float2.Zero;
            _offsetInit       = float2.Zero;

            // Set the clear color for the backbuffer to white (100% intentsity in all color channels R, G, B, A).
            RC.ClearColor = new float4(1, 1, 1, 1);

            // Load the standard model
            _scene = AssetStorage.Get <SceneContainer>("Model.fus");
            AABBCalculator aabbc = new AABBCalculator(_scene);
            var            bbox  = aabbc.GetBox();

            if (bbox != null)
            {
                // If the model origin is more than one third away from its bounding box,
                // recenter it to the bounding box. Do this check individually per dimension.
                // This way, small deviations will keep the model's original center, while big deviations
                // will make the model rotating around its geometric center.
                float3 bbCenter = bbox.Value.Center;
                float3 bbSize   = bbox.Value.Size;
                float3 center   = float3.Zero;
                if (System.Math.Abs(bbCenter.x) > bbSize.x * 0.3)
                {
                    center.x = bbCenter.x;
                }
                if (System.Math.Abs(bbCenter.y) > bbSize.y * 0.3)
                {
                    center.y = bbCenter.y;
                }
                if (System.Math.Abs(bbCenter.z) > bbSize.z * 0.3)
                {
                    center.z = bbCenter.z;
                }
                _sceneCenter = float4x4.CreateTranslation(-center);

                // Adjust the model size
                float maxScale = System.Math.Max(bbSize.x, System.Math.Max(bbSize.y, bbSize.z));
                if (maxScale != 0)
                {
                    _sceneScale = float4x4.CreateScale(200.0f / maxScale);
                }
                else
                {
                    _sceneScale = float4x4.Identity;
                }
            }
            // Wrap a SceneRenderer around the model.
            _sceneRenderer = new SceneRenderer(_scene);
        }
        // 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);
        }