Beispiel #1
0
        /// <summary>Initializes the application</summary>
        public void InitializeApplication()
        {
            isUsingPreshader = true;

            for (int i = 0; i < MaxNumberLights; i++)
            {
                lightControl[i] = new DirectionWidget();
                lightControl[i].LightDirection = new Vector3((float)Math.Sin((float)Math.PI
                                                                             * 2 * i / MaxNumberLights - (float)Math.PI / 6), 0, -(float)Math.Cos((float)Math.PI
                                                                                                                                                  * 2 * i / MaxNumberLights - (float)Math.PI / 6));
            }

            activeLight        = 0;
            numberActiveLights = 1;
            lightScale         = 1.0f;

            int y = 10;
            // Initialize the dialogs
            Button fullScreen   = hud.AddButton(ToggleFullscreen, "Toggle full screen", 35, y, 125, 22);
            Button toggleRef    = hud.AddButton(ToggleReference, "Toggle reference (F3)", 35, y += 24, 125, 22);
            Button changeDevice = hud.AddButton(ChangeDevice, "Change Device (F2)", 35, y += 24, 125, 22);

            // Hook the button events for when these items are clicked
            fullScreen.Click   += new EventHandler(OnFullscreenClicked);
            toggleRef.Click    += new EventHandler(OnRefClicked);
            changeDevice.Click += new EventHandler(OnChangeDevicClicked);

            // Now add the sample specific UI
            y = 10;
            sampleUi.AddStatic(NumberLightsStatic, string.Format("# Lights: {0}", numberActiveLights), 35, y += 24, 125, 22);
            Slider lightSlider = sampleUi.AddSlider(NumberLights, 50, y += 24, 100, 22, 1, MaxNumberLights, numberActiveLights, false);

            y += 24;
            sampleUi.AddStatic(LightScaleStatic, string.Format("Light scale: {0}", lightScale.ToString("f2",
                                                                                                       System.Globalization.CultureInfo.CurrentUICulture)), 35, y += 24, 125, 22);
            Slider scaleSlider = sampleUi.AddSlider(LightScaleControl, 50, y += 24, 100, 22, 0, 20, (int)(lightScale * 10.0f), false);

            y += 24;
            Button activeLightControl = sampleUi.AddButton(ActiveLightControl, "Change active light (K)", 35, y += 24, 125, 22,
                                                           System.Windows.Forms.Keys.K, false);
            Checkbox preShader = sampleUi.AddCheckBox(EnablePreshader, "Enable preshaders", 35, y += 24, 125, 22, isUsingPreshader);

            // Hook the events
            preShader.Changed        += new EventHandler(OnPreshaderClick);
            lightSlider.ValueChanged += new EventHandler(OnNumberLightsChanged);
            activeLightControl.Click += new EventHandler(OnActiveLightClick);
            scaleSlider.ValueChanged += new EventHandler(OnLightScaleChanged);
        }
Beispiel #2
0
        /// <summary>
        /// Initializes the application
        /// </summary>
        public void InitializeApplication()
        {
            int y = 10;
            // Initialize the HUD
            Button fullScreen   = hud.AddButton(ToggleFullscreen, "Toggle full screen", 35, y, 125, 22);
            Button toggleRef    = hud.AddButton(ToggleReference, "Toggle reference (F3)", 35, y += 24, 125, 22);
            Button changeDevice = hud.AddButton(ChangeDevice, "Change Device (F2)", 35, y += 24, 125, 22);

            // Hook the button events for when these items are clicked
            fullScreen.Click   += new EventHandler(OnFullscreenClicked);
            toggleRef.Click    += new EventHandler(OnRefClicked);
            changeDevice.Click += new EventHandler(OnChangeDevicClicked);

            // Now add the sample specific UI
            y = 10;
            Checkbox fillModeBox = sampleUi.AddCheckBox(FillModeButton, "WireFrame (F8)", 35, y, 150, 20, false,
                                                        System.Windows.Forms.Keys.F8, false);

            sampleUi.AddStatic(SegmentLabel, "Number of segments: 2", 10, y += 30, 150, 16);
            Slider   segmentSlider = sampleUi.AddSlider(SegmentSlider, 10, y += 14, 150, 24, 1, 10, 2, false);
            Checkbox hwPatch       = sampleUi.AddCheckBox(HwPatchButton, "User hardware N-patches", 10, y += 26, 150, 20, true,
                                                          System.Windows.Forms.Keys.H, false);

            // Hook the events
            fillModeBox.Changed        += new EventHandler(OnFillmodeChanged);
            segmentSlider.ValueChanged += new EventHandler(OnSegmentChanged);
            hwPatch.Changed            += new EventHandler(OnHardwareChanged);
        }
