Example #1
0
        /// <summary>
        /// Sets up the device to run in a <see cref="Control"/> with the specified <see cref="Irrlicht.Video.DriverType"/>.
        /// </summary>
        /// <param name="c">Winforms <see cref="Control"/> that Irrlicht is to render in.</param>
        /// <param name="driver"><see cref="Irrlicht.Video.DriverType"/> to use when setting up the IrrlichtDevice.</param>
        /// <returns>True if the setup went well, False otherwise.</returns>
        private bool SetDevice(Control c, video.DriverType driverType)
        {
            if (quitting)
            {
                return(false);
            }

            if (device != null)
            {
                device.CloseDevice();
            }

            CreatePanel();

            device = new IrrlichtDevice(driverType,
                                        new core.Dimension2D(c.ClientRectangle.Width, c.ClientRectangle.Height),
                                        32, false, false, false, true, c.Handle);

            if (device == null)
            {
                return(false);
            }

            device.ResizeAble = true;
            gui.IGUIEnvironment env    = device.GUIEnvironment;
            video.IVideoDriver  driver = device.VideoDriver;
            scene.ISceneManager smgr   = device.SceneManager;
            driver.SetTextureCreationFlag(video.TextureCreationFlag.ALWAYS_32_BIT, true);

            // This sets the gui font from a bmp file.
            gui.IGUISkin skin = env.Skin;
            gui.IGUIFont font = env.GetFont(path + "fonthaettenschweiler.bmp");
            if (font != null)
            {
                skin.Font = font;
            }

            // This is loaded with the default values for the native engine.
            smgr.AddCameraSceneNodeMaya(null, -1500, 500, 1500, -1);
            irrLogo = driver.GetTexture(path + "irrlichtlogoaligned.jpg");

            caption   = captBase + " (using " + driver.Name + " driver)";
            this.Text = caption;

            return(true);
        }
Example #2
0
        /// <summary>
        /// Loads the skybox using the device's driver & scene manager.
        /// </summary>
        private void LoadSkyBox()
        {
            if (device == null)
            {
                MessageBox.Show("Couldn't load skybox because device was null.", caption);
                return;
            }

            video.IVideoDriver  driver = device.VideoDriver;
            scene.ISceneManager smgr   = device.SceneManager;
            skyBox = smgr.AddSkyBoxSceneNode(driver.GetTexture(path + "irrlicht2_up.jpg"),
                                             driver.GetTexture(path + "irrlicht2_dn.jpg"),
                                             driver.GetTexture(path + "irrlicht2_lf.jpg"),
                                             driver.GetTexture(path + "irrlicht2_rt.jpg"),
                                             driver.GetTexture(path + "irrlicht2_ft.jpg"),
                                             driver.GetTexture(path + "irrlicht2_bk.jpg"),
                                             null, -1); // null & -1 are the defaults in the native engine.

            if (skyBox != null)
            {
                skyBox.Visible = chkSkyBox.Checked;
            }
        }