예제 #1
0
        public MainWindow()
        {
            InitializeComponent();

            _tray = new TrayManager(tbiTaskbarIcon)
            {
                State = TrayIconState.Disabled
            };

            _poe = new PoeMonitor();
            _poe.StateChanged += _poe_StateChanged;

            _client = new ClientMonitor {
                ClientPath = Config.Instance.ClientFilePath
            };

            _client.Append += _client_Append;

            _media = new MediaPlayer();

            // Controls
            _bindingFilterCheckers();

            miNitificationChecker.IsChecked = Config.Instance.IsNotificationsEnabled;
        }
예제 #2
0
        private void SetupControls()
        {
            SelectMenu technique = TrayManager.CreateThickSelectMenu(TrayLocation.TopLeft, "TechniqueType",
                                                                     "Instancing Technique", 200, 3);

            technique.AddItem("Instancing");
            technique.AddItem("Static Geometry");
            technique.AddItem("Independent Entities");

            SelectMenu objectType = TrayManager.CreateThickSelectMenu(TrayLocation.TopLeft, "ObjectType", "Object : ", 200, 4);

            objectType.AddItem("razor");
            objectType.AddItem("knot");
            objectType.AddItem("tudorhouse");
            objectType.AddItem("woodpallet");

            TrayManager.CreateThickSlider(TrayLocation.TopLeft, "ObjectCountSlider", "Object count", 200, 50, 0, 1000, 101).
            SetValue(160, false);

            TrayManager.CreateThickSlider(TrayLocation.TopLeft, "CPUOccupationSlider", "CPU Load (ms)", 200, 75, 0, 1000.0f / 60,
                                          20);

            TrayManager.CreateCheckBox(TrayLocation.TopLeft, "ShadowCheckBox", "Shadows", 200);

            TrayManager.CreateCheckBox(TrayLocation.TopLeft, "PostEffectCheckBox", "Post Effect", 200);

            TrayManager.ShowCursor();
        }
예제 #3
0
        private void _setupControls()
        {
            TrayManager.ShowCursor();

            // make room for the controls
            TrayManager.ShowLogo(TrayLocation.TopRight);
            TrayManager.ShowFrameStats(TrayLocation.TopRight);
            TrayManager.ToggleAdvancedFrameStats();

            this.infoLabel = TrayManager.CreateLabel(TrayLocation.Top, "TInfo", "", 350);

            this.editMenu = TrayManager.CreateLongSelectMenu(TrayLocation.Bottom, "EditMode", "Edit Mode", 370, 250, 3);
            this.editMenu.AddItem("None");
            this.editMenu.AddItem("Elevation");
            this.editMenu.AddItem("Blend");
            this.editMenu.SelectItem(0);               // no edit mode
            this.editMenu.SelectedIndexChanged += _itemSelected;

            this.flyBox = TrayManager.CreateCheckBox(TrayLocation.Bottom, "Fly", "Fly");
            this.flyBox.SetChecked(false, false);
            this.flyBox.CheckChanged += _checkBoxToggled;

            this.shadowsMenu = TrayManager.CreateLongSelectMenu(TrayLocation.Bottom, "Shadows", "Shadows", 370, 250, 3);
            this.shadowsMenu.AddItem("None");
            this.shadowsMenu.AddItem("Color Shadows");
            this.shadowsMenu.AddItem("Depth Shadows");
            this.shadowsMenu.SelectItem(0);
            this.shadowsMenu.SelectedIndexChanged += _itemSelected;

            var names = new List <string>();

            names.Add("Help");
            //a friendly reminder
            TrayManager.CreateParamsPanel(TrayLocation.TopLeft, "Help", 100, names).SetParamValue(0, "H/F1");
        }