Beispiel #3
0
        /// <summary>
        /// Initializes the application
        /// </summary>
        public void InitializeApplication()
        {
            int y = 10;
            // Initialize the HUD
            Button fullScreen   = hud.AddButton(ToggleFullscreen, "Toggle full screen", 35, y, 125, 22);
            Button toggleRef    = hud.AddButton(ToggleReference, "Toggle reference (F3)", 35, y += 24, 125, 22);
            Button changeDevice = hud.AddButton(ChangeDevice, "Change Device (F2)", 35, y += 24, 125, 22);

            // Hook the button events for when these items are clicked
            fullScreen.Click   += new EventHandler(OnFullscreenClicked);
            toggleRef.Click    += new EventHandler(OnRefClicked);
            changeDevice.Click += new EventHandler(OnChangeDevicClicked);

            // Now add the sample specific UI
            y = 10;
            sampleUi.IsUsingKeyboardInput = true;
            sampleUi.AddStatic(DetailLabel, "Level of Detail:", 0, y, 200, 16);
            Checkbox opt = sampleUi.AddCheckBox(UseOptimizedCheckBox, "Use optimized mesh", 50, y, 200, 20, true);
            Slider   sl  = sampleUi.AddSlider(Detail, 10, y += 16, 200, 16, 4, 4, 4, false);

            // Hook the sample events
            opt.Changed     += new EventHandler(OnOptimizedChanged);
            sl.ValueChanged += new EventHandler(OnDetailChanged);

            // Set button masks
            camera.SetButtonMasks((int)MouseButtonMask.Left, (int)MouseButtonMask.Wheel, 0);
        }
Beispiel #4
0
        /// <summary>
        /// Initializes the application
        /// </summary>
        public void InitializeApplication()
        {
            int y = 10;
            // Initialize the HUD
            Button fullScreen   = hud.AddButton(ToggleFullscreen, "Toggle full screen", 35, y, 125, 22);
            Button toggleRef    = hud.AddButton(ToggleReference, "Toggle reference (F3)", 35, y += 24, 125, 22);
            Button changeDevice = hud.AddButton(ChangeDevice, "Change Device (F2)", 35, y += 24, 125, 22);

            // Hook the button events for when these items are clicked
            fullScreen.Click   += new EventHandler(OnFullscreenClicked);
            toggleRef.Click    += new EventHandler(OnRefClicked);
            changeDevice.Click += new EventHandler(OnChangeDeviceClicked);

            // Now add the sample specific UI
            y = 10;
            const int ComboBox1     = ChangeDevice + 1;
            const int CheckBox1     = ChangeDevice + 2;
            const int CheckBox2     = ChangeDevice + 3;
            const int Radiobutton1  = ChangeDevice + 4;
            const int Radiobutton2  = ChangeDevice + 5;
            const int Radiobutton3  = ChangeDevice + 6;
            const int Button1       = ChangeDevice + 7;
            const int Button2       = ChangeDevice + 8;
            const int Radiobutton4  = ChangeDevice + 9;
            const int Radiobutton5  = ChangeDevice + 10;
            const int SliderControl = ChangeDevice + 11;

            ComboBox cb1 = sampleUi.AddComboBox(ComboBox1, 35, y += 24, 125, 22);

            for (int i = 0; i < 50; i++)
            {
                cb1.AddItem("Item#" + i.ToString(), null);
            }
            sampleUi.AddCheckBox(CheckBox1, "Checkbox1", 35, y         += 24, 125, 22, false);
            sampleUi.AddCheckBox(CheckBox2, "Checkbox2", 35, y         += 24, 125, 22, false);
            sampleUi.AddRadioButton(Radiobutton1, 1, "Radio1G1", 35, y += 24, 125, 22, true);
            sampleUi.AddRadioButton(Radiobutton2, 1, "Radio2G1", 35, y += 24, 125, 22, false);
            sampleUi.AddRadioButton(Radiobutton3, 1, "Radio3G1", 35, y += 24, 125, 22, false);
            sampleUi.AddButton(Button1, "Button1", 35, y += 24, 125, 22);
            sampleUi.AddButton(Button2, "Button2", 35, y += 24, 125, 22);
            sampleUi.AddRadioButton(Radiobutton4, 2, "Radio1G2", 35, y += 24, 125, 22, true);
            sampleUi.AddRadioButton(Radiobutton5, 2, "Radio2G2", 35, y += 24, 125, 22, false);
            sampleUi.AddSlider(SliderControl, 50, y += 24, 100, 22);

            // If you wanted to respond to any of these you would need to add an event hook here
        }
