2licht

C# / .NET Eample Code

This is basically a ported version of the first Irrlicht Engine example code.

using System;
using Irrlicht;


namespace Example01
{
    
    class MainClass
    {               
        public static void Main (string[] args)
        {
            using (IrrlichtDevice device = new IrrlichtDevice())
            {
                device.WindowCaption = "Hello World! - Irrlicht Engine Demo";
                
                VideoDriver driver = device.VideoDriver;
                SceneManager smgr = device.SceneManager;
                GUIEnvironment guienv = device.GUIEnvironment;
                
                guienv.AddStaticText("Hello World! This is the Irrlicht Software renderer!",
                                     new Rect(10, 10, 260, 22), true);
                
                AnimatedMesh mesh = smgr.GetMesh("../../../media/sydney.md2");
                if (mesh == null) return;
                
                AnimatedMeshSceneNode node = smgr.AddAnimatedMeshSceneNode(mesh);
                if (node != null)
                {
                    node.SetMaterialFlag(MaterialFlag.Lighting, false);
                    node.SetMD2Animation(MD2Animation.Stand);
                    node.SetMaterialTexture(0, driver.GetTexture("../../../media/sydney.bmp"));
                }
                
                smgr.AddCameraSceneNode(null, new Vector3D(0, 30, -40), new Vector3D(0, 5, 0));
                    
                while (device.Run())
                {
                    driver.BeginScene(true, true, new Color(255, 100, 101, 140));
                    smgr.DrawAll();
                    guienv.DrawAll();
                    driver.EndScene();
                }
            }
        }
    }
    
}

Thanks to Oleg Parashchenko for his Syntax Highlighter.