예제 #4
0
        protected override void SetupContent()
        {
            SceneManager.SetSkyBox(true, "Examples/StormySkyBox", 5000); // add a skybox

            // setup some basic lighting for our scene
            SceneManager.AmbientLight = new ColorEx(0.5f, 0.5f, 0.5f);
            SceneManager.CreateLight("DynTexLight1").Position = new Vector3(20, 80, 50);

            // set initial camera position
            CameraManager.setStyle(CameraStyle.Manual);
            Camera.Position = new Vector3(0, 0, 200);

            TrayManager.ShowCursor();

            // create our dynamic texture with 8-bit luminance texels
            var tex = TextureManager.Instance.CreateManual("thaw", ResourceGroupManager.DefaultResourceGroupName,
                                                           TextureType.TwoD, TEXTURE_SIZE, TEXTURE_SIZE, 0, PixelFormat.L8,
                                                           TextureUsage.DynamicWriteOnly);

            this.mTexBuf = tex.GetBuffer(); // save off the texture buffer

            // initialise the texture to have full luminance
            this.mTexBuf.Lock(BufferLocking.Discard);
            Memory.Set(this.mTexBuf.CurrentLock.Data, 0xff, this.mTexBuf.Size);
            this.mTexBuf.Unlock();

            // create a penguin and attach him to our penguin node
            var penguin = SceneManager.CreateEntity("Penguin", "penguin.mesh");

            this.mPenguinNode = SceneManager.RootSceneNode.CreateChildSceneNode();
            this.mPenguinNode.AttachObject(penguin);

            // get and enable the penguin idle animation
            this.mPenguinAnimState           = penguin.GetAnimationState("amuse");
            this.mPenguinAnimState.IsEnabled = true;

            // create a snowstorm over the scene, and fast forward it a little
            var ps = ParticleSystemManager.Instance.CreateSystem("Snow", "Examples/Snow");

            SceneManager.RootSceneNode.AttachObject(ps);
            ps.FastForward(30);

            // create a frosted screen in front of the camera, using our dynamic texture to "thaw" certain areas
            var ent = SceneManager.CreateEntity("Plane", PrefabEntity.Plane);

            ent.MaterialName = "Examples/Frost";
            var node = SceneManager.RootSceneNode.CreateChildSceneNode();

            node.Position = new Vector3(0, 0, 50);
            node.AttachObject(ent);

            this.mPlaneSize = ent.BoundingBox.Size.x;                   // remember the size of the plane

            this.mCursorQuery = SceneManager.CreateRayQuery(new Ray()); // create a ray scene query for the cursor

            this.mTimeSinceLastFreeze = 0;
            this.mWiping = false;
        }
예제 #5
0
 public override bool MousePressed(SharpInputSystem.MouseEventArgs evt, SharpInputSystem.MouseButtonID id)
 {
     if (TrayManager.InjectMouseDown(evt, id))
     {
         return(true);
     }
     this.mWiping = true; // wipe frost if user left clicks in the scene
     return(true);
 }
예제 #6
0
 public override bool MouseReleased(SharpInputSystem.MouseEventArgs evt, SharpInputSystem.MouseButtonID id)
 {
     if (TrayManager.InjectMouseUp(evt, id))
     {
         return(true);
     }
     this.mWiping = false; // stop wiping frost if user releases LMB
     return(true);
 }
 static void Main(string[] args)
 {
     Application.EnableVisualStyles();
     Application.SetCompatibleTextRenderingDefault(false);
     using (TrayManager trayManager = new TrayManager())
     {
         Application.Run();
     }
 }
예제 #8
0
        internal static void DtPadStart(Form1 form, String[] commandLine)
        {
            List <String> args       = new List <String>();
            bool          noteModeOn = false;

            if (commandLine.Length == 2 && commandLine[1] == ConstantUtil.cmdLineJLNew)
            {
                OpenNewTab(form);
            }
            else if (commandLine.Length == 2 && commandLine[1] == ConstantUtil.cmdLineJLNewAndPaste)
            {
                OpenNewTabAndPaste(form);
            }
            else if (commandLine.Length == 2 && commandLine[1] == ConstantUtil.cmdLineJLOpenFile)
            {
                OpenFile(form);
            }
            else if (commandLine.Length == 2 && commandLine[1] == ConstantUtil.cmdLineJLOpenSession)
            {
                OpenSession(form);
            }
            else if (commandLine.Length == 2 && commandLine[1] == ConstantUtil.cmdLineJLSearchInFiles)
            {
                SearchInFiles(form);
            }
            else if (commandLine.Length == 2 && commandLine[1] == ConstantUtil.cmdLineJLCheckNewVersion)
            {
                CheckNewVersion(form);
            }
            else
            {
                for (int i = 1; i < commandLine.Length; i++)
                {
                    if (commandLine[i] == ConstantUtil.cmdLineNoteModeOn)
                    {
                        noteModeOn = true;
                        continue;
                    }
                    args.Add(commandLine[i]);
                }

                if (args.Count > 0)
                {
                    form.WindowState = form.PreviousWindowState;
                    form.TabIdentity = FileManager.OpenFile(form, form.TabIdentity, args.ToArray());
                }
            }
            if (!form.Visible)
            {
                TrayManager.RestoreFormFromTray(form, form.PreviousWindowState);
            }

            if (noteModeOn && form.WindowMode == CustomForm.WindowModeEnum.Normal)
            {
                WindowModeManager.ToggleNoteMode(form);
            }
        }
