コード例 #1
0
ファイル: UserInterface.cs プロジェクト: zaki/irrlicht.net
        public static void Main(string[] args)
        {
            device = new IrrlichtDevice(DriverType.OpenGL, new Dimension2D(640, 480), 32, false, true, false, false);
            if (device == null)
            {
                System.Console.WriteLine("Device could not be created. Exiting.");
                return;
            }

            device.WindowCaption = "Hello World - User Interface Demo";
            device.Resizeable = true;

            videoDriver = device.VideoDriver;
            sceneManager = device.SceneManager;
            guiEnvironment = device.GUIEnvironment;

            GUISkin skin = guiEnvironment.Skin;
            GUIFont font = guiEnvironment.GetFont("../../irrlicht/media/fonthaettenschweiler.bmp");
            if (!font.Null())
                skin.Font = font;

            GUIButton button1 = guiEnvironment.AddButtonW(new Rect(10, 240, 110, 240 + 32), guiEnvironment.RootElement, (int)GuiIds.GUI_ID_QUIT_BUTTON, "Quit");
            button1.ToolTipTextW = "Exits Program";
            GUIButton button2 = guiEnvironment.AddButtonW(new Rect(10, 280, 110, 280 + 32), guiEnvironment.RootElement, (int)GuiIds.GUI_ID_NEW_WINDOW_BUTTON, "New Window");
            button2.ToolTipTextW = "Launches a new Window";
            GUIButton button3 = guiEnvironment.AddButtonW(new Rect(10, 320, 110, 320 + 32), guiEnvironment.RootElement, (int)GuiIds.GUI_ID_FILE_OPEN_BUTTON, "File Open");
            button3.ToolTipTextW = "Opens a file";

            guiEnvironment.AddStaticTextW("Transparency Control:", new Rect(150, 20, 350, 40), true, false, guiEnvironment.RootElement, -1, false);
            GUIScrollBar scrollBar = guiEnvironment.AddScrollBar(true, new Rect(150, 45, 350, 60), guiEnvironment.RootElement, (int)GuiIds.GUI_ID_TRANSPARENCY_SCROLL_BAR);
            scrollBar.Max = 255;

            scrollBar.Pos = guiEnvironment.Skin.GetColor(GuiDefaultColor.Window).A;

            guiEnvironment.AddStaticTextW("Logging ListBox:", new Rect(50, 110, 250, 130), true, false, guiEnvironment.RootElement, -1, false);
            listBox = guiEnvironment.AddListBox(new Rect(50, 140, 250, 210), guiEnvironment.RootElement, -1, true);
            guiEnvironment.AddEditBoxW("Editable Text", new Rect(350, 80, 550, 100), true, guiEnvironment.RootElement, -1);

            guiEnvironment.AddImage(videoDriver.GetTexture("../../irrlicht/media/irrlichtlogo2.png"), new Position2D(10, 10), true, guiEnvironment.RootElement, -1, "");

            device.OnEvent += new OnEventDelegate(device_OnEvent);

            while (device.Run())
            {
                RenderLoop();
            }

            device.Drop();
        }
コード例 #2
0
ファイル: HelloWorld.cs プロジェクト: zaki/irrlicht.net
        public static void Main(string[] args)
        {
            device = new IrrlichtDevice(DriverType.OpenGL, new Dimension2D(640, 480), 32, false, true, false, false);
            if (device == null)
            {
                System.Console.WriteLine("Device could not be created. Exiting.");
                return;
            }

            device.WindowCaption = "Hello World - Irrlicht.Net Demo";

            videoDriver = device.VideoDriver;
            sceneManager = device.SceneManager;
            guiEnvironment = device.GUIEnvironment;

            guiEnvironment.AddStaticTextW("Hello World! This is the Irrlicht.Net demo application", new Rect(10, 10, 590, 32), true, false, guiEnvironment.RootElement, -1, false);

            AnimatedMesh mesh = sceneManager.GetMesh("../../irrlicht/media/sydney.md2");
            if (mesh == null)
            {
                System.Console.WriteLine("Meshfile could not be loaded");
                return;
            }
            AnimatedMeshSceneNode node = sceneManager.AddAnimatedMeshSceneNode(mesh);
            if (node != null)
            {
                node.SetMaterialFlag(MaterialFlag.Lighting, false);
                node.SetMD2Animation(MD2Animation.Stand);
                node.SetMaterialTexture(0, videoDriver.GetTexture("../../irrlicht/media/sydney.bmp"));
            }

            CameraSceneNode camera = sceneManager.AddCameraSceneNode(sceneManager.RootSceneNode);
            camera.Position = new Vector3D(0, 30, -40);
            camera.Target = new Vector3D(0, 5, 0);

            device.OnEvent += new OnEventDelegate(device_OnEvent);

            while (device.Run())
            {
                RenderLoop();
            }

            device.Drop();
        }