Beispiel #5
0
        /// <summary>
        /// Initializes the application
        /// </summary>
        public void InitializeApplication()
        {
            int y = 10;
            // Initialize the HUD
            Button fullScreen   = hud.AddButton(ToggleFullscreen, "Toggle full screen", 35, y, 125, 22);
            Button toggleRef    = hud.AddButton(ToggleReference, "Toggle reference (F3)", 35, y += 24, 125, 22);
            Button changeDevice = hud.AddButton(ChangeDevice, "Change Device (F2)", 35, y += 24, 125, 22);

            // Hook the button events for when these items are clicked
            fullScreen.Click   += new EventHandler(OnFullscreenClicked);
            toggleRef.Click    += new EventHandler(OnRefClicked);
            changeDevice.Click += new EventHandler(OnChangeDevicClicked);

            // Update some fonts
            sampleUi.SetFont(1, "Comic Sans MS", 24, FontWeight.Normal);
            sampleUi.SetFont(2, "Courier New", 16, FontWeight.Normal);

            // Now add the sample specific UI
            y = 10;
            sampleUi.AddStatic(StaticControl, "This is a static control.", 0, 0, 200, 30);
            sampleUi.AddStatic(OutputStaticControl, "This static control provides feedback for your action.  It will change as you interact with the UI controls.",
                               20, 50, 620, 300);

            sampleUi.GetStaticText(OutputStaticControl)[0].FontColor.States[(int)ControlState.Normal] = new ColorValue(0.0f, 1.0f, 0.0f, 1.0f); // Change color to green
            sampleUi.GetStaticText(OutputStaticControl)[0].textFormat = DrawTextFormat.Left | DrawTextFormat.Top | DrawTextFormat.WordBreak;
            sampleUi.GetStaticText(OutputStaticControl)[0].FontIndex  = 1;

            // Edit box
            EditBox edit = sampleUi.AddEditBox(EditBoxControl, "Edit control with default styles.  Type text here and press Enter.",
                                               20, 440, 600, 32);

            // Slider
            Slider sl = sampleUi.AddSlider(SliderControl, 200, 450, 200, 24, 0, 1000, 500, false);

            // Check boxes
            Checkbox hotKey = sampleUi.AddCheckBox(CheckBoxControl, "This is a checkbox with hotkey.  Press 'C' to toggle the check state.",
                                                   150, 450, 350, 24, false, System.Windows.Forms.Keys.C, false);
            Checkbox clearEdit = sampleUi.AddCheckBox(ClearEditControl, "This checkbox controls whether the edit control text is cleared when Enter is pressed.",
                                                      150, 460, 430, 24, false);

            // Combo box
            ComboBox combo = sampleUi.AddComboBox(ComboBoxControl, 0, 0, 200, 24);

            if (combo != null)
            {
                // Add some items
                combo.SetDropHeight(100);
                combo.AddItem("Combo box item", 0x11111111);
                combo.AddItem("Placeholder", 0x12121212);
                combo.AddItem("One more", 0x13131313);
                combo.AddItem("I can't get enough", 0x14141414);
                combo.AddItem("Ok, last one, I promise", 0x15151515);
            }

            // Radio buttons
            sampleUi.AddRadioButton(RadioButton1A, 1, "Radio group 1 Amy", 0, 50, 200, 24, false);
            sampleUi.AddRadioButton(RadioButton1B, 1, "Radio group 1 Brian", 0, 50, 200, 24, false);
            sampleUi.AddRadioButton(RadioButton1C, 1, "Radio group 1 Clark", 0, 50, 200, 24, false);

            sampleUi.AddRadioButton(RadioButton2A, 2, "Single", 0, 50, 70, 24, false);
            sampleUi.AddRadioButton(RadioButton2B, 2, "Double", 0, 50, 70, 24, false);
            sampleUi.AddRadioButton(RadioButton2C, 2, "Trouble", 0, 50, 70, 24, false);

            // List boxes
            ListBox singleBox = sampleUi.AddListBox(ListBoxControl, 30, 400, 200, 150, ListBoxStyle.SingleSelection);

            for (int i = 0; i < 15; i++)
            {
                singleBox.AddItem("Single-selection listbox item " + i.ToString(), i);
            }

            ListBox multiBox = sampleUi.AddListBox(ListBoxControlMulti, 30, 400, 200, 150, ListBoxStyle.Multiselection);

            for (int i = 0; i < 30; i++)
            {
                multiBox.AddItem("Multi-selection listbox item " + i.ToString(), i);
            }

            // Hook some events
            sl.ValueChanged   += new EventHandler(OnValueChanged);
            hotKey.Changed    += new EventHandler(OnHotkeyBoxChanged);
            clearEdit.Changed += new EventHandler(OnClearEditChanged);
            combo.Changed     += new EventHandler(OnComboChanged);
            edit.Changed      += new EventHandler(OnEditChanged);
            edit.Enter        += new EventHandler(OnEnterHit);
            // All the radio buttons
            sampleUi.GetRadioButton(RadioButton1A).Changed += new EventHandler(OnRadioButtonChanged);
            sampleUi.GetRadioButton(RadioButton1B).Changed += new EventHandler(OnRadioButtonChanged);
            sampleUi.GetRadioButton(RadioButton1C).Changed += new EventHandler(OnRadioButtonChanged);
            sampleUi.GetRadioButton(RadioButton2A).Changed += new EventHandler(OnRadioButtonChanged);
            sampleUi.GetRadioButton(RadioButton2B).Changed += new EventHandler(OnRadioButtonChanged);
            sampleUi.GetRadioButton(RadioButton2C).Changed += new EventHandler(OnRadioButtonChanged);
            // Finally the listboxes
            singleBox.DoubleClick += new EventHandler(OnDoubleClick);
            singleBox.Selection   += new EventHandler(OnSingleSelection);
            multiBox.DoubleClick  += new EventHandler(OnDoubleClick);
            multiBox.Selection    += new EventHandler(OnMultiSelection);
        }