예제 #9
0
        internal static void OpenNewTab(Form1 form)
        {
            TrayManager.RestoreFormFromTray(form, form.PreviousWindowState);

            if (TabManager.IsCurrentTabInUse(form))
            {
                form.TabIdentity = TabManager.AddNewPage(form, form.TabIdentity);
            }
        }
 static void Main(string[] args)
 {
     Application.EnableVisualStyles();
     Application.SetCompatibleTextRenderingDefault(false);
     using (TrayManager trayManager = new TrayManager())
     {
         TrayOnlyApplication app = new TrayOnlyApplication();
         app.StartupNextInstance += (s, e) => trayManager
                                    .SetToolTipText(e.CommandLine.Count > 0 ? e.CommandLine[0] : "<no value given>");
         app.Run(args);
     }
 }
예제 #11
0
파일: BSPSample.cs 프로젝트: axiom3d/axiom
        protected override void LoadResources()
        {
            /* NOTE: The browser initializes everything at the beginning already, so we use a 0 init proportion.
             *          If you're not compiling this sample for use with the browser, then leave the init proportion at 0.7. */
            TrayManager.ShowLoadingBar(1, 1, 0);
            // associate the world geometry with the world resource group, and then load the group
            //ResourceGroupManager.Instance.LinkWorldGeometryToResourceGroup( "BSPSAMPLE", "maps/chiropteradm.bsp", SceneManager );
            ResourceGroupManager.Instance.LinkWorldGeometryToResourceGroup("BSPSAMPLE", "maps/chiropteradm.bsp", SceneManager);
            ResourceGroupManager.Instance.InitializeResourceGroup("BSPSAMPLE");
            ResourceGroupManager.Instance.LoadResourceGroup("BSPSAMPLE", false, true);

            TrayManager.HideLoadingBar();
        }
예제 #12
0
        /// <summary>
        /// Creates and initializes all the scene's GUI elements not defined in SdkSample
        /// </summary>
        protected void SetupGUI()
        {
            this.selectionModeMenu = TrayManager.CreateLongSelectMenu(TrayLocation.TopRight, "SelectionModeMenu",
                                                                       "Selection Mode",
                                                                       300, 150, 3);
            this.selectionModeMenu.AddItem("None");
            this.selectionModeMenu.AddItem("Mouse Select");
            this.selectionModeMenu.AddItem("Selection Box");
            this.selectionModeMenu.SelectItem(0);
            this.selectionModeMenu.SelectedIndexChanged += selectionModeMenu_SelectedIndexChanged;

            this.MouseLocationLabel = TrayManager.CreateLabel(TrayLocation.TopLeft, "Mouse Location", "", 350);

            TrayManager.ShowCursor();
        }
예제 #13
0
        /// <summary>
        ///
        /// </summary>
        protected override void SetupContent()
        {
            // set background and some fog
            Viewport.BackgroundColor = new ColorEx(1.0f, 1.0f, 0.8f);
            SceneManager.SetFog(FogMode.Linear, new ColorEx(1.0f, 1.0f, 1.0f), 0, 15, 100);

            // set shadow properties
            SceneManager.ShadowTechnique    = ShadowTechnique.TextureModulative;
            SceneManager.ShadowColor        = new ColorEx(0.5f, 0.5f, 0.5f);
            SceneManager.ShadowTextureSize  = 1024;
            SceneManager.ShadowTextureCount = 1;

            // disable default camera control so the character can do its own
            CameraManager.setStyle(CameraStyle.Manual);

            // use a small amount of ambient lighting
            SceneManager.AmbientLight = new ColorEx(0.3f, 0.3f, 0.3f);

            // add a bright light above the scene
            Light light = SceneManager.CreateLight("CharacterLight");

            light.Type     = LightType.Point;
            light.Position = new Vector3(-10, 40, 20);
            light.Specular = ColorEx.White;

            MeshManager.Instance.CreatePlane("floor", ResourceGroupManager.DefaultResourceGroupName,
                                             new Plane(Vector3.UnitY, 0), 100, 100, 10, 10, true, 1, 10, 10, Vector3.UnitZ);

            // create a floor entity, give it a material, and place it at the origin
            Entity floor = SceneManager.CreateEntity("Floor", "floor");

            floor.MaterialName = "Examples/Rockwall";
            floor.CastShadows  = false;
            SceneManager.RootSceneNode.AttachObject(floor);


            // create our character controller
            this.chara = new SinbadCharacterController(Camera);

            TrayManager.ToggleAdvancedFrameStats();

            var items = new List <string>();

            items.Add("Help");
            ParamsPanel help = TrayManager.CreateParamsPanel(TrayLocation.TopLeft, "HelpMessage", 100, items);

            help.SetParamValue("Help", " H / F1");
        }
예제 #14
0
        protected override void SetupContent()
        {
            Viewport.BackgroundColor = ColorEx.White;
            // setup some basic lighting for our scene
            SceneManager.AmbientLight = new ColorEx(0.3f, 0.3f, 0.3f);
            SceneManager.CreateLight("SphereMappingSampleLight").Position = new Vector3(20, 80, 50);
            // set our camera to orbit around the origin and show cursor
            CameraManager.setStyle(CameraStyle.Orbit);
            TrayManager.ShowCursor();

            // create our model, give it the environment mapped material, and place it at the origin
            Entity ent = SceneManager.CreateEntity("Head", "ogrehead.mesh");

            ent.MaterialName = "Examples/SphereMappedRustySteel";
            SceneManager.RootSceneNode.AttachObject(ent);
        }
예제 #15
0
        protected void CreateControls()
        {
            TrayManager.CreateLabel(TrayLocation.TopLeft, "JuliaParamLabel", "Julia Parameters", 200);
            Slider sl = TrayManager.CreateThickSlider(TrayLocation.TopLeft, "RealSlider", "Real", 200, 80, -1, 1, 50);

            sl.SetValue(this.globalReal, false);
            sl.SliderMoved += new SliderMovedHandler(sl_SliderMoved);
            sl              = TrayManager.CreateThickSlider(TrayLocation.TopLeft, "ImagSlider", "Imag", 200, 80, -1, 1, 50);
            sl.SetValue(this.globalImag, false);
            sl.SliderMoved += new SliderMovedHandler(sl_SliderMoved);
            sl              = TrayManager.CreateThickSlider(TrayLocation.TopLeft, "ThetaSlider", "Theta", 200, 80, -1, 1, 50);
            sl.SetValue(this.globalTheta, false);
            sl.SliderMoved += new SliderMovedHandler(sl_SliderMoved);

            TrayManager.ShowCursor();
        }
예제 #16
0
        protected override void SetupContent()
        {
            // setup some basic lighting for our scene
            SceneManager.AmbientLight = new ColorEx(0.3f, 0.3f, 0.3f);
            SceneManager.CreateLight("ParticleSampleLight").Position = new Vector3(20, 80, 50);

            // set our camera to orbit around the origin and show cursor
            CameraManager.setStyle(CameraStyle.Orbit);
            CameraManager.SetYawPitchDist(0, 15, 250);
            TrayManager.ShowCursor();

            // create an ogre head entity and place it at the origin
            Entity ent = SceneManager.CreateEntity("Head", "ogrehead.mesh");

            SceneManager.RootSceneNode.AttachObject(ent);

            SetupParticles();
            SetupTogglers();
        }
예제 #17
0
        private void _addTextureDebugOverlay(TrayLocation loc, string texname, int i)
        {
            // Create material
            var matName  = "Axiom/DebugTexture" + i;
            var debugMat = (Material)MaterialManager.Instance.GetByName(matName);

            if (debugMat == null)
            {
                debugMat = (Material)MaterialManager.Instance.Create(matName, ResourceGroupManager.DefaultResourceGroupName);
            }

            var p = debugMat.GetTechnique(0).GetPass(0);

            p.RemoveAllTextureUnitStates();
            p.LightingEnabled = false;
            var t = p.CreateTextureUnitState(texname);

            t.SetTextureAddressingMode(TextureAddressing.Clamp);

            // create template
            if (OverlayManager.Instance.Elements.GetElement("Axiom/DebugTexOverlay", true) == null)
            {
                var e = OverlayManager.Instance.Elements.CreateElement("Panel", "Axiom/DebugTexOverlay", true);
                e.MetricsMode = MetricsMode.Pixels;
                e.Width       = 128;
                e.Height      = 128;
            }

            // add widget
            var widgetName = "DebugTex" + i;
            var w          = TrayManager.GetWidget(widgetName);

            if (w == null)
            {
                w = TrayManager.CreateDecorWidget(loc, widgetName, "", "Axiom/DebugTexOverlay");
            }

            w.OverlayElement.MaterialName = matName;
        }
예제 #18
0
    static void Main(string[] args)
    {
        Application.EnableVisualStyles();
        Application.SetCompatibleTextRenderingDefault(false);
        TrayManager         trayManager = null;
        TrayOnlyApplication app         = new TrayOnlyApplication();

        // Startup is raised only when no other instance of the
        // program is already running.
        app.Startup += (s, e) => trayManager = new TrayManager();
        // StartNextInstance is run when the program if a
        // previously -run instance is still running.
        app.StartupNextInstance += (s, e) => trayManager
                                   .SetToolTipText(e.CommandLine.Count > 0 ? e.CommandLine[0] : "<no value given>");
        try
        {
            app.Run(args);
        }
        finally
        {
            trayManager?.Dispose();
        }
    }