Beispiel #6
0
        /// <summary>Initializes the application</summary>
        public void InitializeApplication()
        {
            lightControl = new DirectionWidget();
            lightControl.LightDirection = new Vector3((float)Math.Sin((float)Math.PI
                                                                      * 2 - (float)Math.PI / 6), 0, -(float)Math.Cos((float)Math.PI
                                                                                                                     * 2 - (float)Math.PI / 6));

            lightScale    = 1.0f;
            ambLightScale = 0.1f;

            int y = 10;
            // Initialize the dialogs
            Button fullScreen   = hud.AddButton(ToggleFullscreen, "Toggle full screen", 35, y, 125, 22);
            Button changeDevice = hud.AddButton(ChangeDevice, "Change Device (F2)", 35, y += 24, 125, 22);

            // Hook the button events for when these items are clicked
            fullScreen.Click   += new EventHandler(OnFullscreenClicked);
            changeDevice.Click += new EventHandler(OnChangeDevicClicked);

            // Now add the sample specific UI
            y = 10;

            //lighting
            sampleUi.AddStatic(LightScaleStatic, string.Format("Light scale: {0}", lightScale.ToString("f2",
                                                                                                       System.Globalization.CultureInfo.CurrentUICulture)), 35, y += 24, 125, 22);
            Slider scaleSlider = sampleUi.AddSlider(LightScaleControl, 50, y += 24, 100, 22, 0, 20, (int)(lightScale * 10.0f), false);
            Button lightButton = sampleUi.AddButton(LightColorPicker, "Change light colour", 35, y += 24, 125, 22);

            sampleUi.AddStatic(AmbLightScaleStatic, string.Format("Ambient light scale: {0}", ambLightScale.ToString("f2",
                                                                                                                     System.Globalization.CultureInfo.CurrentUICulture)), 35, y += 24, 125, 22);
            Slider ambScaleSlider = sampleUi.AddSlider(AmbLightScaleControl, 50, y += 24, 100, 22, 0, 20, (int)(ambLightScale * 10.0f), false);
            Button ambLightButton = sampleUi.AddButton(AmbLightColorPicker, "Change ambient colour", 35, y += 24, 125, 22);

            y += 19;
            ComboBox shaderPicker = sampleUi.AddComboBox(ChangeShader, 35, y += 24, 125, 22);

            shaderPicker.AddItem("Standard", null);
            shaderPicker.AddItem("Color map", "ColorMap");
            shaderPicker.AddItem("Alpha/height map", "HeightMap");
            shaderPicker.AddItem("Normal map", "NormalMap");
            shaderPicker.AddItem("Specular map", "SpecularMap");
            shaderPicker.AddItem("Glow map", "GlowMap");
            shaderPicker.AddItem("Ambient material", "AmbMat");
            shaderPicker.AddItem("Diffuse material", "DifMat");
            shaderPicker.AddItem("Specular material", "SpecMat");
            shaderPicker.AddItem("Emissive material", "GlowMat");
            shaderPicker.AddItem("Vertex position", "vPosition");
            shaderPicker.AddItem("Vertex normals", "vNormal");
            shaderPicker.AddItem("Vertex colours", "vColor");
            shaderPicker.AddItem("Texture coords", "vUV");
            shaderPicker.AddItem("Vertex tangents", "vTangent");
            shaderPicker.AddItem("Vertex binormals", "vBinormal");
            Checkbox wireframeCheckbox = sampleUi.AddCheckBox(WireFrame, "Wireframe", 35, y += 24, 125, 22, false);
            Checkbox cullCheckBox      = sampleUi.AddCheckBox(ToggleCulling, "Backface culling", 35, y += 24, 125, 22, true);

            y += 19;
            ComboBox subsetControl = sampleUi.AddComboBox(SubsetControl, 35, y += 24, 125, 22);

            y += 19;
            Button loadButton = sampleUi.AddButton(LoadMeshButton, "Load mesh", 35, y += 24, 125, 22);

            // Hook the events
            scaleSlider.ValueChanged    += new EventHandler(OnLightScaleChanged);
            lightButton.Click           += new EventHandler(lightButton_Click);
            ambScaleSlider.ValueChanged += new EventHandler(ambScaleSlider_ValueChanged);
            ambLightButton.Click        += new EventHandler(ambLightButton_Click);
            shaderPicker.Changed        += new EventHandler(shaderPicker_Changed);
            wireframeCheckbox.Changed   += new EventHandler(wireframeCheckbox_Changed);
            subsetControl.Changed       += new EventHandler(subsetControl_Changed);
            loadButton.Click            += new EventHandler(loadButton_Click);
            cullCheckBox.Changed        += new EventHandler(cullCheckBox_Changed);
        }