예제 #19
0
        protected void SetupTogglers()
        {
            // create check boxes to toggle the visibility of our particle systems
            TrayManager.CreateLabel(TrayLocation.TopLeft, "VisLabel", "Particles");
            var box = TrayManager.CreateCheckBox(TrayLocation.TopLeft, "Fireworks", "Fireworks", 130);

            box.CheckChanged += new CheckChangedHandler(_checkBoxToggled);
            box.IsChecked     = true;
            box = TrayManager.CreateCheckBox(TrayLocation.TopLeft, "Fountain1", "Fountain A", 130);
            box.CheckChanged += new CheckChangedHandler(_checkBoxToggled);
            box.IsChecked     = true;
            box = TrayManager.CreateCheckBox(TrayLocation.TopLeft, "Fountain2", "Fountain B", 130);
            box.CheckChanged += new CheckChangedHandler(_checkBoxToggled);
            box.IsChecked     = true;
            box = TrayManager.CreateCheckBox(TrayLocation.TopLeft, "Aureola", "Aureola", 130);
            box.CheckChanged += new CheckChangedHandler(_checkBoxToggled);
            box.IsChecked     = false;
            box = TrayManager.CreateCheckBox(TrayLocation.TopLeft, "Nimbus", "Nimbus", 130);
            box.CheckChanged += new CheckChangedHandler(_checkBoxToggled);
            box.IsChecked     = false;
            box = TrayManager.CreateCheckBox(TrayLocation.TopLeft, "Rain", "Rain", 130);
            box.CheckChanged += new CheckChangedHandler(_checkBoxToggled);
            box.IsChecked     = false;
        }
예제 #20
0
        public Context()
        {
            var settings = AppSettings.Instance;

            var clients = settings.Clients.Split(',');

            var exchangeClients = new Dictionary <string, ICryptoExchangeClient>();

            _exchangeRateConverter = new FiatExchangeRateConverter(settings.FiatCurrency, settings.FiatCurrencyExchangeRateRefreshInterval, settings.OpenExchangeRatesAppId);

            _logger = new FileLogger(Constants.LogFilename);

            foreach (var client in clients)
            {
                switch (client.Trim().ToLowerInvariant())
                {
                // ReSharper disable StringLiteralTypo
                case "coinbaseexchangeclient":
                    exchangeClients.Add("Coinbase", new CoinbaseExchangeClient(settings.CoinbaseCredentials.ApiKey, settings.CoinbaseCredentials.ApiSecret, settings.FiatCurrency));
                    break;

                case "coinbaseproexchangeclient":
                    foreach (var credentials in settings.CoinbaseProCredentials)
                    {
                        exchangeClients.Add($"Coinbase Pro - {credentials.Portfolio}", new CoinbaseProExchangeClient(credentials.ApiKey,
                                                                                                                     credentials.ApiSecret,
                                                                                                                     credentials.Passphrase,
                                                                                                                     settings.FiatCurrency,
                                                                                                                     _exchangeRateConverter,
                                                                                                                     settings.ExchangeRateFallbacks
                                                                                                                     ?.Where(f => f.Exchange.Equals(
                                                                                                                                 "coinbasepro", StringComparison.InvariantCultureIgnoreCase))
                                                                                                                     .ToDictionary(f => f.CryptoCurrency, f => f.FiatCurrency),
                                                                                                                     _logger));
                    }
                    break;

                case "binanceexchangeclient":
                    exchangeClients.Add("Binance", new BinanceExchangeClient(settings.BinanceCredentials.ApiKey, settings.BinanceCredentials.SecretKey, settings.FiatCurrency));
                    break;

                default:
                    throw new MoneyMonitorConfigurationException($"Unknown API client {client}.");
                    // ReSharper restore StringLiteralTypo
                }
            }

            _historyManager = new HistoryManager(Constants.HistoryLength, Constants.HistoryFilename, settings.FiatCurrency);

            _historyManager.Load();

            _formManager = new FormManager(_historyManager);

            _formManager.RestoreState();

            _trayManager = new TrayManager(_formManager)
            {
                ExitClicked                = ExitClicked,
                IconClicked                = IconClicked,
                TopMostToggled             = TopMostToggled,
                ShowCurrencyHistoryClicked = ShowCurrencyHistoryClicked,
                HideCurrencyHistoryClicked = HideCurrencyHistoryClicked,
                RefreshClicked             = RefreshClicked
            };

            _exchangeAggregator = new ExchangeAggregator(exchangeClients);

            _poller = new ExchangeApiPoller(_logger, _exchangeAggregator, Polled);

            _poller.StartPolling(settings.PollInterval);
        }
예제 #21
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="pageNum"></param>
        protected void ChangePage(int pageNum)
        {
            if (this.materialControlsContainer.Count == 0)
            {
                return;
            }

            this.currentPage = (pageNum == -1) ? (this.currentPage + 1) % this.numPages : pageNum;

            string pageText = string.Format("Parameters {0} / {1}", this.currentPage + 1, this.numPages);

            ((Button)TrayManager.GetWidget("PageButtonControl")).Caption = pageText;

            if (this.activeMaterial != null && this.activeMaterial.SupportedTechniques.Count > 0)
            {
                Technique currentTechnique = this.activeMaterial.SupportedTechniques[0];
                if (currentTechnique != null)
                {
                    this.activePass = currentTechnique.GetPass(0);
                    if (this.activePass != null)
                    {
                        if (this.activePass.HasFragmentProgram)
                        {
                            this.activeFragmentProgram    = this.activePass.FragmentProgram;
                            this.activeFragmentParameters = this.activePass.FragmentProgramParameters;
                        }
                        if (this.activePass.HasVertexProgram)
                        {
                            this.activeVertexProgram    = this.activePass.VertexProgram;
                            this.activeVertexParameters = this.activePass.VertexProgramParameters;
                        }

                        int activeControlCount = this.materialControlsContainer[this.currentMaterial].ShaderControlsCount;

                        int startControlIndex = this.currentPage * ControlsPerPage;
                        int numControls       = activeControlCount - startControlIndex;
                        if (numControls <= 0)
                        {
                            this.currentPage  = 0;
                            startControlIndex = 0;
                            numControls       = activeControlCount;
                        }

                        for (int i = 0; i < ControlsPerPage; i++)
                        {
                            Slider shaderControlSlider = this.shaderControls[i];
                            if (i < numControls)
                            {
                                shaderControlSlider.Show();

                                int           controlIndex    = startControlIndex + i;
                                ShaderControl activeShaderDef =
                                    this.materialControlsContainer[this.currentMaterial].GetShaderControl(controlIndex);
                                shaderControlSlider.SetRange(activeShaderDef.MinVal, activeShaderDef.MaxVal, 50, false);
                                shaderControlSlider.Caption      = activeShaderDef.Name;
                                shaderControlSlider.SliderMoved += new SliderMovedHandler(shaderControlSlider_SliderMoved);
                                float uniformVal = 0.0f;
                                switch (activeShaderDef.Type)
                                {
                                case ShaderType.GpuVertex:
                                case ShaderType.GpuFragment:
                                {
                                    GpuProgramParameters activeParameters = (activeShaderDef.Type == ShaderType.GpuVertex)
                                                                                                                                ? this.activeVertexParameters
                                                                                                                                : this.activeFragmentParameters;

                                    if (activeParameters != null)
                                    {
                                        throw new NotImplementedException("Fix this");
                                        //int idx = activeParameters.GetParamIndex( activeShaderDef.ParamName );
                                        //activeShaderDef.PhysicalIndex = idx;

                                        //uniformVal = activeParameters.GetNamedFloatConstant( activeShaderDef.ParamName ).val[ activeShaderDef.ElementIndex ];
                                    }
                                }
                                break;

                                case ShaderType.MatSpecular:
                                {
                                    // get the specular values from the material pass
                                    ColorEx oldSpec = this.activePass.Specular;
                                    int     x       = activeShaderDef.ElementIndex;
                                    uniformVal = x == 0 ? oldSpec.r : x == 1 ? oldSpec.g : x == 2 ? oldSpec.b : x == 3 ? oldSpec.a : 0;
                                }
                                break;

                                case ShaderType.MatDiffuse:
                                {
                                    // get the specular values from the material pass
                                    ColorEx oldSpec = this.activePass.Diffuse;
                                    int     x       = activeShaderDef.ElementIndex;
                                    uniformVal = x == 0 ? oldSpec.r : x == 1 ? oldSpec.g : x == 2 ? oldSpec.b : x == 3 ? oldSpec.a : 0;
                                }
                                break;

                                case ShaderType.MatAmbient:
                                {
                                    // get the specular values from the material pass
                                    ColorEx oldSpec = this.activePass.Ambient;
                                    int     x       = activeShaderDef.ElementIndex;
                                    uniformVal = x == 0 ? oldSpec.r : x == 1 ? oldSpec.g : x == 2 ? oldSpec.b : x == 3 ? oldSpec.a : 0;
                                }
                                break;

                                case ShaderType.MatShininess:
                                {
                                    // get the specular values from the material pass
                                    uniformVal = this.activePass.Shininess;
                                }
                                break;
                                }
                                shaderControlSlider.Value = uniformVal;
                            }
                        }
                    }
                }
            }
        }
예제 #22
0
        protected override void SetupContent()
        {
            ResourceGroupManager.Instance.InitializeAllResourceGroups();
            // setup some basic lighting for our scene
            SceneManager.AmbientLight = new ColorEx(0.5f, 0.5f, 0.5f);
            SceneManager.CreateLight("BezierLight").Position = new Vector3(100, 100, 100);

            // define the control point vertices for our patch
            // Patch data
            var patchVertices = new PatchVertex[9];

            patchVertices[0].X  = -500;
            patchVertices[0].Y  = 200;
            patchVertices[0].Z  = -500;
            patchVertices[0].Nx = -0.5f;
            patchVertices[0].Ny = 0.5f;
            patchVertices[0].Nz = 0;
            patchVertices[0].U  = 0;
            patchVertices[0].V  = 0;

            patchVertices[1].X  = 0;
            patchVertices[1].Y  = 500;
            patchVertices[1].Z  = -750;
            patchVertices[1].Nx = 0;
            patchVertices[1].Ny = 0.5f;
            patchVertices[1].Nz = 0;
            patchVertices[1].U  = 0.5f;
            patchVertices[1].V  = 0;

            patchVertices[2].X  = 500;
            patchVertices[2].Y  = 1000;
            patchVertices[2].Z  = -500;
            patchVertices[2].Nx = 0.5f;
            patchVertices[2].Ny = 0.5f;
            patchVertices[2].Nz = 0;
            patchVertices[2].U  = 1;
            patchVertices[2].V  = 0;

            patchVertices[3].X  = -500;
            patchVertices[3].Y  = 0;
            patchVertices[3].Z  = 0;
            patchVertices[3].Nx = -0.5f;
            patchVertices[3].Ny = 0.5f;
            patchVertices[3].Nz = 0;
            patchVertices[3].U  = 0;
            patchVertices[3].V  = 0.5f;

            patchVertices[4].X  = 0;
            patchVertices[4].Y  = 500;
            patchVertices[4].Z  = 0;
            patchVertices[4].Nx = 0;
            patchVertices[4].Ny = 0.5f;
            patchVertices[4].Nz = 0;
            patchVertices[4].U  = 0.5f;
            patchVertices[4].V  = 0.5f;

            patchVertices[5].X  = 500;
            patchVertices[5].Y  = -50;
            patchVertices[5].Z  = 0;
            patchVertices[5].Nx = 0.5f;
            patchVertices[5].Ny = 0.5f;
            patchVertices[5].Nz = 0;
            patchVertices[5].U  = 1;
            patchVertices[5].V  = 0.5f;

            patchVertices[6].X  = -500;
            patchVertices[6].Y  = 0;
            patchVertices[6].Z  = 500;
            patchVertices[6].Nx = -0.5f;
            patchVertices[6].Ny = 0.5f;
            patchVertices[6].Nz = 0;
            patchVertices[6].U  = 0;
            patchVertices[6].V  = 1;

            patchVertices[7].X  = 0;
            patchVertices[7].Y  = 500;
            patchVertices[7].Z  = 500;
            patchVertices[7].Nx = 0;
            patchVertices[7].Ny = 0.5f;
            patchVertices[7].Nz = 0;
            patchVertices[7].U  = 0.5f;
            patchVertices[7].V  = 1;

            patchVertices[8].X  = 500;
            patchVertices[8].Y  = 200;
            patchVertices[8].Z  = 800;
            patchVertices[8].Nx = 0.5f;
            patchVertices[8].Ny = 0.5f;
            patchVertices[8].Nz = 0;
            patchVertices[8].U  = 1;
            patchVertices[8].V  = 1;
            // specify a vertex format declaration for our patch: 3 floats for position, 3 floats for normal, 2 floats for UV
            this.patchDeclaration = HardwareBufferManager.Instance.CreateVertexDeclaration();
            this.patchDeclaration.AddElement(0, 0, VertexElementType.Float3, VertexElementSemantic.Position);
            this.patchDeclaration.AddElement(0, 12, VertexElementType.Float3, VertexElementSemantic.Normal);
            this.patchDeclaration.AddElement(0, 24, VertexElementType.Float2, VertexElementSemantic.TexCoords, 0);

            // create a patch mesh using vertices and declaration
            this.patch = MeshManager.Instance.CreateBezierPatch("patch", ResourceGroupManager.DefaultResourceGroupName,
                                                                patchVertices,
                                                                this.patchDeclaration, 3, 3, 5, 5, VisibleSide.Both,
                                                                BufferUsage.StaticWriteOnly, BufferUsage.DynamicWriteOnly, true,
                                                                true);

            // Start patch at 0 detail
            this.patch.Subdivision = 0;

            // Create entity based on patch
            this.patchEntity = SceneManager.CreateEntity("Entity1", "patch");
            var material =
                (Material)MaterialManager.Instance.Create("TextMat", ResourceGroupManager.DefaultResourceGroupName, null);

            material.GetTechnique(0).GetPass(0).CreateTextureUnitState("BumpyMetal.jpg");

            this.patchEntity.MaterialName = "TextMat";
            this.patchPass = material.GetTechnique(0).GetPass(0);

            // Attach the entity to the root of the scene
            SceneManager.RootSceneNode.AttachObject(this.patchEntity);

            // save the main pass of the material so we can toggle wireframe on it
            if (material != null)
            {
                this.patchPass = material.GetTechnique(0).GetPass(0);

                // use an orbit style camera
                CameraManager.setStyle(CameraStyle.Orbit);
                CameraManager.SetYawPitchDist(0, 0, 250);

                TrayManager.ShowCursor();

                // create slider to adjust detail and checkbox to toggle wireframe
                Slider   slider = TrayManager.CreateThickSlider(TrayLocation.TopLeft, "Detail", "Detail", 120, 44, 0, 1, 6);
                CheckBox box    = TrayManager.CreateCheckBox(TrayLocation.TopLeft, "Wireframe", "Wireframe", 120);
                slider.SliderMoved += new SliderMovedHandler(slider_SliderMoved);
                box.CheckChanged   += new CheckChangedHandler(box_CheckChanged);
            }
        }
예제 #23
0
        public override bool FrameRenderingQueued(FrameEventArgs evt)
        {
            if (this.mode != Mode.Normal)
            {
                // fire ray
                Ray ray;
                ray = TrayManager.GetCursorRay(Camera);

                var rayResult = this.terrainGroup.RayIntersects(ray);
                if (rayResult.Hit)
                {
                    this.editMarker.IsVisible = true;
                    this.editNode.Position    = rayResult.Position;

                    // figure out which terrains this affects
                    List <Axiom.Components.Terrain.Terrain> terrainList;
                    var brushSizeWorldSpace = TerrainWorldSize * this.brushSizeTerrainSpace;
                    var sphere = new Sphere(rayResult.Position, brushSizeWorldSpace);
                    this.terrainGroup.SphereIntersects(sphere, out terrainList);

                    foreach (var ti in terrainList)
                    {
                        DoTerrainModify(ti, rayResult.Position, evt.TimeSinceLastFrame);
                    }
                }
                else
                {
                    this.editMarker.IsVisible = false;
                }
            }

            if (!this.fly)
            {
                // clamp to terrain
                var camPos = Camera.Position;
                var ray    = new Ray(new Vector3(camPos.x, this.terrainPos.y + 10000, camPos.z), Vector3.NegativeUnitY);

                TerrainGroup.RayResult rayResult = this.terrainGroup.RayIntersects(ray);
                Real distanceAboveTerrain        = 50;
                Real fallSpeed = 300;
                Real newy      = camPos.y;
                if (rayResult.Hit)
                {
                    if (camPos.y > rayResult.Position.y + distanceAboveTerrain)
                    {
                        this.fallVelocity += evt.TimeSinceLastFrame * 20;
                        this.fallVelocity  = Utility.Min(this.fallVelocity, fallSpeed);
                        newy = camPos.y - this.fallVelocity * evt.TimeSinceLastFrame;
                    }
                    newy            = Utility.Max(rayResult.Position.y + distanceAboveTerrain, newy);
                    Camera.Position = new Vector3(camPos.x, newy, camPos.z);
                }
            }

            if (this.heightUpdateCountDown > 0)
            {
                this.heightUpdateCountDown -= evt.TimeSinceLastFrame;
                if (this.heightUpdateCountDown <= 0)
                {
                    this.terrainGroup.Update();
                    this.heightUpdateCountDown = 0;
                }
            }

            if (this.terrainGroup.IsDerivedDataUpdateInProgress)
            {
                TrayManager.MoveWidgetToTray(this.infoLabel, TrayLocation.Top, 0);
                this.infoLabel.Show();
                if (this.terrainsImported)
                {
                    this.infoLabel.Caption = "Building terrain, please wait...";
                }
                else
                {
                    this.infoLabel.Caption = "Updating textures, patience...";
                }
            }
            else
            {
                TrayManager.RemoveWidgetFromTray(this.infoLabel);
                this.infoLabel.Hide();
                if (this.terrainsImported)
                {
                    SaveTerrains(true);
                    this.terrainsImported = false;
                }
            }

            return(base.FrameRenderingQueued(evt));
        }
예제 #24
0
 internal static void OpenFile(Form1 form)
 {
     TrayManager.RestoreFormFromTray(form, form.PreviousWindowState);
     form.TabIdentity = FileManager.OpenFile(form, form.TabIdentity);
 }